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

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

Issue 2838833002: 🔍 Introduce default search engine dialog (Closed)
Patch Set: Redo how the dialog is created Created 3 years, 7 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.locale; 5 package org.chromium.chrome.browser.locale;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.content.SharedPreferences; 9 import android.content.SharedPreferences;
10 import android.support.annotation.IntDef; 10 import android.support.annotation.IntDef;
11 import android.support.annotation.Nullable;
11 12
12 import org.chromium.base.ContextUtils; 13 import org.chromium.base.ContextUtils;
13 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
14 import org.chromium.chrome.R; 15 import org.chromium.chrome.R;
15 import org.chromium.chrome.browser.AppHooks; 16 import org.chromium.chrome.browser.AppHooks;
16 import org.chromium.chrome.browser.ChromeFeatureList; 17 import org.chromium.chrome.browser.ChromeFeatureList;
17 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 18 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
18 import org.chromium.chrome.browser.preferences.SearchEnginePreference; 19 import org.chromium.chrome.browser.preferences.SearchEnginePreference;
19 import org.chromium.chrome.browser.snackbar.Snackbar; 20 import org.chromium.chrome.browser.snackbar.Snackbar;
20 import org.chromium.chrome.browser.snackbar.SnackbarManager; 21 import org.chromium.chrome.browser.snackbar.SnackbarManager;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // As long as the user is in the special locale, special engines sho uld be in the list. 170 // As long as the user is in the special locale, special engines sho uld be in the list.
170 addSpecialSearchEngines(); 171 addSpecialSearchEngines();
171 } 172 }
172 preferences.edit().putBoolean(PREF_WAS_IN_SPECIAL_LOCALE, isInSpecialLoc ale).apply(); 173 preferences.edit().putBoolean(PREF_WAS_IN_SPECIAL_LOCALE, isInSpecialLoc ale).apply();
173 } 174 }
174 175
175 /** 176 /**
176 * Shows a promotion dialog about search engines depending on Locale and oth er conditions. 177 * Shows a promotion dialog about search engines depending on Locale and oth er conditions.
177 * See {@link LocaleManager#getSearchEnginePromoShowType()} for possible typ es and logic. 178 * See {@link LocaleManager#getSearchEnginePromoShowType()} for possible typ es and logic.
178 * 179 *
180 * @param context Context showing the dialog.
181 * @param onSelected Run when the dialog has been closed.
179 * @return Whether such dialog is needed. 182 * @return Whether such dialog is needed.
180 */ 183 */
181 public boolean showSearchEnginePromoIfNeeded(Context context) { 184 public boolean showSearchEnginePromoIfNeeded(Context context, @Nullable Runn able onSelected) {
182 int shouldShow = getSearchEnginePromoShowType(); 185 int shouldShow = getSearchEnginePromoShowType();
183 186 switch (shouldShow) {
184 if (shouldShow == SEARCH_ENGINE_PROMO_SHOW_SOGOU) { 187 case SEARCH_ENGINE_PROMO_DONT_SHOW:
185 new SogouPromoDialog(context, this).show(); 188 return false;
186 return true; 189 case SEARCH_ENGINE_PROMO_SHOW_SOGOU:
190 new SogouPromoDialog(context, this, onSelected).show();
191 return true;
192 case SEARCH_ENGINE_PROMO_SHOW_EXISTING:
193 case SEARCH_ENGINE_PROMO_SHOW_NEW:
194 DefaultSearchEnginePromoDialog.create(context, shouldShow, onSel ected);
195 return true;
196 default:
197 assert false;
198 return false;
187 } 199 }
188 return false;
189 } 200 }
190 201
191 /** 202 /**
192 * @return Whether auto switch for search engine is enabled. 203 * @return Whether auto switch for search engine is enabled.
193 */ 204 */
194 public boolean isSearchEngineAutoSwitchEnabled() { 205 public boolean isSearchEngineAutoSwitchEnabled() {
195 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_AUTO_SWITC H, false); 206 return ContextUtils.getAppSharedPreferences().getBoolean(PREF_AUTO_SWITC H, false);
196 } 207 }
197 208
198 /** 209 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return SEARCH_ENGINE_PROMO_DONT_SHOW; 253 return SEARCH_ENGINE_PROMO_DONT_SHOW;
243 } 254 }
244 return SEARCH_ENGINE_PROMO_SHOW_SOGOU; 255 return SEARCH_ENGINE_PROMO_SHOW_SOGOU;
245 } 256 }
246 257
247 private SpecialLocaleHandler getSpecialLocaleHandler() { 258 private SpecialLocaleHandler getSpecialLocaleHandler() {
248 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId()); 259 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId());
249 return mLocaleHandler; 260 return mLocaleHandler;
250 } 261 }
251 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698