OLD | NEW |
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 177 } |
177 }; | 178 }; |
178 } | 179 } |
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 String localeString = LocaleUtils.getDefaultLocaleListString(); | 187 String localeString = LocaleUtils.getDefaultLocaleListString(); |
188 if (hasLocaleChanged(localeString)) { | 188 if (hasLocaleChanged(localeString)) { |
189 instance.resetAcceptLanguages(localeString); | 189 PrefServiceBridge.getInstance().resetAcceptLanguages(localeString); |
190 // Clear cache so that accept-languages change can be applied immedi
ately. | 190 // Clear cache so that accept-languages change can be applied immedi
ately. |
191 // TODO(changwan): The underlying BrowsingDataRemover::Remove() is a
n asynchronous call. | 191 // 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 | 192 // 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. | 193 // OnBrowsingDataRemoverDone() is called, in which case we may have
to reload as well. |
194 // Check if it can happen. | 194 // Check if it can happen. |
195 instance.clearBrowsingData( | 195 BrowsingDataBridge.getInstance().clearBrowsingData( |
196 null, new int[]{ BrowsingDataType.CACHE }, TimePeriod.ALL_TI
ME); | 196 null, new int[] {BrowsingDataType.CACHE}, TimePeriod.ALL_TIM
E); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 private boolean hasLocaleChanged(String newLocale) { | 200 private boolean hasLocaleChanged(String newLocale) { |
201 String previousLocale = ContextUtils.getAppSharedPreferences().getString
(PREF_LOCALE, null); | 201 String previousLocale = ContextUtils.getAppSharedPreferences().getString
(PREF_LOCALE, null); |
202 if (!TextUtils.equals(previousLocale, newLocale)) { | 202 if (!TextUtils.equals(previousLocale, newLocale)) { |
203 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); | 203 SharedPreferences prefs = ContextUtils.getAppSharedPreferences(); |
204 SharedPreferences.Editor editor = prefs.edit(); | 204 SharedPreferences.Editor editor = prefs.edit(); |
205 editor.putString(PREF_LOCALE, newLocale); | 205 editor.putString(PREF_LOCALE, newLocale); |
206 editor.apply(); | 206 editor.apply(); |
(...skipping 27 matching lines...) Expand all Loading... |
234 } | 234 } |
235 | 235 |
236 /** | 236 /** |
237 * @return The PowerBroadcastReceiver for the browser process. | 237 * @return The PowerBroadcastReceiver for the browser process. |
238 */ | 238 */ |
239 @VisibleForTesting | 239 @VisibleForTesting |
240 public PowerBroadcastReceiver getPowerBroadcastReceiverForTesting() { | 240 public PowerBroadcastReceiver getPowerBroadcastReceiverForTesting() { |
241 return mPowerBroadcastReceiver; | 241 return mPowerBroadcastReceiver; |
242 } | 242 } |
243 } | 243 } |
OLD | NEW |