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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/service/service_process_control.h" 25 #include "chrome/browser/service/service_process_control.h"
26 #include "chrome/browser/ui/options/options_util.h" 26 #include "chrome/browser/ui/options/options_util.h"
27 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "content/browser/download/download_manager.h" 31 #include "content/browser/download/download_manager.h"
32 #include "content/browser/tab_contents/tab_contents.h" 32 #include "content/browser/tab_contents/tab_contents.h"
33 #include "content/browser/tab_contents/tab_contents_view.h" 33 #include "content/browser/tab_contents/tab_contents_view.h"
34 #include "content/browser/user_metrics.h"
35 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
36 #include "content/public/browser/notification_types.h" 35 #include "content/public/browser/notification_types.h"
36 #include "content/public/browser/user_metrics.h"
37 #include "content/public/common/page_zoom.h" 37 #include "content/public/common/page_zoom.h"
38 #include "grit/chromium_strings.h" 38 #include "grit/chromium_strings.h"
39 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
40 #include "grit/locale_settings.h" 40 #include "grit/locale_settings.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 43
44 #if !defined(OS_CHROMEOS) 44 #if !defined(OS_CHROMEOS)
45 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" 45 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h"
46 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" 46 #include "chrome/browser/ui/webui/options/advanced_options_utils.h"
47 #endif 47 #endif
48 48
49 using content::UserMetricsAction;
50
49 AdvancedOptionsHandler::AdvancedOptionsHandler() { 51 AdvancedOptionsHandler::AdvancedOptionsHandler() {
50 52
51 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) 53 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN))
52 // On Windows, we need the PDF plugin which is only guaranteed to exist on 54 // On Windows, we need the PDF plugin which is only guaranteed to exist on
53 // Google Chrome builds. Use a command-line switch for Windows non-Google 55 // Google Chrome builds. Use a command-line switch for Windows non-Google
54 // Chrome builds. 56 // Chrome builds.
55 cloud_print_proxy_ui_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch( 57 cloud_print_proxy_ui_enabled_ = CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kEnableCloudPrintProxy); 58 switches::kEnableCloudPrintProxy);
57 #elif(!defined(OS_CHROMEOS)) 59 #elif(!defined(OS_CHROMEOS))
58 // Always enabled for Mac, Linux and Google Chrome Windows builds. 60 // Always enabled for Mac, Linux and Google Chrome Windows builds.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 select_folder_dialog_->SelectFile( 349 select_folder_dialog_->SelectFile(
348 SelectFileDialog::SELECT_FOLDER, 350 SelectFileDialog::SELECT_FOLDER,
349 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), 351 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE),
350 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), 352 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory),
351 NULL, 0, FILE_PATH_LITERAL(""), web_ui_->tab_contents(), 353 NULL, 0, FILE_PATH_LITERAL(""), web_ui_->tab_contents(),
352 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); 354 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL);
353 } 355 }
354 356
355 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index, 357 void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index,
356 void* params) { 358 void* params) {
357 UserMetrics::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); 359 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory"));
358 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); 360 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
359 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); 361 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path);
360 } 362 }
361 363
362 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() { 364 void AdvancedOptionsHandler::OnCloudPrintSetupClosed() {
363 #if !defined(OS_CHROMEOS) 365 #if !defined(OS_CHROMEOS)
364 if (cloud_print_proxy_ui_enabled_) 366 if (cloud_print_proxy_ui_enabled_)
365 SetupCloudPrintProxySection(); 367 SetupCloudPrintProxySection();
366 #endif 368 #endif
367 } 369 }
368 370
369 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) { 371 void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) {
370 UserMetrics::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); 372 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"));
371 DownloadManager* manager = 373 DownloadManager* manager =
372 web_ui_->tab_contents()->browser_context()->GetDownloadManager(); 374 web_ui_->tab_contents()->browser_context()->GetDownloadManager();
373 if (manager) 375 if (manager)
374 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); 376 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen();
375 } 377 }
376 378
377 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( 379 void AdvancedOptionsHandler::HandleMetricsReportingCheckbox(
378 const ListValue* args) { 380 const ListValue* args) {
379 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) 381 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
380 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 382 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
381 bool enabled = checked_str == "true"; 383 bool enabled = checked_str == "true";
382 UserMetrics::RecordAction( 384 content::RecordAction(
383 enabled ? 385 enabled ?
384 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : 386 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
385 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); 387 UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
386 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); 388 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled);
387 enable_metrics_recording_.SetValue(is_enabled); 389 enable_metrics_recording_.SetValue(is_enabled);
388 SetupMetricsReportingCheckbox(); 390 SetupMetricsReportingCheckbox();
389 #endif 391 #endif
390 } 392 }
391 393
392 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { 394 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) {
393 int font_size; 395 int font_size;
394 if (ExtractIntegerValue(args, &font_size)) { 396 if (ExtractIntegerValue(args, &font_size)) {
395 if (font_size > 0) { 397 if (font_size > 0) {
396 default_font_size_.SetValue(font_size); 398 default_font_size_.SetValue(font_size);
397 SetupFontSizeSelector(); 399 SetupFontSizeSelector();
398 } 400 }
399 } 401 }
400 } 402 }
401 403
402 void AdvancedOptionsHandler::HandleDefaultZoomFactor(const ListValue* args) { 404 void AdvancedOptionsHandler::HandleDefaultZoomFactor(const ListValue* args) {
403 double zoom_factor; 405 double zoom_factor;
404 if (ExtractDoubleValue(args, &zoom_factor)) { 406 if (ExtractDoubleValue(args, &zoom_factor)) {
405 default_zoom_level_.SetValue( 407 default_zoom_level_.SetValue(
406 WebKit::WebView::zoomFactorToZoomLevel(zoom_factor)); 408 WebKit::WebView::zoomFactorToZoomLevel(zoom_factor));
407 } 409 }
408 } 410 }
409 411
410 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( 412 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox(
411 const ListValue* args) { 413 const ListValue* args) {
412 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 414 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
413 bool enabled = checked_str == "true"; 415 bool enabled = checked_str == "true";
414 UserMetrics::RecordAction( 416 content::RecordAction(
415 enabled ? 417 enabled ?
416 UserMetricsAction("Options_CheckCertRevocation_Enable") : 418 UserMetricsAction("Options_CheckCertRevocation_Enable") :
417 UserMetricsAction("Options_CheckCertRevocation_Disable")); 419 UserMetricsAction("Options_CheckCertRevocation_Disable"));
418 rev_checking_enabled_.SetValue(enabled); 420 rev_checking_enabled_.SetValue(enabled);
419 } 421 }
420 422
421 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 423 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
422 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox( 424 void AdvancedOptionsHandler::HandleBackgroundModeCheckbox(
423 const ListValue* args) { 425 const ListValue* args) {
424 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 426 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
425 bool enabled = checked_str == "true"; 427 bool enabled = checked_str == "true";
426 UserMetrics::RecordAction(enabled ? 428 content::RecordAction(enabled ?
427 UserMetricsAction("Options_BackgroundMode_Enable") : 429 UserMetricsAction("Options_BackgroundMode_Enable") :
428 UserMetricsAction("Options_BackgroundMode_Disable")); 430 UserMetricsAction("Options_BackgroundMode_Disable"));
429 background_mode_enabled_.SetValue(enabled); 431 background_mode_enabled_.SetValue(enabled);
430 } 432 }
431 433
432 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { 434 void AdvancedOptionsHandler::SetupBackgroundModeSettings() {
433 base::FundamentalValue checked(background_mode_enabled_.GetValue()); 435 base::FundamentalValue checked(background_mode_enabled_.GetValue());
434 web_ui_->CallJavascriptFunction( 436 web_ui_->CallJavascriptFunction(
435 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); 437 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked);
436 } 438 }
437 #endif 439 #endif
438 440
439 #if !defined(OS_CHROMEOS) 441 #if !defined(OS_CHROMEOS)
440 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { 442 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) {
441 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings")); 443 content::RecordAction(UserMetricsAction("Options_ShowProxySettings"));
442 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); 444 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents());
443 } 445 }
444 #endif 446 #endif
445 447
446 #if !defined(USE_NSS) && !defined(USE_OPENSSL) 448 #if !defined(USE_NSS) && !defined(USE_OPENSSL)
447 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { 449 void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) {
448 UserMetrics::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); 450 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates"));
449 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents()); 451 AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents());
450 } 452 }
451 #endif 453 #endif
452 454
453 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { 455 void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
454 UserMetrics::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); 456 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters"));
455 // Open a new tab in the current window for the management page. 457 // Open a new tab in the current window for the management page.
456 Profile* profile = Profile::FromWebUI(web_ui_); 458 Profile* profile = Profile::FromWebUI(web_ui_);
457 web_ui_->tab_contents()->OpenURL( 459 web_ui_->tab_contents()->OpenURL(
458 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), 460 CloudPrintURL(profile).GetCloudPrintServiceManageURL(),
459 GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); 461 GURL(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK);
460 } 462 }
461 463
462 #if !defined(OS_CHROMEOS) 464 #if !defined(OS_CHROMEOS)
463 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { 465 void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) {
464 UserMetrics::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); 466 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy"));
465 // Open the connector enable page in the current tab. 467 // Open the connector enable page in the current tab.
466 Profile* profile = Profile::FromWebUI(web_ui_); 468 Profile* profile = Profile::FromWebUI(web_ui_);
467 web_ui_->tab_contents()->OpenURL( 469 web_ui_->tab_contents()->OpenURL(
468 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( 470 CloudPrintURL(profile).GetCloudPrintServiceEnableURL(
469 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), 471 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()),
470 GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK); 472 GURL(), CURRENT_TAB, content::PAGE_TRANSITION_LINK);
471 } 473 }
472 474
473 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy( 475 void AdvancedOptionsHandler::HandleDisableCloudPrintProxy(
474 const ListValue* args) { 476 const ListValue* args) {
475 UserMetrics::RecordAction( 477 content::RecordAction(
476 UserMetricsAction("Options_DisableCloudPrintProxy")); 478 UserMetricsAction("Options_DisableCloudPrintProxy"));
477 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))-> 479 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))->
478 DisableForUser(); 480 DisableForUser();
479 } 481 }
480 482
481 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() { 483 void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() {
482 if (cloud_print_proxy_ui_enabled_) 484 if (cloud_print_proxy_ui_enabled_)
483 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))-> 485 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui_))->
484 RefreshStatusFromService(); 486 RefreshStatusFromService();
485 } 487 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 634
633 void AdvancedOptionsHandler::SetupSSLConfigSettings() { 635 void AdvancedOptionsHandler::SetupSSLConfigSettings() {
634 { 636 {
635 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); 637 base::FundamentalValue checked(rev_checking_enabled_.GetValue());
636 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); 638 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged());
637 web_ui_->CallJavascriptFunction( 639 web_ui_->CallJavascriptFunction(
638 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, 640 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked,
639 disabled); 641 disabled);
640 } 642 }
641 } 643 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_ui.cc ('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