| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_WEBUI_INSPECT_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
| 13 #include "chrome/browser/devtools/devtools_adb_bridge.h" | |
| 14 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/web_ui_controller.h" | 15 #include "content/public/browser/web_ui_controller.h" |
| 17 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class Value; | 19 class Value; |
| 20 class ListValue; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class Browser; | 23 class Browser; |
| 24 class DevToolsTargetImpl; | 24 class DevToolsRemoteTargetsUIHandler; |
| 25 class DevToolsTargetsUIHandler; |
| 25 | 26 |
| 26 class InspectUI : public content::WebUIController, | 27 class InspectUI : public content::WebUIController, |
| 27 public content::NotificationObserver, | 28 public content::NotificationObserver { |
| 28 public DevToolsAdbBridge::Listener { | |
| 29 public: | 29 public: |
| 30 explicit InspectUI(content::WebUI* web_ui); | 30 explicit InspectUI(content::WebUI* web_ui); |
| 31 virtual ~InspectUI(); | 31 virtual ~InspectUI(); |
| 32 | 32 |
| 33 void InitUI(); | 33 void InitUI(); |
| 34 DevToolsTargetImpl* FindTarget(const std::string& type, | 34 void Inspect(const std::string& source_id, const std::string& target_id); |
| 35 const std::string& id); | 35 void Activate(const std::string& source_id, const std::string& target_id); |
| 36 scoped_refptr<DevToolsAdbBridge::RemoteBrowser> FindRemoteBrowser( | 36 void Close(const std::string& source_id, const std::string& target_id); |
| 37 const std::string& id); | 37 void Reload(const std::string& source_id, const std::string& target_id); |
| 38 void Open(const std::string& source_id, |
| 39 const std::string& browser_id, |
| 40 const std::string& url); |
| 38 | 41 |
| 39 static void InspectDevices(Browser* browser); | 42 static void InspectDevices(Browser* browser); |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 class WorkerCreationDestructionListener; | |
| 43 | |
| 44 void PopulateWebContentsTargets(); | |
| 45 void PopulateWorkerTargets(const std::vector<DevToolsTargetImpl*>&); | |
| 46 | |
| 47 // content::NotificationObserver overrides. | 45 // content::NotificationObserver overrides. |
| 48 virtual void Observe(int type, | 46 virtual void Observe(int type, |
| 49 const content::NotificationSource& source, | 47 const content::NotificationSource& source, |
| 50 const content::NotificationDetails& details) OVERRIDE; | 48 const content::NotificationDetails& details) OVERRIDE; |
| 51 | 49 |
| 52 void StartListeningNotifications(); | 50 void StartListeningNotifications(); |
| 53 void StopListeningNotifications(); | 51 void StopListeningNotifications(); |
| 54 | 52 |
| 55 content::WebUIDataSource* CreateInspectUIHTMLSource(); | 53 content::WebUIDataSource* CreateInspectUIHTMLSource(); |
| 56 | 54 |
| 57 // DevToolsAdbBridge::Listener overrides. | |
| 58 virtual void RemoteDevicesChanged( | |
| 59 DevToolsAdbBridge::RemoteDevices* devices) OVERRIDE; | |
| 60 | |
| 61 void UpdateDiscoverUsbDevicesEnabled(); | 55 void UpdateDiscoverUsbDevicesEnabled(); |
| 62 void UpdatePortForwardingEnabled(); | 56 void UpdatePortForwardingEnabled(); |
| 63 void UpdatePortForwardingConfig(); | 57 void UpdatePortForwardingConfig(); |
| 64 | 58 |
| 65 void SetPortForwardingDefaults(); | 59 void SetPortForwardingDefaults(); |
| 66 | 60 |
| 67 const base::Value* GetPrefValue(const char* name); | 61 const base::Value* GetPrefValue(const char* name); |
| 68 | 62 |
| 69 scoped_refptr<WorkerCreationDestructionListener> observer_; | 63 void AddTargetUIHandler( |
| 64 scoped_ptr<DevToolsTargetsUIHandler> handler); |
| 65 void AddRemoteTargetUIHandler( |
| 66 scoped_ptr<DevToolsRemoteTargetsUIHandler> handler); |
| 67 |
| 68 DevToolsTargetsUIHandler* FindTargetHandler(const std::string& source_id); |
| 69 DevToolsRemoteTargetsUIHandler* FindRemoteTargetHandler( |
| 70 const std::string& source_id); |
| 71 |
| 72 void PopulateTargets(const std::string& source_id, |
| 73 scoped_ptr<base::ListValue> targets); |
| 70 | 74 |
| 71 // A scoped container for notification registries. | 75 // A scoped container for notification registries. |
| 72 content::NotificationRegistrar notification_registrar_; | 76 content::NotificationRegistrar notification_registrar_; |
| 73 | 77 |
| 74 // A scoped container for preference change registries. | 78 // A scoped container for preference change registries. |
| 75 PrefChangeRegistrar pref_change_registrar_; | 79 PrefChangeRegistrar pref_change_registrar_; |
| 76 | 80 |
| 77 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; | 81 typedef std::map<std::string, DevToolsTargetsUIHandler*> TargetHandlerMap; |
| 78 TargetMap render_view_host_targets_; | 82 TargetHandlerMap target_handlers_; |
| 79 TargetMap worker_targets_; | |
| 80 TargetMap remote_targets_; | |
| 81 | 83 |
| 82 typedef std::map<std::string, | 84 typedef std::map<std::string, DevToolsRemoteTargetsUIHandler*> |
| 83 scoped_refptr<DevToolsAdbBridge::RemoteBrowser> > RemoteBrowsers; | 85 RemoteTargetHandlerMap; |
| 84 RemoteBrowsers remote_browsers_; | 86 RemoteTargetHandlerMap remote_target_handlers_; |
| 85 | 87 |
| 86 DISALLOW_COPY_AND_ASSIGN(InspectUI); | 88 DISALLOW_COPY_AND_ASSIGN(InspectUI); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ | 91 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ |
| OLD | NEW |