Commit c0bfdaf6 authored by Bence Béky's avatar Bence Béky Committed by Chromium LUCI CQ

Remove migrateNetworkPredictionPreferences().

migrateNetworkPredictionPreferences has been part of
PrivacyPreferencesManager ever since it was upstreamed
on 2015-02-19 at https://codereview.chromium.org/935903002.
This removal only affects users who had set this particular
preference to non-default before 2015 and have not launched
their Chrome since than.

Remove now unused PRIVACY_NETWORK_PREDICTIONS.

Bug: 526773
Change-Id: Iba72578c9e7bd77e95433098b29d727166326d97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568665Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarNatalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Bence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836075}
parent 021da979
......@@ -45,91 +45,6 @@ public class PrivacyPreferencesManagerImpl implements PrivacyPreferencesManager
return sInstance;
}
@Override
public void migrateNetworkPredictionPreferences() {
// See if PREF_NETWORK_PREDICTIONS is an old boolean value.
boolean predictionOptionIsBoolean = false;
try {
mPrefs.readString(ChromePreferenceKeys.PRIVACY_NETWORK_PREDICTIONS, "");
} catch (ClassCastException ex) {
predictionOptionIsBoolean = true;
}
// Nothing to do if the user or this migration code has already set the new
// preference.
if (!predictionOptionIsBoolean && obsoleteNetworkPredictionOptionsHasUserSetting()) {
return;
}
// Nothing to do if the old preferences are unset.
if (!predictionOptionIsBoolean
&& !mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD)
&& !mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_NO_CELLULAR_OLD)) {
return;
}
// Migrate if the old preferences are at their default values.
// (Note that for PREF_BANDWIDTH*, if the setting is default, then there is no way to tell
// whether the user has set it.)
final String prefBandwidthDefault =
BandwidthType.title(BandwidthType.Type.PRERENDER_ON_WIFI);
final String prefBandwidth =
mPrefs.readString(ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD, prefBandwidthDefault);
boolean prefBandwidthNoCellularDefault = true;
boolean prefBandwidthNoCellular =
mPrefs.readBoolean(ChromePreferenceKeys.PRIVACY_BANDWIDTH_NO_CELLULAR_OLD,
prefBandwidthNoCellularDefault);
if (!(prefBandwidthDefault.equals(prefBandwidth))
|| (prefBandwidthNoCellular != prefBandwidthNoCellularDefault)) {
boolean newValue = true;
// Observe PREF_BANDWIDTH on mobile network capable devices.
if (isMobileNetworkCapable()) {
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD)) {
@BandwidthType.Type
int prefetchBandwidthTypePref =
BandwidthType.getBandwidthFromTitle(prefBandwidth);
if (BandwidthType.Type.NEVER_PRERENDER == prefetchBandwidthTypePref) {
newValue = false;
} else if (BandwidthType.Type.PRERENDER_ON_WIFI == prefetchBandwidthTypePref
|| BandwidthType.Type.ALWAYS_PRERENDER == prefetchBandwidthTypePref) {
newValue = true;
}
}
}
// Observe PREF_BANDWIDTH_NO_CELLULAR on devices without mobile network.
else {
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_NO_CELLULAR_OLD)) {
newValue = prefBandwidthNoCellular;
}
}
// Save new value in Chrome PrefService.
setNetworkPredictionEnabled(newValue);
}
// Delete old sharedPreferences.
// Delete PREF_BANDWIDTH and PREF_BANDWIDTH_NO_CELLULAR: just migrated these options.
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD)) {
mPrefs.removeKey(ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD);
}
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_BANDWIDTH_NO_CELLULAR_OLD)) {
mPrefs.removeKey(ChromePreferenceKeys.PRIVACY_BANDWIDTH_NO_CELLULAR_OLD);
}
// Also delete ALLOW_PRERENDER, which was updated based on PREF_BANDWIDTH[_NO_CELLULAR] and
// network connectivity type, therefore does not carry additional information.
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_ALLOW_PRERENDER_OLD)) {
mPrefs.removeKey(ChromePreferenceKeys.PRIVACY_ALLOW_PRERENDER_OLD);
}
// Delete bool PREF_NETWORK_PREDICTIONS so that string values can be stored. Note that this
// SharedPreference carries no information, because it used to be overwritten by
// kNetworkPredictionEnabled on startup, and now it is overwritten by
// kNetworkPredictionOptions on startup.
if (mPrefs.contains(ChromePreferenceKeys.PRIVACY_NETWORK_PREDICTIONS)) {
mPrefs.removeKey(ChromePreferenceKeys.PRIVACY_NETWORK_PREDICTIONS);
}
}
protected boolean isNetworkAvailable() {
ConnectivityManager connectivityManager =
(ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
......@@ -152,7 +67,6 @@ public class PrivacyPreferencesManagerImpl implements PrivacyPreferencesManager
@Override
public boolean shouldPrerender() {
if (!DeviceClassManager.enablePrerendering()) return false;
migrateNetworkPredictionPreferences();
return canPrefetchAndPrerender();
}
......
......@@ -63,7 +63,6 @@ public class PrivacySettings
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
PrivacyPreferencesManagerImpl privacyPrefManager =
PrivacyPreferencesManagerImpl.getInstance();
privacyPrefManager.migrateNetworkPredictionPreferences();
SettingsUtils.addPreferencesFromResource(this, R.xml.privacy_preferences);
assert NEW_PRIVACY_PREFERENCE_ORDER.length
== getPreferenceScreen().getPreferenceCount()
......
......@@ -98,8 +98,6 @@ public class GoogleServicesSettings
@Override
public void onCreatePreferences(@Nullable Bundle savedInstanceState, String rootKey) {
mPrivacyPrefManager.migrateNetworkPredictionPreferences();
getActivity().setTitle(R.string.prefs_google_services);
setHasOptionsMenu(true);
......
......@@ -173,8 +173,6 @@ public class SyncAndServicesSettings extends PreferenceFragmentCompat
mIsFromSigninScreen =
IntentUtils.safeGetBoolean(getArguments(), IS_FROM_SIGNIN_SCREEN, false);
mPrivacyPrefManager.migrateNetworkPredictionPreferences();
getActivity().setTitle(R.string.prefs_sync_and_services);
setHasOptionsMenu(true);
if (mIsFromSigninScreen) {
......
......@@ -545,7 +545,6 @@ public final class ChromePreferenceKeys {
public static final String PRIVACY_METRICS_REPORTING = "metrics_reporting";
public static final String PRIVACY_METRICS_IN_SAMPLE = "in_metrics_sample";
public static final String PRIVACY_NETWORK_PREDICTIONS = "network_predictions";
public static final String PRIVACY_BANDWIDTH_OLD = "prefetch_bandwidth";
public static final String PRIVACY_BANDWIDTH_NO_CELLULAR_OLD = "prefetch_bandwidth_no_cellular";
public static final String PRIVACY_ALLOW_PRERENDER_OLD = "allow_prefetch";
......
......@@ -133,7 +133,6 @@ public class GrandfatheredChromePreferenceKeys {
ChromePreferenceKeys.PRIVACY_BANDWIDTH_OLD,
ChromePreferenceKeys.PRIVACY_METRICS_IN_SAMPLE,
ChromePreferenceKeys.PRIVACY_METRICS_REPORTING,
ChromePreferenceKeys.PRIVACY_NETWORK_PREDICTIONS,
ChromePreferenceKeys.PROFILES_BOOT_TIMESTAMP,
ChromePreferenceKeys.PROMOS_SKIPPED_ON_FIRST_START,
ChromePreferenceKeys.REACHED_CODE_PROFILER_GROUP,
......
......@@ -10,13 +10,6 @@ import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa
* Manages preferences related to privacy, metrics reporting, prerendering, and network prediction.
*/
public interface PrivacyPreferencesManager extends CrashReportingPermissionManager {
/**
* Migrate and delete old preferences. Note that migration has to happen in Android-specific
* code because we need to access ALLOW_PRERENDER sharedPreference.
* TODO(crbug.com/526773): remove this migration code.
*/
void migrateNetworkPredictionPreferences();
/**
* Checks whether prerender should be allowed and updates the preference if it is not set yet.
* @return Whether prerendering should be allowed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment