| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 notification_registrar_.RemoveAll(); | 423 notification_registrar_.RemoveAll(); |
| 424 pref_change_registrar_.RemoveAll(); | 424 pref_change_registrar_.RemoveAll(); |
| 425 } | 425 } |
| 426 | 426 |
| 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 source->OverrideContentSecurityPolicyFrameSrc( | |
| 434 "frame-src chrome://serviceworker-internals;"); | |
| 435 serviceworker_webui_.reset(web_ui()->GetWebContents()->CreateWebUI( | |
| 436 GURL(content::kChromeUIServiceWorkerInternalsURL))); | |
| 437 serviceworker_webui_->OverrideJavaScriptFrame( | |
| 438 content::kChromeUIServiceWorkerInternalsHost); | |
| 439 return source; | 433 return source; |
| 440 } | 434 } |
| 441 | 435 |
| 442 void InspectUI::RenderViewCreated(content::RenderViewHost* render_view_host) { | |
| 443 serviceworker_webui_->GetController()->RenderViewCreated(render_view_host); | |
| 444 } | |
| 445 | |
| 446 void InspectUI::RenderViewReused(content::RenderViewHost* render_view_host) { | |
| 447 serviceworker_webui_->GetController()->RenderViewReused(render_view_host); | |
| 448 } | |
| 449 | |
| 450 bool InspectUI::OverrideHandleWebUIMessage(const GURL& source_url, | |
| 451 const std::string& message, | |
| 452 const base::ListValue& args) { | |
| 453 if (source_url.SchemeIs(content::kChromeUIScheme) && | |
| 454 source_url.host() == content::kChromeUIServiceWorkerInternalsHost) { | |
| 455 serviceworker_webui_->ProcessWebUIMessage(source_url, message, args); | |
| 456 return true; | |
| 457 } | |
| 458 return false; | |
| 459 } | |
| 460 | |
| 461 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { | 436 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { |
| 462 web_ui()->CallJavascriptFunction( | 437 web_ui()->CallJavascriptFunction( |
| 463 "updateDiscoverUsbDevicesEnabled", | 438 "updateDiscoverUsbDevicesEnabled", |
| 464 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); | 439 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); |
| 465 } | 440 } |
| 466 | 441 |
| 467 void InspectUI::UpdatePortForwardingEnabled() { | 442 void InspectUI::UpdatePortForwardingEnabled() { |
| 468 web_ui()->CallJavascriptFunction( | 443 web_ui()->CallJavascriptFunction( |
| 469 "updatePortForwardingEnabled", | 444 "updatePortForwardingEnabled", |
| 470 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); | 445 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 handler->ForceUpdate(); | 526 handler->ForceUpdate(); |
| 552 } | 527 } |
| 553 | 528 |
| 554 void InspectUI::PopulatePortStatus(const base::Value& status) { | 529 void InspectUI::PopulatePortStatus(const base::Value& status) { |
| 555 web_ui()->CallJavascriptFunction("populatePortStatus", status); | 530 web_ui()->CallJavascriptFunction("populatePortStatus", status); |
| 556 } | 531 } |
| 557 | 532 |
| 558 void InspectUI::ShowIncognitoWarning() { | 533 void InspectUI::ShowIncognitoWarning() { |
| 559 web_ui()->CallJavascriptFunction("showIncognitoWarning"); | 534 web_ui()->CallJavascriptFunction("showIncognitoWarning"); |
| 560 } | 535 } |
| OLD | NEW |