]> khamidou — GitHub mirrors - electron.git/commitdiff
implement method on browser window
authordeepak1556 <hop2deep@gmail.com>
Mon, 18 May 2015 14:38:08 +0000 (20:08 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Mon, 18 May 2015 14:38:08 +0000 (20:08 +0530)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
docs/api/browser-window.md

index b71499d3699c32237a85facf92e6767b16ffbf28..74f0ba69ca45ad6133705ad956a6ade3ad86640a 100644 (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
index d5c3ceedd2eb7501d0893529e0506634c70914e9..d0d7b2621c5656d9456a490f92ac2f0ec3bd10da 100644 (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();
index 5bef1acfb8722cc37653511b486f5f78ce114607..9d24e68c8f42260e9384155a53cceb8d156697ee 100644 (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();
 }
index 32c3493cdbf8b18f5a0204b03e34d88409bcb3ba..05742a3880da7a366307fc315fb19277edcb8b24 100644 (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();
index f8ff8e7b9e0cab2449f2ce73888456021fa7af25..e20d809a5e7bc6e6f315f1787178d7c2ea9b78e0 100644 (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()