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

Side by Side Diff: chrome/browser/android/locale/special_locale_handler.cc

Issue 2398533002: Implement search engine auto switch when entering or leaving some locale (Closed)
Patch Set: Created 4 years, 2 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/android/locale/special_locale_handler.h" 5 #include "chrome/browser/android/locale/special_locale_handler.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/android/jni_weak_ref.h" 9 #include "base/android/jni_weak_ref.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 TemplateURL* turl = 107 TemplateURL* turl =
108 FindURLByPrepopulateID(template_url_service_->GetTemplateURLs(), 108 FindURLByPrepopulateID(template_url_service_->GetTemplateURLs(),
109 GetDesignatedPrepopulatedIdForLocale(locale_)); 109 GetDesignatedPrepopulatedIdForLocale(locale_));
110 if (turl) { 110 if (turl) {
111 template_url_service_->SetUserSelectedDefaultSearchProvider(turl); 111 template_url_service_->SetUserSelectedDefaultSearchProvider(turl);
112 } 112 }
113 } 113 }
114 114
115 void SpecialLocaleHandler::SetGoogleAsDefaultSearch(
116 JNIEnv* env,
117 const JavaParamRef<jobject>& obj) {
118 // If the user has changed his default search provider, no-op.
119 TemplateURL* current_dsp = template_url_service_->GetDefaultSearchProvider();
120 if (!current_dsp ||
121 current_dsp->prepopulate_id() !=
122 GetDesignatedPrepopulatedIdForLocale(locale_)) {
123 return;
124 }
125
126 TemplateURL* turl =
127 FindURLByPrepopulateID(template_url_service_->GetTemplateURLs(),
128 TemplateURLPrepopulateData::google.id);
129 if (turl) {
130 template_url_service_->SetUserSelectedDefaultSearchProvider(turl);
131 }
132 }
133
115 SpecialLocaleHandler::~SpecialLocaleHandler() {} 134 SpecialLocaleHandler::~SpecialLocaleHandler() {}
116 135
117 // static 136 // static
118 bool RegisterSpecialLocaleHandler(JNIEnv* env) { 137 bool RegisterSpecialLocaleHandler(JNIEnv* env) {
119 return RegisterNativesImpl(env); 138 return RegisterNativesImpl(env);
120 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698