Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesBasic.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesBasic.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesBasic.java |
| index 8241c0ac83ab6c5c76f28bb861042559ae87885d..5aaa0d5bcc77f098fa5e7d6aa0a303b1d86c943f 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesBasic.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/privacy/ClearBrowsingDataPreferencesBasic.java |
| @@ -4,13 +4,69 @@ |
| package org.chromium.chrome.browser.preferences.privacy; |
| +import android.os.Bundle; |
| + |
| +import org.chromium.base.VisibleForTesting; |
| +import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.browsing_data.ClearBrowsingDataTab; |
| +import org.chromium.chrome.browser.preferences.ClearBrowsingDataTabCheckBoxPreference; |
| +import org.chromium.chrome.browser.sync.ProfileSyncService; |
| +import org.chromium.chrome.browser.tabmodel.TabModel; |
| +import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
| +import org.chromium.components.signin.ChromeSigninController; |
| +import org.chromium.components.sync.AndroidSyncSettings; |
| +import org.chromium.components.sync.ModelType; |
| /** |
| * A simpler version of {@link ClearBrowsingDataPreferences} with fewer dialog options and more |
| * explanatory text. |
| */ |
| public class ClearBrowsingDataPreferencesBasic extends ClearBrowsingDataPreferencesTab { |
| + /** Id of checkbox preference for history. */ |
| + @VisibleForTesting |
| + public static final String HISTORY_CHECKBOX = "clear_history_checkbox"; |
| + /** Id of checkbox preference for cookies. */ |
| + @VisibleForTesting |
| + public static final String COOKIES_CHECKBOX = "clear_cookies_checkbox"; |
|
Theresa
2017/03/24 17:15:37
Can the superclass versions of these be made publi
dullweber
2017/03/27 14:11:04
yes, I will do that
|
| + /** The my activity URL. */ |
| + private static final String MY_ACTIVITY_URL = |
| + "https://myactivity.google.com/myactivity/?utm_source=chrome_cbd"; |
| + |
| + @Override |
| + public void onCreate(Bundle savedInstanceState) { |
| + super.onCreate(savedInstanceState); |
| + |
| + ClearBrowsingDataTabCheckBoxPreference historyCheckbox = |
| + (ClearBrowsingDataTabCheckBoxPreference) findPreference(HISTORY_CHECKBOX); |
| + ClearBrowsingDataTabCheckBoxPreference cookiesCheckbox = |
| + (ClearBrowsingDataTabCheckBoxPreference) findPreference(COOKIES_CHECKBOX); |
| + |
| + historyCheckbox.setLinkClickDelegate(new Runnable() { |
| + @Override |
| + public void run() { |
| + new TabDelegate(false /* incognito */) |
| + .launchUrl(MY_ACTIVITY_URL, TabModel.TabLaunchType.FROM_CHROME_UI); |
| + } |
| + }); |
| + |
| + if (ChromeSigninController.get(getActivity()).isSignedIn()) { |
|
Theresa
2017/03/24 17:15:37
The sign in state can change, possibly in a separa
dullweber
2017/03/27 14:11:04
The old ui uses a similar check to decide which fo
Theresa
2017/03/27 15:24:52
Yes, signing out in Android settings would do it.
|
| + if (isHistorySyncEnabled()) { // is synced |
| + historyCheckbox.setSummary(R.string.clear_browsing_history_summary_synced); |
| + } else { |
| + historyCheckbox.setSummary(R.string.clear_browsing_history_summary_signed_in); |
| + } |
| + cookiesCheckbox.setSummary( |
| + R.string.clear_cookies_and_site_data_signed_in_summary_basic); |
| + } |
| + } |
| + |
| + private boolean isHistorySyncEnabled() { |
| + boolean syncEnabled = AndroidSyncSettings.isSyncEnabled(getActivity()); |
| + ProfileSyncService syncService = ProfileSyncService.get(); |
| + return syncEnabled && syncService != null |
| + && syncService.getPreferredDataTypes().contains(ModelType.TYPED_URLS); |
| + } |
| + |
| @Override |
| protected DialogOption[] getDialogOptions() { |
| return new DialogOption[] {DialogOption.CLEAR_HISTORY, |