OLD | NEW |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (turl && template_url_service_->GetDefaultSearchProvider() != turl) { | 90 if (turl && template_url_service_->GetDefaultSearchProvider() != turl) { |
91 template_url_service_->Remove(turl); | 91 template_url_service_->Remove(turl); |
92 } | 92 } |
93 prepopulate_ids_.pop_back(); | 93 prepopulate_ids_.pop_back(); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 void SpecialLocaleHandler::OverrideDefaultSearchProvider( | 97 void SpecialLocaleHandler::OverrideDefaultSearchProvider( |
98 JNIEnv* env, | 98 JNIEnv* env, |
99 const JavaParamRef<jobject>& obj) { | 99 const JavaParamRef<jobject>& obj) { |
100 // If the user has changed his default search provider, no-op. | 100 // If the user has changed their default search provider, no-op. |
101 TemplateURL* current_dsp = template_url_service_->GetDefaultSearchProvider(); | 101 TemplateURL* current_dsp = template_url_service_->GetDefaultSearchProvider(); |
102 if (!current_dsp || | 102 if (!current_dsp || |
103 current_dsp->prepopulate_id() != TemplateURLPrepopulateData::google.id) { | 103 current_dsp->prepopulate_id() != TemplateURLPrepopulateData::google.id) { |
104 return; | 104 return; |
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( | 115 void SpecialLocaleHandler::SetGoogleAsDefaultSearch( |
116 JNIEnv* env, | 116 JNIEnv* env, |
117 const JavaParamRef<jobject>& obj) { | 117 const JavaParamRef<jobject>& obj) { |
118 // If the user has changed his default search provider, no-op. | 118 // If the user has changed their default search provider, no-op. |
119 TemplateURL* current_dsp = template_url_service_->GetDefaultSearchProvider(); | 119 TemplateURL* current_dsp = template_url_service_->GetDefaultSearchProvider(); |
120 if (!current_dsp || | 120 if (!current_dsp || |
121 current_dsp->prepopulate_id() != | 121 current_dsp->prepopulate_id() != |
122 GetDesignatedPrepopulatedIdForLocale(locale_)) { | 122 GetDesignatedPrepopulatedIdForLocale(locale_)) { |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 TemplateURL* turl = | 126 TemplateURL* turl = |
127 FindURLByPrepopulateID(template_url_service_->GetTemplateURLs(), | 127 FindURLByPrepopulateID(template_url_service_->GetTemplateURLs(), |
128 TemplateURLPrepopulateData::google.id); | 128 TemplateURLPrepopulateData::google.id); |
129 if (turl) { | 129 if (turl) { |
130 template_url_service_->SetUserSelectedDefaultSearchProvider(turl); | 130 template_url_service_->SetUserSelectedDefaultSearchProvider(turl); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 SpecialLocaleHandler::~SpecialLocaleHandler() {} | 134 SpecialLocaleHandler::~SpecialLocaleHandler() {} |
135 | 135 |
136 // static | 136 // static |
137 bool RegisterSpecialLocaleHandler(JNIEnv* env) { | 137 bool RegisterSpecialLocaleHandler(JNIEnv* env) { |
138 return RegisterNativesImpl(env); | 138 return RegisterNativesImpl(env); |
139 } | 139 } |
OLD | NEW |