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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 notification_registrar_.RemoveAll(); | 359 notification_registrar_.RemoveAll(); |
360 pref_change_registrar_.RemoveAll(); | 360 pref_change_registrar_.RemoveAll(); |
361 } | 361 } |
362 | 362 |
363 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { | 363 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { |
364 content::WebUIDataSource* source = | 364 content::WebUIDataSource* source = |
365 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); | 365 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); |
366 source->AddResourcePath("inspect.css", IDR_INSPECT_CSS); | 366 source->AddResourcePath("inspect.css", IDR_INSPECT_CSS); |
367 source->AddResourcePath("inspect.js", IDR_INSPECT_JS); | 367 source->AddResourcePath("inspect.js", IDR_INSPECT_JS); |
368 source->SetDefaultResource(IDR_INSPECT_HTML); | 368 source->SetDefaultResource(IDR_INSPECT_HTML); |
| 369 source->OverrideContentSecurityPolicyFrameSrc( |
| 370 "frame-src chrome://serviceworker-internals;"); |
| 371 serviceworker_webui_.reset(web_ui()->GetWebContents()->CreateWebUI( |
| 372 GURL(content::kChromeUIServiceWorkerInternalsURL))); |
| 373 serviceworker_webui_->OverrideJavaScriptFrame( |
| 374 content::kChromeUIServiceWorkerInternalsHost); |
369 return source; | 375 return source; |
370 } | 376 } |
371 | 377 |
| 378 void InspectUI::RenderViewCreated(content::RenderViewHost* render_view_host) { |
| 379 serviceworker_webui_->GetController()->RenderViewCreated(render_view_host); |
| 380 } |
| 381 |
| 382 void InspectUI::RenderViewReused(content::RenderViewHost* render_view_host) { |
| 383 serviceworker_webui_->GetController()->RenderViewReused(render_view_host); |
| 384 } |
| 385 |
| 386 bool InspectUI::OverrideHandleWebUIMessage(const GURL& source_url, |
| 387 const std::string& message, |
| 388 const base::ListValue& args) { |
| 389 if (source_url.SchemeIs(content::kChromeUIScheme) && |
| 390 source_url.host() == content::kChromeUIServiceWorkerInternalsHost) { |
| 391 serviceworker_webui_->ProcessWebUIMessage(source_url, message, args); |
| 392 return true; |
| 393 } |
| 394 return false; |
| 395 } |
| 396 |
372 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { | 397 void InspectUI::UpdateDiscoverUsbDevicesEnabled() { |
373 web_ui()->CallJavascriptFunction( | 398 web_ui()->CallJavascriptFunction( |
374 "updateDiscoverUsbDevicesEnabled", | 399 "updateDiscoverUsbDevicesEnabled", |
375 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); | 400 *GetPrefValue(prefs::kDevToolsDiscoverUsbDevicesEnabled)); |
376 } | 401 } |
377 | 402 |
378 void InspectUI::UpdatePortForwardingEnabled() { | 403 void InspectUI::UpdatePortForwardingEnabled() { |
379 web_ui()->CallJavascriptFunction( | 404 web_ui()->CallJavascriptFunction( |
380 "updatePortForwardingEnabled", | 405 "updatePortForwardingEnabled", |
381 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); | 406 *GetPrefValue(prefs::kDevToolsPortForwardingEnabled)); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 scoped_ptr<base::Value> source_value(base::Value::CreateStringValue(source)); | 474 scoped_ptr<base::Value> source_value(base::Value::CreateStringValue(source)); |
450 web_ui()->CallJavascriptFunction( | 475 web_ui()->CallJavascriptFunction( |
451 "populateTargets", | 476 "populateTargets", |
452 *source_value.get(), | 477 *source_value.get(), |
453 *targets.get()); | 478 *targets.get()); |
454 } | 479 } |
455 | 480 |
456 void InspectUI::PopulatePortStatus(const base::Value& status) { | 481 void InspectUI::PopulatePortStatus(const base::Value& status) { |
457 web_ui()->CallJavascriptFunction("populatePortStatus", status); | 482 web_ui()->CallJavascriptFunction("populatePortStatus", status); |
458 } | 483 } |
OLD | NEW |