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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/settings/md_settings_ui.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/settings/appearance_handler.h"
11 #include "chrome/browser/ui/webui/settings/downloads_handler.h"
12 #include "chrome/browser/ui/webui/settings/md_settings_localized_strings_provider.h"
13 #include "chrome/browser/ui/webui/settings/settings_startup_pages_handler.h"
14 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_ui.h"
17 #include "content/public/browser/web_ui_data_source.h"
18 #include "grit/settings_resources.h"
19 #include "grit/settings_resources_map.h"
23 SettingsPageUIHandler::SettingsPageUIHandler() {
26 SettingsPageUIHandler::~SettingsPageUIHandler() {
29 MdSettingsUI::MdSettingsUI(content::WebUI
* web_ui
)
30 : content::WebUIController(web_ui
) {
31 AddSettingsPageUIHandler(new AppearanceHandler(web_ui
));
32 AddSettingsPageUIHandler(new DownloadsHandler());
33 AddSettingsPageUIHandler(new StartupPagesHandler(web_ui
));
35 content::WebUIDataSource
* html_source
=
36 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost
);
38 // Add all settings resources.
39 for (size_t i
= 0; i
< kSettingsResourcesSize
; ++i
) {
40 html_source
->AddResourcePath(kSettingsResources
[i
].name
,
41 kSettingsResources
[i
].value
);
44 AddLocalizedStrings(html_source
);
45 html_source
->SetDefaultResource(IDR_SETTINGS_SETTINGS_HTML
);
47 content::WebUIDataSource::Add(web_ui
->GetWebContents()->GetBrowserContext(),
51 MdSettingsUI::~MdSettingsUI() {
54 void MdSettingsUI::AddSettingsPageUIHandler(
55 settings::SettingsPageUIHandler
* handler_raw
) {
56 scoped_ptr
<settings::SettingsPageUIHandler
> handler(handler_raw
);
57 DCHECK(handler
.get());
59 web_ui()->AddMessageHandler(handler
.release());
62 } // namespace settings