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_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
| 11 #include <string> |
11 | 12 |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "chrome/browser/devtools/device/devtools_device_discovery.h" | 15 #include "chrome/browser/devtools/device/devtools_device_discovery.h" |
15 #include "content/public/browser/devtools_agent_host_observer.h" | 16 #include "content/public/browser/devtools_agent_host_observer.h" |
16 #include "content/public/browser/devtools_manager_delegate.h" | 17 #include "content/public/browser/devtools_manager_delegate.h" |
17 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
18 | 19 |
19 class DevToolsNetworkProtocolHandler; | 20 class DevToolsNetworkProtocolHandler; |
20 | 21 |
21 class ChromeDevToolsManagerDelegate : | 22 class ChromeDevToolsManagerDelegate : |
22 public content::DevToolsManagerDelegate, | 23 public content::DevToolsManagerDelegate, |
23 public content::DevToolsAgentHostObserver { | 24 public content::DevToolsAgentHostObserver { |
24 public: | 25 public: |
25 static char kTypeApp[]; | 26 static char kTypeApp[]; |
26 static char kTypeBackgroundPage[]; | 27 static char kTypeBackgroundPage[]; |
27 static char kTypeWebView[]; | 28 static char kTypeWebView[]; |
28 | 29 |
29 ChromeDevToolsManagerDelegate(); | 30 ChromeDevToolsManagerDelegate(); |
30 ~ChromeDevToolsManagerDelegate() override; | 31 ~ChromeDevToolsManagerDelegate() override; |
31 | 32 |
32 private: | 33 private: |
33 class HostData; | 34 class HostData; |
| 35 friend class DevToolsManagerDelegateTest; |
34 using RemoteLocations = std::set<net::HostPortPair>; | 36 using RemoteLocations = std::set<net::HostPortPair>; |
35 | 37 |
36 // content::DevToolsManagerDelegate implementation. | 38 // content::DevToolsManagerDelegate implementation. |
37 void Inspect(content::DevToolsAgentHost* agent_host) override; | 39 void Inspect(content::DevToolsAgentHost* agent_host) override; |
38 base::DictionaryValue* HandleCommand( | 40 base::DictionaryValue* HandleCommand( |
39 content::DevToolsAgentHost* agent_host, | 41 content::DevToolsAgentHost* agent_host, |
40 base::DictionaryValue* command_dict) override; | 42 base::DictionaryValue* command_dict) override; |
41 std::string GetTargetType(content::RenderFrameHost* host) override; | 43 std::string GetTargetType(content::RenderFrameHost* host) override; |
42 std::string GetTargetTitle(content::RenderFrameHost* host) override; | 44 std::string GetTargetTitle(content::RenderFrameHost* host) override; |
43 scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( | 45 scoped_refptr<content::DevToolsAgentHost> CreateNewTarget( |
44 const GURL& url) override; | 46 const GURL& url) override; |
45 std::string GetDiscoveryPageHTML() override; | 47 std::string GetDiscoveryPageHTML() override; |
46 std::string GetFrontendResource(const std::string& path) override; | 48 std::string GetFrontendResource(const std::string& path) override; |
47 | 49 |
48 // content::DevToolsAgentHostObserver overrides. | 50 // content::DevToolsAgentHostObserver overrides. |
49 void DevToolsAgentHostAttached( | 51 void DevToolsAgentHostAttached( |
50 content::DevToolsAgentHost* agent_host) override; | 52 content::DevToolsAgentHost* agent_host) override; |
51 void DevToolsAgentHostDetached( | 53 void DevToolsAgentHostDetached( |
52 content::DevToolsAgentHost* agent_host) override; | 54 content::DevToolsAgentHost* agent_host) override; |
53 | 55 |
54 void UpdateDeviceDiscovery(); | 56 void UpdateDeviceDiscovery(); |
55 void DevicesAvailable( | 57 void DevicesAvailable( |
56 const DevToolsDeviceDiscovery::CompleteDevices& devices); | 58 const DevToolsDeviceDiscovery::CompleteDevices& devices); |
57 | 59 |
58 std::unique_ptr<base::DictionaryValue> SetRemoteLocations( | 60 std::unique_ptr<base::DictionaryValue> SetRemoteLocations( |
59 content::DevToolsAgentHost* agent_host, | 61 content::DevToolsAgentHost* agent_host, |
60 int command_id, | 62 int command_id, |
61 base::DictionaryValue* params); | 63 base::DictionaryValue* params); |
62 | 64 |
| 65 std::unique_ptr<base::DictionaryValue> HandleBrowserCommand( |
| 66 int id, |
| 67 std::string method, |
| 68 base::DictionaryValue* params); |
| 69 static std::unique_ptr<base::DictionaryValue> GetWindowForTarget( |
| 70 int id, |
| 71 base::DictionaryValue* params); |
| 72 static std::unique_ptr<base::DictionaryValue> GetWindowBounds( |
| 73 int id, |
| 74 base::DictionaryValue* params); |
| 75 static std::unique_ptr<base::DictionaryValue> SetWindowBounds( |
| 76 int id, |
| 77 base::DictionaryValue* params); |
| 78 |
63 std::unique_ptr<DevToolsNetworkProtocolHandler> network_protocol_handler_; | 79 std::unique_ptr<DevToolsNetworkProtocolHandler> network_protocol_handler_; |
64 std::map<content::DevToolsAgentHost*, std::unique_ptr<HostData>> host_data_; | 80 std::map<content::DevToolsAgentHost*, std::unique_ptr<HostData>> host_data_; |
65 | 81 |
66 std::unique_ptr<AndroidDeviceManager> device_manager_; | 82 std::unique_ptr<AndroidDeviceManager> device_manager_; |
67 std::unique_ptr<DevToolsDeviceDiscovery> device_discovery_; | 83 std::unique_ptr<DevToolsDeviceDiscovery> device_discovery_; |
68 content::DevToolsAgentHost::List remote_agent_hosts_; | 84 content::DevToolsAgentHost::List remote_agent_hosts_; |
69 RemoteLocations remote_locations_; | 85 RemoteLocations remote_locations_; |
70 | 86 |
71 DISALLOW_COPY_AND_ASSIGN(ChromeDevToolsManagerDelegate); | 87 DISALLOW_COPY_AND_ASSIGN(ChromeDevToolsManagerDelegate); |
72 }; | 88 }; |
73 | 89 |
74 #endif // CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ | 90 #endif // CHROME_BROWSER_DEVTOOLS_CHROME_DEVTOOLS_MANAGER_DELEGATE_H_ |
OLD | NEW |