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

Side by Side Diff: chrome/browser/ui/webui/md_settings_ui.cc

Issue 1019403002: Fetch and actually set prefs (using chrome.send for now). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dan comments Created 5 years, 9 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
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 if (handler->IsEnabled())
37 web_ui->AddMessageHandler(handler.release());
38
21 content::WebUIDataSource* html_source = 39 content::WebUIDataSource* html_source =
22 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); 40 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost);
23 41
24 // Add all settings resources. 42 // Add all settings resources.
25 for (size_t i = 0; i < kSettingsResourcesSize; ++i) { 43 for (size_t i = 0; i < kSettingsResourcesSize; ++i) {
26 html_source->AddResourcePath(kSettingsResources[i].name, 44 html_source->AddResourcePath(kSettingsResources[i].name,
27 kSettingsResources[i].value); 45 kSettingsResources[i].value);
28 } 46 }
29 47
30 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); 48 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS);
31 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); 49 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML);
32 50
33 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), 51 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(),
34 html_source); 52 html_source);
35 } 53 }
36 54
37 MdSettingsUI::~MdSettingsUI() { 55 MdSettingsUI::~MdSettingsUI() {
38 } 56 }
57
58 void MdSettingsUI::InitializeHandlers() {
59 Profile* profile = Profile::FromWebUI(web_ui());
60 DCHECK(!profile->IsOffTheRecord() || profile->IsGuestSession());
61
62 core_handler_->InitializeHandler();
63 core_handler_->InitializePage();
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698