Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: chrome/browser/ui/webui/options/advanced_options_handler.cc

Issue 7314020: Update UMA user actions parsing, primarily to include WebUI metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update regex Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 void AdvancedOptionsHandler::Initialize() { 198 void AdvancedOptionsHandler::Initialize() {
199 DCHECK(web_ui_); 199 DCHECK(web_ui_);
200 SetupMetricsReportingCheckbox(); 200 SetupMetricsReportingCheckbox();
201 SetupMetricsReportingSettingVisibility(); 201 SetupMetricsReportingSettingVisibility();
202 SetupFontSizeLabel(); 202 SetupFontSizeLabel();
203 SetupDownloadLocationPath(); 203 SetupDownloadLocationPath();
204 SetupPromptForDownload(); 204 SetupPromptForDownload();
205 SetupAutoOpenFileTypesDisabledAttribute(); 205 SetupAutoOpenFileTypesDisabledAttribute();
206 SetupProxySettingsSection(); 206 SetupProxySettingsSection();
207 SetupSSLConfigSettings();
208 #if !defined(OS_CHROMEOS) 207 #if !defined(OS_CHROMEOS)
209 if (cloud_print_proxy_ui_enabled_) { 208 if (cloud_print_proxy_ui_enabled_) {
210 SetupCloudPrintProxySection(); 209 SetupCloudPrintProxySection();
211 RefreshCloudPrintStatusFromService(); 210 RefreshCloudPrintStatusFromService();
212 } else { 211 } else {
213 RemoveCloudPrintProxySection(); 212 RemoveCloudPrintProxySection();
214 } 213 }
215 #endif 214 #endif
216 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 215 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
217 SetupBackgroundModeSettings(); 216 SetupBackgroundModeSettings();
218 #endif 217 #endif
219 218
220 } 219 }
221 220
222 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) { 221 WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) {
223 // Call through to superclass. 222 // Call through to superclass.
224 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); 223 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui);
225 224
226 // Register for preferences that we need to observe manually. These have 225 // Register for preferences that we need to observe manually. These have
227 // special behaviors that aren't handled by the standard prefs UI. 226 // special behaviors that aren't handled by the standard prefs UI.
228 DCHECK(web_ui_); 227 DCHECK(web_ui_);
229 PrefService* prefs = web_ui_->GetProfile()->GetPrefs(); 228 PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
230 #if !defined(OS_CHROMEOS) 229 #if !defined(OS_CHROMEOS)
231 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, 230 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled,
232 g_browser_process->local_state(), this); 231 g_browser_process->local_state(), this);
233 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); 232 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this);
234 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this); 233 cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this);
235 #endif 234 #endif
236 235
237 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled,
238 g_browser_process->local_state(), this);
239 ssl3_enabled_.Init(prefs::kSSL3Enabled, g_browser_process->local_state(),
240 this);
241 tls1_enabled_.Init(prefs::kTLS1Enabled, g_browser_process->local_state(),
242 this);
243
244 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 236 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
245 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, 237 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled,
246 g_browser_process->local_state(), 238 g_browser_process->local_state(),
247 this); 239 this);
248 #endif 240 #endif
249 241
250 default_download_location_.Init(prefs::kDownloadDefaultDirectory, 242 default_download_location_.Init(prefs::kDownloadDefaultDirectory,
251 prefs, this); 243 prefs, this);
252 ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this); 244 ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this);
253 allow_file_selection_dialogs_.Init(prefs::kAllowFileSelectionDialogs, 245 allow_file_selection_dialogs_.Init(prefs::kAllowFileSelectionDialogs,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 NewCallback(this, 286 NewCallback(this,
295 &AdvancedOptionsHandler::ShowCloudPrintSetupDialog)); 287 &AdvancedOptionsHandler::ShowCloudPrintSetupDialog));
296 web_ui_->RegisterMessageCallback("disableCloudPrintProxy", 288 web_ui_->RegisterMessageCallback("disableCloudPrintProxy",
297 NewCallback(this, 289 NewCallback(this,
298 &AdvancedOptionsHandler::HandleDisableCloudPrintProxy)); 290 &AdvancedOptionsHandler::HandleDisableCloudPrintProxy));
299 } 291 }
300 web_ui_->RegisterMessageCallback("showNetworkProxySettings", 292 web_ui_->RegisterMessageCallback("showNetworkProxySettings",
301 NewCallback(this, 293 NewCallback(this,
302 &AdvancedOptionsHandler::ShowNetworkProxySettings)); 294 &AdvancedOptionsHandler::ShowNetworkProxySettings));
303 #endif 295 #endif
304 web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction",
305 NewCallback(this,
306 &AdvancedOptionsHandler::HandleCheckRevocationCheckbox));
307 web_ui_->RegisterMessageCallback("useSSL3CheckboxAction",
308 NewCallback(this,
309 &AdvancedOptionsHandler::HandleUseSSL3Checkbox));
310 web_ui_->RegisterMessageCallback("useTLS1CheckboxAction",
311 NewCallback(this,
312 &AdvancedOptionsHandler::HandleUseTLS1Checkbox));
313 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 296 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
314 web_ui_->RegisterMessageCallback("backgroundModeAction", 297 web_ui_->RegisterMessageCallback("backgroundModeAction",
315 NewCallback(this, 298 NewCallback(this,
316 &AdvancedOptionsHandler::HandleBackgroundModeCheckbox)); 299 &AdvancedOptionsHandler::HandleBackgroundModeCheckbox));
317 #endif 300 #endif
318 } 301 }
319 302
320 void AdvancedOptionsHandler::Observe(int type, 303 void AdvancedOptionsHandler::Observe(int type,
321 const NotificationSource& source, 304 const NotificationSource& source,
322 const NotificationDetails& details) { 305 const NotificationDetails& details) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 343 }
361 344
362 void AdvancedOptionsHandler::HandlePromptForDownload( 345 void AdvancedOptionsHandler::HandlePromptForDownload(
363 const ListValue* args) { 346 const ListValue* args) {
364 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 347 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
365 ask_for_save_location_.SetValue(checked_str == "true"); 348 ask_for_save_location_.SetValue(checked_str == "true");
366 } 349 }
367 350
368 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, 351 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index,
369 void* params) { 352 void* params) {
370 UserMetricsRecordAction(UserMetricsAction("Options_SetDownloadDirectory")); 353 UserMetrics::RecordAction(UserMetricsAction("Options_SetDownloadDirectory"));
371 default_download_location_.SetValue(path); 354 default_download_location_.SetValue(path);
372 SetupDownloadLocationPath(); 355 SetupDownloadLocationPath();
373 } 356 }
374 357
375 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { 358 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() {
376 #if !defined(OS_CHROMEOS) 359 #if !defined(OS_CHROMEOS)
377 if (cloud_print_proxy_ui_enabled_) 360 if (cloud_print_proxy_ui_enabled_)
378 SetupCloudPrintProxySection(); 361 SetupCloudPrintProxySection();
379 #endif 362 #endif
380 } 363 }
381 364
382 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { 365 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) {
383 UserMetricsRecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); 366 UserMetrics::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"));
384 DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager(); 367 DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager();
385 if (manager) 368 if (manager)
386 manager->download_prefs()->ResetAutoOpen(); 369 manager->download_prefs()->ResetAutoOpen();
387 } 370 }
388 371
389 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( 372 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox(
390 const ListValue* args) { 373 const ListValue* args) {
391 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) 374 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
392 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 375 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
393 bool enabled = checked_str == "true"; 376 bool enabled = checked_str == "true";
394 UserMetricsRecordAction( 377 UserMetrics::RecordAction(
395 enabled ? 378 enabled ?
396 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : 379 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
397 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); 380 UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
398 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); 381 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled);
399 enable_metrics_recording_.SetValue(is_enabled); 382 enable_metrics_recording_.SetValue(is_enabled);
400 SetupMetricsReportingCheckbox(); 383 SetupMetricsReportingCheckbox();
401 #endif 384 #endif
402 } 385 }
403 386
404 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { 387 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) {
405 int font_size; 388 int font_size;
406 if (ExtractIntegerValue(args, &font_size)) { 389 if (ExtractIntegerValue(args, &font_size)) {
407 if (font_size > 0) { 390 if (font_size > 0) {
408 default_font_size_.SetValue(font_size); 391 default_font_size_.SetValue(font_size);
409 SetupFontSizeLabel(); 392 SetupFontSizeLabel();
410 } 393 }
411 } 394 }
412 } 395 }
413 396
414 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox(
415 const ListValue* args) {
416 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
417 bool enabled = checked_str == "true";
418 std::string metric =
419 (enabled ? "Options_CheckCertRevocation_Enable"
420 : "Options_CheckCertRevocation_Disable");
421 UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
422 rev_checking_enabled_.SetValue(enabled);
423 }
424
425 void AdvancedOptionsHandler::HandleUseSSL3Checkbox(const ListValue* args) {
426 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
427 bool enabled = checked_str == "true";
428 std::string metric =
429 (enabled ? "Options_SSL3_Enable" : "Options_SSL3_Disable");
430 UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
431 ssl3_enabled_.SetValue(enabled);
432 }
433
434 void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) {
435 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
436 bool enabled = checked_str == "true";
437 std::string metric =
438 (enabled ? "Options_TLS1_Enable" : "Options_TLS1_Disable");
439 UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
440 tls1_enabled_.SetValue(enabled);
441 }
442
443 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 397 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
444 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( 398 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox(
445 const ListValue* args) { 399 const ListValue* args) {
446 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 400 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
447 bool enabled = checked_str == "true"; 401 bool enabled = checked_str == "true";
448 std::string metric = enabled ? "Options_BackgroundMode_Enable" : 402 UserMetrics::RecordAction(enabled ?
449 "Options_BackgroundMode_Disable"; 403 UserMetricsAction("Options_BackgroundMode_Enable") :
450 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); 404 UserMetricsAction("Options_BackgroundMode_Disable"));
451 background_mode_enabled_.SetValue(enabled); 405 background_mode_enabled_.SetValue(enabled);
452 } 406 }
453 407
454 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { 408 void AdvancedOptionsHandler::SetupBackgroundModeSettings() {
455 FundamentalValue checked(background_mode_enabled_.GetValue()); 409 FundamentalValue checked(background_mode_enabled_.GetValue());
456 web_ui_->CallJavascriptFunction( 410 web_ui_->CallJavascriptFunction(
457 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); 411 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked);
458 } 412 }
459 #endif 413 #endif
460 414
461 #if !defined(OS_CHROMEOS) 415 #if !defined(OS_CHROMEOS)
462 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { 416 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) {
463 UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings")); 417 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings"));
464 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); 418 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents());
465 } 419 }
466 #endif 420 #endif
467 421
468 #if !defined(USE_NSS) && !defined(USE_OPENSSL) 422 #if !defined(USE_NSS) && !defined(USE_OPENSSL)
469 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { 423 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) {
470 UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates")); 424 UserMetrics::RecordAction(UserMetricsAction("Options_ManageSSLCertificates"));
471 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents()); 425 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents());
472 } 426 }
473 #endif 427 #endif
474 428
475 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { 429 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
476 UserMetricsRecordAction(UserMetricsAction("Options_ManageCloudPrinters")); 430 UserMetrics::RecordAction(UserMetricsAction("Options_ManageCloudPrinters"));
477 // Open a new tab in the current window for the management page. 431 // Open a new tab in the current window for the management page.
478 web_ui_->tab_contents()->OpenURL( 432 web_ui_->tab_contents()->OpenURL(
479 CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceManageURL(), 433 CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceManageURL(),
480 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); 434 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
481 } 435 }
482 436
483 #if !defined(OS_CHROMEOS) 437 #if !defined(OS_CHROMEOS)
484 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { 438 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) {
485 UserMetricsRecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); 439 UserMetrics::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy"));
486 // Open the connector enable page in the current tab. 440 // Open the connector enable page in the current tab.
487 web_ui_->tab_contents()->OpenURL( 441 web_ui_->tab_contents()->OpenURL(
488 CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceEnableURL( 442 CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceEnableURL(
489 CloudPrintProxyServiceFactory::GetForProfile( 443 CloudPrintProxyServiceFactory::GetForProfile(
490 web_ui_->GetProfile())->proxy_id()), 444 web_ui_->GetProfile())->proxy_id()),
491 GURL(), CURRENT_TAB, PageTransition::LINK); 445 GURL(), CURRENT_TAB, PageTransition::LINK);
492 } 446 }
493 447
494 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy( 448 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy(
495 const ListValue* args) { 449 const ListValue* args) {
496 UserMetricsRecordAction(UserMetricsAction("Options_DisableCloudPrintProxy")); 450 UserMetrics::RecordAction(
451 UserMetricsAction("Options_DisableCloudPrintProxy"));
497 CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())-> 452 CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())->
498 DisableForUser(); 453 DisableForUser();
499 } 454 }
500 455
501 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() { 456 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() {
502 DCHECK(web_ui_); 457 DCHECK(web_ui_);
503 if (cloud_print_proxy_ui_enabled_) 458 if (cloud_print_proxy_ui_enabled_)
504 CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())-> 459 CloudPrintProxyServiceFactory::GetForProfile(web_ui_->GetProfile())->
505 RefreshStatusFromService(); 460 RefreshStatusFromService();
506 } 461 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); 581 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL);
627 } else { 582 } else {
628 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, 583 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL,
629 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 584 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
630 } 585 }
631 StringValue label(label_str); 586 StringValue label(label_str);
632 587
633 web_ui_->CallJavascriptFunction( 588 web_ui_->CallJavascriptFunction(
634 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); 589 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label);
635 } 590 }
636
637 void AdvancedOptionsHandler::SetupSSLConfigSettings() {
638 {
639 FundamentalValue checked(rev_checking_enabled_.GetValue());
640 FundamentalValue disabled(rev_checking_enabled_.IsManaged());
641 web_ui_->CallJavascriptFunction(
642 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked,
643 disabled);
644 }
645 {
646 FundamentalValue checked(ssl3_enabled_.GetValue());
647 FundamentalValue disabled(ssl3_enabled_.IsManaged());
648 web_ui_->CallJavascriptFunction(
649 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled);
650 }
651 {
652 FundamentalValue checked(tls1_enabled_.GetValue());
653 FundamentalValue disabled(tls1_enabled_.IsManaged());
654 web_ui_->CallJavascriptFunction(
655 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled);
656 }
657 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/advanced_options_handler.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698