Commit 4475e60e authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Downloads : Added settings to disable prefetch

Added a setting to enable/disable prefetch in downloads settings.
This settings will not be visible if prefetching feature is not enabled.
UX: https://gallery.googleplex.com/projects/MCHbtQVoQ2HCZa-WKS_VfBWp/files/MCHtA7U1iMGr6yF79JTTnBdio_aEa3M5pNg

Bug: 850588
Change-Id: Icb1f4a504c88878ada36c9e642819669e9ee7409
Reviewed-on: https://chromium-review.googlesource.com/1139590
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580070}
parent ac99cce4
......@@ -16,4 +16,9 @@
android:summaryOn="@string/text_on"
android:summaryOff="@string/text_off" />
<org.chromium.chrome.browser.preferences.ChromeSwitchPreference
android:key="prefetching_enabled"
android:title="@string/download_settings_enable_prefetch_title"
android:summary="@string/download_settings_enable_prefetch_description" />
</PreferenceScreen>
......@@ -11,6 +11,7 @@ import android.support.annotation.Nullable;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadPromptStatus;
import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchConfiguration;
import org.chromium.chrome.browser.preferences.ChromeSwitchPreference;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.PreferenceUtils;
......@@ -22,9 +23,11 @@ public class DownloadPreferences
extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
public static final String PREF_LOCATION_CHANGE = "location_change";
private static final String PREF_LOCATION_PROMPT_ENABLED = "location_prompt_enabled";
private static final String PREF_PREFETCHING_ENABLED = "prefetching_enabled";
private DownloadLocationPreference mLocationChangePref;
private ChromeSwitchPreference mLocationPromptEnabledPref;
private ChromeSwitchPreference mPrefetchingEnabled;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
......@@ -38,6 +41,13 @@ public class DownloadPreferences
mLocationPromptEnabledPref.setOnPreferenceChangeListener(this);
mLocationChangePref = (DownloadLocationPreference) findPreference(PREF_LOCATION_CHANGE);
if (PrefetchConfiguration.isPrefetchingFlagEnabled()) {
mPrefetchingEnabled = (ChromeSwitchPreference) findPreference(PREF_PREFETCHING_ENABLED);
mPrefetchingEnabled.setOnPreferenceChangeListener(this);
} else {
getPreferenceScreen().removePreference(findPreference(PREF_PREFETCHING_ENABLED));
}
}
@Override
......@@ -58,6 +68,10 @@ public class DownloadPreferences
!= DownloadPromptStatus.DONT_SHOW;
mLocationPromptEnabledPref.setChecked(isLocationPromptEnabled);
}
if (mPrefetchingEnabled != null) {
mPrefetchingEnabled.setChecked(PrefetchConfiguration.isPrefetchingEnabled());
}
}
// Preference.OnPreferenceChangeListener implementation.
......@@ -76,6 +90,8 @@ public class DownloadPreferences
PrefServiceBridge.getInstance().setPromptForDownloadAndroid(
DownloadPromptStatus.DONT_SHOW);
}
} else if (PREF_PREFETCHING_ENABLED.equals(preference.getKey())) {
PrefetchConfiguration.setPrefetchingEnabledInSettings((boolean) newValue);
}
return true;
}
......
......@@ -1350,6 +1350,12 @@ To obtain new licenses, connect to the internet and play your downloaded content
<message name="IDS_DOWNLOAD_LOCATION_NO_AVAILABLE_LOCATIONS" desc="Text that indicates to the user that there are no download locations available.">
No available download locations
</message>
<message name="IDS_DOWNLOAD_SETTINGS_ENABLE_PREFETCH_TITLE" desc="Title for preference that allows the user to enable or disable the prefetching of articles. Please ensure the words 'articles for you' match the 'articles for you' in New Tab Page. ">
Download articles for you
</message>
<message name="IDS_DOWNLOAD_SETTINGS_ENABLE_PREFETCH_DESCRIPTION" desc="Description for preference that describes that prefetching of articles only happens when connected to Wi-Fi.">
Download occurs only on Wi-Fi
</message>
<!-- About Chrome preferences -->
<message name="IDS_PREFS_ABOUT_CHROME" desc="Title for the About Chrome page. [CHAR-LIMIT=32]">
......
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