OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/webapks_ui.h" | 5 #include "chrome/browser/ui/webui/webapks_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <unordered_set> | 8 #include <unordered_set> |
9 | 9 |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/webui/webapks_handler.h" | 11 #include "chrome/browser/ui/webui/webapks_handler.h" |
12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
13 #include "chrome/grit/webapks_ui_resources.h" | 13 #include "chrome/grit/webapks_ui_resources.h" |
14 #include "components/grit/components_resources.h" | |
15 #include "content/public/browser/web_ui.h" | 14 #include "content/public/browser/web_ui.h" |
16 #include "content/public/browser/web_ui_data_source.h" | 15 #include "content/public/browser/web_ui_data_source.h" |
17 | 16 |
18 using content::WebUIDataSource; | 17 using content::WebUIDataSource; |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 WebUIDataSource* CreateWebApksUIDataSource() { | 21 WebUIDataSource* CreateWebApksUIDataSource() { |
23 WebUIDataSource* html_source = | 22 WebUIDataSource* html_source = |
24 WebUIDataSource::Create(chrome::kChromeUIWebApksHost); | 23 WebUIDataSource::Create(chrome::kChromeUIWebApksHost); |
25 html_source->SetJsonPath("strings.js"); | 24 html_source->SetJsonPath("strings.js"); |
26 html_source->AddResourcePath("webapks.js", IDR_WEBAPKS_UI_JS); | 25 html_source->AddResourcePath("webapks.js", IDR_WEBAPKS_UI_JS); |
27 html_source->AddResourcePath("about_webapks.css", IDR_WEBAPKS_UI_CSS); | 26 html_source->AddResourcePath("about_webapks.css", IDR_WEBAPKS_UI_CSS); |
28 html_source->SetDefaultResource(IDR_WEBAPKS_UI_HTML); | 27 html_source->SetDefaultResource(IDR_WEBAPKS_UI_HTML); |
29 html_source->UseGzip(std::unordered_set<std::string>()); | 28 html_source->UseGzip(std::unordered_set<std::string>()); |
30 | 29 |
31 return html_source; | 30 return html_source; |
32 } | 31 } |
33 | 32 |
34 } // anonymous namespace | 33 } // anonymous namespace |
35 | 34 |
36 WebApksUI::WebApksUI(content::WebUI* web_ui) | 35 WebApksUI::WebApksUI(content::WebUI* web_ui) |
37 : content::WebUIController(web_ui) { | 36 : content::WebUIController(web_ui) { |
38 Profile* profile = Profile::FromWebUI(web_ui); | 37 Profile* profile = Profile::FromWebUI(web_ui); |
39 web_ui->AddMessageHandler(base::MakeUnique<WebApksHandler>()); | 38 web_ui->AddMessageHandler(base::MakeUnique<WebApksHandler>()); |
40 WebUIDataSource::Add(profile, CreateWebApksUIDataSource()); | 39 WebUIDataSource::Add(profile, CreateWebApksUIDataSource()); |
41 } | 40 } |
42 | 41 |
43 WebApksUI::~WebApksUI() {} | 42 WebApksUI::~WebApksUI() {} |
OLD | NEW |