Java Code Examples for org.chromium.chrome.browser.preferences.PrefServiceBridge#clearBrowsingData()

The following examples show how to use org.chromium.chrome.browser.preferences.PrefServiceBridge#clearBrowsingData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeApplication.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Update the accept languages after changing Android locale setting. Doing so kills the
 * Activities but it doesn't kill the ChromeApplication, so this should be called in
 * {@link #onStart} instead of {@link #initialize}.
 */
private void updateAcceptLanguages() {
    PrefServiceBridge instance = PrefServiceBridge.getInstance();
    String localeString = Locale.getDefault().toString();  // ex) en_US, de_DE, zh_CN_#Hans
    if (hasLocaleChanged(localeString)) {
        instance.resetAcceptLanguages(localeString);
        // Clear cache so that accept-languages change can be applied immediately.
        // TODO(changwan): The underlying BrowsingDataRemover::Remove() is an asynchronous call.
        // So cache-clearing may not be effective if URL rendering can happen before
        // OnBrowsingDataRemoverDone() is called, in which case we may have to reload as well.
        // Check if it can happen.
        instance.clearBrowsingData(
                null, new int[]{ BrowsingDataType.CACHE }, TimePeriod.EVERYTHING);
    }
}
 
Example 2
Source File: ChromeActivitySessionTracker.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Update the accept languages after changing Android locale setting. Doing so kills the
 * Activities but it doesn't kill the Application, so this should be called in
 * {@link #onStart} instead of {@link #initialize}.
 */
private void updateAcceptLanguages() {
    PrefServiceBridge instance = PrefServiceBridge.getInstance();
    String localeString = LocaleUtils.getDefaultLocaleListString();
    if (hasLocaleChanged(localeString)) {
        instance.resetAcceptLanguages(localeString);
        // Clear cache so that accept-languages change can be applied immediately.
        // TODO(changwan): The underlying BrowsingDataRemover::Remove() is an asynchronous call.
        // So cache-clearing may not be effective if URL rendering can happen before
        // OnBrowsingDataRemoverDone() is called, in which case we may have to reload as well.
        // Check if it can happen.
        instance.clearBrowsingData(
                null, new int[]{ BrowsingDataType.CACHE }, TimePeriod.ALL_TIME);
    }
}