Chromium Code Reviews| 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 #include "chrome/browser/devtools/device/devtools_android_bridge.h" | 5 #include "chrome/browser/devtools/device/devtools_android_bridge.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "chrome/browser/devtools/devtools_target_impl.h" | 30 #include "chrome/browser/devtools/devtools_target_impl.h" |
| 31 #include "chrome/browser/devtools/devtools_window.h" | 31 #include "chrome/browser/devtools/devtools_window.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 34 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 34 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 35 #include "content/public/browser/devtools_agent_host.h" | 35 #include "content/public/browser/devtools_agent_host.h" |
| 36 #include "content/public/browser/devtools_external_agent_proxy.h" | 36 #include "content/public/browser/devtools_external_agent_proxy.h" |
| 37 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" | 37 #include "content/public/browser/devtools_external_agent_proxy_delegate.h" |
| 38 #include "content/public/browser/user_metrics.h" | 38 #include "content/public/browser/user_metrics.h" |
| 39 #include "net/base/escape.h" | 39 #include "net/base/escape.h" |
| 40 #include "net/base/net_errors.h" | |
| 40 | 41 |
| 41 using content::BrowserThread; | 42 using content::BrowserThread; |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 | 45 |
| 45 const char kPageListRequest[] = "/json"; | 46 const char kPageListRequest[] = "/json"; |
| 46 const char kVersionRequest[] = "/json/version"; | 47 const char kVersionRequest[] = "/json/version"; |
| 47 const char kClosePageRequest[] = "/json/close/%s"; | 48 const char kClosePageRequest[] = "/json/close/%s"; |
| 48 const char kNewPageRequest[] = "/json/new"; | 49 const char kNewPageRequest[] = "/json/new"; |
| 49 const char kNewPageRequestWithURL[] = "/json/new?%s"; | 50 const char kNewPageRequestWithURL[] = "/json/new?%s"; |
| 50 const char kActivatePageRequest[] = "/json/activate/%s"; | 51 const char kActivatePageRequest[] = "/json/activate/%s"; |
| 51 const char kBrowserTargetSocket[] = "/devtools/browser"; | 52 const char kBrowserTargetSocket[] = "/devtools/browser"; |
| 52 const int kAdbPollingIntervalMs = 1000; | 53 const int kAdbPollingIntervalMs = 1000; |
| 53 | 54 |
| 54 const char kUrlParam[] = "url"; | 55 const char kUrlParam[] = "url"; |
| 55 const char kPageReloadCommand[] = "Page.reload"; | 56 const char kPageReloadCommand[] = "Page.reload"; |
| 56 const char kPageNavigateCommand[] = "Page.navigate"; | 57 const char kPageNavigateCommand[] = "Page.navigate"; |
| 57 | 58 |
| 58 const int kMinVersionNewWithURL = 32; | 59 const int kMinVersionNewWithURL = 32; |
| 59 const int kNewPageNavigateDelayMs = 500; | 60 const int kNewPageNavigateDelayMs = 500; |
| 60 | 61 |
| 62 } // namespace | |
| 63 | |
| 61 // DiscoveryRequest ----------------------------------------------------- | 64 // DiscoveryRequest ----------------------------------------------------- |
| 62 | 65 |
| 63 class DiscoveryRequest : public base::RefCountedThreadSafe< | 66 class DevToolsAndroidBridge::DiscoveryRequest |
| 64 DiscoveryRequest, | 67 : public base::RefCountedThreadSafe<DiscoveryRequest, |
| 65 BrowserThread::DeleteOnUIThread> { | 68 BrowserThread::DeleteOnUIThread> { |
| 66 public: | 69 public: |
| 67 typedef AndroidDeviceManager::Device Device; | |
| 68 typedef AndroidDeviceManager::Devices Devices; | |
| 69 typedef AndroidDeviceManager::DeviceInfo DeviceInfo; | |
| 70 typedef DevToolsAndroidBridge::RemoteDevice RemoteDevice; | |
| 71 typedef DevToolsAndroidBridge::RemoteDevices RemoteDevices; | |
| 72 typedef DevToolsAndroidBridge::RemoteBrowser RemoteBrowser; | |
| 73 typedef DevToolsAndroidBridge::RemoteBrowsers RemoteBrowsers; | |
| 74 typedef base::Callback<void(const RemoteDevices&)> DiscoveryCallback; | |
| 75 | |
| 76 DiscoveryRequest(AndroidDeviceManager* device_manager, | 70 DiscoveryRequest(AndroidDeviceManager* device_manager, |
| 77 const DiscoveryCallback& callback); | 71 const DeviceListCallback& callback); |
| 78 private: | 72 private: |
| 79 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 73 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 80 friend class base::DeleteHelper<DiscoveryRequest>; | 74 friend class base::DeleteHelper<DiscoveryRequest>; |
| 81 virtual ~DiscoveryRequest(); | 75 virtual ~DiscoveryRequest(); |
| 82 | 76 |
| 83 void ReceivedDevices(const Devices& devices); | 77 void ReceivedDevices(const AndroidDeviceManager::Devices& devices); |
| 84 void ReceivedDeviceInfo(scoped_refptr<Device> device, | 78 void ReceivedDeviceInfo(scoped_refptr<AndroidDeviceManager::Device> device, |
| 85 const DeviceInfo& device_info); | 79 const AndroidDeviceManager::DeviceInfo& device_info); |
| 86 void ReceivedVersion(scoped_refptr<RemoteBrowser>, | 80 void ReceivedVersion(scoped_refptr<RemoteBrowser>, |
| 87 int result, | 81 int result, |
| 88 const std::string& response); | 82 const std::string& response); |
| 89 void ReceivedPages(scoped_refptr<RemoteBrowser>, | 83 void ReceivedPages(scoped_refptr<RemoteBrowser>, |
| 90 int result, | 84 int result, |
| 91 const std::string& response); | 85 const std::string& response); |
| 92 | 86 |
| 93 DiscoveryCallback callback_; | 87 DeviceListCallback callback_; |
| 94 RemoteDevices remote_devices_; | 88 CompleteDevices complete_devices_; |
| 95 }; | 89 }; |
| 96 | 90 |
| 97 DiscoveryRequest::DiscoveryRequest( | 91 DevToolsAndroidBridge::DiscoveryRequest::DiscoveryRequest( |
| 98 AndroidDeviceManager* device_manager, | 92 AndroidDeviceManager* device_manager, |
| 99 const DiscoveryCallback& callback) | 93 const DeviceListCallback& callback) |
| 100 : callback_(callback) { | 94 : callback_(callback) { |
| 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 102 device_manager->QueryDevices( | 96 device_manager->QueryDevices( |
| 103 base::Bind(&DiscoveryRequest::ReceivedDevices, this)); | 97 base::Bind(&DiscoveryRequest::ReceivedDevices, this)); |
| 104 } | 98 } |
| 105 | 99 |
| 106 DiscoveryRequest::~DiscoveryRequest() { | 100 DevToolsAndroidBridge::DiscoveryRequest::~DiscoveryRequest() { |
| 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 108 callback_.Run(remote_devices_); | 102 callback_.Run(complete_devices_); |
| 109 } | 103 } |
| 110 | 104 |
| 111 void DiscoveryRequest::ReceivedDevices(const Devices& devices) { | 105 void DevToolsAndroidBridge::DiscoveryRequest::ReceivedDevices( |
| 106 const AndroidDeviceManager::Devices& devices) { | |
| 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 113 for (Devices::const_iterator it = devices.begin(); | 108 for (const auto& device : devices) { |
| 114 it != devices.end(); ++it) { | 109 device->QueryDeviceInfo( |
| 115 (*it)->QueryDeviceInfo( | 110 base::Bind(&DiscoveryRequest::ReceivedDeviceInfo, this, device)); |
| 116 base::Bind(&DiscoveryRequest::ReceivedDeviceInfo, this, *it)); | |
| 117 } | 111 } |
| 118 } | 112 } |
| 119 | 113 |
| 120 void DiscoveryRequest::ReceivedDeviceInfo(scoped_refptr<Device> device, | 114 void DevToolsAndroidBridge::DiscoveryRequest::ReceivedDeviceInfo( |
| 121 const DeviceInfo& device_info) { | 115 scoped_refptr<AndroidDeviceManager::Device> device, |
| 116 const AndroidDeviceManager::DeviceInfo& device_info) { | |
| 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 123 scoped_refptr<RemoteDevice> remote_device = | 118 scoped_refptr<RemoteDevice> remote_device = |
| 124 new RemoteDevice(device, device_info); | 119 new RemoteDevice(device->serial(), device_info); |
| 125 remote_devices_.push_back(remote_device); | 120 complete_devices_.push_back(std::make_pair(device, remote_device)); |
| 126 for (RemoteBrowsers::iterator it = remote_device->browsers().begin(); | 121 for (RemoteBrowsers::iterator it = remote_device->browsers().begin(); |
| 127 it != remote_device->browsers().end(); ++it) { | 122 it != remote_device->browsers().end(); ++it) { |
| 128 (*it)->SendJsonRequest( | 123 device->SendJsonRequest( |
| 124 (*it)->socket(), | |
| 129 kVersionRequest, | 125 kVersionRequest, |
| 130 base::Bind(&DiscoveryRequest::ReceivedVersion, this, *it)); | 126 base::Bind(&DiscoveryRequest::ReceivedVersion, this, *it)); |
| 131 (*it)->SendJsonRequest( | 127 device->SendJsonRequest( |
| 128 (*it)->socket(), | |
| 132 kPageListRequest, | 129 kPageListRequest, |
| 133 base::Bind(&DiscoveryRequest::ReceivedPages, this, *it)); | 130 base::Bind(&DiscoveryRequest::ReceivedPages, this, *it)); |
| 134 } | 131 } |
| 135 } | 132 } |
| 136 | 133 |
| 137 void DiscoveryRequest::ReceivedVersion(scoped_refptr<RemoteBrowser> browser, | 134 void DevToolsAndroidBridge::DiscoveryRequest::ReceivedVersion( |
| 138 int result, | 135 scoped_refptr<RemoteBrowser> browser, |
| 139 const std::string& response) { | 136 int result, |
| 137 const std::string& response) { | |
| 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 141 if (result < 0) | 139 if (result < 0) |
| 142 return; | 140 return; |
| 143 // Parse version, append to package name if available, | 141 // Parse version, append to package name if available, |
| 144 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); | 142 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); |
| 145 base::DictionaryValue* dict; | 143 base::DictionaryValue* dict; |
| 146 if (value && value->GetAsDictionary(&dict)) { | 144 if (value && value->GetAsDictionary(&dict)) { |
| 147 std::string browser_name; | 145 std::string browser_name; |
| 148 if (dict->GetString("Browser", &browser_name)) { | 146 if (dict->GetString("Browser", &browser_name)) { |
| 149 std::vector<std::string> parts; | 147 std::vector<std::string> parts; |
| 150 Tokenize(browser_name, "/", &parts); | 148 Tokenize(browser_name, "/", &parts); |
| 151 if (parts.size() == 2) | 149 if (parts.size() == 2) |
| 152 browser->set_version(parts[1]); | 150 browser->version_ = parts[1]; |
| 153 else | 151 else |
| 154 browser->set_version(browser_name); | 152 browser->version_ = browser_name; |
| 155 } | 153 } |
| 156 std::string package; | 154 std::string package; |
| 157 if (dict->GetString("Android-Package", &package)) { | 155 if (dict->GetString("Android-Package", &package)) { |
| 158 browser->set_display_name( | 156 browser->display_name_ = |
| 159 AdbDeviceInfoQuery::GetDisplayName(browser->socket(), package)); | 157 AdbDeviceInfoQuery::GetDisplayName(browser->socket(), package); |
| 160 } | 158 } |
| 161 } | 159 } |
| 162 } | 160 } |
| 163 | 161 |
| 164 void DiscoveryRequest::ReceivedPages(scoped_refptr<RemoteBrowser> browser, | 162 void DevToolsAndroidBridge::DiscoveryRequest::ReceivedPages( |
| 165 int result, | 163 scoped_refptr<RemoteBrowser> browser, |
| 166 const std::string& response) { | 164 int result, |
| 165 const std::string& response) { | |
| 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 168 if (result < 0) | 167 if (result < 0) |
| 169 return; | 168 return; |
| 170 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); | 169 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); |
| 171 base::ListValue* list_value; | 170 base::ListValue* list_value; |
| 172 if (value && value->GetAsList(&list_value)) | 171 if (value && value->GetAsList(&list_value)) |
| 173 browser->SetPageDescriptors(*list_value); | 172 browser->page_descriptors_.reset(list_value->DeepCopy()); |
| 174 } | 173 } |
| 175 | 174 |
| 176 // ProtocolCommand ------------------------------------------------------------ | 175 // ProtocolCommand ------------------------------------------------------------ |
| 177 | 176 |
| 177 namespace { | |
| 178 | |
| 178 class ProtocolCommand | 179 class ProtocolCommand |
| 179 : public DevToolsAndroidBridge::AndroidWebSocket::Delegate { | 180 : public AndroidDeviceManager::AndroidWebSocket::Delegate { |
| 180 public: | 181 public: |
| 181 ProtocolCommand( | 182 ProtocolCommand( |
| 182 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 183 scoped_refptr<AndroidDeviceManager::Device> device, |
| 184 const std::string& socket, | |
| 183 const std::string& debug_url, | 185 const std::string& debug_url, |
| 184 const std::string& command, | 186 const std::string& command, |
| 185 const base::Closure callback); | 187 const base::Closure callback); |
| 186 | 188 |
| 187 private: | 189 private: |
| 188 virtual void OnSocketOpened() OVERRIDE; | 190 virtual void OnSocketOpened() OVERRIDE; |
| 189 virtual void OnFrameRead(const std::string& message) OVERRIDE; | 191 virtual void OnFrameRead(const std::string& message) OVERRIDE; |
| 190 virtual void OnSocketClosed() OVERRIDE; | 192 virtual void OnSocketClosed() OVERRIDE; |
| 191 virtual ~ProtocolCommand(); | 193 virtual ~ProtocolCommand(); |
| 192 | 194 |
| 193 const std::string command_; | 195 const std::string command_; |
| 194 const base::Closure callback_; | 196 const base::Closure callback_; |
| 195 scoped_ptr<DevToolsAndroidBridge::AndroidWebSocket> web_socket_; | 197 scoped_ptr<AndroidDeviceManager::AndroidWebSocket> web_socket_; |
| 196 | 198 |
| 197 DISALLOW_COPY_AND_ASSIGN(ProtocolCommand); | 199 DISALLOW_COPY_AND_ASSIGN(ProtocolCommand); |
| 198 }; | 200 }; |
| 199 | 201 |
| 200 ProtocolCommand::ProtocolCommand( | 202 ProtocolCommand::ProtocolCommand( |
| 201 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 203 scoped_refptr<AndroidDeviceManager::Device> device, |
| 204 const std::string& socket, | |
| 202 const std::string& debug_url, | 205 const std::string& debug_url, |
| 203 const std::string& command, | 206 const std::string& command, |
| 204 const base::Closure callback) | 207 const base::Closure callback) |
| 205 : command_(command), | 208 : command_(command), |
| 206 callback_(callback), | 209 callback_(callback), |
| 207 web_socket_(browser->CreateWebSocket(debug_url, this)) { | 210 web_socket_(device->CreateWebSocket(socket, debug_url, this)) { |
| 208 } | 211 } |
| 209 | 212 |
| 210 void ProtocolCommand::OnSocketOpened() { | 213 void ProtocolCommand::OnSocketOpened() { |
| 211 web_socket_->SendFrame(command_); | 214 web_socket_->SendFrame(command_); |
| 212 } | 215 } |
| 213 | 216 |
| 214 void ProtocolCommand::OnFrameRead(const std::string& message) { | 217 void ProtocolCommand::OnFrameRead(const std::string& message) { |
| 215 delete this; | 218 delete this; |
| 216 } | 219 } |
| 217 | 220 |
| 218 void ProtocolCommand::OnSocketClosed() { | 221 void ProtocolCommand::OnSocketClosed() { |
| 219 delete this; | 222 delete this; |
| 220 } | 223 } |
| 221 | 224 |
| 222 ProtocolCommand::~ProtocolCommand() { | 225 ProtocolCommand::~ProtocolCommand() { |
| 223 if (!callback_.is_null()) | 226 if (!callback_.is_null()) |
| 224 callback_.Run(); | 227 callback_.Run(); |
| 225 } | 228 } |
| 226 | 229 |
| 227 } // namespace | 230 } // namespace |
| 228 | 231 |
| 229 class AgentHostDelegate; | |
| 230 | |
| 231 typedef std::map<std::string, AgentHostDelegate*> AgentHostDelegates; | |
| 232 | |
| 233 base::LazyInstance<AgentHostDelegates>::Leaky g_host_delegates = | |
| 234 LAZY_INSTANCE_INITIALIZER; | |
| 235 | |
| 236 DevToolsAndroidBridge::Wrapper::Wrapper(content::BrowserContext* context) { | 232 DevToolsAndroidBridge::Wrapper::Wrapper(content::BrowserContext* context) { |
| 237 bridge_ = new DevToolsAndroidBridge(Profile::FromBrowserContext(context)); | 233 bridge_ = new DevToolsAndroidBridge(Profile::FromBrowserContext(context)); |
| 238 } | 234 } |
| 239 | 235 |
| 240 DevToolsAndroidBridge::Wrapper::~Wrapper() { | 236 DevToolsAndroidBridge::Wrapper::~Wrapper() { |
| 241 } | 237 } |
| 242 | 238 |
| 243 DevToolsAndroidBridge* DevToolsAndroidBridge::Wrapper::Get() { | 239 DevToolsAndroidBridge* DevToolsAndroidBridge::Wrapper::Get() { |
| 244 return bridge_.get(); | 240 return bridge_.get(); |
| 245 } | 241 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 263 "DevToolsAndroidBridge", | 259 "DevToolsAndroidBridge", |
| 264 BrowserContextDependencyManager::GetInstance()) {} | 260 BrowserContextDependencyManager::GetInstance()) {} |
| 265 | 261 |
| 266 DevToolsAndroidBridge::Factory::~Factory() {} | 262 DevToolsAndroidBridge::Factory::~Factory() {} |
| 267 | 263 |
| 268 KeyedService* DevToolsAndroidBridge::Factory::BuildServiceInstanceFor( | 264 KeyedService* DevToolsAndroidBridge::Factory::BuildServiceInstanceFor( |
| 269 content::BrowserContext* context) const { | 265 content::BrowserContext* context) const { |
| 270 return new DevToolsAndroidBridge::Wrapper(context); | 266 return new DevToolsAndroidBridge::Wrapper(context); |
| 271 } | 267 } |
| 272 | 268 |
| 273 | |
| 274 // AgentHostDelegate ---------------------------------------------------------- | 269 // AgentHostDelegate ---------------------------------------------------------- |
| 275 | 270 |
| 276 class AgentHostDelegate | 271 class DevToolsAndroidBridge::AgentHostDelegate |
| 277 : public content::DevToolsExternalAgentProxyDelegate, | 272 : public content::DevToolsExternalAgentProxyDelegate, |
| 278 public DevToolsAndroidBridge::AndroidWebSocket::Delegate { | 273 public AndroidDeviceManager::AndroidWebSocket::Delegate { |
| 279 public: | 274 public: |
| 280 static scoped_refptr<content::DevToolsAgentHost> GetOrCreateAgentHost( | 275 static scoped_refptr<content::DevToolsAgentHost> GetOrCreateAgentHost( |
| 276 scoped_refptr<DevToolsAndroidBridge> bridge, | |
| 281 const std::string& id, | 277 const std::string& id, |
| 282 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 278 scoped_refptr<RemoteBrowser> browser, |
| 283 const std::string& debug_url); | 279 const std::string& debug_url); |
| 284 | 280 |
| 285 private: | 281 private: |
| 286 AgentHostDelegate( | 282 AgentHostDelegate( |
| 283 scoped_refptr<DevToolsAndroidBridge> bridge, | |
| 287 const std::string& id, | 284 const std::string& id, |
| 288 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 285 scoped_refptr<RemoteBrowser> browser, |
| 289 const std::string& debug_url); | 286 const std::string& debug_url); |
| 290 virtual ~AgentHostDelegate(); | 287 virtual ~AgentHostDelegate(); |
| 291 virtual void Attach(content::DevToolsExternalAgentProxy* proxy) OVERRIDE; | 288 virtual void Attach(content::DevToolsExternalAgentProxy* proxy) OVERRIDE; |
| 292 virtual void Detach() OVERRIDE; | 289 virtual void Detach() OVERRIDE; |
| 293 virtual void SendMessageToBackend( | 290 virtual void SendMessageToBackend( |
| 294 const std::string& message) OVERRIDE; | 291 const std::string& message) OVERRIDE; |
| 295 virtual void OnSocketOpened() OVERRIDE; | 292 virtual void OnSocketOpened() OVERRIDE; |
| 296 virtual void OnFrameRead(const std::string& message) OVERRIDE; | 293 virtual void OnFrameRead(const std::string& message) OVERRIDE; |
| 297 virtual void OnSocketClosed() OVERRIDE; | 294 virtual void OnSocketClosed() OVERRIDE; |
| 298 | 295 |
| 299 const std::string id_; | 296 std::string id_; |
| 300 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser_; | 297 scoped_refptr<DevToolsAndroidBridge> bridge_; |
| 301 const std::string debug_url_; | 298 scoped_refptr<RemoteBrowser> browser_; |
| 299 std::string debug_url_; | |
| 302 bool socket_opened_; | 300 bool socket_opened_; |
| 303 bool is_web_view_; | 301 bool is_web_view_; |
| 304 std::vector<std::string> pending_messages_; | 302 std::vector<std::string> pending_messages_; |
| 305 scoped_ptr<DevToolsAndroidBridge::AndroidWebSocket> web_socket_; | 303 scoped_ptr<AndroidDeviceManager::AndroidWebSocket> web_socket_; |
| 306 content::DevToolsAgentHost* agent_host_; | 304 content::DevToolsAgentHost* agent_host_; |
| 307 content::DevToolsExternalAgentProxy* proxy_; | 305 content::DevToolsExternalAgentProxy* proxy_; |
| 308 DISALLOW_COPY_AND_ASSIGN(AgentHostDelegate); | 306 DISALLOW_COPY_AND_ASSIGN(AgentHostDelegate); |
| 309 }; | 307 }; |
| 310 | 308 |
| 311 // static | 309 // static |
| 312 scoped_refptr<content::DevToolsAgentHost> | 310 scoped_refptr<content::DevToolsAgentHost> |
| 313 AgentHostDelegate::GetOrCreateAgentHost( | 311 DevToolsAndroidBridge::AgentHostDelegate::GetOrCreateAgentHost( |
| 312 scoped_refptr<DevToolsAndroidBridge> bridge, | |
| 314 const std::string& id, | 313 const std::string& id, |
| 315 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 314 scoped_refptr<RemoteBrowser> browser, |
| 316 const std::string& debug_url) { | 315 const std::string& debug_url) { |
| 317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 318 AgentHostDelegates::iterator it = g_host_delegates.Get().find(id); | 317 AgentHostDelegates::iterator it = bridge->host_delegates_.find(id); |
| 319 if (it != g_host_delegates.Get().end()) | 318 if (it != bridge->host_delegates_.end()) |
| 320 return it->second->agent_host_; | 319 return it->second->agent_host_; |
| 321 | 320 |
| 322 AgentHostDelegate* delegate = new AgentHostDelegate(id, browser, debug_url); | 321 AgentHostDelegate* delegate = |
| 322 new AgentHostDelegate(bridge, id, browser, debug_url); | |
| 323 scoped_refptr<content::DevToolsAgentHost> result = | 323 scoped_refptr<content::DevToolsAgentHost> result = |
| 324 content::DevToolsAgentHost::Create(delegate); | 324 content::DevToolsAgentHost::Create(delegate); |
| 325 delegate->agent_host_ = result.get(); | 325 delegate->agent_host_ = result.get(); |
| 326 return result; | 326 return result; |
| 327 } | 327 } |
| 328 | 328 |
| 329 AgentHostDelegate::AgentHostDelegate( | 329 DevToolsAndroidBridge::AgentHostDelegate::AgentHostDelegate( |
| 330 scoped_refptr<DevToolsAndroidBridge> bridge, | |
| 330 const std::string& id, | 331 const std::string& id, |
| 331 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 332 scoped_refptr<RemoteBrowser> browser, |
| 332 const std::string& debug_url) | 333 const std::string& debug_url) |
| 333 : id_(id), | 334 : id_(id), |
| 335 bridge_(bridge), | |
| 334 browser_(browser), | 336 browser_(browser), |
| 335 debug_url_(debug_url), | 337 debug_url_(debug_url), |
| 336 socket_opened_(false), | 338 socket_opened_(false), |
| 337 is_web_view_(browser->IsWebView()), | 339 is_web_view_(browser->IsWebView()), |
| 338 agent_host_(NULL), | 340 agent_host_(NULL), |
| 339 proxy_(NULL) { | 341 proxy_(NULL) { |
| 340 g_host_delegates.Get()[id] = this; | 342 bridge_->host_delegates_[id] = this; |
| 341 } | 343 } |
| 342 | 344 |
| 343 AgentHostDelegate::~AgentHostDelegate() { | 345 DevToolsAndroidBridge::AgentHostDelegate::~AgentHostDelegate() { |
| 344 g_host_delegates.Get().erase(id_); | 346 bridge_->host_delegates_.erase(id_); |
| 345 } | 347 } |
| 346 | 348 |
| 347 void AgentHostDelegate::Attach(content::DevToolsExternalAgentProxy* proxy) { | 349 void DevToolsAndroidBridge::AgentHostDelegate::Attach( |
| 350 content::DevToolsExternalAgentProxy* proxy) { | |
| 348 proxy_ = proxy; | 351 proxy_ = proxy; |
| 349 content::RecordAction(base::UserMetricsAction(is_web_view_ ? | 352 content::RecordAction(base::UserMetricsAction(is_web_view_ ? |
| 350 "DevTools_InspectAndroidWebView" : "DevTools_InspectAndroidPage")); | 353 "DevTools_InspectAndroidWebView" : "DevTools_InspectAndroidPage")); |
| 351 web_socket_.reset(browser_->CreateWebSocket(debug_url_, this)); | 354 web_socket_.reset( |
| 355 bridge_->CreateWebSocket(browser_, debug_url_, this)); | |
| 352 } | 356 } |
| 353 | 357 |
| 354 void AgentHostDelegate::Detach() { | 358 void DevToolsAndroidBridge::AgentHostDelegate::Detach() { |
| 355 web_socket_.reset(); | 359 web_socket_.reset(); |
| 356 } | 360 } |
| 357 | 361 |
| 358 void AgentHostDelegate::SendMessageToBackend(const std::string& message) { | 362 void DevToolsAndroidBridge::AgentHostDelegate::SendMessageToBackend( |
| 363 const std::string& message) { | |
| 359 if (socket_opened_) | 364 if (socket_opened_) |
| 360 web_socket_->SendFrame(message); | 365 web_socket_->SendFrame(message); |
| 361 else | 366 else |
| 362 pending_messages_.push_back(message); | 367 pending_messages_.push_back(message); |
| 363 } | 368 } |
| 364 | 369 |
| 365 void AgentHostDelegate::OnSocketOpened() { | 370 void DevToolsAndroidBridge::AgentHostDelegate::OnSocketOpened() { |
| 366 socket_opened_ = true; | 371 socket_opened_ = true; |
| 367 for (std::vector<std::string>::iterator it = pending_messages_.begin(); | 372 for (std::vector<std::string>::iterator it = pending_messages_.begin(); |
| 368 it != pending_messages_.end(); ++it) { | 373 it != pending_messages_.end(); ++it) { |
| 369 SendMessageToBackend(*it); | 374 SendMessageToBackend(*it); |
| 370 } | 375 } |
| 371 pending_messages_.clear(); | 376 pending_messages_.clear(); |
| 372 } | 377 } |
| 373 | 378 |
| 374 void AgentHostDelegate::OnFrameRead(const std::string& message) { | 379 void DevToolsAndroidBridge::AgentHostDelegate::OnFrameRead( |
| 380 const std::string& message) { | |
| 375 if (proxy_) | 381 if (proxy_) |
| 376 proxy_->DispatchOnClientHost(message); | 382 proxy_->DispatchOnClientHost(message); |
| 377 } | 383 } |
| 378 | 384 |
| 379 void AgentHostDelegate::OnSocketClosed() { | 385 void DevToolsAndroidBridge::AgentHostDelegate::OnSocketClosed() { |
| 380 if (proxy_) | 386 if (proxy_) |
| 381 proxy_->ConnectionClosed(); | 387 proxy_->ConnectionClosed(); |
| 382 } | 388 } |
| 383 | 389 |
| 384 //// RemotePageTarget ---------------------------------------------- | 390 //// RemotePageTarget ---------------------------------------------- |
| 385 | 391 |
| 386 class RemotePageTarget : public DevToolsTargetImpl, | 392 class DevToolsAndroidBridge::RemotePageTarget |
| 387 public DevToolsAndroidBridge::RemotePage { | 393 : public DevToolsTargetImpl, |
| 394 public DevToolsAndroidBridge::RemotePage { | |
| 388 public: | 395 public: |
| 389 RemotePageTarget(scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 396 RemotePageTarget(scoped_refptr<DevToolsAndroidBridge> bridge, |
| 397 scoped_refptr<RemoteBrowser> browser, | |
| 390 const base::DictionaryValue& value); | 398 const base::DictionaryValue& value); |
| 391 virtual ~RemotePageTarget(); | 399 virtual ~RemotePageTarget(); |
| 392 | 400 |
| 393 // DevToolsAndroidBridge::RemotePage implementation. | 401 // DevToolsAndroidBridge::RemotePage implementation. |
| 394 virtual DevToolsTargetImpl* GetTarget() OVERRIDE; | 402 virtual DevToolsTargetImpl* GetTarget() OVERRIDE; |
| 395 virtual std::string GetFrontendURL() OVERRIDE; | 403 virtual std::string GetFrontendURL() OVERRIDE; |
| 396 | 404 |
| 397 // DevToolsTargetImpl overrides. | 405 // DevToolsTargetImpl overrides. |
| 398 virtual std::string GetId() const OVERRIDE; | 406 virtual std::string GetId() const OVERRIDE; |
| 399 virtual bool IsAttached() const OVERRIDE; | 407 virtual bool IsAttached() const OVERRIDE; |
| 400 virtual bool Activate() const OVERRIDE; | 408 virtual bool Activate() const OVERRIDE; |
| 401 virtual bool Close() const OVERRIDE; | 409 virtual bool Close() const OVERRIDE; |
| 402 virtual void Inspect(Profile* profile) const OVERRIDE; | 410 virtual void Inspect(Profile* profile) const OVERRIDE; |
| 403 virtual void Reload() const OVERRIDE; | 411 virtual void Reload() const OVERRIDE; |
| 404 | 412 |
| 405 void Navigate(const std::string& url, base::Closure callback) const; | 413 void Navigate(const std::string& url, base::Closure callback) const; |
| 406 | 414 |
| 407 private: | 415 private: |
| 408 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser_; | 416 scoped_refptr<DevToolsAndroidBridge> bridge_; |
| 417 scoped_refptr<RemoteBrowser> browser_; | |
| 409 std::string debug_url_; | 418 std::string debug_url_; |
| 410 std::string frontend_url_; | 419 std::string frontend_url_; |
| 411 std::string remote_id_; | 420 std::string remote_id_; |
| 412 std::string remote_type_; | 421 std::string remote_type_; |
| 413 std::string local_id_; | 422 std::string local_id_; |
| 414 DISALLOW_COPY_AND_ASSIGN(RemotePageTarget); | 423 DISALLOW_COPY_AND_ASSIGN(RemotePageTarget); |
| 415 }; | 424 }; |
| 416 | 425 |
| 417 static std::string GetStringProperty(const base::DictionaryValue& value, | 426 static std::string GetStringProperty(const base::DictionaryValue& value, |
| 418 const std::string& name) { | 427 const std::string& name) { |
| 419 std::string result; | 428 std::string result; |
| 420 value.GetString(name, &result); | 429 value.GetString(name, &result); |
| 421 return result; | 430 return result; |
| 422 } | 431 } |
| 423 | 432 |
| 424 static std::string BuildUniqueTargetId( | 433 static std::string BuildUniqueTargetId( |
| 425 DevToolsAndroidBridge::RemoteBrowser* browser, | 434 DevToolsAndroidBridge::RemoteBrowser* browser, |
| 426 const base::DictionaryValue& value) { | 435 const base::DictionaryValue& value) { |
| 427 return base::StringPrintf("%s:%s:%s", browser->serial().c_str(), | 436 return base::StringPrintf("%s:%s:%s", browser->serial().c_str(), |
| 428 browser->socket().c_str(), GetStringProperty(value, "id").c_str()); | 437 browser->socket().c_str(), GetStringProperty(value, "id").c_str()); |
| 429 } | 438 } |
| 430 | 439 |
| 431 static std::string GetDebugURL(const base::DictionaryValue& value) { | 440 static std::string GetDebugURL(const base::DictionaryValue& value) { |
| 432 std::string debug_url = GetStringProperty(value, "webSocketDebuggerUrl"); | 441 std::string debug_url = GetStringProperty(value, "webSocketDebuggerUrl"); |
| 433 | 442 |
| 434 if (debug_url.find("ws://") == 0) | 443 if (debug_url.find("ws://") == 0) |
| 435 debug_url = debug_url.substr(5); | 444 debug_url = debug_url.substr(5); |
| 436 else | 445 else |
| 437 debug_url = ""; | 446 debug_url = std::string(); |
| 438 return debug_url; | 447 return debug_url; |
| 439 } | 448 } |
| 440 | 449 |
| 441 RemotePageTarget::RemotePageTarget( | 450 DevToolsAndroidBridge::RemotePageTarget::RemotePageTarget( |
| 442 scoped_refptr<DevToolsAndroidBridge::RemoteBrowser> browser, | 451 scoped_refptr<DevToolsAndroidBridge> bridge, |
| 452 scoped_refptr<RemoteBrowser> browser, | |
| 443 const base::DictionaryValue& value) | 453 const base::DictionaryValue& value) |
| 444 : DevToolsTargetImpl(AgentHostDelegate::GetOrCreateAgentHost( | 454 : DevToolsTargetImpl(AgentHostDelegate::GetOrCreateAgentHost( |
| 455 bridge, | |
| 445 BuildUniqueTargetId(browser.get(), value), | 456 BuildUniqueTargetId(browser.get(), value), |
| 446 browser, GetDebugURL(value))), | 457 browser, |
| 458 GetDebugURL(value))), | |
| 459 bridge_(bridge), | |
| 447 browser_(browser), | 460 browser_(browser), |
| 448 debug_url_(GetDebugURL(value)), | 461 debug_url_(GetDebugURL(value)), |
| 449 remote_id_(GetStringProperty(value, "id")), | 462 remote_id_(GetStringProperty(value, "id")), |
| 450 remote_type_(GetStringProperty(value, "type")), | 463 remote_type_(GetStringProperty(value, "type")), |
| 451 local_id_(BuildUniqueTargetId(browser.get(), value)) { | 464 local_id_(BuildUniqueTargetId(browser.get(), value)) { |
| 452 set_type("adb_page"); | 465 set_type("adb_page"); |
| 453 set_url(GURL(GetStringProperty(value, "url"))); | 466 set_url(GURL(GetStringProperty(value, "url"))); |
| 454 set_title(base::UTF16ToUTF8(net::UnescapeForHTML(base::UTF8ToUTF16( | 467 set_title(base::UTF16ToUTF8(net::UnescapeForHTML(base::UTF8ToUTF16( |
| 455 GetStringProperty(value, "title"))))); | 468 GetStringProperty(value, "title"))))); |
| 456 set_description(GetStringProperty(value, "description")); | 469 set_description(GetStringProperty(value, "description")); |
| 457 set_favicon_url(GURL(GetStringProperty(value, "faviconUrl"))); | 470 set_favicon_url(GURL(GetStringProperty(value, "faviconUrl"))); |
| 458 debug_url_ = GetDebugURL(value); | 471 debug_url_ = GetDebugURL(value); |
| 459 frontend_url_ = GetStringProperty(value, "devtoolsFrontendUrl"); | 472 frontend_url_ = GetStringProperty(value, "devtoolsFrontendUrl"); |
| 460 | 473 |
| 461 size_t ws_param = frontend_url_.find("?ws"); | 474 size_t ws_param = frontend_url_.find("?ws"); |
| 462 if (ws_param != std::string::npos) | 475 if (ws_param != std::string::npos) |
| 463 frontend_url_ = frontend_url_.substr(0, ws_param); | 476 frontend_url_ = frontend_url_.substr(0, ws_param); |
| 464 if (frontend_url_.find("http:") == 0) | 477 if (frontend_url_.find("http:") == 0) |
| 465 frontend_url_ = "https:" + frontend_url_.substr(5); | 478 frontend_url_ = "https:" + frontend_url_.substr(5); |
| 466 } | 479 } |
| 467 | 480 |
| 468 RemotePageTarget::~RemotePageTarget() { | 481 DevToolsAndroidBridge::RemotePageTarget::~RemotePageTarget() { |
| 469 } | 482 } |
| 470 | 483 |
| 471 DevToolsTargetImpl* RemotePageTarget::GetTarget() { | 484 DevToolsTargetImpl* DevToolsAndroidBridge::RemotePageTarget::GetTarget() { |
| 472 return this; | 485 return this; |
| 473 } | 486 } |
| 474 | 487 |
| 475 std::string RemotePageTarget::GetFrontendURL() { | 488 std::string DevToolsAndroidBridge::RemotePageTarget::GetFrontendURL() { |
| 476 return frontend_url_; | 489 return frontend_url_; |
| 477 } | 490 } |
| 478 | 491 |
| 479 std::string RemotePageTarget::GetId() const { | 492 std::string DevToolsAndroidBridge::RemotePageTarget::GetId() const { |
| 480 return local_id_; | 493 return local_id_; |
| 481 } | 494 } |
| 482 | 495 |
| 483 bool RemotePageTarget::IsAttached() const { | 496 bool DevToolsAndroidBridge::RemotePageTarget::IsAttached() const { |
| 484 return debug_url_.empty(); | 497 return debug_url_.empty(); |
| 485 } | 498 } |
| 486 | 499 |
| 487 static void NoOp(int, const std::string&) {} | 500 static void NoOp(int, const std::string&) {} |
| 488 | 501 |
| 489 void RemotePageTarget::Inspect(Profile* profile) const { | 502 void DevToolsAndroidBridge::RemotePageTarget::Inspect(Profile* profile) const { |
| 490 Activate(); | 503 Activate(); |
| 491 bool isWorker = remote_type_ == kTargetTypeWorker || | 504 bool isWorker = remote_type_ == kTargetTypeWorker || |
| 492 remote_type_ == kTargetTypeServiceWorker; | 505 remote_type_ == kTargetTypeServiceWorker; |
| 493 DevToolsWindow::OpenExternalFrontend(profile, frontend_url_, GetAgentHost(), | 506 DevToolsWindow::OpenExternalFrontend(profile, frontend_url_, GetAgentHost(), |
| 494 isWorker); | 507 isWorker); |
| 495 } | 508 } |
| 496 | 509 |
| 497 bool RemotePageTarget::Activate() const { | 510 bool DevToolsAndroidBridge::RemotePageTarget::Activate() const { |
| 498 std::string request = base::StringPrintf(kActivatePageRequest, | 511 std::string request = base::StringPrintf(kActivatePageRequest, |
| 499 remote_id_.c_str()); | 512 remote_id_.c_str()); |
| 500 browser_->SendJsonRequest(request, base::Bind(&NoOp)); | 513 bridge_->SendJsonRequest(browser_, request, base::Bind(&NoOp)); |
| 501 return true; | 514 return true; |
| 502 } | 515 } |
| 503 | 516 |
| 504 bool RemotePageTarget::Close() const { | 517 bool DevToolsAndroidBridge::RemotePageTarget::Close() const { |
| 505 std::string request = base::StringPrintf(kClosePageRequest, | 518 std::string request = base::StringPrintf(kClosePageRequest, |
| 506 remote_id_.c_str()); | 519 remote_id_.c_str()); |
| 507 browser_->SendJsonRequest(request, base::Bind(&NoOp)); | 520 bridge_->SendJsonRequest(browser_, request, base::Bind(&NoOp)); |
| 508 return true; | 521 return true; |
| 509 } | 522 } |
| 510 | 523 |
| 511 void RemotePageTarget::Reload() const { | 524 void DevToolsAndroidBridge::RemotePageTarget::Reload() const { |
| 512 browser_->SendProtocolCommand(debug_url_, kPageReloadCommand, NULL, | 525 bridge_->SendProtocolCommand(browser_, debug_url_, kPageReloadCommand, |
| 513 base::Closure()); | 526 NULL, base::Closure()); |
| 514 } | 527 } |
| 515 | 528 |
| 516 void RemotePageTarget::Navigate(const std::string& url, | 529 void DevToolsAndroidBridge::RemotePageTarget::Navigate( |
| 517 base::Closure callback) const { | 530 const std::string& url, |
| 531 base::Closure callback) const { | |
| 518 base::DictionaryValue params; | 532 base::DictionaryValue params; |
| 519 params.SetString(kUrlParam, url); | 533 params.SetString(kUrlParam, url); |
| 520 browser_->SendProtocolCommand(debug_url_, kPageNavigateCommand, ¶ms, | 534 bridge_->SendProtocolCommand(browser_, debug_url_, kPageNavigateCommand, |
| 521 callback); | 535 ¶ms, callback); |
| 522 } | 536 } |
| 523 | 537 |
| 524 // DevToolsAndroidBridge::RemoteBrowser --------------------------------------- | 538 // DevToolsAndroidBridge::RemoteBrowser --------------------------------------- |
| 525 | 539 |
| 526 DevToolsAndroidBridge::RemoteBrowser::RemoteBrowser( | 540 DevToolsAndroidBridge::RemoteBrowser::RemoteBrowser( |
| 527 scoped_refptr<Device> device, | 541 const std::string& serial, |
| 528 const AndroidDeviceManager::BrowserInfo& browser_info) | 542 const AndroidDeviceManager::BrowserInfo& browser_info) |
| 529 : device_(device), | 543 : serial_(serial), |
| 530 socket_(browser_info.socket_name), | 544 socket_(browser_info.socket_name), |
| 531 display_name_(browser_info.display_name), | 545 display_name_(browser_info.display_name), |
| 532 type_(browser_info.type), | 546 type_(browser_info.type), |
| 533 page_descriptors_(new base::ListValue()) { | 547 page_descriptors_(new base::ListValue()) { |
| 534 } | 548 } |
| 535 | 549 |
| 536 bool DevToolsAndroidBridge::RemoteBrowser::IsChrome() const { | 550 bool DevToolsAndroidBridge::RemoteBrowser::IsChrome() { |
| 537 return type_ == AndroidDeviceManager::BrowserInfo::kTypeChrome; | 551 return type_ == AndroidDeviceManager::BrowserInfo::kTypeChrome; |
| 538 } | 552 } |
| 539 | 553 |
| 540 bool DevToolsAndroidBridge::RemoteBrowser::IsWebView() const { | 554 bool DevToolsAndroidBridge::RemoteBrowser::IsWebView() { |
| 541 return type_ == AndroidDeviceManager::BrowserInfo::kTypeWebView; | 555 return type_ == AndroidDeviceManager::BrowserInfo::kTypeWebView; |
| 542 } | 556 } |
| 543 | 557 |
| 544 DevToolsAndroidBridge::RemoteBrowser::ParsedVersion | 558 DevToolsAndroidBridge::RemoteBrowser::ParsedVersion |
| 545 DevToolsAndroidBridge::RemoteBrowser::GetParsedVersion() const { | 559 DevToolsAndroidBridge::RemoteBrowser::GetParsedVersion() { |
| 546 ParsedVersion result; | 560 ParsedVersion result; |
| 547 std::vector<std::string> parts; | 561 std::vector<std::string> parts; |
| 548 Tokenize(version_, ".", &parts); | 562 Tokenize(version_, ".", &parts); |
| 549 for (size_t i = 0; i != parts.size(); ++i) { | 563 for (size_t i = 0; i != parts.size(); ++i) { |
| 550 int value = 0; | 564 int value = 0; |
| 551 base::StringToInt(parts[i], &value); | 565 base::StringToInt(parts[i], &value); |
| 552 result.push_back(value); | 566 result.push_back(value); |
| 553 } | 567 } |
| 554 return result; | 568 return result; |
| 555 } | 569 } |
| 556 | 570 |
| 557 std::vector<DevToolsAndroidBridge::RemotePage*> | 571 std::vector<DevToolsAndroidBridge::RemotePage*> |
| 558 DevToolsAndroidBridge::RemoteBrowser::CreatePages() { | 572 DevToolsAndroidBridge::CreatePages(scoped_refptr<RemoteBrowser> browser) { |
| 559 std::vector<DevToolsAndroidBridge::RemotePage*> result; | 573 std::vector<RemotePage*> result; |
| 560 for (size_t i = 0; i < page_descriptors_->GetSize(); ++i) { | 574 for (const auto& value : browser->page_descriptors()) { |
| 561 base::Value* item; | |
| 562 page_descriptors_->Get(i, &item); | |
| 563 if (!item) | |
| 564 continue; | |
| 565 base::DictionaryValue* dict; | 575 base::DictionaryValue* dict; |
| 566 if (!item->GetAsDictionary(&dict)) | 576 if (value && value->GetAsDictionary(&dict)) |
|
dgozman
2014/10/02 13:21:48
I think, |if (value)| is redundant.
vkuzkokov
2014/10/03 10:53:32
Done.
| |
| 567 continue; | 577 result.push_back(new RemotePageTarget(this, browser, *dict)); |
| 568 result.push_back(new RemotePageTarget(this, *dict)); | |
| 569 } | 578 } |
| 570 return result; | 579 return result; |
| 571 } | 580 } |
| 572 | 581 |
| 573 void DevToolsAndroidBridge::RemoteBrowser::SetPageDescriptors( | 582 const base::ListValue& |
| 574 const base::ListValue& list) { | 583 DevToolsAndroidBridge::RemoteBrowser::page_descriptors() { |
| 575 page_descriptors_.reset(list.DeepCopy()); | 584 return *page_descriptors_; |
| 576 } | 585 } |
| 577 | 586 |
| 578 static void RespondOnUIThread( | 587 void DevToolsAndroidBridge::SendJsonRequest( |
| 579 const DevToolsAndroidBridge::JsonRequestCallback& callback, | 588 scoped_refptr<RemoteBrowser> browser, |
| 580 int result, | 589 const std::string& request, |
| 581 const std::string& response) { | 590 const JsonRequestCallback& callback) { |
| 582 if (callback.is_null()) | 591 DeviceMap::iterator it = device_map_.find(browser->serial()); |
| 592 if (it == device_map_.end()) { | |
| 593 callback.Run(net::ERR_FAILED, std::string()); | |
| 583 return; | 594 return; |
| 584 BrowserThread::PostTask( | 595 } |
| 585 BrowserThread::UI, FROM_HERE, base::Bind(callback, result, response)); | 596 it->second->SendJsonRequest(browser->socket(), request, callback); |
| 586 } | 597 } |
| 587 | 598 |
| 588 void DevToolsAndroidBridge::RemoteBrowser::SendJsonRequest( | 599 void DevToolsAndroidBridge::SendProtocolCommand( |
| 589 const std::string& request, const JsonRequestCallback& callback) { | 600 scoped_refptr<RemoteBrowser> browser, |
| 590 device_->SendJsonRequest(socket_, request, callback); | |
| 591 } | |
| 592 | |
| 593 void DevToolsAndroidBridge::RemoteBrowser::SendProtocolCommand( | |
| 594 const std::string& debug_url, | 601 const std::string& debug_url, |
| 595 const std::string& method, | 602 const std::string& method, |
| 596 base::DictionaryValue* params, | 603 base::DictionaryValue* params, |
| 597 const base::Closure callback) { | 604 const base::Closure callback) { |
| 598 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 605 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 599 if (debug_url.empty()) | 606 if (debug_url.empty()) |
| 600 return; | 607 return; |
| 608 DeviceMap::iterator it = device_map_.find(browser->serial()); | |
| 609 if (it == device_map_.end()) { | |
| 610 callback.Run(); | |
| 611 return; | |
| 612 } | |
| 601 DevToolsProtocol::Command command(1, method, params); | 613 DevToolsProtocol::Command command(1, method, params); |
| 602 new ProtocolCommand(this, debug_url, command.Serialize(), callback); | 614 new ProtocolCommand(it->second, browser->socket(), debug_url, |
| 603 } | 615 command.Serialize(), callback); |
| 604 | |
| 605 void DevToolsAndroidBridge::RemoteBrowser::Open( | |
| 606 const std::string& url, | |
| 607 const DevToolsAndroidBridge::RemotePageCallback& callback) { | |
| 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 609 InnerOpen(url, base::Bind(&RemoteBrowser::RespondToOpenOnUIThread, | |
| 610 this, callback)); | |
| 611 } | 616 } |
| 612 | 617 |
| 613 scoped_refptr<content::DevToolsAgentHost> | 618 scoped_refptr<content::DevToolsAgentHost> |
| 614 DevToolsAndroidBridge::RemoteBrowser::GetAgentHost() { | 619 DevToolsAndroidBridge::GetBrowserAgentHost( |
| 620 scoped_refptr<RemoteBrowser> browser) { | |
| 615 return AgentHostDelegate::GetOrCreateAgentHost( | 621 return AgentHostDelegate::GetOrCreateAgentHost( |
| 616 "adb:" + device_->serial() + ":" + socket_, this, kBrowserTargetSocket); | 622 this, |
| 623 "adb:" + browser->serial() + ":" + browser->socket(), | |
| 624 browser, | |
| 625 kBrowserTargetSocket); | |
| 617 } | 626 } |
| 618 | 627 |
| 619 DevToolsAndroidBridge::AndroidWebSocket* | 628 AndroidDeviceManager::AndroidWebSocket* |
| 620 DevToolsAndroidBridge::RemoteBrowser::CreateWebSocket( | 629 DevToolsAndroidBridge::CreateWebSocket( |
| 630 scoped_refptr<RemoteBrowser> browser, | |
| 621 const std::string& url, | 631 const std::string& url, |
| 622 DevToolsAndroidBridge::AndroidWebSocket::Delegate* delegate) { | 632 AndroidDeviceManager::AndroidWebSocket::Delegate* delegate) { |
| 623 return device_->CreateWebSocket(socket_, url, delegate); | 633 DeviceMap::iterator it = device_map_.find(browser->serial()); |
| 634 if (it == device_map_.end()) | |
| 635 return NULL; | |
| 636 | |
| 637 return it->second->CreateWebSocket(browser->socket(), url, delegate); | |
| 624 } | 638 } |
| 625 | 639 |
| 626 void DevToolsAndroidBridge::RemoteBrowser::RespondToOpenOnUIThread( | 640 void DevToolsAndroidBridge::RespondToOpenOnUIThread( |
| 627 const DevToolsAndroidBridge::RemotePageCallback& callback, | 641 scoped_refptr<RemoteBrowser> browser, |
| 642 const RemotePageCallback& callback, | |
| 628 int result, | 643 int result, |
| 629 const std::string& response) { | 644 const std::string& response) { |
| 630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 645 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 631 if (result < 0) { | 646 if (result < 0) { |
| 632 callback.Run(NULL); | 647 callback.Run(NULL); |
| 633 return; | 648 return; |
| 634 } | 649 } |
| 635 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); | 650 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); |
| 636 base::DictionaryValue* dict; | 651 base::DictionaryValue* dict; |
| 637 if (value && value->GetAsDictionary(&dict)) { | 652 if (value && value->GetAsDictionary(&dict)) { |
| 638 RemotePageTarget* new_page = new RemotePageTarget(this, *dict); | 653 RemotePageTarget* new_page = new RemotePageTarget(this, browser, *dict); |
| 639 callback.Run(new_page); | 654 callback.Run(new_page); |
| 640 } | 655 } |
| 641 } | 656 } |
| 642 | 657 |
| 643 void DevToolsAndroidBridge::RemoteBrowser::InnerOpen( | 658 void DevToolsAndroidBridge::OpenRemotePage( |
| 659 scoped_refptr<RemoteBrowser> browser, | |
| 644 const std::string& input_url, | 660 const std::string& input_url, |
| 645 const JsonRequestCallback& callback) { | 661 const DevToolsAndroidBridge::RemotePageCallback& callback) { |
| 646 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 662 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 647 GURL gurl(input_url); | 663 GURL gurl(input_url); |
| 648 if (!gurl.is_valid()) { | 664 if (!gurl.is_valid()) { |
| 649 gurl = GURL("http://" + input_url); | 665 gurl = GURL("http://" + input_url); |
| 650 if (!gurl.is_valid()) | 666 if (!gurl.is_valid()) |
| 651 return; | 667 return; |
| 652 } | 668 } |
| 653 std::string url = gurl.spec(); | 669 std::string url = gurl.spec(); |
| 670 RemoteBrowser::ParsedVersion parsed_version = browser->GetParsedVersion(); | |
| 654 | 671 |
| 655 ParsedVersion parsed_version = GetParsedVersion(); | 672 if (browser->IsChrome() && |
| 656 if (IsChrome() && | |
| 657 !parsed_version.empty() && | 673 !parsed_version.empty() && |
| 658 parsed_version[0] >= kMinVersionNewWithURL) { | 674 parsed_version[0] >= kMinVersionNewWithURL) { |
| 659 std::string query = net::EscapeQueryParamValue(url, false /* use_plus */); | 675 std::string query = net::EscapeQueryParamValue(url, false /* use_plus */); |
| 660 std::string request = | 676 std::string request = |
| 661 base::StringPrintf(kNewPageRequestWithURL, query.c_str()); | 677 base::StringPrintf(kNewPageRequestWithURL, query.c_str()); |
| 662 SendJsonRequest(request, callback); | 678 SendJsonRequest(browser, request, |
| 679 base::Bind(&DevToolsAndroidBridge::RespondToOpenOnUIThread, | |
| 680 this, browser, callback)); | |
| 663 } else { | 681 } else { |
| 664 SendJsonRequest(kNewPageRequest, | 682 SendJsonRequest(browser, kNewPageRequest, |
| 665 base::Bind(&RemoteBrowser::PageCreatedOnUIThread, this, | 683 base::Bind(&DevToolsAndroidBridge::PageCreatedOnUIThread, |
| 666 callback, url)); | 684 this, browser, callback, url)); |
| 667 } | 685 } |
| 668 } | 686 } |
| 669 | 687 |
| 670 void DevToolsAndroidBridge::RemoteBrowser::PageCreatedOnUIThread( | 688 void DevToolsAndroidBridge::PageCreatedOnUIThread( |
| 671 const JsonRequestCallback& callback, | 689 scoped_refptr<RemoteBrowser> browser, |
| 672 const std::string& url, int result, const std::string& response) { | 690 const RemotePageCallback& callback, |
| 691 const std::string& url, | |
| 692 int result, | |
| 693 const std::string& response) { | |
| 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 694 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 674 | 695 |
| 675 if (result < 0) | 696 if (result < 0) |
| 676 return; | 697 return; |
| 677 // Navigating too soon after the page creation breaks navigation history | 698 // Navigating too soon after the page creation breaks navigation history |
| 678 // (crbug.com/311014). This can be avoided by adding a moderate delay. | 699 // (crbug.com/311014). This can be avoided by adding a moderate delay. |
| 679 BrowserThread::PostDelayedTask( | 700 BrowserThread::PostDelayedTask( |
| 680 BrowserThread::UI, FROM_HERE, | 701 BrowserThread::UI, FROM_HERE, |
| 681 base::Bind(&RemoteBrowser::NavigatePageOnUIThread, | 702 base::Bind(&DevToolsAndroidBridge::NavigatePageOnUIThread, |
| 682 this, callback, result, response, url), | 703 this, browser, callback, result, response, url), |
| 683 base::TimeDelta::FromMilliseconds(kNewPageNavigateDelayMs)); | 704 base::TimeDelta::FromMilliseconds(kNewPageNavigateDelayMs)); |
| 684 } | 705 } |
| 685 | 706 |
| 686 void DevToolsAndroidBridge::RemoteBrowser::NavigatePageOnUIThread( | 707 void DevToolsAndroidBridge::NavigatePageOnUIThread( |
| 687 const JsonRequestCallback& callback, | 708 scoped_refptr<RemoteBrowser> browser, |
| 688 int result, const std::string& response, const std::string& url) { | 709 const RemotePageCallback& callback, |
| 710 int result, | |
| 711 const std::string& response, | |
| 712 const std::string& url) { | |
| 689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 713 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 690 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); | 714 scoped_ptr<base::Value> value(base::JSONReader::Read(response)); |
| 691 base::DictionaryValue* dict; | 715 base::DictionaryValue* dict; |
| 692 | 716 |
| 693 if (value && value->GetAsDictionary(&dict)) { | 717 if (value && value->GetAsDictionary(&dict)) { |
| 694 RemotePageTarget new_page(this, *dict); | 718 RemotePageTarget new_page(this, browser, *dict); |
| 695 new_page.Navigate(url, | 719 new_page.Navigate(url, |
| 696 base::Bind(&RespondOnUIThread, callback, result, response)); | 720 base::Bind(&DevToolsAndroidBridge::RespondToOpenOnUIThread, |
| 721 this, browser, callback, result, response)); | |
| 697 } | 722 } |
| 698 } | 723 } |
| 699 | 724 |
| 700 DevToolsAndroidBridge::RemoteBrowser::~RemoteBrowser() { | 725 DevToolsAndroidBridge::RemoteBrowser::~RemoteBrowser() { |
| 701 } | 726 } |
| 702 | 727 |
| 703 // DevToolsAndroidBridge::RemoteDevice ---------------------------------------- | 728 // DevToolsAndroidBridge::RemoteDevice ---------------------------------------- |
| 704 | 729 |
| 705 DevToolsAndroidBridge::RemoteDevice::RemoteDevice( | 730 DevToolsAndroidBridge::RemoteDevice::RemoteDevice( |
| 706 scoped_refptr<AndroidDeviceManager::Device> device, | 731 const std::string& serial, |
| 707 const AndroidDeviceManager::DeviceInfo& device_info) | 732 const AndroidDeviceManager::DeviceInfo& device_info) |
| 708 : device_(device), | 733 : serial_(serial), |
| 709 model_(device_info.model), | 734 model_(device_info.model), |
| 710 connected_(device_info.connected), | 735 connected_(device_info.connected), |
| 711 screen_size_(device_info.screen_size) { | 736 screen_size_(device_info.screen_size) { |
| 712 for (std::vector<AndroidDeviceManager::BrowserInfo>::const_iterator it = | 737 for (std::vector<AndroidDeviceManager::BrowserInfo>::const_iterator it = |
| 713 device_info.browser_info.begin(); | 738 device_info.browser_info.begin(); |
| 714 it != device_info.browser_info.end(); | 739 it != device_info.browser_info.end(); |
| 715 ++it) { | 740 ++it) { |
| 716 browsers_.push_back(new DevToolsAndroidBridge::RemoteBrowser(device, *it)); | 741 browsers_.push_back(new RemoteBrowser(serial, *it)); |
| 717 } | 742 } |
| 718 } | 743 } |
| 719 | 744 |
| 720 void DevToolsAndroidBridge::RemoteDevice::OpenSocket( | |
| 721 const std::string& socket_name, | |
| 722 const AndroidDeviceManager::SocketCallback& callback) { | |
| 723 device_->OpenSocket(socket_name, callback); | |
| 724 } | |
| 725 | |
| 726 DevToolsAndroidBridge::RemoteDevice::~RemoteDevice() { | 745 DevToolsAndroidBridge::RemoteDevice::~RemoteDevice() { |
| 727 } | 746 } |
| 728 | 747 |
| 729 // DevToolsAndroidBridge ------------------------------------------------------ | 748 // DevToolsAndroidBridge ------------------------------------------------------ |
| 730 | 749 |
| 731 DevToolsAndroidBridge::DevToolsAndroidBridge(Profile* profile) | 750 DevToolsAndroidBridge::DevToolsAndroidBridge(Profile* profile) |
| 732 : profile_(profile), | 751 : profile_(profile), |
| 733 device_manager_(AndroidDeviceManager::Create()), | 752 device_manager_(AndroidDeviceManager::Create()), |
| 734 task_scheduler_(base::Bind(&DevToolsAndroidBridge::ScheduleTaskDefault)), | 753 task_scheduler_(base::Bind(&DevToolsAndroidBridge::ScheduleTaskDefault)), |
| 735 port_forwarding_controller_(new PortForwardingController(profile)) { | 754 port_forwarding_controller_(new PortForwardingController(profile)) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 PortForwardingListeners::iterator it = std::find( | 811 PortForwardingListeners::iterator it = std::find( |
| 793 port_forwarding_listeners_.begin(), | 812 port_forwarding_listeners_.begin(), |
| 794 port_forwarding_listeners_.end(), | 813 port_forwarding_listeners_.end(), |
| 795 listener); | 814 listener); |
| 796 DCHECK(it != port_forwarding_listeners_.end()); | 815 DCHECK(it != port_forwarding_listeners_.end()); |
| 797 port_forwarding_listeners_.erase(it); | 816 port_forwarding_listeners_.erase(it); |
| 798 if (!NeedsDeviceListPolling()) | 817 if (!NeedsDeviceListPolling()) |
| 799 StopDeviceListPolling(); | 818 StopDeviceListPolling(); |
| 800 } | 819 } |
| 801 | 820 |
| 802 // static | |
| 803 bool DevToolsAndroidBridge::HasDevToolsWindow(const std::string& agent_id) { | 821 bool DevToolsAndroidBridge::HasDevToolsWindow(const std::string& agent_id) { |
| 804 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 822 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 805 return g_host_delegates.Get().find(agent_id) != g_host_delegates.Get().end(); | 823 return host_delegates_.find(agent_id) != host_delegates_.end(); |
| 806 } | 824 } |
| 807 | 825 |
| 808 DevToolsAndroidBridge::~DevToolsAndroidBridge() { | 826 DevToolsAndroidBridge::~DevToolsAndroidBridge() { |
| 809 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 827 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 810 DCHECK(device_list_listeners_.empty()); | 828 DCHECK(device_list_listeners_.empty()); |
| 811 DCHECK(device_count_listeners_.empty()); | 829 DCHECK(device_count_listeners_.empty()); |
| 812 DCHECK(port_forwarding_listeners_.empty()); | 830 DCHECK(port_forwarding_listeners_.empty()); |
| 813 } | 831 } |
| 814 | 832 |
| 815 void DevToolsAndroidBridge::StartDeviceListPolling() { | 833 void DevToolsAndroidBridge::StartDeviceListPolling() { |
| 816 device_list_callback_.Reset( | 834 device_list_callback_.Reset( |
| 817 base::Bind(&DevToolsAndroidBridge::ReceivedDeviceList, this)); | 835 base::Bind(&DevToolsAndroidBridge::ReceivedDeviceList, this)); |
| 818 RequestDeviceList(device_list_callback_.callback()); | 836 RequestDeviceList(device_list_callback_.callback()); |
| 819 } | 837 } |
| 820 | 838 |
| 821 void DevToolsAndroidBridge::StopDeviceListPolling() { | 839 void DevToolsAndroidBridge::StopDeviceListPolling() { |
| 822 device_list_callback_.Cancel(); | 840 device_list_callback_.Cancel(); |
| 823 devices_.clear(); | 841 device_map_.clear(); |
| 824 } | 842 } |
| 825 | 843 |
| 826 bool DevToolsAndroidBridge::NeedsDeviceListPolling() { | 844 bool DevToolsAndroidBridge::NeedsDeviceListPolling() { |
| 827 return !device_list_listeners_.empty() || !port_forwarding_listeners_.empty(); | 845 return !device_list_listeners_.empty() || !port_forwarding_listeners_.empty(); |
| 828 } | 846 } |
| 829 | 847 |
| 830 void DevToolsAndroidBridge::RequestDeviceList( | 848 void DevToolsAndroidBridge::RequestDeviceList( |
| 831 const base::Callback<void(const RemoteDevices&)>& callback) { | 849 const DeviceListCallback& callback) { |
| 832 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 850 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 833 | 851 |
| 834 if (!NeedsDeviceListPolling() || | 852 if (!NeedsDeviceListPolling() || |
| 835 !callback.Equals(device_list_callback_.callback())) | 853 !callback.Equals(device_list_callback_.callback())) |
| 836 return; | 854 return; |
| 837 | 855 |
| 838 new DiscoveryRequest(device_manager_.get(), callback); | 856 new DiscoveryRequest(device_manager_.get(), callback); |
| 839 } | 857 } |
| 840 | 858 |
| 841 void DevToolsAndroidBridge::ReceivedDeviceList(const RemoteDevices& devices) { | 859 void DevToolsAndroidBridge::ReceivedDeviceList( |
| 860 const CompleteDevices& complete_devices) { | |
| 842 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 861 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 843 | 862 |
| 863 device_map_.clear(); | |
| 864 RemoteDevices remote_devices; | |
| 865 for (const auto& pair : complete_devices) { | |
| 866 device_map_[pair.first->serial()] = pair.first; | |
| 867 remote_devices.push_back(pair.second); | |
| 868 } | |
| 869 | |
| 844 DeviceListListeners copy(device_list_listeners_); | 870 DeviceListListeners copy(device_list_listeners_); |
| 845 for (DeviceListListeners::iterator it = copy.begin(); it != copy.end(); ++it) | 871 for (DeviceListListeners::iterator it = copy.begin(); it != copy.end(); ++it) |
| 846 (*it)->DeviceListChanged(devices); | 872 (*it)->DeviceListChanged(remote_devices); |
| 847 | 873 |
| 848 ForwardingStatus status = | 874 ForwardingStatus status = |
| 849 port_forwarding_controller_->DeviceListChanged(devices); | 875 port_forwarding_controller_->DeviceListChanged(complete_devices); |
| 850 PortForwardingListeners forwarding_listeners(port_forwarding_listeners_); | 876 PortForwardingListeners forwarding_listeners(port_forwarding_listeners_); |
| 851 for (PortForwardingListeners::iterator it = forwarding_listeners.begin(); | 877 for (PortForwardingListeners::iterator it = forwarding_listeners.begin(); |
| 852 it != forwarding_listeners.end(); ++it) { | 878 it != forwarding_listeners.end(); ++it) { |
| 853 (*it)->PortStatusChanged(status); | 879 (*it)->PortStatusChanged(status); |
| 854 } | 880 } |
| 855 | 881 |
| 856 if (!NeedsDeviceListPolling()) | 882 if (!NeedsDeviceListPolling()) |
| 857 return; | 883 return; |
| 858 | 884 |
| 859 devices_ = devices; | |
| 860 | |
| 861 task_scheduler_.Run( | 885 task_scheduler_.Run( |
| 862 base::Bind(&DevToolsAndroidBridge::RequestDeviceList, | 886 base::Bind(&DevToolsAndroidBridge::RequestDeviceList, |
| 863 this, device_list_callback_.callback())); | 887 this, device_list_callback_.callback())); |
| 864 } | 888 } |
| 865 | 889 |
| 866 void DevToolsAndroidBridge::StartDeviceCountPolling() { | 890 void DevToolsAndroidBridge::StartDeviceCountPolling() { |
| 867 device_count_callback_.Reset( | 891 device_count_callback_.Reset( |
| 868 base::Bind(&DevToolsAndroidBridge::ReceivedDeviceCount, this)); | 892 base::Bind(&DevToolsAndroidBridge::ReceivedDeviceCount, this)); |
| 869 RequestDeviceCount(device_count_callback_.callback()); | 893 RequestDeviceCount(device_count_callback_.callback()); |
| 870 } | 894 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 bool enabled; | 951 bool enabled; |
| 928 if (pref_value->GetAsBoolean(&enabled) && enabled) { | 952 if (pref_value->GetAsBoolean(&enabled) && enabled) { |
| 929 device_providers.push_back(new UsbDeviceProvider(profile_)); | 953 device_providers.push_back(new UsbDeviceProvider(profile_)); |
| 930 } | 954 } |
| 931 device_manager_->SetDeviceProviders(device_providers); | 955 device_manager_->SetDeviceProviders(device_providers); |
| 932 if (NeedsDeviceListPolling()) { | 956 if (NeedsDeviceListPolling()) { |
| 933 StopDeviceListPolling(); | 957 StopDeviceListPolling(); |
| 934 StartDeviceListPolling(); | 958 StartDeviceListPolling(); |
| 935 } | 959 } |
| 936 } | 960 } |
| OLD | NEW |