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/browser/profiles/profile.h" | |
11 #include "chrome/browser/ui/webui/options/core_options_handler.h" | |
10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
11 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
12 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
13 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
14 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
15 #include "grit/browser_resources.h" | 17 #include "grit/browser_resources.h" |
16 #include "grit/settings_resources.h" | 18 #include "grit/settings_resources.h" |
17 #include "grit/settings_resources_map.h" | 19 #include "grit/settings_resources_map.h" |
18 | 20 |
21 #if defined(OS_CHROMEOS) | |
22 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler .h" | |
23 #endif | |
24 | |
19 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) | 25 MdSettingsUI::MdSettingsUI(content::WebUI* web_ui) |
20 : content::WebUIController(web_ui) { | 26 : content::WebUIController(web_ui) { |
27 // TODO(jlklein): Remove handler logic once settingsPrivate is ready. | |
28 #if defined(OS_CHROMEOS) | |
29 core_handler_ = new chromeos::options::CoreChromeOSOptionsHandler(); | |
30 #else | |
31 core_handler_ = new options::CoreOptionsHandler(); | |
32 #endif | |
33 | |
34 core_handler_->set_handlers_host(this); | |
35 scoped_ptr<options::OptionsPageUIHandler> handler(core_handler_); | |
36 DCHECK(handler.get()); | |
37 if (handler->IsEnabled()) { | |
38 web_ui->AddMessageHandler(handler.release()); | |
39 } | |
40 | |
Kyle Horimoto
2015/03/19 22:42:11
nit: Remove extra newline.
Jeremy Klein
2015/03/19 23:04:21
Done.
| |
41 | |
21 content::WebUIDataSource* html_source = | 42 content::WebUIDataSource* html_source = |
22 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); | 43 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); |
23 | 44 |
24 // Add all settings resources. | 45 // Add all settings resources. |
25 for (size_t i = 0; i < kSettingsResourcesSize; ++i) { | 46 for (size_t i = 0; i < kSettingsResourcesSize; ++i) { |
26 html_source->AddResourcePath(kSettingsResources[i].name, | 47 html_source->AddResourcePath(kSettingsResources[i].name, |
27 kSettingsResources[i].value); | 48 kSettingsResources[i].value); |
28 } | 49 } |
29 | 50 |
30 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); | 51 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); |
31 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); | 52 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); |
32 | 53 |
33 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | 54 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
34 html_source); | 55 html_source); |
35 } | 56 } |
36 | 57 |
37 MdSettingsUI::~MdSettingsUI() { | 58 MdSettingsUI::~MdSettingsUI() { |
38 } | 59 } |
60 | |
61 void MdSettingsUI::InitializeHandlers() { | |
62 Profile* profile = Profile::FromWebUI(web_ui()); | |
63 DCHECK(!profile->IsOffTheRecord() || profile->IsGuestSession()); | |
64 | |
65 core_handler_->InitializeHandler(); | |
66 core_handler_->InitializePage(); | |
67 } | |
68 | |
69 void MdSettingsUI::OnFinishedLoading() {} | |
OLD | NEW |