]> khamidou — GitHub mirrors - electron.git/commitdiff
Make DevToolsDelegate respond to messages.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 4 Mar 2014 09:50:57 +0000 (17:50 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 4 Mar 2014 09:50:57 +0000 (17:50 +0800)
browser/devtools_delegate.cc
browser/devtools_delegate.h

index dc11dd35e12cda1f8e83029370a43fe98e76a58c..0cd9d0198fd4e497b44f452961a06e6ac97befb6 100644 (file)
 #include "content/public/browser/devtools_http_handler.h"
 #include "content/public/browser/devtools_manager.h"
 #include "content/public/browser/web_contents.h"
+#include "ui/gfx/point.h"
 
 namespace atom {
 
 DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
                                    content::WebContents* target_web_contents)
     : content::WebContentsObserver(window->GetWebContents()),
-      owner_window_(window) {
+      owner_window_(window),
+      embedder_message_dispatcher_(
+          new DevToolsEmbedderMessageDispatcher(this)) {
   content::WebContents* web_contents = window->GetWebContents();
 
   // Setup devtools.
@@ -34,7 +37,7 @@ DevToolsDelegate::DevToolsDelegate(NativeWindow* window,
   options.SetString("title", "DevTools Debugger");
   window->InitFromOptions(&options);
   web_contents->GetController().LoadURL(
-      GURL("chrome-devtools://devtools/devtools.html"),
+      GURL("chrome-devtools://devtools/devtools.html?dockSide=undocked"),
       content::Referrer(),
       content::PAGE_TRANSITION_AUTO_TOPLEVEL,
       std::string());
@@ -44,6 +47,7 @@ DevToolsDelegate::~DevToolsDelegate() {
 }
 
 void DevToolsDelegate::DispatchOnEmbedder(const std::string& message) {
+  embedder_message_dispatcher_->Dispatch(message);
 }
 
 void DevToolsDelegate::InspectedContentsClosing() {
@@ -60,4 +64,53 @@ void DevToolsDelegate::OnWindowClosed() {
   delete owner_window_;
 }
 
+void DevToolsDelegate::ActivateWindow() {
+}
+
+void DevToolsDelegate::CloseWindow() {
+  owner_window_->Close();
+}
+
+void DevToolsDelegate::MoveWindow(int x, int y) {
+  owner_window_->SetPosition(gfx::Point(x, y));
+}
+
+void DevToolsDelegate::SetDockSide(const std::string& dock_side) {
+  if (dock_side != "undocked")
+    owner_window_->Close();
+}
+
+void DevToolsDelegate::OpenInNewTab(const std::string& url) {
+}
+
+void DevToolsDelegate::SaveToFile(
+    const std::string& url, const std::string& content, bool save_as) {
+}
+
+void DevToolsDelegate::AppendToFile(
+    const std::string& url, const std::string& content) {
+}
+
+void DevToolsDelegate::RequestFileSystems() {
+}
+
+void DevToolsDelegate::AddFileSystem() {
+}
+
+void DevToolsDelegate::RemoveFileSystem(const std::string& file_system_path) {
+}
+
+void DevToolsDelegate::IndexPath(
+    int request_id, const std::string& file_system_path) {
+}
+
+void DevToolsDelegate::StopIndexing(int request_id) {
+}
+
+void DevToolsDelegate::SearchInPath(
+    int request_id,
+    const std::string& file_system_path,
+    const std::string& query) {
+}
+
 }  // namespace atom
index d8a8be529748ed996f9f99f723827b7c4c05a418..be0c1b298e0a9d0cebaa8b63ceadcd21ce42ee86 100644 (file)
@@ -9,19 +9,23 @@
 #include "browser/native_window_observer.h"
 #include "content/public/browser/devtools_frontend_host_delegate.h"
 #include "content/public/browser/web_contents_observer.h"
+#include "vendor/brightray/browser/devtools_embedder_message_dispatcher.h"
 
 namespace content {
 class DevToolsAgentHost;
 class DevToolsClientHost;
 }
 
+using brightray::DevToolsEmbedderMessageDispatcher;
+
 namespace atom {
 
 class NativeWindow;
 
 class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
                          public content::WebContentsObserver,
-                         public NativeWindowObserver {
+                         public NativeWindowObserver,
+                         public DevToolsEmbedderMessageDispatcher::Delegate {
  public:
   DevToolsDelegate(NativeWindow* window,
                    content::WebContents* target_web_contents);
@@ -39,11 +43,33 @@ class DevToolsDelegate : public content::DevToolsFrontendHostDelegate,
   // Implementations of NativeWindowObserver.
   virtual void OnWindowClosed() OVERRIDE;
 
+  // Implementations of DevToolsEmbedderMessageDispatcher::Delegate.
+  virtual void ActivateWindow() OVERRIDE;
+  virtual void CloseWindow() OVERRIDE;
+  virtual void MoveWindow(int x, int y) OVERRIDE;
+  virtual void SetDockSide(const std::string& dock_side) OVERRIDE;
+  virtual void OpenInNewTab(const std::string& url) OVERRIDE;
+  virtual void SaveToFile(const std::string& url,
+                          const std::string& content,
+                          bool save_as) OVERRIDE;
+  virtual void AppendToFile(const std::string& url,
+                            const std::string& content) OVERRIDE;
+  virtual void RequestFileSystems() OVERRIDE;
+  virtual void AddFileSystem() OVERRIDE;
+  virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
+  virtual void IndexPath(int request_id,
+                         const std::string& file_system_path) OVERRIDE;
+  virtual void StopIndexing(int request_id) OVERRIDE;
+  virtual void SearchInPath(int request_id,
+                            const std::string& file_system_path,
+                            const std::string& query) OVERRIDE;
+
  private:
   NativeWindow* owner_window_;
 
   scoped_refptr<content::DevToolsAgentHost> devtools_agent_host_;
   scoped_ptr<content::DevToolsClientHost> devtools_client_host_;
+  scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
 
   DISALLOW_COPY_AND_ASSIGN(DevToolsDelegate);
 };