Bind WebContents APIs to <webview>

This commit is contained in:
Cheng Zhao 2014-10-24 20:49:51 +08:00
parent 46ed83a057
commit 07a8a50861
2 changed files with 36 additions and 1 deletions

View 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

View 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.