From a8c59110942c3d48c33a6f77e56380fc2146ca9a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 8 Dec 2013 23:11:29 -0800 Subject: [PATCH] Implement IsDevToolsOpened for Linux. --- .../linux/inspectable_web_contents_view_linux.cc | 15 +++++++++++++++ .../linux/inspectable_web_contents_view_linux.h | 1 + 2 files changed, 16 insertions(+) diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.cc b/brightray/browser/linux/inspectable_web_contents_view_linux.cc index cbe8e4e9c34..54f54cadabe 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.cc +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.cc @@ -10,6 +10,17 @@ namespace brightray { +namespace { + +bool IsWidgetAncestryVisible(GtkWidget* widget) { + GtkWidget* parent = widget; + while (parent && gtk_widget_get_visible(parent)) + parent = gtk_widget_get_parent(parent); + return !parent; +} + +} + InspectableWebContentsView* CreateInspectableContentsView( InspectableWebContentsImpl* inspectable_web_contents) { return new InspectableWebContentsViewLinux(inspectable_web_contents); @@ -155,6 +166,10 @@ void InspectableWebContentsViewLinux::CloseDevTools() { } } +bool InspectableWebContentsViewLinux::IsDevToolsOpened() { + return devtools_window_ && IsWidgetAncestryVisible(devtools_window_); +} + bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) { DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\""; diff --git a/brightray/browser/linux/inspectable_web_contents_view_linux.h b/brightray/browser/linux/inspectable_web_contents_view_linux.h index c6605b3939f..79ab6f731d5 100644 --- a/brightray/browser/linux/inspectable_web_contents_view_linux.h +++ b/brightray/browser/linux/inspectable_web_contents_view_linux.h @@ -18,6 +18,7 @@ class InspectableWebContentsViewLinux : public InspectableWebContentsView { virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual void ShowDevTools() OVERRIDE; virtual void CloseDevTools() OVERRIDE; + virtual bool IsDevToolsOpened() OVERRIDE; virtual bool SetDockSide(const std::string& side) OVERRIDE; InspectableWebContentsImpl* inspectable_web_contents() {