implement method on browser window

This commit is contained in:
deepak1556 2015-05-18 20:08:08 +05:30
parent 46d80e8f05
commit 9963ddc485
5 changed files with 23 additions and 1 deletions

View file

@ -351,6 +351,10 @@ void Window::InspectElement(int x, int y) {
window_->InspectElement(x, y);
}
void Window::InspectServiceWorker() {
window_->InspectServiceWorker();
}
void Window::FocusOnWebView() {
window_->FocusOnWebView();
}
@ -524,7 +528,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
&Window::ShowDefinitionForSelection)
#endif
.SetMethod("_getWebContents", &Window::GetWebContents)
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents);
.SetMethod("_getDevToolsWebContents", &Window::GetDevToolsWebContents)
.SetMethod("inspectServiceWorker", &Window::InspectServiceWorker);
}
} // namespace api

View file

@ -116,6 +116,7 @@ class Window : public mate::EventEmitter,
void CloseDevTools();
bool IsDevToolsOpened();
void InspectElement(int x, int y);
void InspectServiceWorker();
void FocusOnWebView();
void BlurWebView();
bool IsWebViewFocused();

View file

@ -317,6 +317,17 @@ void NativeWindow::InspectElement(int x, int y) {
agent->InspectElement(x, y);
}
void NativeWindow::InspectServiceWorker() {
for (const auto& agent_host : content::DevToolsAgentHost::GetOrCreateAll()) {
if (agent_host->GetType() ==
content::DevToolsAgentHost::TYPE_SERVICE_WORKER) {
OpenDevTools(true);
inspectable_web_contents()->AttachTo(agent_host);
break;
}
}
}
void NativeWindow::FocusOnWebView() {
GetWebContents()->GetRenderViewHost()->Focus();
}

View file

@ -153,6 +153,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void CloseDevTools();
virtual bool IsDevToolsOpened();
virtual void InspectElement(int x, int y);
virtual void InspectServiceWorker();
virtual void FocusOnWebView();
virtual void BlurWebView();

View file

@ -500,6 +500,10 @@ Toggle the developer tools.
Starts inspecting element at position (`x`, `y`).
### BrowserWindow.inspectServiceWorker()
Opens the developer tools for the service worker context present in the web contents.
### BrowserWindow.focusOnWebView()
### BrowserWindow.blurWebView()