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_client_host.h" | 20 #include "content/public/browser/devtools_agent_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; | |
31 struct FileChooserParams; | 30 struct FileChooserParams; |
32 class WebContents; | 31 class WebContents; |
33 } | 32 } |
34 | 33 |
35 // Base implementation of DevTools bindings around front-end. | 34 // Base implementation of DevTools bindings around front-end. |
36 class DevToolsUIBindings : public content::NotificationObserver, | 35 class DevToolsUIBindings : public content::NotificationObserver, |
37 public content::DevToolsFrontendHost::Delegate, | 36 public content::DevToolsFrontendHost::Delegate, |
38 public DevToolsEmbedderMessageDispatcher::Delegate, | 37 public DevToolsEmbedderMessageDispatcher::Delegate, |
39 public DevToolsAndroidBridge::DeviceCountListener, | 38 public DevToolsAndroidBridge::DeviceCountListener, |
40 public content::DevToolsClientHost { | 39 public content::DevToolsAgentHost::Client { |
41 public: | 40 public: |
42 static GURL ApplyThemeToURL(Profile* profile, const GURL& base_url); | 41 static GURL ApplyThemeToURL(Profile* profile, const GURL& base_url); |
43 | 42 |
44 class Delegate { | 43 class Delegate { |
45 public: | 44 public: |
46 virtual ~Delegate() {} | 45 virtual ~Delegate() {} |
47 virtual void ActivateWindow() = 0; | 46 virtual void ActivateWindow() = 0; |
48 virtual void CloseWindow() = 0; | 47 virtual void CloseWindow() = 0; |
49 virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; | 48 virtual void SetInspectedPageBounds(const gfx::Rect& rect) = 0; |
50 virtual void SetContentsResizingStrategy( | 49 virtual void SetContentsResizingStrategy( |
51 const gfx::Insets& insets, const gfx::Size& min_size) = 0; | 50 const gfx::Insets& insets, const gfx::Size& min_size) = 0; |
52 virtual void InspectElementCompleted() = 0; | 51 virtual void InspectElementCompleted() = 0; |
53 virtual void MoveWindow(int x, int y) = 0; | 52 virtual void MoveWindow(int x, int y) = 0; |
54 virtual void SetIsDocked(bool is_docked) = 0; | 53 virtual void SetIsDocked(bool is_docked) = 0; |
55 virtual void OpenInNewTab(const std::string& url) = 0; | 54 virtual void OpenInNewTab(const std::string& url) = 0; |
56 virtual void SetWhitelistedShortcuts(const std::string& message) = 0; | 55 virtual void SetWhitelistedShortcuts(const std::string& message) = 0; |
57 | 56 |
58 virtual void InspectedContentsClosing() = 0; | 57 virtual void InspectedContentsClosing() = 0; |
59 virtual void OnLoadCompleted() = 0; | 58 virtual void OnLoadCompleted() = 0; |
60 virtual InfoBarService* GetInfoBarService() = 0; | 59 virtual InfoBarService* GetInfoBarService() = 0; |
61 virtual void RenderProcessGone() = 0; | 60 virtual void RenderProcessGone() = 0; |
62 }; | 61 }; |
63 | 62 |
64 DevToolsUIBindings(content::WebContents* web_contents, const GURL& url); | 63 DevToolsUIBindings(content::WebContents* web_contents, const GURL& url); |
65 virtual ~DevToolsUIBindings(); | 64 virtual ~DevToolsUIBindings(); |
66 | 65 |
67 content::WebContents* web_contents() { return web_contents_; } | 66 content::WebContents* web_contents() { return web_contents_; } |
68 Profile* profile() { return profile_; } | 67 Profile* profile() { return profile_; } |
| 68 content::DevToolsAgentHost* agent_host() { return agent_host_.get(); } |
69 | 69 |
70 // Takes ownership over the |delegate|. | 70 // Takes ownership over the |delegate|. |
71 void SetDelegate(Delegate* delegate); | 71 void SetDelegate(Delegate* delegate); |
72 void CallClientFunction(const std::string& function_name, | 72 void CallClientFunction(const std::string& function_name, |
73 const base::Value* arg1, | 73 const base::Value* arg1, |
74 const base::Value* arg2, | 74 const base::Value* arg2, |
75 const base::Value* arg3); | 75 const base::Value* arg3); |
| 76 void AttachTo(content::DevToolsAgentHost* agent_host); |
| 77 void Reattach(); |
| 78 void Detach(); |
| 79 bool IsAttachedTo(content::DevToolsAgentHost* agent_host); |
| 80 |
76 private: | 81 private: |
77 // content::NotificationObserver overrides. | 82 // content::NotificationObserver overrides. |
78 virtual void Observe(int type, | 83 virtual void Observe(int type, |
79 const content::NotificationSource& source, | 84 const content::NotificationSource& source, |
80 const content::NotificationDetails& details) OVERRIDE; | 85 const content::NotificationDetails& details) OVERRIDE; |
81 | 86 |
82 // content::DevToolsFrontendHost::Delegate implementation. | 87 // content::DevToolsFrontendHost::Delegate implementation. |
83 virtual void HandleMessageFromDevToolsFrontend( | 88 virtual void HandleMessageFromDevToolsFrontend( |
84 const std::string& message) OVERRIDE; | 89 const std::string& message) OVERRIDE; |
85 virtual void HandleMessageFromDevToolsFrontendToBackend( | 90 virtual void HandleMessageFromDevToolsFrontendToBackend( |
86 const std::string& message) OVERRIDE; | 91 const std::string& message) OVERRIDE; |
87 | 92 |
88 // content::DevToolsClientHost implementation. | 93 // content::DevToolsAgentHost::Client implementation. |
89 virtual void DispatchOnInspectorFrontend(const std::string& message) OVERRIDE; | 94 virtual void DispatchProtocolMessage( |
90 virtual void InspectedContentsClosing() OVERRIDE; | 95 content::DevToolsAgentHost* agent_host, |
91 virtual void ReplacedWithAnotherClient() OVERRIDE; | 96 const std::string& message) OVERRIDE; |
| 97 virtual void AgentHostClosed( |
| 98 content::DevToolsAgentHost* agent_host, |
| 99 bool replaced_with_another_client) OVERRIDE; |
92 | 100 |
93 // DevToolsEmbedderMessageDispatcher::Delegate implementation. | 101 // DevToolsEmbedderMessageDispatcher::Delegate implementation. |
94 virtual void ActivateWindow() OVERRIDE; | 102 virtual void ActivateWindow() OVERRIDE; |
95 virtual void CloseWindow() OVERRIDE; | 103 virtual void CloseWindow() OVERRIDE; |
96 virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; | 104 virtual void SetInspectedPageBounds(const gfx::Rect& rect) OVERRIDE; |
97 virtual void SetContentsResizingStrategy( | 105 virtual void SetContentsResizingStrategy( |
98 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE; | 106 const gfx::Insets& insets, const gfx::Size& min_size) OVERRIDE; |
99 virtual void InspectElementCompleted() OVERRIDE; | 107 virtual void InspectElementCompleted() OVERRIDE; |
100 virtual void InspectedURLChanged(const std::string& url) OVERRIDE; | 108 virtual void InspectedURLChanged(const std::string& url) OVERRIDE; |
101 virtual void MoveWindow(int x, int y) OVERRIDE; | 109 virtual void MoveWindow(int x, int y) OVERRIDE; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void UpdateTheme(); | 171 void UpdateTheme(); |
164 void AddDevToolsExtensionsToClient(); | 172 void AddDevToolsExtensionsToClient(); |
165 | 173 |
166 class FrontendWebContentsObserver; | 174 class FrontendWebContentsObserver; |
167 friend class FrontendWebContentsObserver; | 175 friend class FrontendWebContentsObserver; |
168 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; | 176 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; |
169 | 177 |
170 Profile* profile_; | 178 Profile* profile_; |
171 content::WebContents* web_contents_; | 179 content::WebContents* web_contents_; |
172 scoped_ptr<Delegate> delegate_; | 180 scoped_ptr<Delegate> delegate_; |
| 181 scoped_refptr<content::DevToolsAgentHost> agent_host_; |
173 content::NotificationRegistrar registrar_; | 182 content::NotificationRegistrar registrar_; |
174 scoped_ptr<content::DevToolsFrontendHost> frontend_host_; | 183 scoped_ptr<content::DevToolsFrontendHost> frontend_host_; |
175 scoped_ptr<DevToolsFileHelper> file_helper_; | 184 scoped_ptr<DevToolsFileHelper> file_helper_; |
176 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; | 185 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; |
177 typedef std::map< | 186 typedef std::map< |
178 int, | 187 int, |
179 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > | 188 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > |
180 IndexingJobsMap; | 189 IndexingJobsMap; |
181 IndexingJobsMap indexing_jobs_; | 190 IndexingJobsMap indexing_jobs_; |
182 | 191 |
183 bool device_count_updates_enabled_; | 192 bool device_count_updates_enabled_; |
184 bool devices_updates_enabled_; | 193 bool devices_updates_enabled_; |
185 scoped_ptr<DevToolsTargetsUIHandler> remote_targets_handler_; | 194 scoped_ptr<DevToolsTargetsUIHandler> remote_targets_handler_; |
186 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; | 195 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; |
187 GURL url_; | 196 GURL url_; |
188 base::WeakPtrFactory<DevToolsUIBindings> weak_factory_; | 197 base::WeakPtrFactory<DevToolsUIBindings> weak_factory_; |
189 | 198 |
190 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindings); | 199 DISALLOW_COPY_AND_ASSIGN(DevToolsUIBindings); |
191 }; | 200 }; |
192 | 201 |
193 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ | 202 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_BINDINGS_H_ |
OLD | NEW |