diff options
11 files changed, 53 insertions, 361 deletions
diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml index 1af3ede..c08e9bb 100644 --- a/chrome/android/java/res/xml/privacy_preferences.xml +++ b/chrome/android/java/res/xml/privacy_preferences.xml @@ -45,10 +45,6 @@ android:key="crash_dump_upload_no_cellular" android:title="@string/crash_dump_upload_title" android:defaultValue="false" /> - <Preference - android:key="usage_and_crash_reports" - android:title="@string/usage_and_crash_reports_title" - android:fragment="org.chromium.chrome.browser.preferences.privacy.UsageAndCrashReportsPreferenceFragment" /> <Preference android:fragment="org.chromium.chrome.browser.preferences.privacy.DoNotTrackPreference" diff --git a/chrome/android/java/res/xml/usage_and_crash_reports_preferences.xml b/chrome/android/java/res/xml/usage_and_crash_reports_preferences.xml deleted file mode 100644 index a983190..0000000 --- a/chrome/android/java/res/xml/usage_and_crash_reports_preferences.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright 2015 The Chromium Authors. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. --> - -<PreferenceScreen - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:chrome="http://schemas.android.com/apk/res-auto"> - - <org.chromium.chrome.browser.preferences.ChromeSwitchPreference - android:key="usage_and_crash_reports_switch" - android:summaryOn="@string/text_on" - android:summaryOff="@string/text_off"/> - - <org.chromium.chrome.browser.preferences.TextMessagePreference - android:title="@string/usage_and_crash_reports_description"/> - - <org.chromium.chrome.browser.preferences.HyperlinkPreference - android:key="usage_and_crash_reports_learn_more" - android:title="@string/learn_more" - chrome:url="@string/usage_and_crash_reports_learn_more_url" - chrome:imitateWebLink="true" /> - -</PreferenceScreen> diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java index b5e8134..e3de19b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java @@ -8,18 +8,15 @@ import android.app.Activity; import android.content.ComponentCallbacks; import android.content.Context; import android.content.res.Configuration; -import android.text.TextUtils; import org.chromium.base.ActivityState; import org.chromium.base.ApplicationStatus; import org.chromium.chrome.browser.Tab; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.privacy.CrashReportingPermissionManager; import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager; import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; -import org.chromium.components.variations.VariationsAssociatedData; import org.chromium.content_public.browser.WebContents; import org.chromium.net.NetworkChangeNotifier; @@ -105,7 +102,6 @@ public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse nativeUmaResumeSession(sNativeUmaSessionStats); NetworkChangeNotifier.addConnectionTypeObserver(this); - updatePreferences(); updateMetricsServiceState(); } @@ -163,32 +159,6 @@ public class UmaSessionStats implements NetworkChangeNotifier.ConnectionTypeObse nativeUpdateMetricsServiceState(mayRecordStats, mayUploadStats); } - /** - * Updating Android preferences according to equivalent native preferences so that the values - * can be retrieved while native preferences are not accessible. - */ - private void updatePreferences() { - // Update cellular experiment preference. - PrivacyPreferencesManager prefManager = PrivacyPreferencesManager.getInstance(mContext); - boolean cellularExperiment = TextUtils.equals("true", - VariationsAssociatedData.getVariationParamValue( - "UMA_EnableCellularLogUpload", "Enabled")); - prefManager.setCellularExperiment(cellularExperiment); - - // Update metrics reporting preference. - if (cellularExperiment) { - PrefServiceBridge prefBridge = PrefServiceBridge.getInstance(); - // If the native preference metrics reporting has not been set, then initialize it - // based on the older android preference. - if (!prefBridge.hasSetMetricsReporting()) { - prefBridge.setMetricsReportingEnabled(prefManager.isUploadCrashDumpEnabled()); - } - - // Set new Android preference for usage and crash reporting. - prefManager.setUsageAndCrashReporting(prefBridge.isMetricsReportingEnabled()); - } - } - @Override public void onConnectionTypeChanged(int connectionType) { updateMetricsServiceState(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java index 80b5797..d336d84 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java @@ -863,28 +863,6 @@ public final class PrefServiceBridge { int contentSettingsType, List<ContentSettingException> list); public native void nativeSetContentSettingForPattern( int contentSettingType, String pattern, int setting); - - /** - * @return whether Metrics reporting is enabled. - */ - public boolean isMetricsReportingEnabled() { - return nativeGetMetricsReportingEnabled(); - } - - /** - * Sets whether the metrics reporting should be enabled. - */ - public void setMetricsReportingEnabled(boolean enabled) { - nativeSetMetricsReportingEnabled(enabled); - } - - /** - * @return whether the metrics reporting preference has been set by user. - */ - public boolean hasSetMetricsReporting() { - return nativeHasSetMetricsReporting(); - } - private native boolean nativeGetAcceptCookiesEnabled(); private native boolean nativeGetAcceptCookiesManaged(); private native boolean nativeGetBlockThirdPartyCookiesEnabled(); @@ -967,7 +945,4 @@ public final class PrefServiceBridge { private native String nativeGetSupervisedUserSecondCustodianName(); private native String nativeGetSupervisedUserSecondCustodianEmail(); private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(); - private native boolean nativeGetMetricsReportingEnabled(); - private native void nativeSetMetricsReportingEnabled(boolean enabled); - private native boolean nativeHasSetMetricsReporting(); } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java index 9e6e7e7..289fdcc 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferences.java @@ -10,7 +10,6 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -47,7 +46,6 @@ public class PrivacyPreferences extends PreferenceFragment "crash_dump_upload_no_cellular"; private static final String PREF_DO_NOT_TRACK = "do_not_track"; private static final String PREF_CLEAR_BROWSING_DATA = "clear_browsing_data"; - private static final String PREF_USAGE_AND_CRASH_REPORTING = "usage_and_crash_reports"; private ClearBrowsingDataDialogFragment mClearBrowsingDataDialogFragment; private ManagedPreferenceDelegate mManagedPreferenceDelegate; @@ -55,9 +53,7 @@ public class PrivacyPreferences extends PreferenceFragment @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - PrivacyPreferencesManager privacyPrefManager = - PrivacyPreferencesManager.getInstance(getActivity()); - privacyPrefManager.migrateNetworkPredictionPreferences(); + PrivacyPreferencesManager.getInstance(getActivity()).migrateNetworkPredictionPreferences(); addPreferencesFromResource(R.xml.privacy_preferences); getActivity().setTitle(R.string.prefs_privacy); setHasOptionsMenu(true); @@ -71,15 +67,15 @@ public class PrivacyPreferences extends PreferenceFragment NetworkPredictionOptions networkPredictionOptions = PrefServiceBridge.getInstance() .getNetworkPredictionOptions(); - PreferenceScreen preferenceScreen = getPreferenceScreen(); - boolean isMobileNetworkCapable = privacyPrefManager.isMobileNetworkCapable(); + boolean isMobileNetworkCapable = + PrivacyPreferencesManager.getInstance(getActivity()).isMobileNetworkCapable(); if (isMobileNetworkCapable) { - preferenceScreen.removePreference(networkPredictionNoCellularPref); + getPreferenceScreen().removePreference(networkPredictionNoCellularPref); networkPredictionPref.setValue(networkPredictionOptions.enumToString()); networkPredictionPref.setOnPreferenceChangeListener(this); networkPredictionPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate); } else { - preferenceScreen.removePreference(networkPredictionPref); + getPreferenceScreen().removePreference(networkPredictionPref); networkPredictionNoCellularPref.setChecked( networkPredictionOptions != NetworkPredictionOptions.NETWORK_PREDICTION_NEVER); networkPredictionNoCellularPref.setOnPreferenceChangeListener(this); @@ -87,28 +83,19 @@ public class PrivacyPreferences extends PreferenceFragment mManagedPreferenceDelegate); } - // Display the correct settings fragment according to the user experiment group and to type - // of the device, by removing not applicable preference fragments. CrashDumpUploadPreference uploadCrashDumpPref = (CrashDumpUploadPreference) findPreference(PREF_CRASH_DUMP_UPLOAD); ChromeBaseCheckBoxPreference uploadCrashDumpNoCellularPref = (ChromeBaseCheckBoxPreference) findPreference(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR); - if (privacyPrefManager.isCellularExperimentEnabled()) { - preferenceScreen.removePreference(uploadCrashDumpNoCellularPref); - preferenceScreen.removePreference(uploadCrashDumpPref); + if (isMobileNetworkCapable) { + getPreferenceScreen().removePreference(uploadCrashDumpNoCellularPref); + uploadCrashDumpPref.setOnPreferenceChangeListener(this); + uploadCrashDumpPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate); } else { - preferenceScreen.removePreference(findPreference(PREF_USAGE_AND_CRASH_REPORTING)); - if (isMobileNetworkCapable) { - preferenceScreen.removePreference(uploadCrashDumpNoCellularPref); - uploadCrashDumpPref.setOnPreferenceChangeListener(this); - uploadCrashDumpPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate); - } else { - preferenceScreen.removePreference(uploadCrashDumpPref); - uploadCrashDumpNoCellularPref.setOnPreferenceChangeListener(this); - uploadCrashDumpNoCellularPref.setManagedPreferenceDelegate( - mManagedPreferenceDelegate); - } + getPreferenceScreen().removePreference(uploadCrashDumpPref); + uploadCrashDumpNoCellularPref.setOnPreferenceChangeListener(this); + uploadCrashDumpNoCellularPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate); } ChromeBaseCheckBoxPreference navigationErrorPref = @@ -122,7 +109,7 @@ public class PrivacyPreferences extends PreferenceFragment searchSuggestionsPref.setManagedPreferenceDelegate(mManagedPreferenceDelegate); if (!((Preferences) getActivity()).isContextualSearchEnabled()) { - preferenceScreen.removePreference(findPreference(PREF_CONTEXTUAL_SEARCH)); + getPreferenceScreen().removePreference(findPreference(PREF_CONTEXTUAL_SEARCH)); } ButtonPreference clearBrowsingData = diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java index 8d8bc99..10156b1 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManager.java @@ -29,8 +29,6 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage private static final String PREF_NETWORK_PREDICTIONS = "network_predictions"; private static final String PREF_BANDWIDTH_OLD = "prefetch_bandwidth"; private static final String PREF_BANDWIDTH_NO_CELLULAR_OLD = "prefetch_bandwidth_no_cellular"; - private static final String PREF_METRICS_REPORTING = "metrics_reporting"; - private static final String PREF_CELLULAR_EXPERIMENT = "cellular_experiment"; private static final String ALLOW_PRERENDER_OLD = "allow_prefetch"; private static PrivacyPreferencesManager sInstance; @@ -206,65 +204,20 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage } /** - * Check whether to allow uploading usage and crash reporting. The option should be either - * "always upload", or "wifi only" with current connection being wifi/ethernet for the - * three-choice pref or ON for the new two-choice pref. + * Check whether to allow uploading crash dump. The option should be either + * "always upload", or "wifi only" with current connection being wifi/ethernet. * - * @return boolean whether to allow uploading crash dump. + * @return boolean to whether to allow uploading crash dump. */ private boolean allowUploadCrashDump() { - if (isCellularExperimentEnabled()) return isUsageAndCrashReportingEnabled(); - - if (isMobileNetworkCapable()) { + if (!isMobileNetworkCapable()) { + return mSharedPreferences.getBoolean(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR, false); + } else { String option = mSharedPreferences.getString(PREF_CRASH_DUMP_UPLOAD, mCrashDumpNeverUpload); return option.equals(mCrashDumpAlwaysUpload) || (option.equals(mCrashDumpWifiOnlyUpload) && isWiFiOrEthernetNetwork()); } - - return mSharedPreferences.getBoolean(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR, false); - } - - /** - * Check whether usage and crash reporting set to ON. Also initializes the new pref if - * necessary. - * - * @return boolean whether usage and crash reporting set to ON. - */ - public boolean isUsageAndCrashReportingEnabled() { - // If the preference is not set initialize it based on the old preference value. - if (!mSharedPreferences.contains(PREF_METRICS_REPORTING)) { - setUsageAndCrashReporting(isUploadCrashDumpEnabled()); - } - - return mSharedPreferences.getBoolean(PREF_METRICS_REPORTING, false); - } - - /** - * Sets the usage and crash reporting preference ON or OFF. - * - * @param enabled A boolean corresponding whether usage and crash reports uploads are allowed. - */ - public void setUsageAndCrashReporting(boolean enabled) { - mSharedPreferences.edit().putBoolean(PREF_METRICS_REPORTING, enabled).apply(); - } - - /** - * Sets whether cellular experiment is enabled or not. - */ - @VisibleForTesting - public void setCellularExperiment(boolean enabled) { - mSharedPreferences.edit().putBoolean(PREF_CELLULAR_EXPERIMENT, enabled).apply(); - } - - /** - * Checks whether user is assigned to experimental group for enabling new cellular uploads - * functionality. - * - * @return boolean whether user is assigned to experimental group. - */ - public boolean isCellularExperimentEnabled() { - return mSharedPreferences.getBoolean(PREF_CELLULAR_EXPERIMENT, false); } /** @@ -289,27 +242,19 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage } /** - * Check whether crash dump upload preference is disabled according to corresponding preference. - * - * @return boolean {@code true} if the option is set to not send. - */ - public boolean isNeverUploadCrashDump() { - if (isCellularExperimentEnabled()) return !isUsageAndCrashReportingEnabled(); - return !isUploadCrashDumpEnabled(); - } - - /** * Check whether crash dump upload preference is set to NEVER only. * - * @return boolean {@code true} if the option is set to NEVER. + * @return boolean {@code true} if the option is set to NEVER */ - public boolean isUploadCrashDumpEnabled() { + public boolean isNeverUploadCrashDump() { + boolean option; if (isMobileNetworkCapable()) { - return !mSharedPreferences.getString(PREF_CRASH_DUMP_UPLOAD, mCrashDumpNeverUpload) - .equals(mCrashDumpNeverUpload); + option = mSharedPreferences.getString(PREF_CRASH_DUMP_UPLOAD, mCrashDumpNeverUpload) + .equals(mCrashDumpNeverUpload); + } else { + option = !mSharedPreferences.getBoolean(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR, false); } - - return mSharedPreferences.getBoolean(PREF_CRASH_DUMP_UPLOAD_NO_CELLULAR, false); + return option; } /** @@ -337,9 +282,6 @@ public class PrivacyPreferencesManager implements CrashReportingPermissionManage * {@link #allowUploadCrashDump()} should return {@code true}, * and the network should be connected as well. * - * This function should not result in a native call as it can be called in circumstances where - * natives are not guaranteed to be loaded. - * * @return boolean to whether to allow uploading crash dump now. */ @Override diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/UsageAndCrashReportsPreferenceFragment.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/UsageAndCrashReportsPreferenceFragment.java deleted file mode 100644 index e414c5b..0000000 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/UsageAndCrashReportsPreferenceFragment.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser.preferences.privacy; - -import android.os.Bundle; -import android.preference.Preference; -import android.preference.Preference.OnPreferenceChangeListener; -import android.preference.PreferenceFragment; - -import org.chromium.chrome.R; -import org.chromium.chrome.browser.preferences.ChromeSwitchPreference; -import org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; - -/** - * Fragment to manage the Usage and crash reports preference and to explain to - * the user what it does. - */ -public class UsageAndCrashReportsPreferenceFragment extends PreferenceFragment { - private static final String PREF_USAGE_AND_CRASH_REPORTS_SWITCH = - "usage_and_crash_reports_switch"; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.usage_and_crash_reports_preferences); - getActivity().setTitle(R.string.usage_and_crash_reports_title); - initUsageAndCrashReportsSwitch(); - } - - private void initUsageAndCrashReportsSwitch() { - ChromeSwitchPreference usageAndCrashReportsSwitch = - (ChromeSwitchPreference) findPreference(PREF_USAGE_AND_CRASH_REPORTS_SWITCH); - boolean enabled = PrivacyPreferencesManager.getInstance(getActivity()) - .isUsageAndCrashReportingEnabled(); - usageAndCrashReportsSwitch.setChecked(enabled); - - usageAndCrashReportsSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - boolean enabled = (boolean) newValue; - PrivacyPreferencesManager privacyManager = - PrivacyPreferencesManager.getInstance(getActivity()); - - // Update new two-choice android and chromium preferences. - PrefServiceBridge.getInstance().setMetricsReportingEnabled(enabled); - privacyManager.setUsageAndCrashReporting(enabled); - - // Update old three-choice android and chromium preference. - PrefServiceBridge.getInstance().setCrashReporting(enabled); - privacyManager.initCrashUploadPreference(enabled); - return true; - } - }); - - usageAndCrashReportsSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() { - @Override - public boolean isPreferenceControlledByPolicy(Preference preference) { - return PrefServiceBridge.getInstance().isCrashReportManaged(); - } - }); - } -} diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd index 2fdddfe..8241177 100644 --- a/chrome/android/java/strings/android_chrome_strings.grd +++ b/chrome/android/java/strings/android_chrome_strings.grd @@ -384,17 +384,6 @@ For example, some websites may respond to this request by showing you ads that a <message name="IDS_CAN_NOT_CLEAR_BROWSING_HISTORY_TOAST" desc="Message on the toast explaining that child account users can not clear their browsing history."> Browsing history can't be cleared with accounts for kids </message> - <message name="IDS_USAGE_AND_CRASH_REPORTS_TITLE" desc="Title for 'Usage and crash reports' preference"> - Usage and crash reports - </message> - <message name="IDS_USAGE_AND_CRASH_REPORTS_DESCRIPTION" desc="Description for 'Usage and crash reports' preference"> - Help us prioritize the features and improvements we should work on by sending Google information about the files, applications, and services running whenever you experience a crash. - - Usage statistics include information such as preferences, button clicks, and memory usage. They do not include webpage URLs or any personal information. Crash reports contain system information at the time of the crash, and may contain web page URLs or personal information, depending on what was happening at the time of the crash. - </message> - <message name="IDS_USAGE_AND_CRASH_REPORTS_LEARN_MORE_URL" desc="URL for learning more about 'Usage and crash reports' preference" translateable="false"> - https://support.google.com/chrome/answer/96817 - </message> <!-- Accessibility preferences --> <message name="IDS_PREFS_ACCESSIBILITY" desc="Title of Accessibility settings, which allows the user to change webpage font sizes. [CHAR-LIMIT=32]"> diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManagerTest.java index 99a2f43..8bdaf3b 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManagerTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/privacy/PrivacyPreferencesManagerTest.java @@ -34,13 +34,6 @@ public class PrivacyPreferencesManagerTest extends InstrumentationTestCase { private static final UserUploadPreference UPLOAD_WIFI_ONLY = UserUploadPreference.WIFI_ONLY; private static final UserUploadPreference UPLOAD_NEVER = UserUploadPreference.NEVER; - private static final boolean EXPERIMENT_ENABLED = true; - private static final boolean EXPERIMENT_DISABLED = false; - private static final boolean METRIC_REPORTING_SET = true; - private static final boolean METRIC_REPORTING_NOT_SET = false; - private static final boolean METRIC_REPORTING_ENABLED = true; - private static final boolean METRIC_REPORTING_DISABLED = false; - // Perform the same test a few times to make sure any sort of // caching still works. private static final int REPS = 3; @@ -73,50 +66,20 @@ public class PrivacyPreferencesManagerTest extends InstrumentationTestCase { @UiThreadTest public void testAllowCrashDumpUploadNowCellDev() { CommandLine.init(null); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, CONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, DISCONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, CONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, DISCONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(CELLULAR_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_DISABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_DISABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_DISABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_OFF, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_DISABLED, UPLOAD_NOT_PERMITTED); - runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, UPLOAD_OK); + runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_ON, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_OFF, UPLOAD_OK); + runTest(CELLULAR_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); + + runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, CONNECTED, WIFI_ON, UPLOAD_OK); + runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, DISCONNECTED, WIFI_ON, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, CONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_WIFI_ONLY, DISCONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); + + runTest(CELLULAR_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_ON, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); + runTest(CELLULAR_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); } @SmallTest @@ -124,44 +87,24 @@ public class PrivacyPreferencesManagerTest extends InstrumentationTestCase { @UiThreadTest public void testAllowCrashDumpUploadNowWifiDev() { CommandLine.init(null); - runTest(WIFI_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(WIFI_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(WIFI_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - runTest(WIFI_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_OFF, EXPERIMENT_DISABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(WIFI_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(WIFI_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_NOT_SET, METRIC_REPORTING_ENABLED, UPLOAD_NOT_PERMITTED); - - runTest(WIFI_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_ENABLED, UPLOAD_OK); - runTest(WIFI_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, EXPERIMENT_ENABLED, - METRIC_REPORTING_SET, METRIC_REPORTING_DISABLED, UPLOAD_NOT_PERMITTED); + runTest(WIFI_DEVICE, UPLOAD_ALWAYS, CONNECTED, WIFI_ON, UPLOAD_OK); + runTest(WIFI_DEVICE, UPLOAD_ALWAYS, DISCONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); + + runTest(WIFI_DEVICE, UPLOAD_NEVER, CONNECTED, WIFI_ON, UPLOAD_NOT_PERMITTED); + runTest(WIFI_DEVICE, UPLOAD_NEVER, DISCONNECTED, WIFI_OFF, UPLOAD_NOT_PERMITTED); } private void runTest(boolean mobileCapable, UserUploadPreference userPreference, - boolean isConnected, boolean wifiOn, boolean experimentEnabled, - boolean hasSetMetricsReporting, boolean isMetricsReportinEnabled, - boolean uploadPermitted) { + boolean isConnected, boolean wifiOn, boolean uploadPermitted) { PermissionContext context = new PermissionContext(getInstrumentation().getTargetContext()); PrivacyPreferencesManager preferenceManager = - new MockPrivacyPreferencesManager(context, mobileCapable, isConnected, wifiOn, - hasSetMetricsReporting, isMetricsReportinEnabled); - preferenceManager.setCellularExperiment(experimentEnabled); + new MockPrivacyPreferencesManager(context, mobileCapable, isConnected, wifiOn); for (int i = 0; i < REPS; i++) { setUpUserPreferences(context, userPreference); - String state = - String.format("[cellular = %b, preference = %b, connected = %b, wifi = %b," - + "experiment = %b, reporting_set = %b, reporting = %b]", - mobileCapable, userPreference.toBooleanValue(), isConnected, wifiOn, - experimentEnabled, hasSetMetricsReporting, isMetricsReportinEnabled); + String state = String.format( + "[cellular = %b, preference = %b, connected = %b, wifi = %b]", + mobileCapable, userPreference.toBooleanValue(), isConnected, wifiOn); boolean res = preferenceManager.isUploadPermitted(); if (uploadPermitted) { assertTrue("Upload should be permitted for " + state, res); @@ -187,13 +130,11 @@ public class PrivacyPreferencesManagerTest extends InstrumentationTestCase { private final boolean mIsWifi; MockPrivacyPreferencesManager(Context context, boolean isMobileCapable, boolean isConnected, - boolean isWifi, boolean hasSetMetricsReporting, boolean isMetricsReportinEnabled) { + boolean isWifi) { super(context); mIsMobileCapable = isMobileCapable; mIsConnected = isConnected; mIsWifi = isWifi; - - if (hasSetMetricsReporting) setUsageAndCrashReporting(isMetricsReportinEnabled); } @Override diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc index a902a04..189bab0 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.cc +++ b/chrome/browser/android/preferences/pref_service_bridge.cc @@ -380,23 +380,6 @@ static jboolean GetFullscreenAllowed(JNIEnv* env, jobject obj) { CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; } -static jboolean GetMetricsReportingEnabled(JNIEnv* env, jobject obj) { - PrefService* local_state = g_browser_process->local_state(); - return local_state->GetBoolean(prefs::kMetricsReportingEnabled); -} - -static void SetMetricsReportingEnabled(JNIEnv* env, - jobject obj, - jboolean enabled) { - PrefService* local_state = g_browser_process->local_state(); - local_state->SetBoolean(prefs::kMetricsReportingEnabled, enabled); -} - -static jboolean HasSetMetricsReporting(JNIEnv* env, jobject obj) { - PrefService* local_state = g_browser_process->local_state(); - return local_state->HasPrefPath(prefs::kMetricsReportingEnabled); -} - namespace { // Redirects a BrowsingDataRemover completion callback back into Java. diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index a676db0..fc63611 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -842,12 +842,10 @@ void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { &enable_metrics_); #elif defined(OS_ANDROID) // TODO(dwkang): rename or unify the pref for UMA once we have conclusion - // in crbug.com/246495. + // in crbugs.com/246495. // Android has it's own preferences for metrics / crash uploading. enable_metrics_.Init(prefs::kCrashReportingEnabled, g_browser_process->local_state()); - enable_metrics_.Init(prefs::kMetricsReportingEnabled, - g_browser_process->local_state()); enable_metrics_.MoveToThread( BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); #else |