OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cast/cast_ui.h" | 5 #include "chrome/browser/ui/webui/cast/cast_ui.h" |
6 | 6 |
7 #include "chrome/browser/media/router/media_router_factory.h" | 7 #include "chrome/browser/media/router/event_page_request_manager.h" |
8 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" | 8 #include "chrome/browser/media/router/event_page_request_manager_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/browser_resources.h" | 11 #include "chrome/grit/browser_resources.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_ui.h" | 13 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_data_source.h" | 14 #include "content/public/browser/web_ui_data_source.h" |
15 | 15 |
16 CastUI::CastUI(content::WebUI* web_ui) | 16 CastUI::CastUI(content::WebUI* web_ui) |
17 : content::WebUIController(web_ui) { | 17 : content::WebUIController(web_ui) { |
18 // Retrieve the ID of the component extension. | 18 // Retrieve the ID of the component extension. |
19 // TODO(crbug.com/597778): remove reference to MediaRouterMojoImpl. | 19 auto* event_page_request_manager = |
20 auto* router = static_cast<media_router::MediaRouterMojoImpl*>( | 20 media_router::EventPageRequestManagerFactory::GetApiForBrowserContext( |
21 media_router::MediaRouterFactory::GetApiForBrowserContext( | 21 web_ui->GetWebContents()->GetBrowserContext()); |
22 web_ui->GetWebContents()->GetBrowserContext())); | 22 std::string extension_id = |
23 std::string extension_id = router->media_route_provider_extension_id(); | 23 event_page_request_manager->media_route_provider_extension_id(); |
24 | 24 |
25 // Set up the chrome://cast data source and add required resources. | 25 // Set up the chrome://cast data source and add required resources. |
26 content::WebUIDataSource* html_source = | 26 content::WebUIDataSource* html_source = |
27 content::WebUIDataSource::Create(chrome::kChromeUICastHost); | 27 content::WebUIDataSource::Create(chrome::kChromeUICastHost); |
28 | 28 |
29 html_source->AddResourcePath("cast.css", IDR_CAST_CSS); | 29 html_source->AddResourcePath("cast.css", IDR_CAST_CSS); |
30 html_source->AddResourcePath("cast.js", IDR_CAST_JS); | 30 html_source->AddResourcePath("cast.js", IDR_CAST_JS); |
31 html_source->AddResourcePath("cast_favicon.ico", IDR_CAST_FAVICON); | 31 html_source->AddResourcePath("cast_favicon.ico", IDR_CAST_FAVICON); |
32 html_source->AddString("extensionId", extension_id); | 32 html_source->AddString("extensionId", extension_id); |
33 html_source->SetJsonPath("strings.js"); | 33 html_source->SetJsonPath("strings.js"); |
34 html_source->SetDefaultResource(IDR_CAST_HTML); | 34 html_source->SetDefaultResource(IDR_CAST_HTML); |
35 html_source->OverrideContentSecurityPolicyObjectSrc("object-src * chrome:;"); | 35 html_source->OverrideContentSecurityPolicyObjectSrc("object-src * chrome:;"); |
36 | 36 |
37 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); | 37 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); |
38 } | 38 } |
39 | 39 |
40 CastUI::~CastUI() { | 40 CastUI::~CastUI() { |
41 } | 41 } |
OLD | NEW |