| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 | 122 |
| 123 base::android::ScopedJavaLocalRef<jobject> | 123 base::android::ScopedJavaLocalRef<jobject> |
| 124 TemplateUrlServiceAndroid::GetTemplateUrlAt(JNIEnv* env, | 124 TemplateUrlServiceAndroid::GetTemplateUrlAt(JNIEnv* env, |
| 125 const JavaParamRef<jobject>& obj, | 125 const JavaParamRef<jobject>& obj, |
| 126 jint index) { | 126 jint index) { |
| 127 TemplateURL* template_url = template_url_service_->GetTemplateURLs()[index]; | 127 TemplateURL* template_url = template_url_service_->GetTemplateURLs()[index]; |
| 128 return Java_TemplateUrl_create( | 128 return Java_TemplateUrl_create( |
| 129 env, index, | 129 env, index, |
| 130 base::android::ConvertUTF16ToJavaString(env, template_url->short_name()), | 130 base::android::ConvertUTF16ToJavaString(env, template_url->short_name()), |
| 131 base::android::ConvertUTF8ToJavaString(env, template_url->url()), |
| 131 IsPrepopulatedTemplate(template_url) || | 132 IsPrepopulatedTemplate(template_url) || |
| 132 template_url->created_by_policy()); | 133 template_url->created_by_policy()); |
| 133 } | 134 } |
| 134 | 135 |
| 135 bool TemplateUrlServiceAndroid::IsPrepopulatedTemplate(TemplateURL* url) { | 136 bool TemplateUrlServiceAndroid::IsPrepopulatedTemplate(TemplateURL* url) { |
| 136 return url->prepopulate_id() > 0; | 137 return url->prepopulate_id() > 0; |
| 137 } | 138 } |
| 138 | 139 |
| 139 void TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded() { | 140 void TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded() { |
| 140 template_url_subscription_.reset(); | 141 template_url_subscription_.reset(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 272 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 272 TemplateUrlServiceAndroid* template_url_service_android = | 273 TemplateUrlServiceAndroid* template_url_service_android = |
| 273 new TemplateUrlServiceAndroid(env, obj); | 274 new TemplateUrlServiceAndroid(env, obj); |
| 274 return reinterpret_cast<intptr_t>(template_url_service_android); | 275 return reinterpret_cast<intptr_t>(template_url_service_android); |
| 275 } | 276 } |
| 276 | 277 |
| 277 // static | 278 // static |
| 278 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { | 279 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { |
| 279 return RegisterNativesImpl(env); | 280 return RegisterNativesImpl(env); |
| 280 } | 281 } |
| OLD | NEW |