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 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/devtools/device/android_device_manager.h" | 8 #include "chrome/browser/devtools/device/android_device_manager.h" |
| 9 #include "chrome/browser/devtools/device/webrtc/devtools_bridge_instances_reques t.h" | 9 #include "chrome/browser/devtools/device/webrtc/devtools_bridge_instances_reques t.h" |
| 10 #include "chrome/browser/devtools/device/webrtc/send_command_request.h" | 10 #include "chrome/browser/devtools/device/webrtc/send_command_request.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class WebUI; | 23 class WebUI; |
| 24 } // namespace content | 24 } // namespace content |
| 25 | 25 |
| 26 namespace local_discovery { | 26 namespace local_discovery { |
| 27 class GCDApiFlow; | 27 class GCDApiFlow; |
| 28 } // local_discovery | 28 } // local_discovery |
| 29 | 29 |
| 30 // Lives on the UI thread. | 30 // Lives on the UI thread. |
| 31 class DevToolsBridgeClient final | 31 class DevToolsBridgeClient |
| 32 : private content::NotificationObserver, | 32 : protected content::WebContentsObserver, |
| 33 private content::NotificationObserver, | |
| 33 private IdentityProvider::Observer, | 34 private IdentityProvider::Observer, |
| 34 private content::WebContentsObserver, | |
| 35 private SendCommandRequest::Delegate, | 35 private SendCommandRequest::Delegate, |
| 36 private DevToolsBridgeInstancesRequest::Delegate { | 36 private DevToolsBridgeInstancesRequest::Delegate { |
| 37 public: | 37 public: |
| 38 using BrowserInfo = AndroidDeviceManager::BrowserInfo; | 38 using BrowserInfo = AndroidDeviceManager::BrowserInfo; |
| 39 using DeviceInfo = AndroidDeviceManager::DeviceInfo; | 39 using DeviceInfo = AndroidDeviceManager::DeviceInfo; |
| 40 using SerialList = std::vector<std::string>; | 40 using SerialList = std::vector<std::string>; |
| 41 using BrowserInfoList = std::vector<BrowserInfo>; | 41 using BrowserInfoList = std::vector<BrowserInfo>; |
| 42 | 42 |
| 43 static base::WeakPtr<DevToolsBridgeClient> Create( | 43 static base::WeakPtr<DevToolsBridgeClient> Create( |
| 44 Profile* profile, | 44 Profile* profile, |
| 45 SigninManagerBase* signin_manager, | 45 SigninManagerBase* signin_manager, |
| 46 ProfileOAuth2TokenService* token_service); | 46 ProfileOAuth2TokenService* token_service); |
| 47 | 47 |
| 48 void DeleteSelf(); | 48 void DeleteSelf(); |
| 49 | 49 |
| 50 static SerialList GetDevices(base::WeakPtr<DevToolsBridgeClient> weak_ptr); | 50 static SerialList GetDevices(base::WeakPtr<DevToolsBridgeClient> weak_ptr); |
| 51 static DeviceInfo GetDeviceInfo(base::WeakPtr<DevToolsBridgeClient> weak_ptr, | 51 static DeviceInfo GetDeviceInfo(base::WeakPtr<DevToolsBridgeClient> weak_ptr, |
| 52 const std::string& serial); | 52 const std::string& serial); |
| 53 void StartSessionIfNeeded(const std::string& socket_name); | 53 void StartSessionIfNeeded(const std::string& socket_name); |
| 54 | 54 |
| 55 static DevToolsBridgeClient* FromWebContents( | 55 static DevToolsBridgeClient* FromWebContents( |
| 56 content::WebContents* web_contents); | 56 content::WebContents* web_contents); |
| 57 void RegisterMessageHandlers(content::WebUI* web_ui); | 57 void RegisterMessageHandlers(content::WebUI* web_ui); |
| 58 | 58 |
| 59 private: | 59 protected: |
| 60 DevToolsBridgeClient(Profile* profile, | 60 DevToolsBridgeClient(Profile* profile, |
| 61 SigninManagerBase* signin_manager, | 61 SigninManagerBase* signin_manager, |
| 62 ProfileOAuth2TokenService* token_service); | 62 ProfileOAuth2TokenService* token_service); |
| 63 | 63 |
| 64 ~DevToolsBridgeClient(); | 64 // Implementation of content::WebContentsObserver. |
| 65 void DocumentOnLoadCompletedInMainFrame() override; | |
| 66 | |
| 67 ~DevToolsBridgeClient() override; | |
| 65 | 68 |
| 66 bool IsAuthenticated(); | 69 bool IsAuthenticated(); |
| 67 | 70 |
| 71 // Overridden in tests. | |
| 72 virtual scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow(); | |
| 73 virtual void OnBrowserListUpdatedForTests() {} | |
| 74 const BrowserInfoList& browsers() const { return browsers_; } | |
|
dgozman
2014/12/22 17:08:38
nit: please insert blank line before these, as the
SeRya
2014/12/22 17:14:42
Done.
| |
| 75 ProfileIdentityProvider& identity_provider() { return identity_provider_; } | |
| 76 | |
| 77 private: | |
| 68 void CreateBackgroundWorker(); | 78 void CreateBackgroundWorker(); |
| 69 scoped_ptr<local_discovery::GCDApiFlow> CreateGCDApiFlow(); | |
| 70 void UpdateBrowserList(); | 79 void UpdateBrowserList(); |
| 71 | 80 |
| 72 void HandleSendCommand(const base::ListValue* args); | 81 void HandleSendCommand(const base::ListValue* args); |
| 73 | 82 |
| 74 // Implementation of IdentityProvider::Observer. | 83 // Implementation of IdentityProvider::Observer. |
| 75 void OnActiveAccountLogin() override; | 84 void OnActiveAccountLogin() override; |
| 76 void OnActiveAccountLogout() override; | 85 void OnActiveAccountLogout() override; |
| 77 | 86 |
| 78 // Implementation of WebContentsObserver. | |
| 79 void DocumentOnLoadCompletedInMainFrame() override; | |
| 80 | |
| 81 // Implementation of NotificationObserver. | 87 // Implementation of NotificationObserver. |
| 82 void Observe(int type, | 88 void Observe(int type, |
| 83 const content::NotificationSource& source, | 89 const content::NotificationSource& source, |
| 84 const content::NotificationDetails& details) override; | 90 const content::NotificationDetails& details) override; |
| 85 | 91 |
| 86 // Implementation of SendCommandRequest::Delegate. | 92 // Implementation of SendCommandRequest::Delegate. |
| 87 void OnCommandSucceeded(const base::DictionaryValue& response) override; | 93 void OnCommandSucceeded(const base::DictionaryValue& response) override; |
| 88 void OnCommandFailed() override; | 94 void OnCommandFailed() override; |
| 89 | 95 |
| 90 // Implementation of DevToolsBridgeInstancesRequest::Delegate. | 96 // Implementation of DevToolsBridgeInstancesRequest::Delegate. |
| 91 void OnDevToolsBridgeInstancesRequestSucceeded( | 97 void OnDevToolsBridgeInstancesRequestSucceeded( |
| 92 const DevToolsBridgeInstancesRequest::InstanceList& instances) override; | 98 const DevToolsBridgeInstancesRequest::InstanceList& instances) override; |
| 93 void OnDevToolsBridgeInstancesRequestFailed() override; | 99 void OnDevToolsBridgeInstancesRequestFailed() override; |
| 94 | 100 |
| 95 Profile* const profile_; | 101 Profile* const profile_; |
| 96 ProfileIdentityProvider identity_provider_; | 102 ProfileIdentityProvider identity_provider_; |
| 97 content::NotificationRegistrar registrar_; | 103 content::NotificationRegistrar registrar_; |
| 98 scoped_ptr<content::WebContents> background_worker_; | 104 scoped_ptr<content::WebContents> background_worker_; |
| 99 scoped_ptr<local_discovery::GCDApiFlow> browser_list_request_; | 105 scoped_ptr<local_discovery::GCDApiFlow> browser_list_request_; |
| 100 scoped_ptr<local_discovery::GCDApiFlow> send_command_request_; | 106 scoped_ptr<local_discovery::GCDApiFlow> send_command_request_; |
| 101 BrowserInfoList browsers_; | 107 BrowserInfoList browsers_; |
| 102 bool worker_is_loaded_; | 108 bool worker_is_loaded_; |
| 103 base::WeakPtrFactory<DevToolsBridgeClient> weak_factory_; | 109 base::WeakPtrFactory<DevToolsBridgeClient> weak_factory_; |
| 104 | 110 |
| 105 DISALLOW_COPY_AND_ASSIGN(DevToolsBridgeClient); | 111 DISALLOW_COPY_AND_ASSIGN(DevToolsBridgeClient); |
| 106 }; | 112 }; |
| 107 | 113 |
| 108 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ | 114 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_WEBRTC_DEVTOOLS_BRIDGE_CLIENT_H_ |
| OLD | NEW |