OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options/core_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/webui/help/help_handler.h" | |
21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
24 #include "chrome/grit/chromium_strings.h" | 23 #include "chrome/grit/chromium_strings.h" |
25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
26 #include "chrome/grit/locale_settings.h" | 25 #include "chrome/grit/locale_settings.h" |
27 #include "components/url_fixer/url_fixer.h" | 26 #include "components/url_fixer/url_fixer.h" |
28 #include "content/public/browser/notification_details.h" | 27 #include "content/public/browser/notification_details.h" |
29 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
30 #include "content/public/browser/user_metrics.h" | 29 #include "content/public/browser/user_metrics.h" |
(...skipping 24 matching lines...) Expand all Loading... |
55 // value should never be set to "extension". | 54 // value should never be set to "extension". |
56 return preference->name() != prefs::kURLsToRestoreOnStartup && | 55 return preference->name() != prefs::kURLsToRestoreOnStartup && |
57 preference->name() != prefs::kRestoreOnStartup && | 56 preference->name() != prefs::kRestoreOnStartup && |
58 preference->name() != prefs::kHomePage && | 57 preference->name() != prefs::kHomePage && |
59 preference->name() != prefs::kHomePageIsNewTabPage; | 58 preference->name() != prefs::kHomePageIsNewTabPage; |
60 #else | 59 #else |
61 return true; | 60 return true; |
62 #endif | 61 #endif |
63 } | 62 } |
64 | 63 |
| 64 // Hack to re-use IDS_ABOUT, which is a menu item for the About page. |
| 65 // Since it's a menu item, it may include a "&" to indicate a hotkey. |
| 66 base::string16 GetAboutString() { |
| 67 if (!switches::AboutInSettingsEnabled()) |
| 68 return base::string16(); |
| 69 |
| 70 base::string16 str = l10n_util::GetStringUTF16(IDS_ABOUT); |
| 71 size_t start_pos = str.find(base::ASCIIToUTF16("&")); |
| 72 if (start_pos != base::string16::npos) |
| 73 str.erase(start_pos, 1); |
| 74 return str; |
| 75 } |
| 76 |
65 } // namespace | 77 } // namespace |
66 | 78 |
67 CoreOptionsHandler::CoreOptionsHandler() | 79 CoreOptionsHandler::CoreOptionsHandler() |
68 : handlers_host_(NULL) { | 80 : handlers_host_(NULL) { |
69 } | 81 } |
70 | 82 |
71 CoreOptionsHandler::~CoreOptionsHandler() {} | 83 CoreOptionsHandler::~CoreOptionsHandler() {} |
72 | 84 |
73 void CoreOptionsHandler::InitializeHandler() { | 85 void CoreOptionsHandler::InitializeHandler() { |
74 Profile* profile = Profile::FromWebUI(web_ui()); | 86 Profile* profile = Profile::FromWebUI(web_ui()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 localized_strings->SetString("searchPageNoMatches", | 152 localized_strings->SetString("searchPageNoMatches", |
141 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES)); | 153 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES)); |
142 localized_strings->SetString("searchPageHelpLabel", | 154 localized_strings->SetString("searchPageHelpLabel", |
143 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL)); | 155 l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL)); |
144 localized_strings->SetString("searchPageHelpTitle", | 156 localized_strings->SetString("searchPageHelpTitle", |
145 l10n_util::GetStringFUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_TITLE, | 157 l10n_util::GetStringFUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_TITLE, |
146 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 158 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
147 localized_strings->SetString("searchPageHelpURL", | 159 localized_strings->SetString("searchPageHelpURL", |
148 chrome::kSettingsSearchHelpURL); | 160 chrome::kSettingsSearchHelpURL); |
149 | 161 |
| 162 // About |
| 163 localized_strings->SetBoolean("showAbout", |
| 164 switches::AboutInSettingsEnabled()); |
| 165 localized_strings->SetString("aboutButton", GetAboutString()); |
| 166 |
150 // Common | 167 // Common |
151 localized_strings->SetString("ok", | 168 localized_strings->SetString("ok", |
152 l10n_util::GetStringUTF16(IDS_OK)); | 169 l10n_util::GetStringUTF16(IDS_OK)); |
153 localized_strings->SetString("cancel", | 170 localized_strings->SetString("cancel", |
154 l10n_util::GetStringUTF16(IDS_CANCEL)); | 171 l10n_util::GetStringUTF16(IDS_CANCEL)); |
155 localized_strings->SetString("learnMore", | 172 localized_strings->SetString("learnMore", |
156 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); | 173 l10n_util::GetStringUTF16(IDS_LEARN_MORE)); |
157 localized_strings->SetString("close", | 174 localized_strings->SetString("close", |
158 l10n_util::GetStringUTF16(IDS_CLOSE)); | 175 l10n_util::GetStringUTF16(IDS_CLOSE)); |
159 localized_strings->SetString("done", | 176 localized_strings->SetString("done", |
160 l10n_util::GetStringUTF16(IDS_DONE)); | 177 l10n_util::GetStringUTF16(IDS_DONE)); |
161 localized_strings->SetString("deletableItemDeleteButtonTitle", | 178 localized_strings->SetString("deletableItemDeleteButtonTitle", |
162 l10n_util::GetStringUTF16(IDS_OPTIONS_DELETABLE_ITEM_DELETE_BUTTON)); | 179 l10n_util::GetStringUTF16(IDS_OPTIONS_DELETABLE_ITEM_DELETE_BUTTON)); |
163 localized_strings->SetString( | |
164 "browserVersion", | |
165 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, | |
166 HelpHandler::BuildBrowserVersionString())); | |
167 localized_strings->SetBoolean("showVersion", | |
168 switches::AboutInSettingsEnabled()); | |
169 } | 180 } |
170 | 181 |
171 void CoreOptionsHandler::Uninitialize() { | 182 void CoreOptionsHandler::Uninitialize() { |
172 std::string last_pref; | 183 std::string last_pref; |
173 for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin(); | 184 for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin(); |
174 iter != pref_callback_map_.end(); | 185 iter != pref_callback_map_.end(); |
175 ++iter) { | 186 ++iter) { |
176 if (last_pref != iter->first) { | 187 if (last_pref != iter->first) { |
177 StopObservingPref(iter->first); | 188 StopObservingPref(iter->first); |
178 last_pref = iter->first; | 189 last_pref = iter->first; |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()); | 665 plugin_status_pref_setter_.IsPepperFlashSettingsEnabled()); |
655 web_ui()->CallJavascriptFunction( | 666 web_ui()->CallJavascriptFunction( |
656 "OptionsPage.setPepperFlashSettingsEnabled", enabled); | 667 "OptionsPage.setPepperFlashSettingsEnabled", enabled); |
657 } | 668 } |
658 | 669 |
659 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) { | 670 bool CoreOptionsHandler::IsUserUnsupervised(const base::Value* to_value) { |
660 return !Profile::FromWebUI(web_ui())->IsSupervised(); | 671 return !Profile::FromWebUI(web_ui())->IsSupervised(); |
661 } | 672 } |
662 | 673 |
663 } // namespace options | 674 } // namespace options |
OLD | NEW |