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/advanced_options_handler.h" | 5 #include "chrome/browser/dom_ui/advanced_options_handler.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 l10n_util::GetStringUTF16(IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE)); | 120 l10n_util::GetStringUTF16(IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE)); |
121 localized_strings->SetString("enableLogging", | 121 localized_strings->SetString("enableLogging", |
122 l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_LOGGING)); | 122 l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_LOGGING)); |
123 localized_strings->SetString("disableServices", | 123 localized_strings->SetString("disableServices", |
124 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_SERVICES)); | 124 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_SERVICES)); |
125 } | 125 } |
126 | 126 |
127 void AdvancedOptionsHandler::Initialize() { | 127 void AdvancedOptionsHandler::Initialize() { |
128 SetupDownloadLocationPath(); | 128 SetupDownloadLocationPath(); |
129 SetupAutoOpenFileTypesDisabledAttribute(); | 129 SetupAutoOpenFileTypesDisabledAttribute(); |
130 SetupProxySettingsDisabledAttribute(); | 130 SetupProxySettingsSection(); |
131 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
132 SetupSSLConfigSettings(); | 132 SetupSSLConfigSettings(); |
133 #endif | 133 #endif |
134 banner_handler_.reset( | 134 banner_handler_.reset( |
135 new OptionsManagedBannerHandler(dom_ui_, | 135 new OptionsManagedBannerHandler(dom_ui_, |
136 ASCIIToUTF16("AdvancedOptions"), | 136 ASCIIToUTF16("AdvancedOptions"), |
137 OPTIONS_PAGE_ADVANCED)); | 137 OPTIONS_PAGE_ADVANCED)); |
138 } | 138 } |
139 | 139 |
140 DOMMessageHandler* AdvancedOptionsHandler::Attach(DOMUI* dom_ui) { | 140 DOMMessageHandler* AdvancedOptionsHandler::Attach(DOMUI* dom_ui) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 void AdvancedOptionsHandler::Observe(NotificationType type, | 187 void AdvancedOptionsHandler::Observe(NotificationType type, |
188 const NotificationSource& source, | 188 const NotificationSource& source, |
189 const NotificationDetails& details) { | 189 const NotificationDetails& details) { |
190 if (type == NotificationType::PREF_CHANGED) { | 190 if (type == NotificationType::PREF_CHANGED) { |
191 std::string* pref_name = Details<std::string>(details).ptr(); | 191 std::string* pref_name = Details<std::string>(details).ptr(); |
192 if (*pref_name == prefs::kDownloadDefaultDirectory) { | 192 if (*pref_name == prefs::kDownloadDefaultDirectory) { |
193 SetupDownloadLocationPath(); | 193 SetupDownloadLocationPath(); |
194 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { | 194 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
195 SetupAutoOpenFileTypesDisabledAttribute(); | 195 SetupAutoOpenFileTypesDisabledAttribute(); |
196 } else { | |
197 // Assume that one of the proxy settings may have changed. | |
198 SetupProxySettingsSection(); | |
196 } | 199 } |
197 } | 200 } |
198 } | 201 } |
199 | 202 |
200 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 203 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
201 const ListValue* args) { | 204 const ListValue* args) { |
202 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); | 205 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); |
203 select_folder_dialog_ = SelectFileDialog::Create(this); | 206 select_folder_dialog_ = SelectFileDialog::Create(this); |
204 select_folder_dialog_->SelectFile( | 207 select_folder_dialog_->SelectFile( |
205 SelectFileDialog::SELECT_FOLDER, | 208 SelectFileDialog::SELECT_FOLDER, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 263 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
261 // We enable the button if the user has any auto-open file types registered. | 264 // We enable the button if the user has any auto-open file types registered. |
262 DCHECK(dom_ui_); | 265 DCHECK(dom_ui_); |
263 DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); | 266 DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); |
264 bool disabled = !(manager && manager->HasAutoOpenFileTypesRegistered()); | 267 bool disabled = !(manager && manager->HasAutoOpenFileTypesRegistered()); |
265 FundamentalValue value(disabled); | 268 FundamentalValue value(disabled); |
266 dom_ui_->CallJavascriptFunction( | 269 dom_ui_->CallJavascriptFunction( |
267 L"options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); | 270 L"options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); |
268 } | 271 } |
269 | 272 |
270 void AdvancedOptionsHandler::SetupProxySettingsDisabledAttribute() { | 273 void AdvancedOptionsHandler::SetupProxySettingsSection() { |
271 // Set the enabled state for the proxy settings button. | 274 // Disable the button if proxy settings are managed by a sysadmin or |
272 // We enable the button if proxy settings are not managed by a sysadmin. | 275 // overridden by an extension. |
273 FundamentalValue value(proxy_prefs_->IsManaged()); | 276 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); |
277 const PrefService::Preference* proxy_server = | |
278 pref_service->FindPreference(prefs::kProxyServer); | |
279 CHECK(proxy_server); | |
James Hawkins
2010/08/20 19:51:41
If you really want to check here, this should be a
csilv
2010/08/20 20:21:42
Done.
| |
280 | |
281 FundamentalValue disabled(proxy_prefs_->IsManaged() || | |
282 proxy_server->IsExtensionControlled()); | |
283 | |
284 // Get the appropriate info string to describe the button. | |
285 string16 label_str; | |
286 if (proxy_server->IsExtensionControlled()) { | |
287 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); | |
288 } else { | |
289 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, | |
290 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | |
291 } | |
292 StringValue label(label_str); | |
293 | |
274 dom_ui_->CallJavascriptFunction( | 294 dom_ui_->CallJavascriptFunction( |
275 L"options.AdvancedOptions.SetProxySettingsDisabledAttribute", value); | 295 L"options.AdvancedOptions.SetupProxySettingsSection", disabled, label); |
276 } | 296 } |
277 | 297 |
278 #if defined(OS_WIN) | 298 #if defined(OS_WIN) |
279 void AdvancedOptionsHandler::SetupSSLConfigSettings() { | 299 void AdvancedOptionsHandler::SetupSSLConfigSettings() { |
280 DCHECK(dom_ui_); | 300 DCHECK(dom_ui_); |
281 bool checkRevocationSetting = false; | 301 bool checkRevocationSetting = false; |
282 bool useSSLSetting = false; | 302 bool useSSLSetting = false; |
283 | 303 |
284 net::SSLConfig config; | 304 net::SSLConfig config; |
285 if (net::SSLConfigServiceWin::GetSSLConfigNow(&config)) { | 305 if (net::SSLConfigServiceWin::GetSSLConfigNow(&config)) { |
286 checkRevocationSetting = config.rev_checking_enabled; | 306 checkRevocationSetting = config.rev_checking_enabled; |
287 useSSLSetting = config.ssl2_enabled; | 307 useSSLSetting = config.ssl2_enabled; |
288 } | 308 } |
289 FundamentalValue checkRevocationValue(checkRevocationSetting); | 309 FundamentalValue checkRevocationValue(checkRevocationSetting); |
290 dom_ui_->CallJavascriptFunction( | 310 dom_ui_->CallJavascriptFunction( |
291 L"options.AdvancedOptions.SetCheckRevocationCheckboxState", | 311 L"options.AdvancedOptions.SetCheckRevocationCheckboxState", |
292 checkRevocationValue); | 312 checkRevocationValue); |
293 FundamentalValue useSSLValue(useSSLSetting); | 313 FundamentalValue useSSLValue(useSSLSetting); |
294 dom_ui_->CallJavascriptFunction( | 314 dom_ui_->CallJavascriptFunction( |
295 L"options.AdvancedOptions.SetUseSSL2CheckboxStatechecked", useSSLValue); | 315 L"options.AdvancedOptions.SetUseSSL2CheckboxStatechecked", useSSLValue); |
296 } | 316 } |
297 #endif | 317 #endif |
OLD | NEW |