Add InspectableWebContentsViewDelegate
authorCheng Zhao <zcbenz@gmail.com>
Thu, 25 Jun 2015 04:30:04 +0000 (12:30 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 25 Jun 2015 04:30:04 +0000 (12:30 +0800)
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_views.h
vendor/brightray

index 8748388..3e2bbd1 100644 (file)
@@ -96,6 +96,8 @@ NativeWindow::NativeWindow(
       zoom_factor_(1.0),
       inspectable_web_contents_(inspectable_web_contents),
       weak_factory_(this) {
+  inspectable_web_contents->GetView()->SetDelegate(this);
+
   options.Get(switches::kFrame, &has_frame_);
   options.Get(switches::kTransparent, &transparent_);
   options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_);
@@ -496,6 +498,7 @@ void NativeWindow::RenderViewCreated(
 }
 
 void NativeWindow::CloseContents(content::WebContents* source) {
+  inspectable_web_contents_->GetView()->SetDelegate(nullptr);
   inspectable_web_contents_ = nullptr;
 
   // When the web contents is gone, close the window immediately, but the
@@ -525,6 +528,18 @@ void NativeWindow::RendererResponsive(content::WebContents* source) {
   FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
 }
 
+void NativeWindow::DevToolsFocused() {
+  FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsFocus());
+}
+
+void NativeWindow::DevToolsOpened() {
+  FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsOpened());
+}
+
+void NativeWindow::DevToolsClosed() {
+  FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnDevToolsClosed());
+}
+
 void NativeWindow::BeforeUnloadDialogCancelled() {
   WindowList::WindowCloseCancelled(this);
 
index 8fe5143..c52a1e0 100644 (file)
@@ -15,6 +15,7 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "base/observer_list.h"
+#include "brightray/browser/inspectable_web_contents_view_delegate.h"
 #include "content/public/browser/readback_types.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "content/public/browser/web_contents_user_data.h"
@@ -53,7 +54,8 @@ namespace atom {
 
 struct DraggableRegion;
 
-class NativeWindow : public content::WebContentsObserver {
+class NativeWindow : public content::WebContentsObserver,
+                     public brightray::InspectableWebContentsViewDelegate {
  public:
   typedef base::Callback<void(const SkBitmap& bitmap)> CapturePageCallback;
 
@@ -228,7 +230,12 @@ class NativeWindow : public content::WebContentsObserver {
   virtual void UpdateDraggableRegions(
       const std::vector<DraggableRegion>& regions) = 0;
 
-  // Implementations of content::WebContentsObserver.
+  // brightray::InspectableWebContentsViewDelegate:
+  void DevToolsFocused() override;
+  void DevToolsOpened() override;
+  void DevToolsClosed() override;
+
+  // content::WebContentsObserver:
   void RenderViewCreated(content::RenderViewHost* render_view_host) override;
   void BeforeUnloadDialogCancelled() override;
   void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
index c446d53..fe4e8a8 100644 (file)
@@ -120,7 +120,7 @@ class NativeWindowViews : public NativeWindow,
   bool ExecuteWindowsCommand(int command_id) override;
 #endif
 
-  // brightray::InspectableWebContentsDelegate:
+  // brightray::InspectableWebContentsViewDelegate:
   gfx::ImageSkia GetDevToolsWindowIcon() override;
 #if defined(USE_X11)
   void GetDevToolsWindowWMClass(
index 2087135..b05e019 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 20871355cb590e009d7ee394a7d9da0e4666ea0b
+Subproject commit b05e019d2f66023fad1ae2f16cc765e3d62ffd5e