| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 15 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
| 16 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" | 16 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" |
| 17 #include "chrome/browser/devtools/devtools_file_helper.h" | 17 #include "chrome/browser/devtools/devtools_file_helper.h" |
| 18 #include "chrome/browser/devtools/devtools_file_system_indexer.h" | 18 #include "chrome/browser/devtools/devtools_file_system_indexer.h" |
| 19 #include "chrome/browser/devtools/devtools_targets_ui.h" | 19 #include "chrome/browser/devtools/devtools_targets_ui.h" |
| 20 #include "content/public/browser/devtools_agent_host.h" | 20 #include "content/public/browser/devtools_client_host.h" |
| 21 #include "content/public/browser/devtools_frontend_host.h" | 21 #include "content/public/browser/devtools_frontend_host.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
| 25 | 25 |
| 26 class InfoBarService; | 26 class InfoBarService; |
| 27 class Profile; | 27 class Profile; |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 class DevToolsClientHost; |
| 30 struct FileChooserParams; | 31 struct FileChooserParams; |
| 31 class WebContents; | 32 class WebContents; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Base implementation of DevTools bindings around front-end. | 35 // Base implementation of DevTools bindings around front-end. |
| 35 class DevToolsUIBindings : public content::NotificationObserver, | 36 class DevToolsUIBindings : public content::NotificationObserver, |
| 36 public content::DevToolsFrontendHost::Delegate, | 37 public content::DevToolsFrontendHost::Delegate, |
| 37 public DevToolsEmbedderMessageDispatcher::Delegate, | 38 public DevToolsEmbedderMessageDispatcher::Delegate, |
| 38 public DevToolsAndroidBridge::DeviceCountListener, | 39 public DevToolsAndroidBridge::DeviceCountListener, |
| 39 public content::DevToolsAgentHostClient { | 40 public content::DevToolsClientHost { |
| 40 public: | 41 public: |
| 41 static GURL ApplyThemeToURL(Profile* profile, const GURL& base_url); | 42 static GURL ApplyThemeToURL(Profile* profile, const GURL& base_url); |
| 42 | 43 |
| 43 class Delegate { | 44 class Delegate { |
| 44 public: | 45 public: |
| 45 virtual ~Delegate() {} | 46 virtual ~Delegate() {} |
| 46 virtual void ActivateWindow() = 0; | 47 virtual void ActivateWindow() = 0; |
| 47 virtual void CloseWindow() = 0; | 48 virtual void CloseWindow() = 0; |
| 48 virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; | 49 virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; |
| 49 virtual void InspectElementCompleted() = 0; | 50 virtual void InspectElementCompleted() = 0; |
| 50 virtual void MoveWindow(int x, int y) = 0; | 51 virtual void MoveWindow(int x, int y) = 0; |
| 51 virtual void SetIsDocked(bool is_docked) = 0; | 52 virtual void SetIsDocked(bool is_docked) = 0; |
| 52 virtual void OpenInNewTab(const std::string& url) = 0; | 53 virtual void OpenInNewTab(const std::string& url) = 0; |
| 53 virtual void SetWhitelistedShortcuts(const std::string& message) = 0; | 54 virtual void SetWhitelistedShortcuts(const std::string& message) = 0; |
| 54 | 55 |
| 55 virtual void InspectedContentsClosing() = 0; | 56 virtual void InspectedContentsClosing() = 0; |
| 56 virtual void OnLoadCompleted() = 0; | 57 virtual void OnLoadCompleted() = 0; |
| 57 virtual InfoBarService* GetInfoBarService() = 0; | 58 virtual InfoBarService* GetInfoBarService() = 0; |
| 58 virtual void RenderProcessGone() = 0; | 59 virtual void RenderProcessGone() = 0; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 DevToolsUIBindings(content::WebContents* web_contents, const GURL& url); | 62 DevToolsUIBindings(content::WebContents* web_contents, const GURL& url); |
| 62 virtual ~DevToolsUIBindings(); | 63 virtual ~DevToolsUIBindings(); |
| 63 | 64 |
| 64 content::WebContents* web_contents() { return web_contents_; } | 65 content::WebContents* web_contents() { return web_contents_; } |
| 65 Profile* profile() { return profile_; } | 66 Profile* profile() { return profile_; } |
| 66 content::DevToolsAgentHost* agent_host() { return agent_host_.get(); } | |
| 67 | 67 |
| 68 // Takes ownership over the |delegate|. | 68 // Takes ownership over the |delegate|. |
| 69 void SetDelegate(Delegate* delegate); | 69 void SetDelegate(Delegate* delegate); |
| 70 void CallClientFunction(const std::string& function_name, | 70 void CallClientFunction(const std::string& function_name, |
| 71 const base::Value* arg1, | 71 const base::Value* arg1, |
| 72 const base::Value* arg2, | 72 const base::Value* arg2, |
| 73 const base::Value* arg3); | 73 const base::Value* arg3); |
| 74 void AttachTo(content::DevToolsAgentHost* agent_host); | |
| 75 void Reattach(); | |
| 76 void Detach(); | |
| 77 bool IsAttachedTo(content::DevToolsAgentHost* agent_host); | |
| 78 | |
| 79 private: | 74 private: |
| 80 // content::NotificationObserver overrides. | 75 // content::NotificationObserver overrides. |
| 81 virtual void Observe(int type, | 76 virtual void Observe(int type, |
| 82 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
| 83 const content::NotificationDetails& details) OVERRIDE; | 78 const content::NotificationDetails& details) OVERRIDE; |
| 84 | 79 |
| 85 // content::DevToolsFrontendHost::Delegate implementation. | 80 // content::DevToolsFrontendHost::Delegate implementation. |
| 86 virtual void HandleMessageFromDevToolsFrontend( | 81 virtual void HandleMessageFromDevToolsFrontend( |
| 87 const std::string& message) OVERRIDE; | 82 const std::string& message) OVERRIDE; |
| 88 virtual void HandleMessageFromDevToolsFrontendToBackend( | 83 virtual void HandleMessageFromDevToolsFrontendToBackend( |
| 89 const std::string& message) OVERRIDE; | 84 const std::string& message) OVERRIDE; |
| 90 | 85 |
| 91 // content::DevToolsAgentHostClient implementation. | 86 // content::DevToolsClientHost implementation. |
| 92 virtual void DispatchProtocolMessage( | 87 virtual void DispatchOnInspectorFrontend(const std::string& message) OVERRIDE; |
| 93 content::DevToolsAgentHost* agent_host, | 88 virtual void InspectedContentsClosing() OVERRIDE; |
| 94 const std::string& message) OVERRIDE; | 89 virtual void ReplacedWithAnotherClient() OVERRIDE; |
| 95 virtual void AgentHostClosed( | |
| 96 content::DevToolsAgentHost* agent_host, | |
| 97 bool replaced_with_another_client) OVERRIDE; | |
| 98 | 90 |
| 99 // DevToolsEmbedderMessageDispatcher::Delegate implementation. | 91 // DevToolsEmbedderMessageDispatcher::Delegate implementation. |
| 100 virtual void ActivateWindow() OVERRIDE; | 92 virtual void ActivateWindow() OVERRIDE; |
| 101 virtual void CloseWindow() OVERRIDE; | 93 virtual void CloseWindow() OVERRIDE; |
| 102 virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; | 94 virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; |
| 103 virtual void InspectElementCompleted() OVERRIDE; | 95 virtual void InspectElementCompleted() OVERRIDE; |
| 104 virtual void InspectedURLChanged(const std::string& url) OVERRIDE; | 96 virtual void InspectedURLChanged(const std::string& url) OVERRIDE; |
| 105 virtual void MoveWindow(int x, int y) OVERRIDE; | 97 virtual void MoveWindow(int x, int y) OVERRIDE; |
| 106 virtual void SetIsDocked(bool is_docked) OVERRIDE; | 98 virtual void SetIsDocked(bool is_docked) OVERRIDE; |
| 107 virtual void OpenInNewTab(const std::string& url) OVERRIDE; | 99 virtual void OpenInNewTab(const std::string& url) OVERRIDE; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void UpdateTheme(); | 159 void UpdateTheme(); |
| 168 void AddDevToolsExtensionsToClient(); | 160 void AddDevToolsExtensionsToClient(); |
| 169 | 161 |
| 170 class FrontendWebContentsObserver; | 162 class FrontendWebContentsObserver; |
| 171 friend class FrontendWebContentsObserver; | 163 friend class FrontendWebContentsObserver; |
| 172 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; | 164 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; |
| 173 | 165 |
| 174 Profile* profile_; | 166 Profile* profile_; |
| 175 content::WebContents* web_contents_; | 167 content::WebContents* web_contents_; |
| 176 scoped_ptr<Delegate> delegate_; | 168 scoped_ptr<Delegate> delegate_; |
| 177 scoped_refptr<content::DevToolsAgentHost> agent_host_; | |
| 178 content::NotificationRegistrar registrar_; | 169 content::NotificationRegistrar registrar_; |
| 179 scoped_ptr<content::DevToolsFrontendHost> frontend_host_; | 170 scoped_ptr<content::DevToolsFrontendHost> frontend_host_; |
| 180 scoped_ptr<DevToolsFileHelper> file_helper_; | 171 scoped_ptr<DevToolsFileHelper> file_helper_; |
| 181 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; | 172 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; |
| 182 typedef std::map< | 173 typedef std::map< |
| 183 int, | 174 int, |
| 184 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > | 175 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > |
| 185 IndexingJobsMap; | 176 IndexingJobsMap; |
| 186 IndexingJobsMap indexing_jobs_; | 177 IndexingJobsMap indexing_jobs_; |
| 187 | 178 |
| 188 bool device_count_updates_enabled_; | 179 bool device_count_updates_enabled_; |
| 189 bool devices_updates_enabled_; | 180 bool devices_updates_enabled_; |
| 190 scoped_ptr<DevToolsTargetsUIHandler> remote_targets_handler_; | 181 scoped_ptr<DevToolsTargetsUIHandler> remote_targets_handler_; |
| 191 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; | 182 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; |
| 192 GURL url_; | 183 GURL url_; |
| 193 base::WeakPtrFactory<DevToolsUIBindings> weak_factory_; | 184 base::WeakPtrFactory<DevToolsUIBindings> weak_factory_; |
| 194 | 185 |
| 195 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindings); | 186 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindings); |
| 196 }; | 187 }; |
| 197 | 188 |
| 198 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ | 189 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ |
| OLD | NEW |