| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 base::android::ScopedJavaLocalRef<jobject> | 120 base::android::ScopedJavaLocalRef<jobject> |
| 121 TemplateUrlServiceAndroid::GetTemplateUrlAt(JNIEnv* env, | 121 TemplateUrlServiceAndroid::GetTemplateUrlAt(JNIEnv* env, |
| 122 const JavaParamRef<jobject>& obj, | 122 const JavaParamRef<jobject>& obj, |
| 123 jint index) const { | 123 jint index) const { |
| 124 TemplateURL* template_url = template_urls_[index]; | 124 TemplateURL* template_url = template_urls_[index]; |
| 125 return Java_TemplateUrl_create( | 125 return Java_TemplateUrl_create( |
| 126 env, index, | 126 env, index, |
| 127 base::android::ConvertUTF16ToJavaString(env, template_url->short_name()), | 127 base::android::ConvertUTF16ToJavaString(env, template_url->short_name()), |
| 128 base::android::ConvertUTF8ToJavaString(env, template_url->url()), | |
| 129 template_url_service_->IsPrepopulatedOrCreatedByPolicy(template_url), | 128 template_url_service_->IsPrepopulatedOrCreatedByPolicy(template_url), |
| 130 base::android::ConvertUTF16ToJavaString(env, template_url->keyword())); | 129 base::android::ConvertUTF16ToJavaString(env, template_url->keyword())); |
| 131 } | 130 } |
| 132 | 131 |
| 133 void TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded() { | 132 void TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded() { |
| 134 template_url_subscription_.reset(); | 133 template_url_subscription_.reset(); |
| 135 JNIEnv* env = base::android::AttachCurrentThread(); | 134 JNIEnv* env = base::android::AttachCurrentThread(); |
| 136 if (weak_java_obj_.get(env).is_null()) | 135 if (weak_java_obj_.get(env).is_null()) |
| 137 return; | 136 return; |
| 138 LoadTemplateURLs(); | 137 LoadTemplateURLs(); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 286 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 288 TemplateUrlServiceAndroid* template_url_service_android = | 287 TemplateUrlServiceAndroid* template_url_service_android = |
| 289 new TemplateUrlServiceAndroid(env, obj); | 288 new TemplateUrlServiceAndroid(env, obj); |
| 290 return reinterpret_cast<intptr_t>(template_url_service_android); | 289 return reinterpret_cast<intptr_t>(template_url_service_android); |
| 291 } | 290 } |
| 292 | 291 |
| 293 // static | 292 // static |
| 294 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { | 293 bool TemplateUrlServiceAndroid::Register(JNIEnv* env) { |
| 295 return RegisterNativesImpl(env); | 294 return RegisterNativesImpl(env); |
| 296 } | 295 } |
| OLD | NEW |