Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivitySessionTracker.java

Issue 2756173002: Move code about browsing data from PrefServiceBridge to BrowsingDataBridge. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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; 5 package org.chromium.chrome.browser;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.SharedPreferences; 8 import android.content.SharedPreferences;
9 import android.provider.Settings; 9 import android.provider.Settings;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
11 11
12 import org.chromium.base.ApplicationState; 12 import org.chromium.base.ApplicationState;
13 import org.chromium.base.ApplicationStatus; 13 import org.chromium.base.ApplicationStatus;
14 import org.chromium.base.ApplicationStatus.ApplicationStateListener; 14 import org.chromium.base.ApplicationStatus.ApplicationStateListener;
15 import org.chromium.base.ContextUtils; 15 import org.chromium.base.ContextUtils;
16 import org.chromium.base.LocaleUtils; 16 import org.chromium.base.LocaleUtils;
17 import org.chromium.base.ThreadUtils; 17 import org.chromium.base.ThreadUtils;
18 import org.chromium.base.VisibleForTesting; 18 import org.chromium.base.VisibleForTesting;
19 import org.chromium.base.metrics.RecordHistogram; 19 import org.chromium.base.metrics.RecordHistogram;
20 import org.chromium.chrome.browser.accessibility.FontSizePrefs; 20 import org.chromium.chrome.browser.accessibility.FontSizePrefs;
21 import org.chromium.chrome.browser.browsing_data.BrowsingDataType; 21 import org.chromium.chrome.browser.browsing_data.BrowsingDataType;
22 import org.chromium.chrome.browser.browsing_data.TimePeriod; 22 import org.chromium.chrome.browser.browsing_data.TimePeriod;
23 import org.chromium.chrome.browser.metrics.UmaUtils; 23 import org.chromium.chrome.browser.metrics.UmaUtils;
24 import org.chromium.chrome.browser.metrics.VariationsSession; 24 import org.chromium.chrome.browser.metrics.VariationsSession;
25 import org.chromium.chrome.browser.notifications.NotificationPlatformBridge; 25 import org.chromium.chrome.browser.notifications.NotificationPlatformBridge;
26 import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomiza tions; 26 import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomiza tions;
27 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 27 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
28 import org.chromium.chrome.browser.preferences.privacy.BrowsingDataBridge;
28 import org.chromium.chrome.browser.share.ShareHelper; 29 import org.chromium.chrome.browser.share.ShareHelper;
29 import org.chromium.chrome.browser.tabmodel.TabModelSelector; 30 import org.chromium.chrome.browser.tabmodel.TabModelSelector;
30 import org.chromium.chrome.browser.util.FeatureUtilities; 31 import org.chromium.chrome.browser.util.FeatureUtilities;
31 import org.chromium.content.browser.ChildProcessLauncher; 32 import org.chromium.content.browser.ChildProcessLauncher;
32 33
33 import java.lang.ref.WeakReference; 34 import java.lang.ref.WeakReference;
34 35
35 /** 36 /**
36 * Tracks the foreground session state for the Chrome activities. 37 * Tracks the foreground session state for the Chrome activities.
37 */ 38 */
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 180
180 /** 181 /**
181 * Update the accept languages after changing Android locale setting. Doing so kills the 182 * Update the accept languages after changing Android locale setting. Doing so kills the
182 * Activities but it doesn't kill the Application, so this should be called in 183 * Activities but it doesn't kill the Application, so this should be called in
183 * {@link #onStart} instead of {@link #initialize}. 184 * {@link #onStart} instead of {@link #initialize}.
184 */ 185 */
185 private void updateAcceptLanguages() { 186 private void updateAcceptLanguages() {
186 PrefServiceBridge instance = PrefServiceBridge.getInstance(); 187 PrefServiceBridge instance = PrefServiceBridge.getInstance();
187 String localeString = LocaleUtils.getDefaultLocaleListString(); 188 String localeString = LocaleUtils.getDefaultLocaleListString();
188 if (hasLocaleChanged(localeString)) { 189 if (hasLocaleChanged(localeString)) {
189 instance.resetAcceptLanguages(localeString); 190 instance.resetAcceptLanguages(localeString);
msramek 2017/03/23 16:02:04 nit: This should now be called differently, since
dullweber 2017/03/24 09:19:43 I removed the local variable because now it is onl
190 // Clear cache so that accept-languages change can be applied immedi ately. 191 // Clear cache so that accept-languages change can be applied immedi ately.
191 // TODO(changwan): The underlying BrowsingDataRemover::Remove() is a n asynchronous call. 192 // TODO(changwan): The underlying BrowsingDataRemover::Remove() is a n asynchronous call.
192 // So cache-clearing may not be effective if URL rendering can happe n before 193 // So cache-clearing may not be effective if URL rendering can happe n before
193 // OnBrowsingDataRemoverDone() is called, in which case we may have to reload as well. 194 // OnBrowsingDataRemoverDone() is called, in which case we may have to reload as well.
194 // Check if it can happen. 195 // Check if it can happen.
195 instance.clearBrowsingData( 196 BrowsingDataBridge.getInstance().clearBrowsingData(
196 null, new int[]{ BrowsingDataType.CACHE }, TimePeriod.ALL_TI ME); 197 null, new int[] {BrowsingDataType.CACHE}, TimePeriod.ALL_TIM E);
197 } 198 }
198 } 199 }
199 200
200 private boolean hasLocaleChanged(String newLocale) { 201 private boolean hasLocaleChanged(String newLocale) {
201 String previousLocale = ContextUtils.getAppSharedPreferences().getString (PREF_LOCALE, null); 202 String previousLocale = ContextUtils.getAppSharedPreferences().getString (PREF_LOCALE, null);
202 if (!TextUtils.equals(previousLocale, newLocale)) { 203 if (!TextUtils.equals(previousLocale, newLocale)) {
203 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); 204 SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
204 SharedPreferences.Editor editor = prefs.edit(); 205 SharedPreferences.Editor editor = prefs.edit();
205 editor.putString(PREF_LOCALE, newLocale); 206 editor.putString(PREF_LOCALE, newLocale);
206 editor.apply(); 207 editor.apply();
(...skipping 27 matching lines...) Expand all
234 } 235 }
235 236
236 /** 237 /**
237 * @return The PowerBroadcastReceiver for the browser process. 238 * @return The PowerBroadcastReceiver for the browser process.
238 */ 239 */
239 @VisibleForTesting 240 @VisibleForTesting
240 public PowerBroadcastReceiver getPowerBroadcastReceiverForTesting() { 241 public PowerBroadcastReceiver getPowerBroadcastReceiverForTesting() {
241 return mPowerBroadcastReceiver; 242 return mPowerBroadcastReceiver;
242 } 243 }
243 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698