Chromium Code Reviews| 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.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 import android.support.annotation.Nullable; |
| 12 | 12 |
| 13 import org.chromium.base.Callback; | |
| 13 import org.chromium.base.ContextUtils; | 14 import org.chromium.base.ContextUtils; |
| 14 import org.chromium.base.ThreadUtils; | 15 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.chrome.R; | 16 import org.chromium.chrome.R; |
| 16 import org.chromium.chrome.browser.AppHooks; | 17 import org.chromium.chrome.browser.AppHooks; |
| 17 import org.chromium.chrome.browser.ChromeFeatureList; | 18 import org.chromium.chrome.browser.ChromeFeatureList; |
| 18 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 19 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
| 19 import org.chromium.chrome.browser.preferences.SearchEnginePreference; | 20 import org.chromium.chrome.browser.preferences.SearchEnginePreference; |
| 20 import org.chromium.chrome.browser.snackbar.Snackbar; | 21 import org.chromium.chrome.browser.snackbar.Snackbar; |
| 21 import org.chromium.chrome.browser.snackbar.SnackbarManager; | 22 import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| 22 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; | 23 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 addSpecialSearchEngines(); | 172 addSpecialSearchEngines(); |
| 172 } | 173 } |
| 173 preferences.edit().putBoolean(PREF_WAS_IN_SPECIAL_LOCALE, isInSpecialLoc ale).apply(); | 174 preferences.edit().putBoolean(PREF_WAS_IN_SPECIAL_LOCALE, isInSpecialLoc ale).apply(); |
| 174 } | 175 } |
| 175 | 176 |
| 176 /** | 177 /** |
| 177 * Shows a promotion dialog about search engines depending on Locale and oth er conditions. | 178 * Shows a promotion dialog about search engines depending on Locale and oth er conditions. |
| 178 * See {@link LocaleManager#getSearchEnginePromoShowType()} for possible typ es and logic. | 179 * See {@link LocaleManager#getSearchEnginePromoShowType()} for possible typ es and logic. |
| 179 * | 180 * |
| 180 * @param context Context showing the dialog. | 181 * @param context Context showing the dialog. |
| 181 * @param onDismissed Run when the dialog has been dismissed. | 182 * @param onDismissed Notified when the dialog is dismissed about whether th e user acted on it. |
|
Ted C
2017/04/27 18:10:32
dismissed [and] whether the user acted on it?
gone
2017/04/27 18:15:22
little weird, but i'll go with it
| |
| 182 * @return Whether such dialog is needed. | 183 * @return Whether such dialog is needed. |
| 183 */ | 184 */ |
| 184 public boolean showSearchEnginePromoIfNeeded(Context context, @Nullable Runn able onDismissed) { | 185 public boolean showSearchEnginePromoIfNeeded( |
| 186 Context context, @Nullable Callback<Boolean> onDismissed) { | |
| 185 int shouldShow = getSearchEnginePromoShowType(); | 187 int shouldShow = getSearchEnginePromoShowType(); |
| 186 switch (shouldShow) { | 188 switch (shouldShow) { |
| 187 case SEARCH_ENGINE_PROMO_DONT_SHOW: | 189 case SEARCH_ENGINE_PROMO_DONT_SHOW: |
| 188 return false; | 190 return false; |
| 189 case SEARCH_ENGINE_PROMO_SHOW_SOGOU: | 191 case SEARCH_ENGINE_PROMO_SHOW_SOGOU: |
| 190 new SogouPromoDialog(context, this, onDismissed).show(); | 192 new SogouPromoDialog(context, this, onDismissed).show(); |
| 191 return true; | 193 return true; |
| 192 case SEARCH_ENGINE_PROMO_SHOW_EXISTING: | 194 case SEARCH_ENGINE_PROMO_SHOW_EXISTING: |
| 193 case SEARCH_ENGINE_PROMO_SHOW_NEW: | 195 case SEARCH_ENGINE_PROMO_SHOW_NEW: |
| 194 // TODO(dfalcantara): Show the search engine dialog. | 196 DefaultSearchEnginePromoDialog.show(context, shouldShow, onDismi ssed); |
| 195 return false; | 197 return true; |
| 196 default: | 198 default: |
| 197 assert false; | 199 assert false; |
| 198 return false; | 200 return false; |
| 199 } | 201 } |
| 200 } | 202 } |
| 201 | 203 |
| 202 /** | 204 /** |
| 203 * @return Whether auto switch for search engine is enabled. | 205 * @return Whether auto switch for search engine is enabled. |
| 204 */ | 206 */ |
| 205 public boolean isSearchEngineAutoSwitchEnabled() { | 207 public boolean isSearchEngineAutoSwitchEnabled() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 return SEARCH_ENGINE_PROMO_DONT_SHOW; | 255 return SEARCH_ENGINE_PROMO_DONT_SHOW; |
| 254 } | 256 } |
| 255 return SEARCH_ENGINE_PROMO_SHOW_SOGOU; | 257 return SEARCH_ENGINE_PROMO_SHOW_SOGOU; |
| 256 } | 258 } |
| 257 | 259 |
| 258 private SpecialLocaleHandler getSpecialLocaleHandler() { | 260 private SpecialLocaleHandler getSpecialLocaleHandler() { |
| 259 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId()); | 261 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId()); |
| 260 return mLocaleHandler; | 262 return mLocaleHandler; |
| 261 } | 263 } |
| 262 } | 264 } |
| OLD | NEW |