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