Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/ui/webui/cast/cast_ui.cc

Issue 1820023002: Implementation of chrome://cast page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added c/b/ui/webui/cast/OWNERS and c/b/resources/cast/OWNERS. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/cast/cast_ui.h"
6
7 #include "chrome/browser/media/router/media_router_factory.h"
8 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/browser_resources.h"
15 #include "grit/generated_resources.h"
16
17 namespace {
18 const char kRequestExtensionId[] = "requestExtensionId";
19 const char kSetExtensionId[] = "setExtensionId";
20 }
21
22 CastUI::CastUI(content::WebUI* web_ui)
23 : content::WebUIController(web_ui) {
24 // Retrieve the ID of the component extension.
25 auto wc = web_ui->GetWebContents();
26 DCHECK(wc);
27 auto router = static_cast<media_router::MediaRouterMojoImpl*>(
28 media_router::MediaRouterFactory::GetApiForBrowserContext(
29 wc->GetBrowserContext()));
30 DCHECK(router);
31 component_extension_id_ = router->media_route_provider_extension_id();
mark a. foltz 2016/05/18 21:21:05 Digging through the MR to find out the ID of the c
sheretov 2016/05/18 21:58:46 Done.
32
33 web_ui->RegisterMessageCallback(
34 kRequestExtensionId,
35 base::Bind(&CastUI::OnRequestExtensionId, base::Unretained(this)));
36
37 // Set up the chrome://cast source.
38 content::WebUIDataSource* html_source =
39 content::WebUIDataSource::Create(chrome::kChromeUICastHost);
40
41 // Add required resources.
42 html_source->AddResourcePath("cast.css", IDR_CAST_CSS);
43 html_source->AddResourcePath("cast.js", IDR_CAST_JS);
44 html_source->AddResourcePath("cast_favicon.ico", IDR_CAST_FAVICON);
45 html_source->SetDefaultResource(IDR_CAST_HTML);
46 html_source->OverrideContentSecurityPolicyObjectSrc("object-src *;");
47
48 Profile* profile = Profile::FromWebUI(web_ui);
49 content::WebUIDataSource::Add(profile, html_source);
50 }
51
52 CastUI::~CastUI() {
53 }
54
55 void CastUI::OnRequestExtensionId(const base::ListValue* args) {
56 base::StringValue result(component_extension_id_);
57 web_ui()->CallJavascriptFunction(kSetExtensionId, result);
58 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/cast/cast_ui.h ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698