| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 13 #include "base/string_piece.h" | 13 #include "base/string_piece.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/thread.h" | 15 #include "base/thread.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/chrome_thread.h" | 18 #include "chrome/browser/chrome_thread.h" |
| 19 #include "chrome/browser/dom_ui/advanced_options_handler.h" | 19 #include "chrome/browser/dom_ui/advanced_options_handler.h" |
| 20 #include "chrome/browser/dom_ui/browser_options_handler.h" | 20 #include "chrome/browser/dom_ui/browser_options_handler.h" |
| 21 #include "chrome/browser/dom_ui/content_settings_handler.h" |
| 21 #include "chrome/browser/dom_ui/core_options_handler.h" | 22 #include "chrome/browser/dom_ui/core_options_handler.h" |
| 22 #include "chrome/browser/dom_ui/personal_options_handler.h" | 23 #include "chrome/browser/dom_ui/personal_options_handler.h" |
| 23 #include "chrome/browser/metrics/user_metrics.h" | 24 #include "chrome/browser/metrics/user_metrics.h" |
| 24 #include "chrome/browser/pref_service.h" | 25 #include "chrome/browser/pref_service.h" |
| 25 #include "chrome/browser/profile.h" | 26 #include "chrome/browser/profile.h" |
| 26 #include "chrome/browser/tab_contents/tab_contents.h" | 27 #include "chrome/browser/tab_contents/tab_contents.h" |
| 27 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 28 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 28 #include "chrome/common/jstemplate_builder.h" | 29 #include "chrome/common/jstemplate_builder.h" |
| 29 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
| 30 #include "chrome/common/notification_type.h" | 31 #include "chrome/common/notification_type.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // TODO(zelidrag): Add all other page handlers here as we implement them. | 106 // TODO(zelidrag): Add all other page handlers here as we implement them. |
| 106 AddOptionsPageUIHandler(localized_strings, new CoreOptionsHandler()); | 107 AddOptionsPageUIHandler(localized_strings, new CoreOptionsHandler()); |
| 107 AddOptionsPageUIHandler(localized_strings, new BrowserOptionsHandler()); | 108 AddOptionsPageUIHandler(localized_strings, new BrowserOptionsHandler()); |
| 108 AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler()); | 109 AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler()); |
| 109 AddOptionsPageUIHandler(localized_strings, new AdvancedOptionsHandler()); | 110 AddOptionsPageUIHandler(localized_strings, new AdvancedOptionsHandler()); |
| 110 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 111 AddOptionsPageUIHandler(localized_strings, new SystemOptionsHandler()); | 112 AddOptionsPageUIHandler(localized_strings, new SystemOptionsHandler()); |
| 112 AddOptionsPageUIHandler(localized_strings, new SyncOptionsHandler()); | 113 AddOptionsPageUIHandler(localized_strings, new SyncOptionsHandler()); |
| 113 AddOptionsPageUIHandler(localized_strings, new LabsHandler()); | 114 AddOptionsPageUIHandler(localized_strings, new LabsHandler()); |
| 114 #endif | 115 #endif |
| 116 AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler()); |
| 115 | 117 |
| 116 // |localized_strings| ownership is taken over by this constructor. | 118 // |localized_strings| ownership is taken over by this constructor. |
| 117 OptionsUIHTMLSource* html_source = | 119 OptionsUIHTMLSource* html_source = |
| 118 new OptionsUIHTMLSource(localized_strings); | 120 new OptionsUIHTMLSource(localized_strings); |
| 119 | 121 |
| 120 // Set up the chrome://options/ source. | 122 // Set up the chrome://options/ source. |
| 121 ChromeThread::PostTask( | 123 ChromeThread::PostTask( |
| 122 ChromeThread::IO, FROM_HERE, | 124 ChromeThread::IO, FROM_HERE, |
| 123 NewRunnableMethod( | 125 NewRunnableMethod( |
| 124 Singleton<ChromeURLDataManager>::get(), | 126 Singleton<ChromeURLDataManager>::get(), |
| 125 &ChromeURLDataManager::AddDataSource, | 127 &ChromeURLDataManager::AddDataSource, |
| 126 make_scoped_refptr(html_source))); | 128 make_scoped_refptr(html_source))); |
| 127 } | 129 } |
| 128 | 130 |
| 129 // static | 131 // static |
| 130 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 132 RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
| 131 // TODO(csilv): uncomment this once we have a FAVICON | 133 // TODO(csilv): uncomment this once we have a FAVICON |
| 132 // return ResourceBundle::GetSharedInstance(). | 134 // return ResourceBundle::GetSharedInstance(). |
| 133 // LoadDataResourceBytes(IDR_OPTIONS_FAVICON); | 135 // LoadDataResourceBytes(IDR_OPTIONS_FAVICON); |
| 134 return NULL; | 136 return NULL; |
| 135 } | 137 } |
| 136 | 138 |
| 137 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, | 139 void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, |
| 138 OptionsPageUIHandler* handler) { | 140 OptionsPageUIHandler* handler) { |
| 139 DCHECK(handler); | 141 DCHECK(handler); |
| 140 handler->GetLocalizedValues(localized_strings); | 142 handler->GetLocalizedValues(localized_strings); |
| 141 AddMessageHandler(handler->Attach(this)); | 143 AddMessageHandler(handler->Attach(this)); |
| 142 } | 144 } |
| OLD | NEW |