]> khamidou — GitHub mirrors - electron.git/commitdiff
Bind WebContents APIs to <webview>
authorCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 12:49:51 +0000 (20:49 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 24 Oct 2014 12:49:51 +0000 (20:49 +0800)
atom/renderer/lib/web-view.coffee
docs/api/browser-window.md

index aeb7f1ee5a696ff0853c140087939ac88453c0b8..1a09aed3c084471fbfe335f42464fde10962488c 100644 (file)
@@ -494,6 +494,41 @@ registerWebViewElement = ->
       internal.elementAttached = true
       internal.parseAttributes()
 
+  # Public-facing API methods.
+  methods = [
+    "getUrl"
+    "getTitle"
+    "isLoading"
+    "isWaitingForResponse"
+    "stop"
+    "reload"
+    "reloadIngoringCache"
+    "canGoBack"
+    "canGoForward"
+    "canGoToOffset"
+    "goBack"
+    "goForward"
+    "goToIndex"
+    "goToOffset"
+    "isCrashed"
+    "executeJavaScript"
+    "send"
+    # "getUserAgent"
+    # "getZoom"
+    # "insertCSS"
+    # "print"
+    # "setUserAgentOverride"
+    # "setZoom"
+    # "terminate"
+  ]
+
+  # Forward proto.foo* method calls to WebView.foo*.
+  createHandler = (m) ->
+    (args...) ->
+      internal = v8Util.getHiddenValue this, 'internal'
+      remote.getGuestWebContents(internal.guestInstanceId)[m]  args...
+  proto[m] = createHandler m for m in methods
+
   window.WebView = webFrame.registerEmbedderCustomElement 'webview',
     prototype: proto
 
index 6d50ef1b46916366f14ac05fbf447908b5444731..1cead5071682c1e3711d216309c1cc60b8c67945 100644 (file)
@@ -602,7 +602,7 @@ Navigates to the specified absolute index.
 
 Navigates to the specified offset from the "current entry".
 
-### WebContents.IsCrashed()
+### WebContents.isCrashed()
 
 Whether the renderer process has crashed.