Commit 2673b441 authored by ianwen's avatar ianwen Committed by Commit bot

Adjust Chrome to normal behavior once user leaves special locale

If the user leaves a special locale, changes we made previously shall be
reverted.

BUG=638062

Review-Url: https://codereview.chromium.org/2385543002
Cr-Commit-Position: refs/heads/master@{#422956}
parent c9604416
......@@ -435,6 +435,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
mTabModelSelectorImpl.saveState();
StartupMetrics.getInstance().recordHistogram(true);
mActivityStopMetrics.onStopWithNative(this);
mLocaleManager.stopObservingPhoneChanges();
}
@Override
......@@ -449,6 +451,8 @@ public class ChromeTabbedActivity extends ChromeActivity implements OverviewMode
// If we don't have a current tab, show the overview mode.
if (getActivityTab() == null) mLayoutManager.showOverview(false);
mLocaleManager.startObservingPhoneChanges();
resetSavedInstanceState();
}
......
......@@ -17,12 +17,23 @@ import org.chromium.chrome.browser.ChromeFeatureList;
*/
public class LocaleManager {
public static final String PREF_PROMO_SHOWN = "LocaleManager_PREF_PROMO_SHOWN";
public static final String PREF_WAS_IN_SPECIAL_LOCALE = "LocaleManager_WAS_IN_SPECIAL_LOCALE";
public static final String SPECIAL_LOCALE_ID = "US";
private static LocaleManager sInstance;
private SpecialLocaleHandler mLocaleHandler;
/**
* Starts listening to state changes of the phone.
*/
public void startObservingPhoneChanges() {}
/**
* Stops listening to state changes of the phone.
*/
public void stopObservingPhoneChanges() {}
/**
* @return An instance of the {@link LocaleManager}. This should only be called on UI thread.
*/
......@@ -49,7 +60,10 @@ public class LocaleManager {
return false;
}
boolean inSpecialLocale = ChromeFeatureList.isEnabled("SpecialLocale");
return isReallyInSpecialLocale(inSpecialLocale);
inSpecialLocale = isReallyInSpecialLocale(inSpecialLocale);
ContextUtils.getAppSharedPreferences().edit()
.putBoolean(PREF_WAS_IN_SPECIAL_LOCALE, inSpecialLocale).apply();
return inSpecialLocale;
}
/**
......@@ -63,7 +77,6 @@ public class LocaleManager {
* Adds local search engines for special locale.
*/
public void addSpecialSearchEngines() {
// TODO(ianwen): Let this method be called in ChromeActivity#finishNativeInitialization().
if (!isSpecialLocaleEnabled()) return;
getSpecialLocaleHandler().loadTemplateUrls();
}
......@@ -82,7 +95,6 @@ public class LocaleManager {
* Removes local search engines for special locale.
*/
public void removeSpecialSearchEngines() {
// TODO(ianwen): Let this method be called when device configuration changes.
if (isSpecialLocaleEnabled()) return;
getSpecialLocaleHandler().removeTemplateUrls();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment