OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/advanced_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/advanced_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL }, | 155 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL }, |
156 { "cloudPrintProxyDisabledButton", | 156 { "cloudPrintProxyDisabledButton", |
157 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON }, | 157 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON }, |
158 { "cloudPrintProxyEnabledButton", | 158 { "cloudPrintProxyEnabledButton", |
159 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON }, | 159 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON }, |
160 { "cloudPrintProxyEnabledManageButton", | 160 { "cloudPrintProxyEnabledManageButton", |
161 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON }, | 161 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON }, |
162 { "cloudPrintProxyEnablingButton", | 162 { "cloudPrintProxyEnablingButton", |
163 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON }, | 163 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON }, |
164 #endif | 164 #endif |
165 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
166 { "advancedSectionTitleBackground", | |
167 IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND }, | |
168 { "backgroundModeCheckbox", | |
169 IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE }, | |
170 #endif | |
165 }; | 171 }; |
166 | 172 |
167 RegisterStrings(localized_strings, resources, arraysize(resources)); | 173 RegisterStrings(localized_strings, resources, arraysize(resources)); |
168 RegisterTitle(localized_strings, "advancedPage", | 174 RegisterTitle(localized_strings, "advancedPage", |
169 IDS_OPTIONS_ADVANCED_TAB_LABEL); | 175 IDS_OPTIONS_ADVANCED_TAB_LABEL); |
170 | 176 |
171 localized_strings->SetString("privacyLearnMoreURL", | 177 localized_strings->SetString("privacyLearnMoreURL", |
172 google_util::AppendGoogleLocaleParam( | 178 google_util::AppendGoogleLocaleParam( |
173 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 179 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
174 } | 180 } |
175 | 181 |
176 void AdvancedOptionsHandler::Initialize() { | 182 void AdvancedOptionsHandler::Initialize() { |
177 DCHECK(web_ui_); | 183 DCHECK(web_ui_); |
178 SetupMetricsReportingCheckbox(); | 184 SetupMetricsReportingCheckbox(); |
179 SetupMetricsReportingSettingVisibility(); | 185 SetupMetricsReportingSettingVisibility(); |
180 SetupFontSizeLabel(); | 186 SetupFontSizeLabel(); |
181 SetupDownloadLocationPath(); | 187 SetupDownloadLocationPath(); |
182 SetupPromptForDownload(); | 188 SetupPromptForDownload(); |
183 SetupAutoOpenFileTypesDisabledAttribute(); | 189 SetupAutoOpenFileTypesDisabledAttribute(); |
184 SetupProxySettingsSection(); | 190 SetupProxySettingsSection(); |
185 SetupSSLConfigSettings(); | 191 SetupSSLConfigSettings(); |
186 #if !defined(OS_CHROMEOS) | 192 #if !defined(OS_CHROMEOS) |
187 if (cloud_print_proxy_ui_enabled_) { | 193 if (cloud_print_proxy_ui_enabled_) { |
188 SetupCloudPrintProxySection(); | 194 SetupCloudPrintProxySection(); |
189 RefreshCloudPrintStatusFromService(); | 195 RefreshCloudPrintStatusFromService(); |
190 } else { | 196 } else { |
191 RemoveCloudPrintProxySection(); | 197 RemoveCloudPrintProxySection(); |
192 } | 198 } |
193 #endif | 199 #endif |
200 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
201 SetupBackgroundModeSettings(); | |
202 #endif | |
194 | 203 |
195 banner_handler_.reset( | 204 banner_handler_.reset( |
196 new OptionsManagedBannerHandler(web_ui_, | 205 new OptionsManagedBannerHandler(web_ui_, |
197 ASCIIToUTF16("AdvancedOptions"), | 206 ASCIIToUTF16("AdvancedOptions"), |
198 OPTIONS_PAGE_ADVANCED)); | 207 OPTIONS_PAGE_ADVANCED)); |
199 } | 208 } |
200 | 209 |
201 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { | 210 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { |
202 // Call through to superclass. | 211 // Call through to superclass. |
203 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); | 212 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); |
204 | 213 |
205 // Register for preferences that we need to observe manually. These have | 214 // Register for preferences that we need to observe manually. These have |
206 // special behaviors that aren't handled by the standard prefs UI. | 215 // special behaviors that aren't handled by the standard prefs UI. |
207 DCHECK(web_ui_); | 216 DCHECK(web_ui_); |
208 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); | 217 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); |
209 #if !defined(OS_CHROMEOS) | 218 #if !defined(OS_CHROMEOS) |
210 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, | 219 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
211 g_browser_process->local_state(), this); | 220 g_browser_process->local_state(), this); |
212 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); | 221 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
213 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this); | 222 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this); |
214 #endif | 223 #endif |
215 | 224 |
216 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, | 225 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |
217 g_browser_process->local_state(), this); | 226 g_browser_process->local_state(), this); |
218 ssl3_enabled_.Init(prefs::kSSL3Enabled, g_browser_process->local_state(), | 227 ssl3_enabled_.Init(prefs::kSSL3Enabled, g_browser_process->local_state(), |
219 this); | 228 this); |
220 tls1_enabled_.Init(prefs::kTLS1Enabled, g_browser_process->local_state(), | 229 tls1_enabled_.Init(prefs::kTLS1Enabled, g_browser_process->local_state(), |
221 this); | 230 this); |
222 | 231 |
232 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
233 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, | |
234 g_browser_process->local_state(), | |
235 this); | |
236 #endif | |
237 | |
223 default_download_location_.Init(prefs::kDownloadDefaultDirectory, | 238 default_download_location_.Init(prefs::kDownloadDefaultDirectory, |
224 prefs, this); | 239 prefs, this); |
225 ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this); | 240 ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this); |
226 allow_file_selection_dialogs_.Init(prefs::kAllowFileSelectionDialogs, | 241 allow_file_selection_dialogs_.Init(prefs::kAllowFileSelectionDialogs, |
227 g_browser_process->local_state(), this); | 242 g_browser_process->local_state(), this); |
228 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); | 243 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
229 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); | 244 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); |
230 proxy_prefs_.reset( | 245 proxy_prefs_.reset( |
231 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 246 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
232 | 247 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 #endif | 291 #endif |
277 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", | 292 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction", |
278 NewCallback(this, | 293 NewCallback(this, |
279 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); | 294 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox)); |
280 web_ui_->RegisterMessageCallback("useSSL3CheckboxAction", | 295 web_ui_->RegisterMessageCallback("useSSL3CheckboxAction", |
281 NewCallback(this, | 296 NewCallback(this, |
282 &AdvancedOptionsHandler::HandleUseSSL3Checkbox)); | 297 &AdvancedOptionsHandler::HandleUseSSL3Checkbox)); |
283 web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", | 298 web_ui_->RegisterMessageCallback("useTLS1CheckboxAction", |
284 NewCallback(this, | 299 NewCallback(this, |
285 &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); | 300 &AdvancedOptionsHandler::HandleUseTLS1Checkbox)); |
301 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
302 web_ui_->RegisterMessageCallback("backgroundModeAction", | |
303 NewCallback(this, | |
304 &AdvancedOptionsHandler::HandleBackgroundModeCheckbox)); | |
305 #endif | |
286 } | 306 } |
287 | 307 |
288 void AdvancedOptionsHandler::Observe(NotificationType type, | 308 void AdvancedOptionsHandler::Observe(NotificationType type, |
289 const NotificationSource& source, | 309 const NotificationSource& source, |
290 const NotificationDetails& details) { | 310 const NotificationDetails& details) { |
291 if (type == NotificationType::PREF_CHANGED) { | 311 if (type == NotificationType::PREF_CHANGED) { |
292 std::string* pref_name = Details<std::string>(details).ptr(); | 312 std::string* pref_name = Details<std::string>(details).ptr(); |
293 if ((*pref_name == prefs::kDownloadDefaultDirectory) || | 313 if ((*pref_name == prefs::kDownloadDefaultDirectory) || |
294 (*pref_name == prefs::kPromptForDownload) || | 314 (*pref_name == prefs::kPromptForDownload) || |
295 (*pref_name == prefs::kAllowFileSelectionDialogs)) { | 315 (*pref_name == prefs::kAllowFileSelectionDialogs)) { |
296 SetupDownloadLocationPath(); | 316 SetupDownloadLocationPath(); |
297 SetupPromptForDownload(); | 317 SetupPromptForDownload(); |
298 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { | 318 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
299 SetupAutoOpenFileTypesDisabledAttribute(); | 319 SetupAutoOpenFileTypesDisabledAttribute(); |
300 } else if (proxy_prefs_->IsObserved(*pref_name)) { | 320 } else if (proxy_prefs_->IsObserved(*pref_name)) { |
301 SetupProxySettingsSection(); | 321 SetupProxySettingsSection(); |
302 } else if ((*pref_name == prefs::kCloudPrintEmail) || | 322 } else if ((*pref_name == prefs::kCloudPrintEmail) || |
303 (*pref_name == prefs::kCloudPrintProxyEnabled)) { | 323 (*pref_name == prefs::kCloudPrintProxyEnabled)) { |
304 #if !defined(OS_CHROMEOS) | 324 #if !defined(OS_CHROMEOS) |
305 if (cloud_print_proxy_ui_enabled_) | 325 if (cloud_print_proxy_ui_enabled_) |
306 SetupCloudPrintProxySection(); | 326 SetupCloudPrintProxySection(); |
307 #endif | 327 #endif |
308 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { | 328 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { |
309 SetupFontSizeLabel(); | 329 SetupFontSizeLabel(); |
330 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
331 } else if (*pref_name == prefs::kBackgroundModeEnabled) { | |
332 SetupBackgroundModeSettings(); | |
333 #endif | |
310 } | 334 } |
311 } | 335 } |
312 } | 336 } |
313 | 337 |
314 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 338 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
315 const ListValue* args) { | 339 const ListValue* args) { |
316 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); | 340 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); |
317 select_folder_dialog_ = SelectFileDialog::Create(this); | 341 select_folder_dialog_ = SelectFileDialog::Create(this); |
318 select_folder_dialog_->SelectFile( | 342 select_folder_dialog_->SelectFile( |
319 SelectFileDialog::SELECT_FOLDER, | 343 SelectFileDialog::SELECT_FOLDER, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 | 421 |
398 void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) { | 422 void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) { |
399 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | 423 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
400 bool enabled = checked_str == "true"; | 424 bool enabled = checked_str == "true"; |
401 std::string metric = | 425 std::string metric = |
402 (enabled ? "Options_TLS1_Enable" : "Options_TLS1_Disable"); | 426 (enabled ? "Options_TLS1_Enable" : "Options_TLS1_Disable"); |
403 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); | 427 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); |
404 tls1_enabled_.SetValue(enabled); | 428 tls1_enabled_.SetValue(enabled); |
405 } | 429 } |
406 | 430 |
431 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
432 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( | |
433 const ListValue* args) { | |
434 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); | |
435 bool enabled = checked_str == "true"; | |
436 std::string metric = (enabled ? "Options_BackgroundMode_Enable" : | |
Evan Stade
2011/05/12 18:36:32
no parens
Andrew T Wilson (Slow)
2011/05/12 23:34:31
Done.
| |
437 "Options_BackgroundMode_Disable"); | |
Evan Stade
2011/05/12 18:36:32
indent to same horizontal position as Options_Back
Andrew T Wilson (Slow)
2011/05/12 23:34:31
Done.
| |
438 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); | |
439 background_mode_enabled_.SetValue(enabled); | |
440 } | |
441 | |
442 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { | |
443 FundamentalValue checked(background_mode_enabled_.GetValue()); | |
444 web_ui_->CallJavascriptFunction( | |
445 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); | |
446 } | |
447 #endif | |
448 | |
407 #if !defined(OS_CHROMEOS) | 449 #if !defined(OS_CHROMEOS) |
408 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { | 450 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
409 UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings")); | 451 UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings")); |
410 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); | 452 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); |
411 } | 453 } |
412 #endif | 454 #endif |
413 | 455 |
414 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 456 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
415 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { | 457 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
416 UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates")); | 458 UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 web_ui_->CallJavascriptFunction( | 633 web_ui_->CallJavascriptFunction( |
592 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); | 634 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); |
593 } | 635 } |
594 { | 636 { |
595 FundamentalValue checked(tls1_enabled_.GetValue()); | 637 FundamentalValue checked(tls1_enabled_.GetValue()); |
596 FundamentalValue disabled(tls1_enabled_.IsManaged()); | 638 FundamentalValue disabled(tls1_enabled_.IsManaged()); |
597 web_ui_->CallJavascriptFunction( | 639 web_ui_->CallJavascriptFunction( |
598 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); | 640 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); |
599 } | 641 } |
600 } | 642 } |
OLD | NEW |