return WebContents::Create(isolate, window_->GetDevToolsWebContents());
}
-mate::Dictionary Window::GetDevTools(v8::Isolate* isolate) {
- mate::Dictionary dict(mate::Dictionary::CreateEmpty(isolate));
- content::WebContents* web_contents = window_->GetDevToolsWebContents();
- dict.Set("processId", web_contents->GetRenderProcessHost()->GetID());
- dict.Set("routingId", web_contents->GetRoutingID());
- return dict;
-}
-
-void Window::ExecuteJavaScriptInDevTools(const std::string& code) {
- window_->ExecuteJavaScriptInDevTools(code);
-}
-
void Window::LoadURL(const GURL& url) {
NavigationController& controller = window_->GetWebContents()->GetController();
.SetMethod("capturePage", &Window::CapturePage)
.SetMethod("getWebContents", &Window::GetWebContents)
.SetMethod("getDevToolsWebContents", &Window::GetDevToolsWebContents)
- .SetMethod("getDevTools", &Window::GetDevTools)
- .SetMethod("executeJavaScriptInDevTools",
- &Window::ExecuteJavaScriptInDevTools)
.SetMethod("loadUrl", &Window::LoadURL)
.SetMethod("canGoBack", &Window::CanGoBack)
.SetMethod("canGoForward", &Window::CanGoForward)
mate::Handle<WebContents> GetWebContents(v8::Isolate* isolate) const;
mate::Handle<WebContents> GetDevToolsWebContents(v8::Isolate* isolate) const;
- // APIs for devtools.
- mate::Dictionary GetDevTools(v8::Isolate* isolate);
- void ExecuteJavaScriptInDevTools(const std::string& code);
-
// APIs for NavigationController.
void LoadURL(const GURL& url);
bool CanGoBack();
menu = app.getApplicationMenu()
@setMenu menu if menu?
+ # Define getter for webContents.
@webContents = @getWebContents()
+ @__devToolsWebContents = null
+ @__defineGetter__ 'devToolsWebContents', ->
+ if @isDevToolsOpened()
+ @__devToolsWebContents ?= @getDevToolsWebContents()
+ else
+ @__devToolsWebContents = null
# Remember the window.
id = BrowserWindow.windows.add this
BrowserWindow::getRoutingId = -> @webContents.getRoutingId()
BrowserWindow::getProcessId = -> @webContents.getProcessId()
BrowserWindow::isCrashed = -> @webContents.isCrashed()
+BrowserWindow::getDevTools = ->
+ processId: @devToolsWebContents.getProcessId()
+ routingId: @devToolsWebContents.getRoutingId()
+BrowserWindow::executeJavaScriptInDevTools = (code) ->
+ @devToolsWebContents.executeJavaScript code
module.exports = BrowserWindow
agent->InspectElement(x, y);
}
-void NativeWindow::ExecuteJavaScriptInDevTools(const std::string& script) {
- GetDevToolsWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
- string16(), base::UTF8ToUTF16(script));
-}
-
void NativeWindow::FocusOnWebView() {
GetWebContents()->GetRenderViewHost()->Focus();
}
}
}
}
- ExecuteJavaScriptInDevTools(function_name + "(" + params + ");");
+ GetDevToolsWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
+ string16(), base::UTF8ToUTF16(function_name + "(" + params + ");"));
}
void NativeWindow::OnRendererMessage(const string16& channel,
virtual void CloseDevTools();
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
- virtual void ExecuteJavaScriptInDevTools(const std::string& script);
virtual void FocusOnWebView();
virtual void BlurWebView();