OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/md_settings_ui.h" | 5 #include "chrome/browser/ui/webui/md_settings_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_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 #include "grit/browser_resources.h" | 15 #include "grit/browser_resources.h" |
16 #include "grit/settings_resources.h" | |
17 #include "grit/settings_resources_map.h" | |
18 #include "ui/base/resource/resource_bundle.h" | |
16 | 19 |
17 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) | 20 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) |
18 : content::WebUIController(web_ui) { | 21 : content::WebUIController(web_ui) { |
19 content::WebUIDataSource* html_source = | 22 content::WebUIDataSource* html_source = |
20 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); | 23 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); |
21 | 24 |
25 // Add all settings resources. | |
26 for (size_t i = 0; i < kSettingsResourcesSize; ++i) { | |
27 const std::string resource_name = kSettingsResources[i].name; | |
28 const int resource_id = kSettingsResources[i].value; | |
29 html_source->AddResourcePath(resource_name, resource_id); | |
michaelpg
2015/03/06 02:08:17
nit: just call the function directly without creat
Jeremy Klein
2015/03/06 02:20:01
Done.
| |
30 } | |
31 | |
22 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); | 32 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); |
23 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); | 33 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); |
24 | 34 |
25 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | 35 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
26 html_source); | 36 html_source); |
27 } | 37 } |
28 | 38 |
29 MdSettingsUI::~MdSettingsUI() { | 39 MdSettingsUI::~MdSettingsUI() { |
30 } | 40 } |
OLD | NEW |