| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options_ui.h" | 5 #include "chrome/browser/dom_ui/options_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/dom_ui/browser_options_handler.h" | 22 #include "chrome/browser/dom_ui/browser_options_handler.h" |
| 23 #include "chrome/browser/dom_ui/clear_browser_data_handler.h" | 23 #include "chrome/browser/dom_ui/clear_browser_data_handler.h" |
| 24 #include "chrome/browser/dom_ui/content_settings_handler.h" | 24 #include "chrome/browser/dom_ui/content_settings_handler.h" |
| 25 #include "chrome/browser/dom_ui/core_options_handler.h" | 25 #include "chrome/browser/dom_ui/core_options_handler.h" |
| 26 #include "chrome/browser/dom_ui/font_settings_handler.h" | 26 #include "chrome/browser/dom_ui/font_settings_handler.h" |
| 27 #include "chrome/browser/dom_ui/import_data_handler.h" | 27 #include "chrome/browser/dom_ui/import_data_handler.h" |
| 28 #include "chrome/browser/dom_ui/personal_options_handler.h" | 28 #include "chrome/browser/dom_ui/personal_options_handler.h" |
| 29 #include "chrome/browser/dom_ui/search_engine_manager_handler.h" | 29 #include "chrome/browser/dom_ui/search_engine_manager_handler.h" |
| 30 #include "chrome/browser/dom_ui/stop_syncing_handler.h" | 30 #include "chrome/browser/dom_ui/stop_syncing_handler.h" |
| 31 #include "chrome/browser/dom_ui/sync_options_handler.h" | 31 #include "chrome/browser/dom_ui/sync_options_handler.h" |
| 32 #include "chrome/browser/dom_ui/dom_ui_theme_source.h" |
| 32 #include "chrome/browser/metrics/user_metrics.h" | 33 #include "chrome/browser/metrics/user_metrics.h" |
| 33 #include "chrome/browser/pref_service.h" | 34 #include "chrome/browser/pref_service.h" |
| 34 #include "chrome/browser/profile.h" | 35 #include "chrome/browser/profile.h" |
| 35 #include "chrome/browser/tab_contents/tab_contents.h" | 36 #include "chrome/browser/tab_contents/tab_contents.h" |
| 36 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 37 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 37 #include "chrome/common/jstemplate_builder.h" | 38 #include "chrome/common/jstemplate_builder.h" |
| 38 #include "chrome/common/notification_service.h" | 39 #include "chrome/common/notification_service.h" |
| 39 #include "chrome/common/notification_type.h" | 40 #include "chrome/common/notification_type.h" |
| 40 #include "chrome/common/time_format.h" | 41 #include "chrome/common/time_format.h" |
| 41 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 OptionsUIHTMLSource* html_source = | 158 OptionsUIHTMLSource* html_source = |
| 158 new OptionsUIHTMLSource(localized_strings); | 159 new OptionsUIHTMLSource(localized_strings); |
| 159 | 160 |
| 160 // Set up the chrome://options/ source. | 161 // Set up the chrome://options/ source. |
| 161 ChromeThread::PostTask( | 162 ChromeThread::PostTask( |
| 162 ChromeThread::IO, FROM_HERE, | 163 ChromeThread::IO, FROM_HERE, |
| 163 NewRunnableMethod( | 164 NewRunnableMethod( |
| 164 Singleton<ChromeURLDataManager>::get(), | 165 Singleton<ChromeURLDataManager>::get(), |
| 165 &ChromeURLDataManager::AddDataSource, | 166 &ChromeURLDataManager::AddDataSource, |
| 166 make_scoped_refptr(html_source))); | 167 make_scoped_refptr(html_source))); |
| 168 |
| 169 // Set up chrome://theme/ source. |
| 170 DOMUIThemeSource* theme = new DOMUIThemeSource(GetProfile()); |
| 171 ChromeThread::PostTask( |
| 172 ChromeThread::IO, FROM_HERE, |
| 173 NewRunnableMethod( |
| 174 Singleton<ChromeURLDataManager>::get(), |
| 175 &ChromeURLDataManager::AddDataSource, |
| 176 make_scoped_refptr(theme))); |
| 167 } | 177 } |
| 168 | 178 |
| 169 // static | 179 // static |
| 170 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 180 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
| 171 // TODO(csilv): uncomment this once we have a FAVICON | 181 // TODO(csilv): uncomment this once we have a FAVICON |
| 172 // return ResourceBundle::GetSharedInstance(). | 182 // return ResourceBundle::GetSharedInstance(). |
| 173 // LoadDataResourceBytes(IDR_OPTIONS_FAVICON); | 183 // LoadDataResourceBytes(IDR_OPTIONS_FAVICON); |
| 174 return NULL; | 184 return NULL; |
| 175 } | 185 } |
| 176 | 186 |
| 177 void OptionsUI::InitializeHandlers() { | 187 void OptionsUI::InitializeHandlers() { |
| 178 std::vector<DOMMessageHandler*>::iterator iter; | 188 std::vector<DOMMessageHandler*>::iterator iter; |
| 179 for (iter = handlers_.begin(); iter != handlers_.end(); ++iter) { | 189 for (iter = handlers_.begin(); iter != handlers_.end(); ++iter) { |
| 180 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); | 190 (static_cast<OptionsPageUIHandler*>(*iter))->Initialize(); |
| 181 } | 191 } |
| 182 } | 192 } |
| 183 | 193 |
| 184 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 194 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
| 185 OptionsPageUIHandler* handler) { | 195 OptionsPageUIHandler* handler) { |
| 186 DCHECK(handler); | 196 DCHECK(handler); |
| 187 handler->GetLocalizedValues(localized_strings); | 197 handler->GetLocalizedValues(localized_strings); |
| 188 AddMessageHandler(handler->Attach(this)); | 198 AddMessageHandler(handler->Attach(this)); |
| 189 } | 199 } |
| OLD | NEW |