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

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

Issue 46523002: Fix Telemetry. (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
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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/ui/webui/inspect_ui.h" 5 #include "chrome/browser/ui/webui/inspect_ui.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
13 #include "base/prefs/pref_service.h"
14 #include "base/stl_util.h"
15 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 17 #include "base/values.h"
20 #include "chrome/browser/devtools/devtools_target_impl.h" 18 #include "chrome/browser/devtools/devtools_window.h"
21 #include "chrome/browser/devtools/port_forwarding_controller.h" 19 #include "chrome/browser/devtools/port_forwarding_controller.h"
20 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser_navigator.h" 22 #include "chrome/browser/ui/browser_navigator.h"
24 #include "chrome/browser/ui/singleton_tabs.h" 23 #include "chrome/browser/ui/singleton_tabs.h"
25 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 24 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
25 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
26 #include "chrome/browser/ui/webui/theme_source.h" 26 #include "chrome/browser/ui/webui/theme_source.h"
27 #include "chrome/common/extensions/extension_constants.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
29 #include "content/public/browser/browser_child_process_observer.h" 30 #include "content/public/browser/browser_child_process_observer.h"
30 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/child_process_data.h" 32 #include "content/public/browser/child_process_data.h"
32 #include "content/public/browser/devtools_agent_host.h" 33 #include "content/public/browser/devtools_agent_host.h"
33 #include "content/public/browser/devtools_client_host.h" 34 #include "content/public/browser/devtools_client_host.h"
34 #include "content/public/browser/devtools_manager.h" 35 #include "content/public/browser/devtools_manager.h"
36 #include "content/public/browser/favicon_status.h"
37 #include "content/public/browser/navigation_entry.h"
35 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
37 #include "content/public/browser/notification_types.h" 40 #include "content/public/browser/notification_types.h"
38 #include "content/public/browser/render_process_host.h" 41 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/render_view_host.h" 42 #include "content/public/browser/render_view_host.h"
40 #include "content/public/browser/user_metrics.h" 43 #include "content/public/browser/user_metrics.h"
41 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
42 #include "content/public/browser/web_ui.h" 45 #include "content/public/browser/web_ui.h"
43 #include "content/public/browser/web_ui_data_source.h" 46 #include "content/public/browser/web_ui_data_source.h"
44 #include "content/public/browser/web_ui_message_handler.h" 47 #include "content/public/browser/web_ui_message_handler.h"
(...skipping 15 matching lines...) Expand all
60 using content::RenderViewHost; 63 using content::RenderViewHost;
61 using content::RenderViewHostDelegate; 64 using content::RenderViewHostDelegate;
62 using content::RenderWidgetHost; 65 using content::RenderWidgetHost;
63 using content::WebContents; 66 using content::WebContents;
64 using content::WebUIMessageHandler; 67 using content::WebUIMessageHandler;
65 using content::WorkerService; 68 using content::WorkerService;
66 using content::WorkerServiceObserver; 69 using content::WorkerServiceObserver;
67 70
68 namespace { 71 namespace {
69 72
73 const char kAppTargetType[] = "app";
74 const char kExtensionTargetType[] = "extension";
75 const char kPageTargetType[] = "page";
70 const char kWorkerTargetType[] = "worker"; 76 const char kWorkerTargetType[] = "worker";
71 const char kAdbTargetType[] = "adb_page"; 77 const char kAdbTargetType[] = "adb_page";
72 78
73 const char kInitUICommand[] = "init-ui"; 79 const char kInitUICommand[] = "init-ui";
74 const char kInspectCommand[] = "inspect"; 80 const char kInspectCommand[] = "inspect";
75 const char kActivateCommand[] = "activate"; 81 const char kActivateCommand[] = "activate";
76 const char kCloseCommand[] = "close"; 82 const char kTerminateCommand[] = "terminate";
77 const char kReloadCommand[] = "reload"; 83 const char kReloadCommand[] = "reload";
78 const char kOpenCommand[] = "open"; 84 const char kOpenCommand[] = "open";
79 85
80 const char kDiscoverUsbDevicesEnabledCommand[] = 86 const char kDiscoverUsbDevicesEnabledCommand[] =
81 "set-discover-usb-devices-enabled"; 87 "set-discover-usb-devices-enabled";
82 const char kPortForwardingEnabledCommand[] = 88 const char kPortForwardingEnabledCommand[] =
83 "set-port-forwarding-enabled"; 89 "set-port-forwarding-enabled";
84 const char kPortForwardingConfigCommand[] = "set-port-forwarding-config"; 90 const char kPortForwardingConfigCommand[] = "set-port-forwarding-config";
85 91
86 const char kPortForwardingDefaultPort[] = "8080"; 92 const char kPortForwardingDefaultPort[] = "8080";
87 const char kPortForwardingDefaultLocation[] = "localhost:8080"; 93 const char kPortForwardingDefaultLocation[] = "localhost:8080";
88 94
89 const char kTargetIdField[] = "id";
90 const char kTargetTypeField[] = "type"; 95 const char kTargetTypeField[] = "type";
91 const char kAttachedField[] = "attached"; 96 const char kAttachedField[] = "attached";
97 const char kProcessIdField[] = "processId";
98 const char kRouteIdField[] = "routeId";
92 const char kUrlField[] = "url"; 99 const char kUrlField[] = "url";
93 const char kNameField[] = "name"; 100 const char kNameField[] = "name";
94 const char kFaviconUrlField[] = "faviconUrl"; 101 const char kFaviconUrlField[] = "faviconUrl";
95 const char kDescription[] = "description"; 102 const char kDescription[] = "description";
103 const char kPidField[] = "pid";
96 const char kAdbConnectedField[] = "adbConnected"; 104 const char kAdbConnectedField[] = "adbConnected";
97 const char kAdbModelField[] = "adbModel"; 105 const char kAdbModelField[] = "adbModel";
98 const char kAdbSerialField[] = "adbSerial"; 106 const char kAdbSerialField[] = "adbSerial";
99 const char kAdbBrowserProductField[] = "adbBrowserProduct"; 107 const char kAdbBrowserProductField[] = "adbBrowserProduct";
100 const char kAdbBrowserPackageField[] = "adbBrowserPackage"; 108 const char kAdbBrowserPackageField[] = "adbBrowserPackage";
101 const char kAdbBrowserVersionField[] = "adbBrowserVersion"; 109 const char kAdbBrowserVersionField[] = "adbBrowserVersion";
102 const char kAdbGlobalIdField[] = "adbGlobalId"; 110 const char kAdbGlobalIdField[] = "adbGlobalId";
103 const char kAdbBrowsersField[] = "browsers"; 111 const char kAdbBrowsersField[] = "browsers";
104 const char kAdbPagesField[] = "pages"; 112 const char kAdbPagesField[] = "pages";
105 const char kAdbPortStatus[] = "adbPortStatus"; 113 const char kAdbPortStatus[] = "adbPortStatus";
106 const char kAdbScreenWidthField[] = "adbScreenWidth"; 114 const char kAdbScreenWidthField[] = "adbScreenWidth";
107 const char kAdbScreenHeightField[] = "adbScreenHeight"; 115 const char kAdbScreenHeightField[] = "adbScreenHeight";
108 const char kAdbAttachedForeignField[] = "adbAttachedForeign"; 116 const char kAdbAttachedForeignField[] = "adbAttachedForeign";
109 const char kGuestList[] = "guests"; 117 const char kGuestList[] = "guests";
110 118
111 DictionaryValue* BuildTargetDescriptor( 119 DictionaryValue* BuildTargetDescriptor(
112 const DevToolsTargetImpl& target) { 120 const std::string& target_type,
121 bool attached,
122 const GURL& url,
123 const std::string& name,
124 const GURL& favicon_url,
125 const std::string& description,
126 int process_id,
127 int route_id,
128 base::ProcessHandle handle = base::kNullProcessHandle) {
113 DictionaryValue* target_data = new DictionaryValue(); 129 DictionaryValue* target_data = new DictionaryValue();
114 target_data->SetString(kTargetIdField, target.GetId()); 130 target_data->SetString(kTargetTypeField, target_type);
115 target_data->SetString(kTargetTypeField, target.GetType()); 131 target_data->SetBoolean(kAttachedField, attached);
116 target_data->SetBoolean(kAttachedField, target.IsAttached()); 132 target_data->SetInteger(kProcessIdField, process_id);
117 target_data->SetString(kUrlField, target.GetUrl().spec()); 133 target_data->SetInteger(kRouteIdField, route_id);
118 target_data->SetString(kNameField, net::EscapeForHTML(target.GetTitle())); 134 target_data->SetString(kUrlField, url.spec());
119 target_data->SetString(kFaviconUrlField, target.GetFaviconUrl().spec()); 135 target_data->SetString(kNameField, net::EscapeForHTML(name));
120 target_data->SetString(kDescription, target.GetDescription()); 136 target_data->SetInteger(kPidField, base::GetProcId(handle));
137 target_data->SetString(kFaviconUrlField, favicon_url.spec());
138 target_data->SetString(kDescription, description);
121 139
122 return target_data; 140 return target_data;
123 } 141 }
124 142
143 bool HasClientHost(RenderViewHost* rvh) {
144 if (!DevToolsAgentHost::HasFor(rvh))
145 return false;
146
147 scoped_refptr<DevToolsAgentHost> agent(
148 DevToolsAgentHost::GetOrCreateFor(rvh));
149 return agent->IsAttached();
150 }
151
152 bool HasClientHost(int process_id, int route_id) {
153 if (!DevToolsAgentHost::HasForWorker(process_id, route_id))
154 return false;
155
156 scoped_refptr<DevToolsAgentHost> agent(
157 DevToolsAgentHost::GetForWorker(process_id, route_id));
158 return agent->IsAttached();
159 }
160
161 DictionaryValue* BuildTargetDescriptor(RenderViewHost* rvh, bool is_tab) {
162 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
163 std::string title;
164 std::string target_type = is_tab ? kPageTargetType : "";
165 GURL url;
166 GURL favicon_url;
167 if (web_contents) {
168 url = web_contents->GetURL();
169 title = UTF16ToUTF8(web_contents->GetTitle());
170 content::NavigationController& controller = web_contents->GetController();
171 content::NavigationEntry* entry = controller.GetActiveEntry();
172 if (entry != NULL && entry->GetURL().is_valid())
173 favicon_url = entry->GetFavicon().url;
174
175 Profile* profile = Profile::FromBrowserContext(
176 web_contents->GetBrowserContext());
177 if (profile) {
178 ExtensionService* extension_service = profile->GetExtensionService();
179 const extensions::Extension* extension = extension_service->
180 extensions()->GetByID(url.host());
181 if (extension) {
182 if (extension->is_hosted_app()
183 || extension->is_legacy_packaged_app()
184 || extension->is_platform_app())
185 target_type = kAppTargetType;
186 else
187 target_type = kExtensionTargetType;
188 title = extension->name();
189 favicon_url = extensions::ExtensionIconSource::GetIconURL(
190 extension, extension_misc::EXTENSION_ICON_SMALLISH,
191 ExtensionIconSet::MATCH_BIGGER, false, NULL);
192 }
193 }
194 }
195
196 return BuildTargetDescriptor(target_type,
197 HasClientHost(rvh),
198 url,
199 title,
200 favicon_url,
201 "",
202 rvh->GetProcess()->GetID(),
203 rvh->GetRoutingID());
204 }
205
125 class InspectMessageHandler : public WebUIMessageHandler { 206 class InspectMessageHandler : public WebUIMessageHandler {
126 public: 207 public:
127 explicit InspectMessageHandler(InspectUI* inspect_ui) 208 explicit InspectMessageHandler(InspectUI* inspect_ui)
128 : inspect_ui_(inspect_ui) {} 209 : inspect_ui_(inspect_ui) {}
129 virtual ~InspectMessageHandler() {} 210 virtual ~InspectMessageHandler() {}
130 211
131 private: 212 private:
132 // WebUIMessageHandler implementation. 213 // WebUIMessageHandler implementation.
133 virtual void RegisterMessages() OVERRIDE; 214 virtual void RegisterMessages() OVERRIDE;
134 215
135 void HandleInitUICommand(const ListValue* args); 216 void HandleInitUICommand(const ListValue* args);
136 void HandleInspectCommand(const ListValue* args); 217 void HandleInspectCommand(const ListValue* args);
137 void HandleActivateCommand(const ListValue* args); 218 void HandleActivateCommand(const ListValue* args);
138 void HandleCloseCommand(const ListValue* args); 219 void HandleTerminateCommand(const ListValue* args);
139 void HandleReloadCommand(const ListValue* args); 220 void HandleReloadCommand(const ListValue* args);
140 void HandleOpenCommand(const ListValue* args); 221 void HandleOpenCommand(const ListValue* args);
141 void HandleBooleanPrefChanged(const char* pref_name, 222 void HandleBooleanPrefChanged(const char* pref_name,
142 const ListValue* args); 223 const ListValue* args);
143 void HandlePortForwardingConfigCommand(const ListValue* args); 224 void HandlePortForwardingConfigCommand(const ListValue* args);
144 225
145 DevToolsTargetImpl* FindTarget(const ListValue* args); 226 static bool GetProcessAndRouteId(const ListValue* args,
227 int* process_id,
228 int* route_id);
229
230 static bool GetRemotePageId(const ListValue* args, std::string* page_id);
146 231
147 InspectUI* inspect_ui_; 232 InspectUI* inspect_ui_;
148 233
149 DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler); 234 DISALLOW_COPY_AND_ASSIGN(InspectMessageHandler);
150 }; 235 };
151 236
152 void InspectMessageHandler::RegisterMessages() { 237 void InspectMessageHandler::RegisterMessages() {
153 web_ui()->RegisterMessageCallback(kInitUICommand, 238 web_ui()->RegisterMessageCallback(kInitUICommand,
154 base::Bind(&InspectMessageHandler::HandleInitUICommand, 239 base::Bind(&InspectMessageHandler::HandleInitUICommand,
155 base::Unretained(this))); 240 base::Unretained(this)));
156 web_ui()->RegisterMessageCallback(kInspectCommand, 241 web_ui()->RegisterMessageCallback(kInspectCommand,
157 base::Bind(&InspectMessageHandler::HandleInspectCommand, 242 base::Bind(&InspectMessageHandler::HandleInspectCommand,
158 base::Unretained(this))); 243 base::Unretained(this)));
159 web_ui()->RegisterMessageCallback(kActivateCommand, 244 web_ui()->RegisterMessageCallback(kActivateCommand,
160 base::Bind(&InspectMessageHandler::HandleActivateCommand, 245 base::Bind(&InspectMessageHandler::HandleActivateCommand,
161 base::Unretained(this))); 246 base::Unretained(this)));
162 web_ui()->RegisterMessageCallback(kCloseCommand, 247 web_ui()->RegisterMessageCallback(kTerminateCommand,
163 base::Bind(&InspectMessageHandler::HandleCloseCommand, 248 base::Bind(&InspectMessageHandler::HandleTerminateCommand,
164 base::Unretained(this))); 249 base::Unretained(this)));
165 web_ui()->RegisterMessageCallback(kDiscoverUsbDevicesEnabledCommand, 250 web_ui()->RegisterMessageCallback(kDiscoverUsbDevicesEnabledCommand,
166 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged, 251 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged,
167 base::Unretained(this), 252 base::Unretained(this),
168 &prefs::kDevToolsDiscoverUsbDevicesEnabled[0])); 253 &prefs::kDevToolsDiscoverUsbDevicesEnabled[0]));
169 web_ui()->RegisterMessageCallback(kPortForwardingEnabledCommand, 254 web_ui()->RegisterMessageCallback(kPortForwardingEnabledCommand,
170 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged, 255 base::Bind(&InspectMessageHandler::HandleBooleanPrefChanged,
171 base::Unretained(this), 256 base::Unretained(this),
172 &prefs::kDevToolsPortForwardingEnabled[0])); 257 &prefs::kDevToolsPortForwardingEnabled[0]));
173 web_ui()->RegisterMessageCallback(kPortForwardingConfigCommand, 258 web_ui()->RegisterMessageCallback(kPortForwardingConfigCommand,
174 base::Bind(&InspectMessageHandler::HandlePortForwardingConfigCommand, 259 base::Bind(&InspectMessageHandler::HandlePortForwardingConfigCommand,
175 base::Unretained(this))); 260 base::Unretained(this)));
176 web_ui()->RegisterMessageCallback(kReloadCommand, 261 web_ui()->RegisterMessageCallback(kReloadCommand,
177 base::Bind(&InspectMessageHandler::HandleReloadCommand, 262 base::Bind(&InspectMessageHandler::HandleReloadCommand,
178 base::Unretained(this))); 263 base::Unretained(this)));
179 web_ui()->RegisterMessageCallback(kOpenCommand, 264 web_ui()->RegisterMessageCallback(kOpenCommand,
180 base::Bind(&InspectMessageHandler::HandleOpenCommand, 265 base::Bind(&InspectMessageHandler::HandleOpenCommand,
181 base::Unretained(this))); 266 base::Unretained(this)));
182 } 267 }
183 268
184 void InspectMessageHandler::HandleInitUICommand(const ListValue*) { 269 void InspectMessageHandler::HandleInitUICommand(const ListValue*) {
185 inspect_ui_->InitUI(); 270 inspect_ui_->InitUI();
186 } 271 }
187 272
188 void InspectMessageHandler::HandleInspectCommand(const ListValue* args) { 273 void InspectMessageHandler::HandleInspectCommand(const ListValue* args) {
189 Profile* profile = Profile::FromWebUI(web_ui()); 274 Profile* profile = Profile::FromWebUI(web_ui());
190 if (!profile) 275 if (!profile)
191 return; 276 return;
192 DevToolsTargetImpl* target = FindTarget(args); 277
193 if (target) 278 std::string page_id;
194 target->Inspect(profile); 279 if (GetRemotePageId(args, &page_id)) {
280 inspect_ui_->InspectRemotePage(page_id);
281 return;
282 }
283
284 int process_id;
285 int route_id;
286 if (!GetProcessAndRouteId(args, &process_id, &route_id) || process_id == 0
287 || route_id == 0) {
288 return;
289 }
290
291 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id);
292 if (rvh) {
293 DevToolsWindow::OpenDevToolsWindow(rvh);
294 return;
295 }
296
297 scoped_refptr<DevToolsAgentHost> agent_host(
298 DevToolsAgentHost::GetForWorker(process_id, route_id));
299 if (!agent_host.get())
300 return;
301
302 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host.get());
195 } 303 }
196 304
197 void InspectMessageHandler::HandleActivateCommand(const ListValue* args) { 305 void InspectMessageHandler::HandleActivateCommand(const ListValue* args) {
198 DevToolsTargetImpl* target = FindTarget(args); 306 std::string page_id;
199 if (target) 307 if (GetRemotePageId(args, &page_id))
200 target->Activate(); 308 inspect_ui_->ActivateRemotePage(page_id);
201 } 309 }
202 310
203 void InspectMessageHandler::HandleCloseCommand(const ListValue* args) { 311 static void TerminateWorker(int process_id, int route_id) {
204 DevToolsTargetImpl* target = FindTarget(args); 312 WorkerService::GetInstance()->TerminateWorker(process_id, route_id);
205 if (target) 313 }
206 target->Close(); 314
315 void InspectMessageHandler::HandleTerminateCommand(const ListValue* args) {
316 std::string page_id;
317 if (GetRemotePageId(args, &page_id)) {
318 inspect_ui_->CloseRemotePage(page_id);
319 return;
320 }
321
322 int process_id;
323 int route_id;
324 if (!GetProcessAndRouteId(args, &process_id, &route_id))
325 return;
326
327 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
328 base::Bind(&TerminateWorker, process_id, route_id));
207 } 329 }
208 330
209 void InspectMessageHandler::HandleReloadCommand(const ListValue* args) { 331 void InspectMessageHandler::HandleReloadCommand(const ListValue* args) {
210 DevToolsTargetImpl* target = FindTarget(args); 332 std::string page_id;
211 if (target) 333 if (GetRemotePageId(args, &page_id))
212 target->Reload(); 334 inspect_ui_->ReloadRemotePage(page_id);
213 } 335 }
214 336
215 void InspectMessageHandler::HandleOpenCommand(const ListValue* args) { 337 void InspectMessageHandler::HandleOpenCommand(const ListValue* args) {
216 if (args->GetSize() != 2)
217 return;
218 std::string browser_id; 338 std::string browser_id;
219 if (!args->GetString(0, &browser_id))
220 return;
221 scoped_refptr<DevToolsAdbBridge::RemoteBrowser> remote_browser =
222 inspect_ui_->FindRemoteBrowser(browser_id);
223 if (!remote_browser)
224 return;
225 std::string url; 339 std::string url;
226 if (!args->GetString(1, &url)) 340 if (args->GetSize() == 2 &&
227 return; 341 args->GetString(0, &browser_id) &&
228 GURL gurl(url); 342 args->GetString(1, &url)) {
229 if (!gurl.is_valid()) { 343 inspect_ui_->OpenRemotePage(browser_id, url);
230 gurl = GURL("http://" + url);
231 if (!gurl.is_valid())
232 return;
233 } 344 }
234 remote_browser->Open(gurl.spec());
235 } 345 }
236 346
237 DevToolsTargetImpl* InspectMessageHandler::FindTarget(const ListValue* args) { 347 bool InspectMessageHandler::GetProcessAndRouteId(const ListValue* args,
348 int* process_id,
349 int* route_id) {
238 const DictionaryValue* data; 350 const DictionaryValue* data;
239 std::string type;
240 std::string id;
241 if (args->GetSize() == 1 && args->GetDictionary(0, &data) && 351 if (args->GetSize() == 1 && args->GetDictionary(0, &data) &&
242 data->GetString(kTargetTypeField, &type) && 352 data->GetInteger(kProcessIdField, process_id) &&
243 data->GetString(kTargetIdField, &id)) { 353 data->GetInteger(kRouteIdField, route_id)) {
244 return inspect_ui_->FindTarget(type, id); 354 return true;
245 } 355 }
246 return NULL; 356 return false;
247 } 357 }
248 358
249 void InspectMessageHandler::HandleBooleanPrefChanged( 359 void InspectMessageHandler::HandleBooleanPrefChanged(
250 const char* pref_name, 360 const char* pref_name,
251 const ListValue* args) { 361 const ListValue* args) {
252 Profile* profile = Profile::FromWebUI(web_ui()); 362 Profile* profile = Profile::FromWebUI(web_ui());
253 if (!profile) 363 if (!profile)
254 return; 364 return;
255 365
256 bool enabled; 366 bool enabled;
257 if (args->GetSize() == 1 && args->GetBoolean(0, &enabled)) 367 if (args->GetSize() == 1 && args->GetBoolean(0, &enabled))
258 profile->GetPrefs()->SetBoolean(pref_name, enabled); 368 profile->GetPrefs()->SetBoolean(pref_name, enabled);
259 } 369 }
260 370
261 void InspectMessageHandler::HandlePortForwardingConfigCommand( 371 void InspectMessageHandler::HandlePortForwardingConfigCommand(
262 const ListValue* args) { 372 const ListValue* args) {
263 Profile* profile = Profile::FromWebUI(web_ui()); 373 Profile* profile = Profile::FromWebUI(web_ui());
264 if (!profile) 374 if (!profile)
265 return; 375 return;
266 376
267 const DictionaryValue* dict_src; 377 const DictionaryValue* dict_src;
268 if (args->GetSize() == 1 && args->GetDictionary(0, &dict_src)) 378 if (args->GetSize() == 1 && args->GetDictionary(0, &dict_src))
269 profile->GetPrefs()->Set(prefs::kDevToolsPortForwardingConfig, *dict_src); 379 profile->GetPrefs()->Set(prefs::kDevToolsPortForwardingConfig, *dict_src);
270 } 380 }
271 381
382 bool InspectMessageHandler::GetRemotePageId(const ListValue* args,
383 std::string* page_id) {
384 const DictionaryValue* data;
385 if (args->GetSize() == 1 && args->GetDictionary(0, &data) &&
386 data->GetString(kAdbGlobalIdField, page_id)) {
387 return true;
388 }
389 return false;
390 }
391
272 } // namespace 392 } // namespace
273 393
274 class InspectUI::WorkerCreationDestructionListener 394 class InspectUI::WorkerCreationDestructionListener
275 : public WorkerServiceObserver, 395 : public WorkerServiceObserver,
276 public content::BrowserChildProcessObserver, 396 public content::BrowserChildProcessObserver,
277 public base::RefCountedThreadSafe<WorkerCreationDestructionListener> { 397 public base::RefCountedThreadSafe<WorkerCreationDestructionListener> {
278 public: 398 public:
279 WorkerCreationDestructionListener() 399 WorkerCreationDestructionListener()
280 : discovery_ui_(NULL) {} 400 : discovery_ui_(NULL) {}
281 401
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 450 }
331 451
332 virtual void BrowserChildProcessHostDisconnected( 452 virtual void BrowserChildProcessHostDisconnected(
333 const content::ChildProcessData& data) OVERRIDE { 453 const content::ChildProcessData& data) OVERRIDE {
334 if (data.process_type == content::PROCESS_TYPE_WORKER) 454 if (data.process_type == content::PROCESS_TYPE_WORKER)
335 UpdateUI(); 455 UpdateUI();
336 } 456 }
337 457
338 void CollectWorkersData() { 458 void CollectWorkersData() {
339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
340 DevToolsTargetImpl::EnumerateWorkerTargets( 460 BrowserThread::PostTask(
341 base::Bind( 461 BrowserThread::UI, FROM_HERE,
342 &WorkerCreationDestructionListener::PopulateWorkersList, this)); 462 base::Bind(&WorkerCreationDestructionListener::PopulateWorkersList,
463 this, WorkerService::GetInstance()->GetWorkers()));
343 } 464 }
344 465
345 void RegisterObserver() { 466 void RegisterObserver() {
346 WorkerService::GetInstance()->AddObserver(this); 467 WorkerService::GetInstance()->AddObserver(this);
347 } 468 }
348 469
349 void UnregisterObserver() { 470 void UnregisterObserver() {
350 WorkerService::GetInstance()->RemoveObserver(this); 471 WorkerService::GetInstance()->RemoveObserver(this);
351 } 472 }
352 473
353 void PopulateWorkersList(const DevToolsTargetImpl::List& targets) { 474 void PopulateWorkersList(
475 const std::vector<WorkerService::WorkerInfo>& worker_info) {
354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 476 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
355 if (discovery_ui_) 477 if (!discovery_ui_)
356 discovery_ui_->PopulateWorkerTargets(targets); 478 return;
479
480 ListValue target_list;
481 for (size_t i = 0; i < worker_info.size(); ++i) {
482 if (!worker_info[i].handle)
483 continue; // Process is still being created.
484 target_list.Append(BuildTargetDescriptor(
485 kWorkerTargetType,
486 HasClientHost(worker_info[i].process_id, worker_info[i].route_id),
487 worker_info[i].url,
488 UTF16ToUTF8(worker_info[i].name),
489 GURL(),
490 "",
491 worker_info[i].process_id,
492 worker_info[i].route_id,
493 worker_info[i].handle));
494 }
495 discovery_ui_->web_ui()->CallJavascriptFunction(
496 "populateWorkersList", target_list);
357 } 497 }
358 498
359 InspectUI* discovery_ui_; 499 InspectUI* discovery_ui_;
360 }; 500 };
361 501
362 InspectUI::InspectUI(content::WebUI* web_ui) 502 InspectUI::InspectUI(content::WebUI* web_ui)
363 : WebUIController(web_ui) { 503 : WebUIController(web_ui) {
364 web_ui->AddMessageHandler(new InspectMessageHandler(this)); 504 web_ui->AddMessageHandler(new InspectMessageHandler(this));
365 Profile* profile = Profile::FromWebUI(web_ui); 505 Profile* profile = Profile::FromWebUI(web_ui);
366 content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource()); 506 content::WebUIDataSource::Add(profile, CreateInspectUIHTMLSource());
367 507
368 // Set up the chrome://theme/ source. 508 // Set up the chrome://theme/ source.
369 ThemeSource* theme = new ThemeSource(profile); 509 ThemeSource* theme = new ThemeSource(profile);
370 content::URLDataSource::Add(profile, theme); 510 content::URLDataSource::Add(profile, theme);
371 } 511 }
372 512
373 InspectUI::~InspectUI() { 513 InspectUI::~InspectUI() {
374 StopListeningNotifications(); 514 StopListeningNotifications();
375 } 515 }
376 516
377 void InspectUI::InitUI() { 517 void InspectUI::InitUI() {
378 SetPortForwardingDefaults(); 518 SetPortForwardingDefaults();
379 StartListeningNotifications(); 519 StartListeningNotifications();
380 PopulateWebContentsTargets(); 520 PopulateLists();
381 UpdateDiscoverUsbDevicesEnabled(); 521 UpdateDiscoverUsbDevicesEnabled();
382 UpdatePortForwardingEnabled(); 522 UpdatePortForwardingEnabled();
383 UpdatePortForwardingConfig(); 523 UpdatePortForwardingConfig();
384 observer_->UpdateUI(); 524 observer_->UpdateUI();
385 } 525 }
386 526
387 DevToolsTargetImpl* InspectUI::FindTarget(const std::string& type, 527 void InspectUI::InspectRemotePage(const std::string& id) {
388 const std::string& id) { 528 RemotePages::iterator it = remote_pages_.find(id);
389 if (type == kWorkerTargetType) { 529 if (it != remote_pages_.end()) {
390 TargetMap::iterator it = worker_targets_.find(id); 530 Profile* profile = Profile::FromWebUI(web_ui());
391 return it == worker_targets_.end() ? NULL : it->second; 531 it->second->Inspect(profile);
392 } else if (type == kAdbTargetType) {
393 TargetMap::iterator it = remote_targets_.find(id);
394 return it == remote_targets_.end() ? NULL : it->second;
395 } else {
396 TargetMap::iterator it = web_contents_targets_.find(id);
397 return it == web_contents_targets_.end() ? NULL : it->second;
398 } 532 }
399 } 533 }
400 534
401 scoped_refptr<DevToolsAdbBridge::RemoteBrowser> 535 void InspectUI::ActivateRemotePage(const std::string& id) {
402 InspectUI::FindRemoteBrowser(const std::string& id) { 536 RemotePages::iterator it = remote_pages_.find(id);
403 RemoteBrowsers::iterator it = remote_browsers_.find(id); 537 if (it != remote_pages_.end())
404 return it == remote_browsers_.end() ? NULL : it->second; 538 it->second->Activate();
539 }
540
541 void InspectUI::ReloadRemotePage(const std::string& id) {
542 RemotePages::iterator it = remote_pages_.find(id);
543 if (it != remote_pages_.end())
544 it->second->Reload();
545 }
546
547 void InspectUI::CloseRemotePage(const std::string& id) {
548 RemotePages::iterator it = remote_pages_.find(id);
549 if (it != remote_pages_.end())
550 it->second->Close();
551 }
552
553 void InspectUI::OpenRemotePage(const std::string& browser_id,
554 const std::string& url) {
555 GURL gurl(url);
556 if (!gurl.is_valid()) {
557 gurl = GURL("http://" + url);
558 if (!gurl.is_valid())
559 return;
560 }
561 RemoteBrowsers::iterator it = remote_browsers_.find(browser_id);
562 if (it != remote_browsers_.end())
563 it->second->Open(gurl.spec());
405 } 564 }
406 565
407 void InspectUI::InspectDevices(Browser* browser) { 566 void InspectUI::InspectDevices(Browser* browser) {
408 content::RecordAction(content::UserMetricsAction("InspectDevices")); 567 content::RecordAction(content::UserMetricsAction("InspectDevices"));
409 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( 568 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams(
410 browser, GURL(chrome::kChromeUIInspectURL))); 569 browser, GURL(chrome::kChromeUIInspectURL)));
411 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 570 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
412 ShowSingletonTabOverwritingNTP(browser, params); 571 ShowSingletonTabOverwritingNTP(browser, params);
413 } 572 }
414 573
415 void InspectUI::PopulateWebContentsTargets() { 574 void InspectUI::PopulateLists() {
416 ListValue list_value; 575 std::set<RenderViewHost*> tab_rvhs;
576 for (TabContentsIterator it; !it.done(); it.Next())
577 tab_rvhs.insert(it->GetRenderViewHost());
417 578
418 std::map<WebContents*, DictionaryValue*> web_contents_to_descriptor_; 579 scoped_ptr<ListValue> target_list(new ListValue());
419 std::vector<DevToolsTargetImpl*> guest_targets;
420 580
421 DevToolsTargetImpl::List targets = 581 std::vector<RenderViewHost*> rvh_vector =
422 DevToolsTargetImpl::EnumerateWebContentsTargets(); 582 DevToolsAgentHost::GetValidRenderViewHosts();
423 583
424 STLDeleteValues(&web_contents_targets_); 584 std::map<WebContents*, DictionaryValue*> description_map;
425 for (DevToolsTargetImpl::List::iterator it = targets.begin(); 585 std::vector<WebContents*> guest_contents;
426 it != targets.end(); ++it) {
427 DevToolsTargetImpl* target = *it;
428 WebContents* web_contents = target->GetWebContents();
429 if (!web_contents)
430 continue;
431 RenderViewHost* rvh = web_contents->GetRenderViewHost();
432 if (!rvh)
433 continue;
434 586
435 web_contents_targets_[target->GetId()] = target; 587 for (std::vector<RenderViewHost*>::iterator it(rvh_vector.begin());
588 it != rvh_vector.end(); it++) {
589 bool is_tab = tab_rvhs.find(*it) != tab_rvhs.end();
590 RenderViewHost* rvh = (*it);
591 WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
436 if (rvh->GetProcess()->IsGuest()) { 592 if (rvh->GetProcess()->IsGuest()) {
437 guest_targets.push_back(target); 593 if (web_contents)
594 guest_contents.push_back(web_contents);
438 } else { 595 } else {
439 DictionaryValue* descriptor = BuildTargetDescriptor(*target); 596 DictionaryValue* dictionary = BuildTargetDescriptor(rvh, is_tab);
440 list_value.Append(descriptor); 597 if (web_contents)
441 web_contents_to_descriptor_[web_contents] = descriptor; 598 description_map[web_contents] = dictionary;
599 target_list->Append(dictionary);
442 } 600 }
443 } 601 }
444 602
445 // Add the list of guest-views to each of its embedders. 603 // Add the list of guest-views to each of its embedders.
446 for (std::vector<DevToolsTargetImpl*>::iterator it(guest_targets.begin()); 604 for (std::vector<WebContents*>::iterator it(guest_contents.begin());
447 it != guest_targets.end(); ++it) { 605 it != guest_contents.end(); ++it) {
448 DevToolsTargetImpl* guest = (*it); 606 WebContents* guest = (*it);
449 WebContents* embedder = guest->GetWebContents()->GetEmbedderWebContents(); 607 WebContents* embedder = guest->GetEmbedderWebContents();
450 if (embedder && web_contents_to_descriptor_.count(embedder) > 0) { 608 if (embedder && description_map.count(embedder) > 0) {
451 DictionaryValue* parent = web_contents_to_descriptor_[embedder]; 609 DictionaryValue* description = description_map[embedder];
452 ListValue* guests = NULL; 610 ListValue* guests = NULL;
453 if (!parent->GetList(kGuestList, &guests)) { 611 if (!description->GetList(kGuestList, &guests)) {
454 guests = new ListValue(); 612 guests = new ListValue();
455 parent->Set(kGuestList, guests); 613 description->Set(kGuestList, guests);
456 } 614 }
457 guests->Append(BuildTargetDescriptor(*guest)); 615 RenderViewHost* rvh = guest->GetRenderViewHost();
616 if (rvh)
617 guests->Append(BuildTargetDescriptor(rvh, false));
458 } 618 }
459 } 619 }
460 620
461 web_ui()->CallJavascriptFunction("populateWebContentsTargets", list_value); 621 web_ui()->CallJavascriptFunction("populateLists", *target_list.get());
462 }
463
464 void InspectUI::PopulateWorkerTargets(const DevToolsTargetImpl::List& targets) {
465 ListValue list_value;
466
467 STLDeleteValues(&worker_targets_);
468 for (DevToolsTargetImpl::List::const_iterator it = targets.begin();
469 it != targets.end(); ++it) {
470 DevToolsTargetImpl* target = *it;
471 list_value.Append(BuildTargetDescriptor(*target));
472 worker_targets_[target->GetId()] = target;
473 }
474
475 web_ui()->CallJavascriptFunction("populateWorkerTargets", list_value);
476 } 622 }
477 623
478 void InspectUI::Observe(int type, 624 void InspectUI::Observe(int type,
479 const content::NotificationSource& source, 625 const content::NotificationSource& source,
480 const content::NotificationDetails& details) { 626 const content::NotificationDetails& details) {
481 if (source != content::Source<WebContents>(web_ui()->GetWebContents())) 627 if (source != content::Source<WebContents>(web_ui()->GetWebContents()))
482 PopulateWebContentsTargets(); 628 PopulateLists();
483 else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) 629 else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED)
484 StopListeningNotifications(); 630 StopListeningNotifications();
485 } 631 }
486 632
487 void InspectUI::StartListeningNotifications() { 633 void InspectUI::StartListeningNotifications() {
488 if (observer_) 634 if (observer_)
489 return; 635 return;
490 636
491 observer_ = new WorkerCreationDestructionListener(); 637 observer_ = new WorkerCreationDestructionListener();
492 observer_->Init(this); 638 observer_->Init(this);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 DevToolsAdbBridge::RemoteDevices* devices) { 693 DevToolsAdbBridge::RemoteDevices* devices) {
548 Profile* profile = Profile::FromWebUI(web_ui()); 694 Profile* profile = Profile::FromWebUI(web_ui());
549 PortForwardingController* port_forwarding_controller = 695 PortForwardingController* port_forwarding_controller =
550 PortForwardingController::Factory::GetForProfile(profile); 696 PortForwardingController::Factory::GetForProfile(profile);
551 PortForwardingController::DevicesStatus port_forwarding_status; 697 PortForwardingController::DevicesStatus port_forwarding_status;
552 if (port_forwarding_controller) 698 if (port_forwarding_controller)
553 port_forwarding_status = 699 port_forwarding_status =
554 port_forwarding_controller->UpdateDeviceList(*devices); 700 port_forwarding_controller->UpdateDeviceList(*devices);
555 701
556 remote_browsers_.clear(); 702 remote_browsers_.clear();
557 STLDeleteValues(&remote_targets_); 703 remote_pages_.clear();
558 ListValue device_list; 704 ListValue device_list;
559 for (DevToolsAdbBridge::RemoteDevices::iterator dit = devices->begin(); 705 for (DevToolsAdbBridge::RemoteDevices::iterator dit = devices->begin();
560 dit != devices->end(); ++dit) { 706 dit != devices->end(); ++dit) {
561 DevToolsAdbBridge::RemoteDevice* device = dit->get(); 707 DevToolsAdbBridge::RemoteDevice* device = dit->get();
562 DictionaryValue* device_data = new DictionaryValue(); 708 DictionaryValue* device_data = new DictionaryValue();
563 device_data->SetString(kAdbModelField, device->GetModel()); 709 device_data->SetString(kAdbModelField, device->GetModel());
564 device_data->SetString(kAdbSerialField, device->GetSerial()); 710 device_data->SetString(kAdbSerialField, device->GetSerial());
565 device_data->SetBoolean(kAdbConnectedField, device->IsConnected()); 711 device_data->SetBoolean(kAdbConnectedField, device->IsConnected());
566 std::string device_id = base::StringPrintf( 712 std::string device_id = base::StringPrintf(
567 "device:%s", 713 "device:%s",
(...skipping 13 matching lines...) Expand all
581 std::string browser_id = base::StringPrintf( 727 std::string browser_id = base::StringPrintf(
582 "browser:%s:%s:%s", 728 "browser:%s:%s:%s",
583 device->GetSerial().c_str(), 729 device->GetSerial().c_str(),
584 browser->product().c_str(), // Force sorting by product name. 730 browser->product().c_str(), // Force sorting by product name.
585 browser->socket().c_str()); 731 browser->socket().c_str());
586 browser_data->SetString(kAdbGlobalIdField, browser_id); 732 browser_data->SetString(kAdbGlobalIdField, browser_id);
587 remote_browsers_[browser_id] = browser; 733 remote_browsers_[browser_id] = browser;
588 ListValue* page_list = new ListValue(); 734 ListValue* page_list = new ListValue();
589 browser_data->Set(kAdbPagesField, page_list); 735 browser_data->Set(kAdbPagesField, page_list);
590 736
591 DevToolsTargetImpl::List pages = browser->CreatePageTargets(); 737 DevToolsAdbBridge::RemotePages& pages = browser->pages();
592 for (DevToolsTargetImpl::List::iterator it = 738 for (DevToolsAdbBridge::RemotePages::iterator it =
593 pages.begin(); it != pages.end(); ++it) { 739 pages.begin(); it != pages.end(); ++it) {
594 DevToolsTargetImpl* page = *it; 740 DevToolsAdbBridge::RemotePage* page = it->get();
595 DictionaryValue* page_data = BuildTargetDescriptor(*page); 741 DictionaryValue* page_data = BuildTargetDescriptor(
596 page_data->SetBoolean( 742 kAdbTargetType, page->attached(),
597 kAdbAttachedForeignField, 743 GURL(page->url()), page->title(), GURL(page->favicon_url()),
598 page->IsAttached() && 744 page->description(), 0, 0);
599 !DevToolsAdbBridge::HasDevToolsWindow(page->GetId())); 745 std::string page_id = base::StringPrintf("page:%s:%s:%s",
746 device->GetSerial().c_str(),
747 browser->socket().c_str(),
748 page->id().c_str());
749 page_data->SetString(kAdbGlobalIdField, page_id);
750 page_data->SetBoolean(kAdbAttachedForeignField,
751 page->attached() && !page->HasDevToolsWindow());
600 // Pass the screen size in the page object to make sure that 752 // Pass the screen size in the page object to make sure that
601 // the caching logic does not prevent the page item from updating 753 // the caching logic does not prevent the page item from updating
602 // when the screen size changes. 754 // when the screen size changes.
603 gfx::Size screen_size = device->screen_size(); 755 gfx::Size screen_size = device->screen_size();
604 page_data->SetInteger(kAdbScreenWidthField, screen_size.width()); 756 page_data->SetInteger(kAdbScreenWidthField, screen_size.width());
605 page_data->SetInteger(kAdbScreenHeightField, screen_size.height()); 757 page_data->SetInteger(kAdbScreenHeightField, screen_size.height());
606 remote_targets_[page->GetId()] = page; 758 remote_pages_[page_id] = page;
607 page_list->Append(page_data); 759 page_list->Append(page_data);
608 } 760 }
609 browser_list->Append(browser_data); 761 browser_list->Append(browser_data);
610 } 762 }
611 763
612 if (port_forwarding_controller) { 764 if (port_forwarding_controller) {
613 PortForwardingController::DevicesStatus::iterator sit = 765 PortForwardingController::DevicesStatus::iterator sit =
614 port_forwarding_status.find(device->GetSerial()); 766 port_forwarding_status.find(device->GetSerial());
615 if (sit != port_forwarding_status.end()) { 767 if (sit != port_forwarding_status.end()) {
616 DictionaryValue* port_status_dict = new DictionaryValue(); 768 DictionaryValue* port_status_dict = new DictionaryValue();
617 typedef PortForwardingController::PortStatusMap StatusMap; 769 typedef PortForwardingController::PortStatusMap StatusMap;
618 const StatusMap& port_status = sit->second; 770 const StatusMap& port_status = sit->second;
619 for (StatusMap::const_iterator it = port_status.begin(); 771 for (StatusMap::const_iterator it = port_status.begin();
620 it != port_status.end(); ++it) { 772 it != port_status.end(); ++it) {
621 port_status_dict->SetInteger( 773 port_status_dict->SetInteger(
622 base::StringPrintf("%d", it->first), it->second); 774 base::StringPrintf("%d", it->first), it->second);
623 } 775 }
624 device_data->Set(kAdbPortStatus, port_status_dict); 776 device_data->Set(kAdbPortStatus, port_status_dict);
625 } 777 }
626 } 778 }
627 779
628 device_list.Append(device_data); 780 device_list.Append(device_data);
629 } 781 }
630 web_ui()->CallJavascriptFunction("populateRemoteTargets", device_list); 782 web_ui()->CallJavascriptFunction("populateDeviceLists", device_list);
631 } 783 }
632 784
633 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { 785 void InspectUI::UpdateDiscoverUsbDevicesEnabled() {
634 const Value* value = GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled); 786 const Value* value = GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled);
635 web_ui()->CallJavascriptFunction("updateDiscoverUsbDevicesEnabled", *value); 787 web_ui()->CallJavascriptFunction("updateDiscoverUsbDevicesEnabled", *value);
636 788
637 // Configure adb bridge. 789 // Configure adb bridge.
638 Profile* profile = Profile::FromWebUI(web_ui()); 790 Profile* profile = Profile::FromWebUI(web_ui());
639 DevToolsAdbBridge* adb_bridge = 791 DevToolsAdbBridge* adb_bridge =
640 DevToolsAdbBridge::Factory::GetForProfile(profile); 792 DevToolsAdbBridge::Factory::GetForProfile(profile);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 base::DictionaryValue default_config; 847 base::DictionaryValue default_config;
696 default_config.SetString( 848 default_config.SetString(
697 kPortForwardingDefaultPort, kPortForwardingDefaultLocation); 849 kPortForwardingDefaultPort, kPortForwardingDefaultLocation);
698 prefs->Set(prefs::kDevToolsPortForwardingConfig, default_config); 850 prefs->Set(prefs::kDevToolsPortForwardingConfig, default_config);
699 } 851 }
700 852
701 const base::Value* InspectUI::GetPrefValue(const char* name) { 853 const base::Value* InspectUI::GetPrefValue(const char* name) {
702 Profile* profile = Profile::FromWebUI(web_ui()); 854 Profile* profile = Profile::FromWebUI(web_ui());
703 return profile->GetPrefs()->FindPreference(name)->GetValue(); 855 return profile->GetPrefs()->FindPreference(name)->GetValue();
704 } 856 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698