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

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: 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/browser/BUILD.gn » ('j') | components/search_engines/search_terms_data.h » ('J')
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.snackbar.Snackbar; 24 import org.chromium.chrome.browser.snackbar.Snackbar;
24 import org.chromium.chrome.browser.snackbar.SnackbarManager; 25 import org.chromium.chrome.browser.snackbar.SnackbarManager;
25 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController; 26 import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarController;
26 27
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 Context context = ContextUtils.getApplicationContext(); 79 Context context = ContextUtils.getApplicationContext();
79 Intent intent = PreferencesLauncher.createIntentForSettingsPage(cont ext, 80 Intent intent = PreferencesLauncher.createIntentForSettingsPage(cont ext,
80 SearchEnginePreference.class.getName()); 81 SearchEnginePreference.class.getName());
81 context.startActivity(intent); 82 context.startActivity(intent);
82 } 83 }
83 }; 84 };
84 85
85 /** 86 /**
86 * @return An instance of the {@link LocaleManager}. This should only be cal led on UI thread. 87 * @return An instance of the {@link LocaleManager}. This should only be cal led on UI thread.
87 */ 88 */
89 @CalledByNative
88 public static LocaleManager getInstance() { 90 public static LocaleManager getInstance() {
89 assert ThreadUtils.runningOnUiThread(); 91 assert ThreadUtils.runningOnUiThread();
90 if (sInstance == null) { 92 if (sInstance == null) {
91 sInstance = AppHooks.get().createLocaleManager(); 93 sInstance = AppHooks.get().createLocaleManager();
92 } 94 }
93 return sInstance; 95 return sInstance;
94 } 96 }
95 97
96 /** 98 /**
97 * Starts listening to state changes of the phone. 99 * Starts listening to state changes of the phone.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 public int getSearchEnginePromoShowType() { 267 public int getSearchEnginePromoShowType() {
266 if (!isSpecialLocaleEnabled()) return SEARCH_ENGINE_PROMO_DONT_SHOW; 268 if (!isSpecialLocaleEnabled()) return SEARCH_ENGINE_PROMO_DONT_SHOW;
267 SharedPreferences preferences = ContextUtils.getAppSharedPreferences(); 269 SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
268 if (preferences.getBoolean(PREF_PROMO_SHOWN, false)) { 270 if (preferences.getBoolean(PREF_PROMO_SHOWN, false)) {
269 return SEARCH_ENGINE_PROMO_DONT_SHOW; 271 return SEARCH_ENGINE_PROMO_DONT_SHOW;
270 } 272 }
271 return SEARCH_ENGINE_PROMO_SHOW_SOGOU; 273 return SEARCH_ENGINE_PROMO_SHOW_SOGOU;
272 } 274 }
273 275
274 /** 276 /**
277 * @return The referral ID to be passed when searching with Yandex as the DS E.
278 */
279 @CalledByNative
280 protected String getYandexReferralId() {
Yusuf 2017/05/09 23:18:52 should this be a static, so that we avoid calling
Ted C 2017/05/10 15:20:29 I thought about that as well, but then it would pr
281 return "";
282 }
283
284 /**
275 * To be called after the user has made a selection from a search engine pro mo dialog. 285 * To be called after the user has made a selection from a search engine pro mo dialog.
276 * @param type The type of search engine promo dialog that was shown. 286 * @param type The type of search engine promo dialog that was shown.
277 * @param keyword The keyword for the search engine chosen. 287 * @param keyword The keyword for the search engine chosen.
278 */ 288 */
279 protected void onUserSearchEngineChoiceFromPromoDialog( 289 protected void onUserSearchEngineChoiceFromPromoDialog(
280 @SearchEnginePromoType int type, String keyword) { 290 @SearchEnginePromoType int type, String keyword) {
281 TemplateUrlService.getInstance().setSearchEngine(keyword); 291 TemplateUrlService.getInstance().setSearchEngine(keyword);
282 ContextUtils.getAppSharedPreferences() 292 ContextUtils.getAppSharedPreferences()
283 .edit() 293 .edit()
284 .putInt(KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_ CHECKED_AND_SHOWN) 294 .putInt(KEY_SEARCH_ENGINE_PROMO_SHOW_STATE, SEARCH_ENGINE_PROMO_ CHECKED_AND_SHOWN)
285 .apply(); 295 .apply();
286 } 296 }
287 297
288 private SpecialLocaleHandler getSpecialLocaleHandler() { 298 private SpecialLocaleHandler getSpecialLocaleHandler() {
289 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId()); 299 if (mLocaleHandler == null) mLocaleHandler = new SpecialLocaleHandler(ge tSpecialLocaleId());
290 return mLocaleHandler; 300 return mLocaleHandler;
291 } 301 }
292 302
293 /** Set a LocaleManager to be used for testing. */ 303 /** Set a LocaleManager to be used for testing. */
294 @VisibleForTesting 304 @VisibleForTesting
295 public static void setInstanceForTest(LocaleManager instance) { 305 public static void setInstanceForTest(LocaleManager instance) {
296 assert sInstance == null; 306 assert sInstance == null;
297 sInstance = instance; 307 sInstance = instance;
298 } 308 }
299 } 309 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/BUILD.gn » ('j') | components/search_engines/search_terms_data.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698