| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/ui/webui/md_settings_ui.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/values.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "chrome/browser/ui/webui/options/core_options_handler.h" | |
| 12 #include "chrome/common/url_constants.h" | |
| 13 #include "chrome/grit/generated_resources.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "content/public/browser/web_ui.h" | |
| 16 #include "content/public/browser/web_ui_data_source.h" | |
| 17 #include "grit/browser_resources.h" | |
| 18 #include "grit/settings_resources.h" | |
| 19 #include "grit/settings_resources_map.h" | |
| 20 | |
| 21 #if defined(OS_CHROMEOS) | |
| 22 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler
.h" | |
| 23 #endif | |
| 24 | |
| 25 MdSettingsUI::MdSettingsUI(content::WebUI* 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 | |
| 39 content::WebUIDataSource* html_source = | |
| 40 content::WebUIDataSource::Create(chrome::kChromeUIMdSettingsHost); | |
| 41 | |
| 42 // Add all settings resources. | |
| 43 for (size_t i = 0; i < kSettingsResourcesSize; ++i) { | |
| 44 html_source->AddResourcePath(kSettingsResources[i].name, | |
| 45 kSettingsResources[i].value); | |
| 46 } | |
| 47 | |
| 48 html_source->AddResourcePath("md_settings.css", IDR_MD_SETTINGS_UI_CSS); | |
| 49 html_source->SetDefaultResource(IDR_MD_SETTINGS_UI_HTML); | |
| 50 | |
| 51 content::WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | |
| 52 html_source); | |
| 53 } | |
| 54 | |
| 55 MdSettingsUI::~MdSettingsUI() { | |
| 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 } | |
| OLD | NEW |