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

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

Issue 506663003: Consolidates accessing and setting the UMA pref to be within metrics code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
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/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "apps/app_window.h" 10 #include "apps/app_window.h"
(...skipping 14 matching lines...) Expand all
25 #include "base/value_conversions.h" 25 #include "base/value_conversions.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "chrome/browser/auto_launch_trial.h" 27 #include "chrome/browser/auto_launch_trial.h"
28 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
30 #include "chrome/browser/chrome_page_zoom.h" 30 #include "chrome/browser/chrome_page_zoom.h"
31 #include "chrome/browser/custom_home_pages_table_model.h" 31 #include "chrome/browser/custom_home_pages_table_model.h"
32 #include "chrome/browser/download/download_prefs.h" 32 #include "chrome/browser/download/download_prefs.h"
33 #include "chrome/browser/gpu/gpu_mode_manager.h" 33 #include "chrome/browser/gpu/gpu_mode_manager.h"
34 #include "chrome/browser/lifetime/application_lifetime.h" 34 #include "chrome/browser/lifetime/application_lifetime.h"
35 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
35 #include "chrome/browser/net/prediction_options.h" 36 #include "chrome/browser/net/prediction_options.h"
36 #include "chrome/browser/prefs/session_startup_pref.h" 37 #include "chrome/browser/prefs/session_startup_pref.h"
37 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" 38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
38 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h" 39 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory. h"
39 #include "chrome/browser/profiles/profile.h" 40 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 41 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
41 #include "chrome/browser/profiles/profile_info_cache.h" 42 #include "chrome/browser/profiles/profile_info_cache.h"
42 #include "chrome/browser/profiles/profile_manager.h" 43 #include "chrome/browser/profiles/profile_manager.h"
43 #include "chrome/browser/profiles/profile_metrics.h" 44 #include "chrome/browser/profiles/profile_metrics.h"
44 #include "chrome/browser/profiles/profile_shortcut_manager.h" 45 #include "chrome/browser/profiles/profile_shortcut_manager.h"
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 values->SetString("username", username); 536 values->SetString("username", username);
536 #endif 537 #endif
537 538
538 // Pass along sync status early so it will be available during page init. 539 // Pass along sync status early so it will be available during page init.
539 values->Set("syncData", GetSyncStateDictionary().release()); 540 values->Set("syncData", GetSyncStateDictionary().release());
540 541
541 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL); 542 values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL);
542 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL); 543 values->SetString("doNotTrackLearnMoreURL", chrome::kDoNotTrackLearnMoreURL);
543 544
544 #if !defined(OS_CHROMEOS) 545 #if !defined(OS_CHROMEOS)
545 PrefService* pref_service = g_browser_process->local_state(); 546 values->SetBoolean("metricsReportingEnabledAtStart",
546 values->SetBoolean("metricsReportingEnabledAtStart", pref_service->GetBoolean( 547 ChromeMetricsServiceAccessor::IsMetricsReportingEnabled());
547 prefs::kMetricsReportingEnabled));
548 #endif 548 #endif
549 549
550 #if defined(OS_CHROMEOS) 550 #if defined(OS_CHROMEOS)
551 // TODO(pastarmovj): replace this with a call to the CrosSettings list 551 // TODO(pastarmovj): replace this with a call to the CrosSettings list
552 // handling functionality to come. 552 // handling functionality to come.
553 values->Set("timezoneList", chromeos::system::GetTimezoneList().release()); 553 values->Set("timezoneList", chromeos::system::GetTimezoneList().release());
554 554
555 values->SetString("accessibilityLearnMoreURL", 555 values->SetString("accessibilityLearnMoreURL",
556 chrome::kChromeAccessibilityHelpURL); 556 chrome::kChromeAccessibilityHelpURL);
557 557
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers, 870 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers,
871 base::Unretained(this))); 871 base::Unretained(this)));
872 profile_pref_registrar_.Add( 872 profile_pref_registrar_.Add(
873 prefs::kSigninAllowed, 873 prefs::kSigninAllowed,
874 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, 874 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange,
875 base::Unretained(this))); 875 base::Unretained(this)));
876 profile_pref_registrar_.Add( 876 profile_pref_registrar_.Add(
877 prefs::kEasyUnlockPairing, 877 prefs::kEasyUnlockPairing,
878 base::Bind(&BrowserOptionsHandler::SetupEasyUnlock, 878 base::Bind(&BrowserOptionsHandler::SetupEasyUnlock,
879 base::Unretained(this))); 879 base::Unretained(this)));
880 880 profile_pref_registrar_.Add(
881 prefs::kMetricsReportingEnabled,
Alexei Svitkine (slow) 2014/08/28 14:46:49 This code shouldn't be registering this pref. That
gayane -on leave until 09-2017 2014/09/03 20:20:08 Done.
882 base::Bind(&BrowserOptionsHandler::SetupMetricsReportingCheckbox,
883 base::Unretained(this)));
881 #if defined(OS_WIN) 884 #if defined(OS_WIN)
882 profile_pref_registrar_.Add( 885 profile_pref_registrar_.Add(
883 prefs::kURLsToRestoreOnStartup, 886 prefs::kURLsToRestoreOnStartup,
884 base::Bind(&BrowserOptionsHandler::SetupExtensionControlledIndicators, 887 base::Bind(&BrowserOptionsHandler::SetupExtensionControlledIndicators,
885 base::Unretained(this))); 888 base::Unretained(this)));
886 profile_pref_registrar_.Add( 889 profile_pref_registrar_.Add(
887 prefs::kHomePage, 890 prefs::kHomePage,
888 base::Bind(&BrowserOptionsHandler::SetupExtensionControlledIndicators, 891 base::Bind(&BrowserOptionsHandler::SetupExtensionControlledIndicators,
889 base::Unretained(this))); 892 base::Unretained(this)));
890 #endif // defined(OS_WIN) 893 #endif // defined(OS_WIN)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 SetupMetricsReportingSettingVisibility(); 927 SetupMetricsReportingSettingVisibility();
925 SetupNetworkPredictionControl(); 928 SetupNetworkPredictionControl();
926 SetupFontSizeSelector(); 929 SetupFontSizeSelector();
927 SetupPageZoomSelector(); 930 SetupPageZoomSelector();
928 SetupAutoOpenFileTypes(); 931 SetupAutoOpenFileTypes();
929 SetupProxySettingsSection(); 932 SetupProxySettingsSection();
930 SetupManageCertificatesSection(); 933 SetupManageCertificatesSection();
931 SetupManagingSupervisedUsers(); 934 SetupManagingSupervisedUsers();
932 SetupEasyUnlock(); 935 SetupEasyUnlock();
933 SetupExtensionControlledIndicators(); 936 SetupExtensionControlledIndicators();
937 SetupMetricsReportingCheckbox();
934 938
935 #if defined(OS_CHROMEOS) 939 #if defined(OS_CHROMEOS)
936 SetupAccessibilityFeatures(); 940 SetupAccessibilityFeatures();
937 policy::BrowserPolicyConnectorChromeOS* connector = 941 policy::BrowserPolicyConnectorChromeOS* connector =
938 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 942 g_browser_process->platform_part()->browser_policy_connector_chromeos();
939 if (!connector->IsEnterpriseManaged() && 943 if (!connector->IsEnterpriseManaged() &&
940 !user_manager::UserManager::Get()->IsLoggedInAsGuest() && 944 !user_manager::UserManager::Get()->IsLoggedInAsGuest() &&
941 !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) { 945 !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()) {
942 web_ui()->CallJavascriptFunction( 946 web_ui()->CallJavascriptFunction(
943 "BrowserOptions.enableFactoryResetSection"); 947 "BrowserOptions.enableFactoryResetSection");
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 // Check if an extension is overwriting the proxy setting. 1867 // Check if an extension is overwriting the proxy setting.
1864 extension = extensions::GetExtensionOverridingProxy( 1868 extension = extensions::GetExtensionOverridingProxy(
1865 Profile::FromWebUI(web_ui())); 1869 Profile::FromWebUI(web_ui()));
1866 AppendExtensionData("proxy", extension, &extension_controlled); 1870 AppendExtensionData("proxy", extension, &extension_controlled);
1867 1871
1868 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", 1872 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators",
1869 extension_controlled); 1873 extension_controlled);
1870 #endif // defined(OS_WIN) 1874 #endif // defined(OS_WIN)
1871 } 1875 }
1872 1876
1877 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() {
1878 const PrefService* pref_service = g_browser_process->local_state();
1879
1880 base::FundamentalValue checked(pref_service->GetBoolean(
1881 prefs::kMetricsReportingEnabled));
Alexei Svitkine (slow) 2014/08/28 14:46:48 This part should be done in chrome/browser/metrics
gayane -on leave until 09-2017 2014/09/03 20:20:08 Done.
1882 const PrefService::Preference* pref = pref_service->FindPreference(
1883 prefs::kMetricsReportingEnabled);
1884 base::FundamentalValue disabled(!(pref && pref->IsManaged()));
1885
1886 web_ui()->CallJavascriptFunction(
1887 "BrowserOptions.setMetricsReportingCheckboxState", checked, disabled);
1888 }
1889
1873 } // namespace options 1890 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698