Chromium Code Reviews| 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 #include "chrome/browser/ui/webui/inspect_ui.h" | 5 #include "chrome/browser/ui/webui/inspect_ui.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/devtools/devtools_target_impl.h" | 9 #include "chrome/browser/devtools/devtools_target_impl.h" |
| 10 #include "chrome/browser/devtools/devtools_targets_ui.h" | 10 #include "chrome/browser/devtools/devtools_targets_ui.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 SetPortForwardingDefaults(); | 268 SetPortForwardingDefaults(); |
| 269 StartListeningNotifications(); | 269 StartListeningNotifications(); |
| 270 UpdateDiscoverUsbDevicesEnabled(); | 270 UpdateDiscoverUsbDevicesEnabled(); |
| 271 UpdatePortForwardingEnabled(); | 271 UpdatePortForwardingEnabled(); |
| 272 UpdatePortForwardingConfig(); | 272 UpdatePortForwardingConfig(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void InspectUI::Inspect(const std::string& source_id, | 275 void InspectUI::Inspect(const std::string& source_id, |
| 276 const std::string& target_id) { | 276 const std::string& target_id) { |
| 277 DevToolsTargetImpl* target = FindTarget(source_id, target_id); | 277 DevToolsTargetImpl* target = FindTarget(source_id, target_id); |
| 278 if (target) | 278 if (target) { |
| 279 std::string target_type = target->GetType(); | |
| 279 target->Inspect(Profile::FromWebUI(web_ui())); | 280 target->Inspect(Profile::FromWebUI(web_ui())); |
| 281 ForceUpdateIfNeeded(source_id, target_type); | |
|
horo
2014/09/16 07:41:37
ForceUpdateIfNeeded(source_id, target->GetType());
dgozman
2014/09/16 08:55:34
What if executing action will lead to target being
horo
2014/09/16 10:31:19
Ah, I got it.
| |
| 282 } | |
| 280 } | 283 } |
| 281 | 284 |
| 282 void InspectUI::Activate(const std::string& source_id, | 285 void InspectUI::Activate(const std::string& source_id, |
| 283 const std::string& target_id) { | 286 const std::string& target_id) { |
| 284 DevToolsTargetImpl* target = FindTarget(source_id, target_id); | 287 DevToolsTargetImpl* target = FindTarget(source_id, target_id); |
| 285 if (target) | 288 if (target) { |
| 289 std::string target_type = target->GetType(); | |
| 286 target->Activate(); | 290 target->Activate(); |
| 291 ForceUpdateIfNeeded(source_id, target_type); | |
|
horo
2014/09/16 07:41:37
ditto
| |
| 292 } | |
| 287 } | 293 } |
| 288 | 294 |
| 289 void InspectUI::Close(const std::string& source_id, | 295 void InspectUI::Close(const std::string& source_id, |
| 290 const std::string& target_id) { | 296 const std::string& target_id) { |
| 291 DevToolsTargetImpl* target = FindTarget(source_id, target_id); | 297 DevToolsTargetImpl* target = FindTarget(source_id, target_id); |
| 292 if (target) | 298 if (target) { |
| 299 std::string target_type = target->GetType(); | |
| 293 target->Close(); | 300 target->Close(); |
| 301 ForceUpdateIfNeeded(source_id, target_type); | |
|
horo
2014/09/16 07:41:38
ditto
| |
| 302 } | |
| 294 } | 303 } |
| 295 | 304 |
| 296 void InspectUI::Reload(const std::string& source_id, | 305 void InspectUI::Reload(const std::string& source_id, |
| 297 const std::string& target_id) { | 306 const std::string& target_id) { |
| 298 DevToolsTargetImpl* target = FindTarget(source_id, target_id); | 307 DevToolsTargetImpl* target = FindTarget(source_id, target_id); |
| 299 if (target) | 308 if (target) { |
| 309 std::string target_type = target->GetType(); | |
| 300 target->Reload(); | 310 target->Reload(); |
| 311 ForceUpdateIfNeeded(source_id, target_type); | |
|
horo
2014/09/16 07:41:38
ditto
| |
| 312 } | |
| 301 } | 313 } |
| 302 | 314 |
| 303 static void NoOp(DevToolsTargetImpl*) {} | 315 static void NoOp(DevToolsTargetImpl*) {} |
| 304 | 316 |
| 305 void InspectUI::Open(const std::string& source_id, | 317 void InspectUI::Open(const std::string& source_id, |
| 306 const std::string& browser_id, | 318 const std::string& browser_id, |
| 307 const std::string& url) { | 319 const std::string& url) { |
| 308 DevToolsTargetsUIHandler* handler = FindTargetHandler(source_id); | 320 DevToolsTargetsUIHandler* handler = FindTargetHandler(source_id); |
| 309 if (handler) | 321 if (handler) |
| 310 handler->Open(browser_id, url, base::Bind(&NoOp)); | 322 handler->Open(browser_id, url, base::Bind(&NoOp)); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 it->second->GetTarget(target_id) : NULL; | 533 it->second->GetTarget(target_id) : NULL; |
| 522 } | 534 } |
| 523 | 535 |
| 524 void InspectUI::PopulateTargets(const std::string& source, | 536 void InspectUI::PopulateTargets(const std::string& source, |
| 525 const base::ListValue& targets) { | 537 const base::ListValue& targets) { |
| 526 web_ui()->CallJavascriptFunction("populateTargets", | 538 web_ui()->CallJavascriptFunction("populateTargets", |
| 527 base::StringValue(source), | 539 base::StringValue(source), |
| 528 targets); | 540 targets); |
| 529 } | 541 } |
| 530 | 542 |
| 543 void InspectUI::ForceUpdateIfNeeded(const std::string& source_id, | |
| 544 const std::string& target_type) { | |
| 545 // TODO(dgozman): remove this after moving discovery to protocol. | |
| 546 // See crbug.com/398049. | |
| 547 if (target_type != DevToolsTargetImpl::kTargetTypeServiceWorker) | |
| 548 return; | |
| 549 DevToolsTargetsUIHandler* handler = FindTargetHandler(source_id); | |
| 550 if (handler) | |
| 551 handler->ForceUpdate(); | |
| 552 } | |
| 553 | |
| 531 void InspectUI::PopulatePortStatus(const base::Value& status) { | 554 void InspectUI::PopulatePortStatus(const base::Value& status) { |
| 532 web_ui()->CallJavascriptFunction("populatePortStatus", status); | 555 web_ui()->CallJavascriptFunction("populatePortStatus", status); |
| 533 } | 556 } |
| 534 | 557 |
| 535 void InspectUI::ShowIncognitoWarning() { | 558 void InspectUI::ShowIncognitoWarning() { |
| 536 web_ui()->CallJavascriptFunction("showIncognitoWarning"); | 559 web_ui()->CallJavascriptFunction("showIncognitoWarning"); |
| 537 } | 560 } |
| OLD | NEW |