Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/ui/webui/inspect_ui.h

Issue 65143004: DevTools: Refactor InspectUI class for extensibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_id code is governed by a BSD-style license that can be
vsevik 2013/11/12 14:24:07 revert
Vladislav Kaznacheev 2013/11/13 16:02:33 Done.
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 scoped_refptr<DevToolsAdbBridge::RemotePackage> FindRemotePackage( 38 void Open(const std::string& source_id,
39 const std::string& id); 39 const std::string& browser_id,
40 const std::string& url);
41 void Launch(const std::string& source_id, const std::string& package_id);
40 42
41 static void InspectDevices(Browser* browser); 43 static void InspectDevices(Browser* browser);
42 44
43 private: 45 private:
44 class WorkerCreationDestructionListener;
45
46 void PopulateWebContentsTargets();
47 void PopulateWorkerTargets(const std::vector<DevToolsTargetImpl*>&);
48
49 // content::NotificationObserver overrides. 46 // content::NotificationObserver overrides.
50 virtual void Observe(int type, 47 virtual void Observe(int type,
51 const content::NotificationSource& source, 48 const content::NotificationSource& source,
52 const content::NotificationDetails& details) OVERRIDE; 49 const content::NotificationDetails& details) OVERRIDE;
53 50
54 void StartListeningNotifications(); 51 void StartListeningNotifications();
55 void StopListeningNotifications(); 52 void StopListeningNotifications();
56 53
57 content::WebUIDataSource* CreateInspectUIHTMLSource(); 54 content::WebUIDataSource* CreateInspectUIHTMLSource();
58 55
59 // DevToolsAdbBridge::Listener overrides.
60 virtual void RemoteDevicesChanged(
61 DevToolsAdbBridge::RemoteDevices* devices) OVERRIDE;
62
63 void UpdateDiscoverUsbDevicesEnabled(); 56 void UpdateDiscoverUsbDevicesEnabled();
64 void UpdatePortForwardingEnabled(); 57 void UpdatePortForwardingEnabled();
65 void UpdatePortForwardingConfig(); 58 void UpdatePortForwardingConfig();
66 59
67 void SetPortForwardingDefaults(); 60 void SetPortForwardingDefaults();
68 61
69 const base::Value* GetPrefValue(const char* name); 62 const base::Value* GetPrefValue(const char* name);
70 63
71 scoped_refptr<WorkerCreationDestructionListener> observer_; 64 void AddTargetUIHandler(
65 scoped_ptr<DevToolsTargetsUIHandler> handler);
66 void AddRemoteTargetUIHandler(
67 scoped_ptr<DevToolsRemoteTargetsUIHandler> handler);
68
69 DevToolsTargetsUIHandler* FindTargetHandler(const std::string& source_id);
70 DevToolsRemoteTargetsUIHandler* FindRemoteTargetHandler(
71 const std::string& source_id);
72
73 void PopulateTargets(const std::string& source_id,
74 scoped_ptr<base::ListValue> targets);
72 75
73 // A scoped container for notification registries. 76 // A scoped container for notification registries.
74 content::NotificationRegistrar notification_registrar_; 77 content::NotificationRegistrar notification_registrar_;
75 78
76 // A scoped container for preference change registries. 79 // A scoped container for preference change registries.
77 PrefChangeRegistrar pref_change_registrar_; 80 PrefChangeRegistrar pref_change_registrar_;
78 81
79 typedef std::map<std::string, DevToolsTargetImpl*> TargetMap; 82 typedef std::map<std::string, DevToolsTargetsUIHandler*> TargetHandlerMap;
80 TargetMap render_view_host_targets_; 83 TargetHandlerMap target_handlers_;
81 TargetMap worker_targets_;
82 TargetMap remote_targets_;
83 84
84 typedef std::map<std::string, 85 typedef std::map<std::string, DevToolsRemoteTargetsUIHandler*>
85 scoped_refptr<DevToolsAdbBridge::RemoteBrowser> > RemoteBrowsers; 86 RemoteTargetHandlerMap;
86 RemoteBrowsers remote_browsers_; 87 RemoteTargetHandlerMap remote_target_handlers_;
87
88 typedef std::map<std::string,
89 scoped_refptr<DevToolsAdbBridge::RemotePackage> > RemotePackages;
90 RemotePackages remote_packages_;
91 88
92 DISALLOW_COPY_AND_ASSIGN(InspectUI); 89 DISALLOW_COPY_AND_ASSIGN(InspectUI);
93 }; 90 };
94 91
95 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_ 92 #endif // CHROME_BROWSER_UI_WEBUI_INSPECT_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698