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/macros.h" | 7 #include "base/macros.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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { | 427 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { |
428 content::WebUIDataSource* source = | 428 content::WebUIDataSource* source = |
429 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); | 429 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); |
430 source->AddResourcePath("inspect.css", IDR_INSPECT_CSS); | 430 source->AddResourcePath("inspect.css", IDR_INSPECT_CSS); |
431 source->AddResourcePath("inspect.js", IDR_INSPECT_JS); | 431 source->AddResourcePath("inspect.js", IDR_INSPECT_JS); |
432 source->SetDefaultResource(IDR_INSPECT_HTML); | 432 source->SetDefaultResource(IDR_INSPECT_HTML); |
433 return source; | 433 return source; |
434 } | 434 } |
435 | 435 |
436 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { | 436 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { |
437 web_ui()->CallJavascriptFunction( | 437 web_ui()->CallJavascriptFunctionUnsafe( |
438 "updateDiscoverUsbDevicesEnabled", | 438 "updateDiscoverUsbDevicesEnabled", |
439 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); | 439 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); |
440 } | 440 } |
441 | 441 |
442 void InspectUI::UpdatePortForwardingEnabled() { | 442 void InspectUI::UpdatePortForwardingEnabled() { |
443 web_ui()->CallJavascriptFunction( | 443 web_ui()->CallJavascriptFunctionUnsafe( |
444 "updatePortForwardingEnabled", | 444 "updatePortForwardingEnabled", |
445 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); | 445 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); |
446 } | 446 } |
447 | 447 |
448 void InspectUI::UpdatePortForwardingConfig() { | 448 void InspectUI::UpdatePortForwardingConfig() { |
449 web_ui()->CallJavascriptFunction( | 449 web_ui()->CallJavascriptFunctionUnsafe( |
450 "updatePortForwardingConfig", | 450 "updatePortForwardingConfig", |
451 *GetPrefValue(prefs::kDevToolsPortForwardingConfig)); | 451 *GetPrefValue(prefs::kDevToolsPortForwardingConfig)); |
452 } | 452 } |
453 | 453 |
454 void InspectUI::SetPortForwardingDefaults() { | 454 void InspectUI::SetPortForwardingDefaults() { |
455 Profile* profile = Profile::FromWebUI(web_ui()); | 455 Profile* profile = Profile::FromWebUI(web_ui()); |
456 PrefService* prefs = profile->GetPrefs(); | 456 PrefService* prefs = profile->GetPrefs(); |
457 | 457 |
458 bool default_set; | 458 bool default_set; |
459 if (!GetPrefValue(prefs::kDevToolsPortForwardingDefaultSet)-> | 459 if (!GetPrefValue(prefs::kDevToolsPortForwardingDefaultSet)-> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 503 |
504 DevToolsTargetImpl* InspectUI::FindTarget( | 504 DevToolsTargetImpl* InspectUI::FindTarget( |
505 const std::string& source_id, const std::string& target_id) { | 505 const std::string& source_id, const std::string& target_id) { |
506 TargetHandlerMap::iterator it = target_handlers_.find(source_id); | 506 TargetHandlerMap::iterator it = target_handlers_.find(source_id); |
507 return it != target_handlers_.end() ? | 507 return it != target_handlers_.end() ? |
508 it->second->GetTarget(target_id) : NULL; | 508 it->second->GetTarget(target_id) : NULL; |
509 } | 509 } |
510 | 510 |
511 void InspectUI::PopulateTargets(const std::string& source, | 511 void InspectUI::PopulateTargets(const std::string& source, |
512 const base::ListValue& targets) { | 512 const base::ListValue& targets) { |
513 web_ui()->CallJavascriptFunction("populateTargets", | 513 web_ui()->CallJavascriptFunctionUnsafe("populateTargets", |
514 base::StringValue(source), | 514 base::StringValue(source), targets); |
515 targets); | |
516 } | 515 } |
517 | 516 |
518 void InspectUI::ForceUpdateIfNeeded(const std::string& source_id, | 517 void InspectUI::ForceUpdateIfNeeded(const std::string& source_id, |
519 const std::string& target_type) { | 518 const std::string& target_type) { |
520 // TODO(dgozman): remove this after moving discovery to protocol. | 519 // TODO(dgozman): remove this after moving discovery to protocol. |
521 // See crbug.com/398049. | 520 // See crbug.com/398049. |
522 if (target_type != DevToolsTargetImpl::kTargetTypeServiceWorker) | 521 if (target_type != DevToolsTargetImpl::kTargetTypeServiceWorker) |
523 return; | 522 return; |
524 DevToolsTargetsUIHandler* handler = FindTargetHandler(source_id); | 523 DevToolsTargetsUIHandler* handler = FindTargetHandler(source_id); |
525 if (handler) | 524 if (handler) |
526 handler->ForceUpdate(); | 525 handler->ForceUpdate(); |
527 } | 526 } |
528 | 527 |
529 void InspectUI::PopulatePortStatus(const base::Value& status) { | 528 void InspectUI::PopulatePortStatus(const base::Value& status) { |
530 web_ui()->CallJavascriptFunction("populatePortStatus", status); | 529 web_ui()->CallJavascriptFunctionUnsafe("populatePortStatus", status); |
531 } | 530 } |
532 | 531 |
533 void InspectUI::ShowIncognitoWarning() { | 532 void InspectUI::ShowIncognitoWarning() { |
534 web_ui()->CallJavascriptFunction("showIncognitoWarning"); | 533 web_ui()->CallJavascriptFunctionUnsafe("showIncognitoWarning"); |
535 } | 534 } |
OLD | NEW |