OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/search_engines/template_url_service_android.h" | 5 #include "chrome/browser/search_engines/template_url_service_android.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 jint TemplateUrlServiceAndroid::GetTemplateUrlCount(JNIEnv* env, jobject obj) { | 84 jint TemplateUrlServiceAndroid::GetTemplateUrlCount(JNIEnv* env, jobject obj) { |
85 return template_url_service_->GetTemplateURLs().size(); | 85 return template_url_service_->GetTemplateURLs().size(); |
86 } | 86 } |
87 | 87 |
88 jboolean TemplateUrlServiceAndroid::IsSearchProviderManaged(JNIEnv* env, | 88 jboolean TemplateUrlServiceAndroid::IsSearchProviderManaged(JNIEnv* env, |
89 jobject obj) { | 89 jobject obj) { |
90 return template_url_service_->is_default_search_managed(); | 90 return template_url_service_->is_default_search_managed(); |
91 } | 91 } |
92 | 92 |
93 jboolean TemplateUrlServiceAndroid::IsSearchByImageAvailable(JNIEnv* env, | |
94 jobject obj) { | |
95 const TemplateURL* default_search_provider = | |
96 template_url_service_->GetDefaultSearchProvider(); | |
97 return default_search_provider && | |
98 !default_search_provider->image_url().empty() && | |
99 default_search_provider->image_url_ref().IsValid( | |
100 template_url_service_->search_terms_data()); | |
101 } | |
102 | |
103 jboolean TemplateUrlServiceAndroid::IsDefaultSearchEngineGoogle(JNIEnv* env, | 93 jboolean TemplateUrlServiceAndroid::IsDefaultSearchEngineGoogle(JNIEnv* env, |
104 jobject obj) { | 94 jobject obj) { |
105 TemplateURL* default_search_provider = | 95 TemplateURL* default_search_provider = |
106 template_url_service_->GetDefaultSearchProvider(); | 96 template_url_service_->GetDefaultSearchProvider(); |
107 return default_search_provider && | 97 return default_search_provider && |
108 default_search_provider->url_ref().HasGoogleBaseURLs( | 98 default_search_provider->url_ref().HasGoogleBaseURLs( |
109 template_url_service_->search_terms_data()); | 99 template_url_service_->search_terms_data()); |
110 } | 100 } |
111 | 101 |
112 base::android::ScopedJavaLocalRef<jobject> | 102 base::android::ScopedJavaLocalRef<jobject> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 250 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
261 TemplateUrlServiceAndroid* template_url_service_android = | 251 TemplateUrlServiceAndroid* template_url_service_android = |
262 new TemplateUrlServiceAndroid(env, obj); | 252 new TemplateUrlServiceAndroid(env, obj); |
263 return reinterpret_cast<intptr_t>(template_url_service_android); | 253 return reinterpret_cast<intptr_t>(template_url_service_android); |
264 } | 254 } |
265 | 255 |
266 // static | 256 // static |
267 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { | 257 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { |
268 return RegisterNativesImpl(env); | 258 return RegisterNativesImpl(env); |
269 } | 259 } |
OLD | NEW |