diff --git a/base/base_switches.cc b/base/base_switches.cc index 7f3be7f516c58..76827b850a14f 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -23,6 +23,16 @@ const char kEnableLowEndDeviceMode[] = "enable-low-end-device-mode"; // Force disabling of low-end device mode when set. const char kDisableLowEndDeviceMode[] = "disable-low-end-device-mode"; +// This option can be used to force field trials when testing changes locally. +// The argument is a list of name and value pairs, separated by slashes. If a +// trial name is prefixed with an asterisk, that trial will start activated. +// For example, the following argument defines two trials, with the second one +// activated: "GoogleNow/Enable/*MaterialDesignNTP/Default/" This option can +// also be used by the browser process to send the list of trials to a +// non-browser process, using the same format. See +// FieldTrialList::CreateTrialsFromString() in field_trial.h for details. +const char kForceFieldTrials[] = "force-fieldtrials"; + // Suppresses all error dialogs when present. const char kNoErrorDialogs[] = "noerrdialogs"; diff --git a/base/base_switches.h b/base/base_switches.h index bbd590bad05da..95f6bffb23d50 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -13,6 +13,7 @@ namespace switches { extern const char kDisableBreakpad[]; extern const char kEnableCrashReporter[]; +extern const char kForceFieldTrials[]; extern const char kFullMemoryCrashReport[]; extern const char kEnableLowEndDeviceMode[]; extern const char kDisableLowEndDeviceMode[]; diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc index b1a54f11b0309..963a006f59bbc 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.cc +++ b/chrome/browser/android/preferences/pref_service_bridge.cc @@ -462,20 +462,20 @@ static jboolean GetFullscreenAllowed(JNIEnv* env, static jboolean GetMetricsReportingEnabled(JNIEnv* env, const JavaParamRef& obj) { PrefService* local_state = g_browser_process->local_state(); - return local_state->GetBoolean(prefs::kMetricsReportingEnabled); + return local_state->GetBoolean(metrics::prefs::kMetricsReportingEnabled); } static void SetMetricsReportingEnabled(JNIEnv* env, const JavaParamRef& obj, jboolean enabled) { PrefService* local_state = g_browser_process->local_state(); - local_state->SetBoolean(prefs::kMetricsReportingEnabled, enabled); + local_state->SetBoolean(metrics::prefs::kMetricsReportingEnabled, enabled); } static jboolean HasSetMetricsReporting(JNIEnv* env, const JavaParamRef& obj) { PrefService* local_state = g_browser_process->local_state(); - return local_state->HasPrefPath(prefs::kMetricsReportingEnabled); + return local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled); } namespace { diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 02896d613afbf..5a6d7fd63efd9 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -822,9 +822,8 @@ void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) { std::string()); #endif // defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS) - registry->RegisterBooleanPref( - prefs::kMetricsReportingEnabled, - GoogleUpdateSettings::GetCollectStatsConsent()); + registry->RegisterBooleanPref(metrics::prefs::kMetricsReportingEnabled, + GoogleUpdateSettings::GetCollectStatsConsent()); #endif // !defined(OS_CHROMEOS) #if defined(OS_ANDROID) @@ -1006,7 +1005,7 @@ void BrowserProcessImpl::CreateLocalState() { // whenever the preference or its controlling policy changes. #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) pref_change_registrar_.Add( - prefs::kMetricsReportingEnabled, + metrics::prefs::kMetricsReportingEnabled, base::Bind(&BrowserProcessImpl::ApplyMetricsReportingPolicy, base::Unretained(this))); #endif diff --git a/chrome/browser/first_run/first_run_internal_posix.cc b/chrome/browser/first_run/first_run_internal_posix.cc index 683b9371a9755..6e97dd89c7711 100644 --- a/chrome/browser/first_run/first_run_internal_posix.cc +++ b/chrome/browser/first_run/first_run_internal_posix.cc @@ -38,7 +38,7 @@ void DoPostImportPlatformSpecificTasks(Profile* profile) { // this is POSIX-specific). if (GoogleUpdateSettings::GetCollectStatsConsent()) { g_browser_process->local_state()->SetBoolean( - prefs::kMetricsReportingEnabled, true); + metrics::prefs::kMetricsReportingEnabled, true); } #endif } diff --git a/chrome/browser/metrics/chrome_metrics_service_accessor.cc b/chrome/browser/metrics/chrome_metrics_service_accessor.cc index 50ee2faf884e7..89741bde4c02a 100644 --- a/chrome/browser/metrics/chrome_metrics_service_accessor.cc +++ b/chrome/browser/metrics/chrome_metrics_service_accessor.cc @@ -42,7 +42,7 @@ bool ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() { prefs::kCrashReportingEnabled); #else enabled = g_browser_process->local_state()-> - GetBoolean(prefs::kMetricsReportingEnabled); + GetBoolean(metrics::prefs::kMetricsReportingEnabled); #endif // #if defined(OS_CHROMEOS) #endif // defined(GOOGLE_CHROME_BUILD) return enabled; diff --git a/chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc b/chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc index dc70144850271..237539bb934c5 100644 --- a/chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc +++ b/chrome/browser/metrics/chrome_metrics_service_accessor_unittest.cc @@ -31,7 +31,7 @@ TEST_F(ChromeMetricsServiceAccessorTest, MetricsReportingEnabled) { #if defined(OS_ANDROID) const char* pref = prefs::kCrashReportingEnabled; #else - const char* pref = prefs::kMetricsReportingEnabled; + const char* pref = metrics::prefs::kMetricsReportingEnabled; #endif // defined(OS_ANDROID) GetLocalState()->SetDefaultPrefValue(pref, new base::FundamentalValue(false)); diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index e9858a6c4a5d8..a8cf6efe8462d 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -113,7 +113,7 @@ bool IsCellularLogicEnabled() { bool ShouldClearSavedMetrics() { #if defined(OS_ANDROID) PrefService* local_state = g_browser_process->local_state(); - return !local_state->HasPrefPath(prefs::kMetricsReportingEnabled) && + return !local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled) && variations::GetVariationParamValue("UMA_EnableCellularLogUpload", "Enabled") == "true"; #else diff --git a/chrome/browser/metrics/metrics_reporting_state.cc b/chrome/browser/metrics/metrics_reporting_state.cc index 318766bc7f2c3..e9d658e80eb04 100644 --- a/chrome/browser/metrics/metrics_reporting_state.cc +++ b/chrome/browser/metrics/metrics_reporting_state.cc @@ -60,7 +60,7 @@ void SetMetricsReporting(bool to_update_pref, } #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) g_browser_process->local_state()->SetBoolean( - prefs::kMetricsReportingEnabled, updated_pref); + metrics::prefs::kMetricsReportingEnabled, updated_pref); #endif // When a user opts in to the metrics reporting service, the previously // collected data should be cleared to ensure that nothing is reported before @@ -103,6 +103,6 @@ void InitiateMetricsReportingChange( bool IsMetricsReportingUserChangable() { const PrefService* pref_service = g_browser_process->local_state(); const PrefService::Preference* pref = - pref_service->FindPreference(prefs::kMetricsReportingEnabled); + pref_service->FindPreference(metrics::prefs::kMetricsReportingEnabled); return pref && !pref->IsManaged(); } diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc index 0a90e51ed62f6..cbb84b6d2073f 100644 --- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc +++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc @@ -119,7 +119,7 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = { prefs::kPrintPreviewDisabled, base::Value::TYPE_BOOLEAN }, { key::kMetricsReportingEnabled, - prefs::kMetricsReportingEnabled, + metrics::prefs::kMetricsReportingEnabled, base::Value::TYPE_BOOLEAN }, { key::kApplicationLocaleValue, prefs::kApplicationLocale, diff --git a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc index d11ba30b54b74..6df10cf793b8c 100644 --- a/chrome/browser/prefs/tracked/pref_hash_browsertest.cc +++ b/chrome/browser/prefs/tracked/pref_hash_browsertest.cc @@ -4,6 +4,7 @@ #include +#include "base/base_switches.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" @@ -31,7 +32,6 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" #include "components/search_engines/default_search_manager.h" -#include "content/public/common/content_switches.h" #include "extensions/browser/pref_names.h" #include "extensions/common/extension.h" diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index ffc1d5fc5945f..57ca56c6cb450 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -887,7 +887,7 @@ void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { #else // Prep the PrefMember and send it to the IO thread, since this value will be // read from there. - enable_metrics_.Init(prefs::kMetricsReportingEnabled, + enable_metrics_.Init(metrics::prefs::kMetricsReportingEnabled, g_browser_process->local_state()); enable_metrics_.MoveToThread( BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); diff --git a/chrome/browser/ui/cocoa/first_run_dialog.mm b/chrome/browser/ui/cocoa/first_run_dialog.mm index f3a9503facf77..b92fce9aaad17 100644 --- a/chrome/browser/ui/cocoa/first_run_dialog.mm +++ b/chrome/browser/ui/cocoa/first_run_dialog.mm @@ -87,7 +87,7 @@ bool ShowFirstRun(Profile* profile) { // (which is likely to be forced in enterprise deployments anyway). const PrefService::Preference* metrics_reporting_pref = g_browser_process->local_state()->FindPreference( - prefs::kMetricsReportingEnabled); + metrics::prefs::kMetricsReportingEnabled); if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) { base::scoped_nsobject dialog( [[FirstRunDialogController alloc] init]); diff --git a/chrome/browser/ui/views/first_run_dialog.cc b/chrome/browser/ui/views/first_run_dialog.cc index 2dc7e2509c687..4c723d5ce7a97 100644 --- a/chrome/browser/ui/views/first_run_dialog.cc +++ b/chrome/browser/ui/views/first_run_dialog.cc @@ -51,7 +51,7 @@ bool FirstRunDialog::Show(Profile* profile) { // If the metrics reporting is managed, we won't ask. const PrefService::Preference* metrics_reporting_pref = g_browser_process->local_state()->FindPreference( - prefs::kMetricsReportingEnabled); + metrics::prefs::kMetricsReportingEnabled); if (!metrics_reporting_pref || !metrics_reporting_pref->IsManaged()) { diff --git a/chrome/browser/ui/views/session_crashed_bubble_view.cc b/chrome/browser/ui/views/session_crashed_bubble_view.cc index 5d166929c6725..c40a497b22260 100644 --- a/chrome/browser/ui/views/session_crashed_bubble_view.cc +++ b/chrome/browser/ui/views/session_crashed_bubble_view.cc @@ -179,8 +179,10 @@ void SessionCrashedBubbleView::ShowForReal( #if defined(GOOGLE_CHROME_BUILD) if (!uma_opted_in_already) { - offer_uma_optin = g_browser_process->local_state()->FindPreference( - prefs::kMetricsReportingEnabled)->IsUserModifiable(); + offer_uma_optin = + g_browser_process->local_state() + ->FindPreference(metrics::prefs::kMetricsReportingEnabled) + ->IsUserModifiable(); } #endif // defined(GOOGLE_CHROME_BUILD) diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 544da59191c6e..80e38bdda1693 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -1254,11 +1254,6 @@ const char kSSLVersionFallbackMin[] = "ssl.version_fallback_min"; const char kCipherSuiteBlacklist[] = "ssl.cipher_suites.blacklist"; const char kDisableSSLRecordSplitting[] = "ssl.ssl_record_splitting.disabled"; -// Boolean that specifies whether or not crash reporting and metrics reporting -// are sent over the network for analysis. -const char kMetricsReportingEnabled[] = - "user_experience_metrics.reporting_enabled"; - // Boolean that specifies whether or not crash reports are sent // over the network for analysis. #if defined(OS_ANDROID) diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 2eae559f887d5..81c756694468b 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -431,11 +431,6 @@ extern const char kGLVendorString[]; extern const char kGLRendererString[]; extern const char kGLVersionString[]; -// For finding out whether metrics and crash reporting is enabled or not use -// |ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()| instead -// of reading platform specific prefs. -extern const char kMetricsReportingEnabled[]; - // Android has it's own metric / crash reporting implemented in Android // Java code so kMetricsReportingEnabled doesn't make sense. We use this // to inform crashes_ui that we have enabled crash reporting. diff --git a/chrome/installer/util/uninstall_metrics.cc b/chrome/installer/util/uninstall_metrics.cc index fe2ee436804cb..fbd1b90a77fab 100644 --- a/chrome/installer/util/uninstall_metrics.cc +++ b/chrome/installer/util/uninstall_metrics.cc @@ -51,7 +51,7 @@ bool ExtractUninstallMetrics(const base::DictionaryValue& root, // Make sure that the user wants us reporting metrics. If not, don't // add our uninstall metrics. bool metrics_reporting_enabled = false; - if (!root.GetBoolean(prefs::kMetricsReportingEnabled, + if (!root.GetBoolean(metrics::prefs::kMetricsReportingEnabled, &metrics_reporting_enabled) || !metrics_reporting_enabled) { return false; diff --git a/components/metrics/metrics_pref_names.cc b/components/metrics/metrics_pref_names.cc index 3cdebabaf175c..a5ad6a521df6a 100644 --- a/components/metrics/metrics_pref_names.cc +++ b/components/metrics/metrics_pref_names.cc @@ -43,6 +43,11 @@ const char kMetricsOngoingLogs[] = // client id and low entropy source should be reset. const char kMetricsResetIds[] = "user_experience_metrics.reset_metrics_ids"; +// Boolean that specifies whether or not crash reporting and metrics reporting +// are sent over the network for analysis. +const char kMetricsReportingEnabled[] = + "user_experience_metrics.reporting_enabled"; + // Date/time when the user opted in to UMA and generated the client id for the // very first time (local machine time, stored as a 64-bit time_t value). const char kMetricsReportingEnabledTimestamp[] = diff --git a/components/metrics/metrics_pref_names.h b/components/metrics/metrics_pref_names.h index f4456a56fa7ec..8118a5978d3b2 100644 --- a/components/metrics/metrics_pref_names.h +++ b/components/metrics/metrics_pref_names.h @@ -17,6 +17,11 @@ extern const char kMetricsLowEntropySource[]; extern const char kMetricsMachineId[]; extern const char kMetricsOngoingLogs[]; extern const char kMetricsResetIds[]; + +// For finding out whether metrics and crash reporting is enabled use +// ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled() instead of +// reading this pref directly. +extern const char kMetricsReportingEnabled[]; extern const char kMetricsReportingEnabledTimestamp[]; extern const char kMetricsSessionID[]; extern const char kStabilityBreakpadRegistrationSuccess[]; diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index b8dd4b2939444..d186a0bc30373 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -494,16 +494,6 @@ const char kExplicitlyAllowedPorts[] = "explicitly-allowed-ports"; // Load NPAPI plugins from the specified directory. const char kExtraPluginDir[] = "extra-plugin-dir"; -// This option can be used to force field trials when testing changes locally. -// The argument is a list of name and value pairs, separated by slashes. If a -// trial name is prefixed with an asterisk, that trial will start activated. -// For example, the following argument defines two trials, with the second one -// activated: "GoogleNow/Enable/*MaterialDesignNTP/Default/" -// This option is also used by the browser to send the list of trials to -// renderers, using the same format. See -// FieldTrialList::CreateTrialsFromString() in field_trial.h for details. -const char kForceFieldTrials[] = "force-fieldtrials"; - // Always use the Skia GPU backend for drawing layer tiles. Only valid with GPU // accelerated compositing + impl-side painting. Overrides the // kEnableGpuRasterization flag. diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 5886b7cda6391..e5b00f04333e7 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -148,7 +148,6 @@ CONTENT_EXPORT extern const char kEnableZeroCopy[]; CONTENT_EXPORT extern const char kExplicitlyAllowedPorts[]; CONTENT_EXPORT extern const char kExtraPluginDir[]; CONTENT_EXPORT extern const char kForceDisplayList2dCanvas[]; -CONTENT_EXPORT extern const char kForceFieldTrials[]; CONTENT_EXPORT extern const char kForceGpuRasterization[]; CONTENT_EXPORT extern const char kForceOverlayFullscreenVideo[]; CONTENT_EXPORT extern const char kForceRendererAccessibility[];