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

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

Issue 2872453005: Add Yandex referral ID to search URL. (Closed)
Patch Set: Clear app data in test setup to remove initial locale set for search engines from previous runs. 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
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import android.support.annotation.Nullable;
12 12
13 import org.chromium.base.Callback; 13 import org.chromium.base.Callback;
14 import org.chromium.base.ContextUtils; 14 import org.chromium.base.ContextUtils;
15 import org.chromium.base.ThreadUtils; 15 import org.chromium.base.ThreadUtils;
16 import org.chromium.base.VisibleForTesting; 16 import org.chromium.base.VisibleForTesting;
17 import org.chromium.base.annotations.CalledByNative;
17 import org.chromium.chrome.R; 18 import org.chromium.chrome.R;
18 import org.chromium.chrome.browser.AppHooks; 19 import org.chromium.chrome.browser.AppHooks;
19 import org.chromium.chrome.browser.ChromeFeatureList; 20 import org.chromium.chrome.browser.ChromeFeatureList;
20 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 21 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
21 import org.chromium.chrome.browser.preferences.SearchEnginePreference; 22 import org.chromium.chrome.browser.preferences.SearchEnginePreference;
22 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 23 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
23 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ; 24 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ;
24 import org.chromium.chrome.browser.snackbar.Snackbar; 25 import org.chromium.chrome.browser.snackbar.Snackbar;
25 import org.chromium.chrome.browser.snackbar.SnackbarManager; 26 import org.chromium.chrome.browser.snackbar.SnackbarManager;
26 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; 27 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 Context context = ContextUtils.getApplicationContext(); 81 Context context = ContextUtils.getApplicationContext();
81 Intent intent = PreferencesLauncher.createIntentForSettingsPage(cont ext, 82 Intent intent = PreferencesLauncher.createIntentForSettingsPage(cont ext,
82 SearchEnginePreference.class.getName()); 83 SearchEnginePreference.class.getName());
83 context.startActivity(intent); 84 context.startActivity(intent);
84 } 85 }
85 }; 86 };
86 87
87 /** 88 /**
88 * @return An instance of the {@link LocaleManager}. This should only be cal led on UI thread. 89 * @return An instance of the {@link LocaleManager}. This should only be cal led on UI thread.
89 */ 90 */
91 @CalledByNative
90 public static LocaleManager getInstance() { 92 public static LocaleManager getInstance() {
91 assert ThreadUtils.runningOnUiThread(); 93 assert ThreadUtils.runningOnUiThread();
92 if (sInstance == null) { 94 if (sInstance == null) {
93 sInstance = AppHooks.get().createLocaleManager(); 95 sInstance = AppHooks.get().createLocaleManager();
94 } 96 }
95 return sInstance; 97 return sInstance;
96 } 98 }
97 99
98 /** 100 /**
99 * Starts listening to state changes of the phone. 101 * Starts listening to state changes of the phone.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 public int getSearchEnginePromoShowType() { 269 public int getSearchEnginePromoShowType() {
268 if (!isSpecialLocaleEnabled()) return SEARCH_ENGINE_PROMO_DONT_SHOW; 270 if (!isSpecialLocaleEnabled()) return SEARCH_ENGINE_PROMO_DONT_SHOW;
269 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); 271 SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
270 if (preferences.getBoolean(PREF_PROMO_SHOWN, false)) { 272 if (preferences.getBoolean(PREF_PROMO_SHOWN, false)) {
271 return SEARCH_ENGINE_PROMO_DONT_SHOW; 273 return SEARCH_ENGINE_PROMO_DONT_SHOW;
272 } 274 }
273 return SEARCH_ENGINE_PROMO_SHOW_SOGOU; 275 return SEARCH_ENGINE_PROMO_SHOW_SOGOU;
274 } 276 }
275 277
276 /** 278 /**
279 * @return The referral ID to be passed when searching with Yandex as the DS E.
280 */
281 @CalledByNative
282 protected String getYandexReferralId() {
283 return "";
284 }
285
286 /**
277 * To be called after the user has made a selection from a search engine pro mo dialog. 287 * To be called after the user has made a selection from a search engine pro mo dialog.
278 * @param type The type of search engine promo dialog that was shown. 288 * @param type The type of search engine promo dialog that was shown.
279 * @param keyword The keyword for the search engine chosen. 289 * @param keyword The keyword for the search engine chosen.
280 */ 290 */
281 protected void onUserSearchEngineChoiceFromPromoDialog( 291 protected void onUserSearchEngineChoiceFromPromoDialog(
282 @SearchEnginePromoType int type, String keyword) { 292 @SearchEnginePromoType int type, String keyword) {
283 TemplateUrlService.getInstance().setSearchEngine(keyword); 293 TemplateUrlService.getInstance().setSearchEngine(keyword);
284 ContextUtils.getAppSharedPreferences() 294 ContextUtils.getAppSharedPreferences()
285 .edit() 295 .edit()
286 .putInt(KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_ CHECKED_AND_SHOWN) 296 .putInt(KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_ CHECKED_AND_SHOWN)
(...skipping 16 matching lines...) Expand all
303 return instance.getSearchEngines(); 313 return instance.getSearchEngines();
304 } 314 }
305 315
306 /** Set a LocaleManager to be used for testing. */ 316 /** Set a LocaleManager to be used for testing. */
307 @VisibleForTesting 317 @VisibleForTesting
308 public static void setInstanceForTest(LocaleManager instance) { 318 public static void setInstanceForTest(LocaleManager instance) {
309 assert sInstance == null; 319 assert sInstance == null;
310 sInstance = instance; 320 sInstance = instance;
311 } 321 }
312 } 322 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java_sources.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698