diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ede6bcd71e6b..1a76c3e5f078 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -414,6 +414,10 @@ bool Window::IsWebViewFocused() { return window_->IsWebViewFocused(); } +bool Window::IsDevToolsFocused() { + return window_->IsDevToolsFocused(); +} + void Window::SetRepresentedFilename(const std::string& filename) { window_->SetRepresentedFilename(filename); } @@ -591,6 +595,7 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("focusOnWebView", &Window::FocusOnWebView) .SetMethod("blurWebView", &Window::BlurWebView) .SetMethod("isWebViewFocused", &Window::IsWebViewFocused) + .SetMethod("isDevToolsFocused", &Window::IsDevToolsFocused) .SetMethod("capturePage", &Window::CapturePage) .SetMethod("setProgressBar", &Window::SetProgressBar) .SetMethod("setOverlayIcon", &Window::SetOverlayIcon) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 4384e03a249f..d60bf0d87ea0 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -124,6 +124,7 @@ class Window : public mate::TrackableObject, void FocusOnWebView(); void BlurWebView(); bool IsWebViewFocused(); + bool IsDevToolsFocused(); void SetRepresentedFilename(const std::string& filename); std::string GetRepresentedFilename(); void SetDocumentEdited(bool edited); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 997fe72c4ae7..f40f7de8dbc3 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -249,6 +249,10 @@ bool NativeWindow::IsWebViewFocused() { return host_view && host_view->HasFocus(); } +bool NativeWindow::IsDevToolsFocused() { + return inspectable_web_contents_->GetView()->IsDevToolsViewFocused(); +} + void NativeWindow::CapturePage(const gfx::Rect& rect, const CapturePageCallback& callback) { const auto view = web_contents()->GetRenderWidgetHostView(); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index b89e2b58e6e4..f09845aad348 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -148,6 +148,7 @@ class NativeWindow : public content::WebContentsObserver, virtual void FocusOnWebView(); virtual void BlurWebView(); virtual bool IsWebViewFocused(); + virtual bool IsDevToolsFocused(); // Captures the page with |rect|, |callback| would be called when capturing is // done.