OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.preferences.privacy; | 5 package org.chromium.chrome.browser.preferences.privacy; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.ProgressDialog; | 8 import android.app.ProgressDialog; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.graphics.drawable.Drawable; | 10 import android.graphics.drawable.Drawable; |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 import java.util.Arrays; | 41 import java.util.Arrays; |
42 import java.util.EnumSet; | 42 import java.util.EnumSet; |
43 | 43 |
44 /** | 44 /** |
45 * Preference screen that allows the user to clear browsing data. | 45 * Preference screen that allows the user to clear browsing data. |
46 * The user can choose which types of data to clear (history, cookies, etc), and
the time range | 46 * The user can choose which types of data to clear (history, cookies, etc), and
the time range |
47 * from which to clear data. | 47 * from which to clear data. |
48 */ | 48 */ |
49 public class ClearBrowsingDataPreferences extends PreferenceFragment | 49 public class ClearBrowsingDataPreferences extends PreferenceFragment |
50 implements PrefServiceBridge.ImportantSitesCallback, | 50 implements BrowsingDataBridge.ImportantSitesCallback, |
51 PrefServiceBridge.OnClearBrowsingDataListener, | 51 BrowsingDataBridge.OnClearBrowsingDataListener, |
52 PrefServiceBridge.OtherFormsOfBrowsingHistoryListener, | 52 BrowsingDataBridge.OtherFormsOfBrowsingHistoryListener, |
53 Preference.OnPreferenceClickListener, Preference.OnPreference
ChangeListener { | 53 Preference.OnPreferenceClickListener, Preference.OnPreference
ChangeListener { |
54 /** | 54 /** |
55 * Represents a single item in the dialog. | 55 * Represents a single item in the dialog. |
56 */ | 56 */ |
57 private static class Item implements BrowsingDataCounterCallback, | 57 private static class Item implements BrowsingDataCounterCallback, |
58 Preference.OnPreferenceClickListener { | 58 Preference.OnPreferenceClickListener { |
59 private static final int MIN_DP_FOR_ICON = 360; | 59 private static final int MIN_DP_FOR_ICON = 360; |
60 private final ClearBrowsingDataPreferences mParent; | 60 private final ClearBrowsingDataPreferences mParent; |
61 private final DialogOption mOption; | 61 private final DialogOption mOption; |
62 private final ClearBrowsingDataCheckBoxPreference mCheckbox; | 62 private final ClearBrowsingDataCheckBoxPreference mCheckbox; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 int i = 0; | 307 int i = 0; |
308 for (DialogOption option : options) { | 308 for (DialogOption option : options) { |
309 dataTypes[i] = option.getDataType(); | 309 dataTypes[i] = option.getDataType(); |
310 ++i; | 310 ++i; |
311 } | 311 } |
312 | 312 |
313 Object spinnerSelection = | 313 Object spinnerSelection = |
314 ((SpinnerPreference) findPreference(PREF_TIME_RANGE)).getSelecte
dOption(); | 314 ((SpinnerPreference) findPreference(PREF_TIME_RANGE)).getSelecte
dOption(); |
315 int timePeriod = ((TimePeriodSpinnerOption) spinnerSelection).getTimePer
iod(); | 315 int timePeriod = ((TimePeriodSpinnerOption) spinnerSelection).getTimePer
iod(); |
316 if (blacklistedDomains != null && blacklistedDomains.length != 0) { | 316 if (blacklistedDomains != null && blacklistedDomains.length != 0) { |
317 PrefServiceBridge.getInstance().clearBrowsingDataExcludingDomains(th
is, dataTypes, | 317 BrowsingDataBridge.getInstance().clearBrowsingDataExcludingDomains(t
his, dataTypes, |
318 timePeriod, blacklistedDomains, blacklistedDomainReasons, ig
noredDomains, | 318 timePeriod, blacklistedDomains, blacklistedDomainReasons, ig
noredDomains, |
319 ignoredDomainReasons); | 319 ignoredDomainReasons); |
320 } else { | 320 } else { |
321 PrefServiceBridge.getInstance().clearBrowsingData(this, dataTypes, t
imePeriod); | 321 BrowsingDataBridge.getInstance().clearBrowsingData(this, dataTypes,
timePeriod); |
322 } | 322 } |
323 | 323 |
324 // Clear all reported entities. | 324 // Clear all reported entities. |
325 AppIndexingReporter.getInstance().clearHistory(); | 325 AppIndexingReporter.getInstance().clearHistory(); |
326 } | 326 } |
327 | 327 |
328 private void dismissProgressDialog() { | 328 private void dismissProgressDialog() { |
329 if (mProgressDialog != null && mProgressDialog.isShowing()) { | 329 if (mProgressDialog != null && mProgressDialog.isShowing()) { |
330 mProgressDialog.dismiss(); | 330 mProgressDialog.dismiss(); |
331 } | 331 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 * @return The id of the preference xml that should be displayed. | 492 * @return The id of the preference xml that should be displayed. |
493 */ | 493 */ |
494 protected int getPreferenceXmlId() { | 494 protected int getPreferenceXmlId() { |
495 return R.xml.clear_browsing_data_preferences; | 495 return R.xml.clear_browsing_data_preferences; |
496 } | 496 } |
497 | 497 |
498 @Override | 498 @Override |
499 public void onCreate(Bundle savedInstanceState) { | 499 public void onCreate(Bundle savedInstanceState) { |
500 super.onCreate(savedInstanceState); | 500 super.onCreate(savedInstanceState); |
501 RecordUserAction.record("ClearBrowsingData_DialogCreated"); | 501 RecordUserAction.record("ClearBrowsingData_DialogCreated"); |
502 mMaxImportantSites = PrefServiceBridge.getMaxImportantSites(); | 502 mMaxImportantSites = BrowsingDataBridge.getMaxImportantSites(); |
503 PrefServiceBridge.getInstance().requestInfoAboutOtherFormsOfBrowsingHist
ory(this); | 503 BrowsingDataBridge.getInstance().requestInfoAboutOtherFormsOfBrowsingHis
tory(this); |
504 getActivity().setTitle(R.string.clear_browsing_data_title); | 504 getActivity().setTitle(R.string.clear_browsing_data_title); |
505 addPreferencesFromResource(getPreferenceXmlId()); | 505 addPreferencesFromResource(getPreferenceXmlId()); |
506 DialogOption[] options = getDialogOptions(); | 506 DialogOption[] options = getDialogOptions(); |
507 mItems = new Item[options.length]; | 507 mItems = new Item[options.length]; |
508 for (int i = 0; i < options.length; i++) { | 508 for (int i = 0; i < options.length; i++) { |
509 boolean enabled = true; | 509 boolean enabled = true; |
510 | 510 |
511 // It is possible to disable the deletion of browsing history. | 511 // It is possible to disable the deletion of browsing history. |
512 if (options[i] == DialogOption.CLEAR_HISTORY | 512 if (options[i] == DialogOption.CLEAR_HISTORY |
513 && !PrefServiceBridge.getInstance().canDeleteBrowsingHistory
()) { | 513 && !PrefServiceBridge.getInstance().canDeleteBrowsingHistory
()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 break; | 549 break; |
550 } | 550 } |
551 } | 551 } |
552 assert spinnerOptionIndex != -1; | 552 assert spinnerOptionIndex != -1; |
553 spinner.setOptions(spinnerOptions, spinnerOptionIndex); | 553 spinner.setOptions(spinnerOptions, spinnerOptionIndex); |
554 | 554 |
555 initClearButtonPreference(); | 555 initClearButtonPreference(); |
556 initFootnote(); | 556 initFootnote(); |
557 | 557 |
558 if (ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD
)) { | 558 if (ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD
)) { |
559 PrefServiceBridge.fetchImportantSites(this); | 559 BrowsingDataBridge.fetchImportantSites(this); |
560 } | 560 } |
561 } | 561 } |
562 | 562 |
563 /** | 563 /** |
564 * Initialize the ButtonPreference. | 564 * Initialize the ButtonPreference. |
565 */ | 565 */ |
566 protected void initClearButtonPreference() { | 566 protected void initClearButtonPreference() { |
567 ButtonPreference clearButton = (ButtonPreference) findPreference(PREF_CL
EAR_BUTTON); | 567 ButtonPreference clearButton = (ButtonPreference) findPreference(PREF_CL
EAR_BUTTON); |
568 clearButton.setOnPreferenceClickListener(this); | 568 clearButton.setOnPreferenceClickListener(this); |
569 clearButton.setShouldDisableView(true); | 569 clearButton.setShouldDisableView(true); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 "History.ClearBrowsingData.ImportantIgnoredPercent", | 735 "History.ClearBrowsingData.ImportantIgnoredPercent", |
736 ignoredDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKE
T_COUNT | 736 ignoredDomains.length * IMPORTANT_SITES_PERCENTAGE_BUCKE
T_COUNT |
737 / mSortedImportantDomains.length, | 737 / mSortedImportantDomains.length, |
738 IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1); | 738 IMPORTANT_SITES_PERCENTAGE_BUCKET_COUNT + 1); |
739 } | 739 } |
740 clearBrowsingData(getSelectedOptions(), deselectedDomains, deselecte
dDomainReasons, | 740 clearBrowsingData(getSelectedOptions(), deselectedDomains, deselecte
dDomainReasons, |
741 ignoredDomains, ignoredDomainReasons); | 741 ignoredDomains, ignoredDomainReasons); |
742 } | 742 } |
743 } | 743 } |
744 } | 744 } |
OLD | NEW |