Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/search_engines/template_url_service.h" | 13 #include "components/search_engines/template_url_service.h" |
| 14 #include "components/search_engines/template_url_service_observer.h" | 14 #include "components/search_engines/template_url_service_observer.h" |
| 15 | 15 |
| 16 class TemplateURL; | 16 class TemplateURL; |
| 17 | 17 |
| 18 | 18 |
| 19 // Android wrapper of the TemplateUrlService which provides access from the Java | 19 // Android wrapper of the TemplateUrlService which provides access from the Java |
| 20 // layer. Note that on Android, there's only a single profile, and therefore | 20 // layer. Note that on Android, there's only a single profile, and therefore |
| 21 // a single instance of this wrapper. | 21 // a single instance of this wrapper. |
| 22 class TemplateUrlServiceAndroid : public TemplateURLServiceObserver { | 22 class TemplateUrlServiceAndroid : public TemplateURLServiceObserver { |
| 23 public: | 23 public: |
| 24 TemplateUrlServiceAndroid(JNIEnv* env, jobject obj); | 24 TemplateUrlServiceAndroid(JNIEnv* env, jobject obj); |
| 25 | 25 |
| 26 void Load(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 26 void Load(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 27 void SetUserSelectedDefaultSearchProvider( | 27 void SetUserSelectedDefaultSearchProvider( |
| 28 JNIEnv* env, | 28 JNIEnv* env, |
| 29 const base::android::JavaParamRef<jobject>& obj, | 29 const base::android::JavaParamRef<jobject>& obj, |
| 30 jint selected_index); | 30 const base::android::JavaParamRef<jstring>& jkeyword); |
| 31 jint GetDefaultSearchProvider( | 31 jint GetDefaultSearchProvider( |
| 32 JNIEnv* env, | 32 JNIEnv* env, |
| 33 const base::android::JavaParamRef<jobject>& obj); | 33 const base::android::JavaParamRef<jobject>& obj); |
| 34 jint GetTemplateUrlCount(JNIEnv* env, | 34 jint GetTemplateUrlCount(JNIEnv* env, |
| 35 const base::android::JavaParamRef<jobject>& obj); | 35 const base::android::JavaParamRef<jobject>& obj); |
| 36 jboolean IsLoaded(JNIEnv* env, | 36 jboolean IsLoaded(JNIEnv* env, |
| 37 const base::android::JavaParamRef<jobject>& obj); | 37 const base::android::JavaParamRef<jobject>& obj); |
| 38 base::android::ScopedJavaLocalRef<jobject> GetTemplateUrlAt( | 38 base::android::ScopedJavaLocalRef<jobject> GetTemplateUrlAt( |
| 39 JNIEnv* env, | 39 JNIEnv* env, |
| 40 const base::android::JavaParamRef<jobject>& obj, | 40 const base::android::JavaParamRef<jobject>& obj, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 64 base::android::ScopedJavaLocalRef<jstring> GetUrlForContextualSearchQuery( | 64 base::android::ScopedJavaLocalRef<jstring> GetUrlForContextualSearchQuery( |
| 65 JNIEnv* env, | 65 JNIEnv* env, |
| 66 const base::android::JavaParamRef<jobject>& obj, | 66 const base::android::JavaParamRef<jobject>& obj, |
| 67 const base::android::JavaParamRef<jstring>& jquery, | 67 const base::android::JavaParamRef<jstring>& jquery, |
| 68 const base::android::JavaParamRef<jstring>& jalternate_term, | 68 const base::android::JavaParamRef<jstring>& jalternate_term, |
| 69 jboolean jshould_prefetch, | 69 jboolean jshould_prefetch, |
| 70 const base::android::JavaParamRef<jstring>& jprotocol_version); | 70 const base::android::JavaParamRef<jstring>& jprotocol_version); |
| 71 base::android::ScopedJavaLocalRef<jstring> GetSearchEngineUrlFromTemplateUrl( | 71 base::android::ScopedJavaLocalRef<jstring> GetSearchEngineUrlFromTemplateUrl( |
| 72 JNIEnv* env, | 72 JNIEnv* env, |
| 73 const base::android::JavaParamRef<jobject>& obj, | 73 const base::android::JavaParamRef<jobject>& obj, |
| 74 jint index); | 74 const base::android::JavaParamRef<jstring>& jkeyword); |
| 75 | 75 |
| 76 static bool Register(JNIEnv* env); | 76 static bool Register(JNIEnv* env); |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 ~TemplateUrlServiceAndroid() override; | 79 ~TemplateUrlServiceAndroid() override; |
| 80 | 80 |
| 81 bool IsPrepopulatedTemplate(TemplateURL* url); | 81 bool IsPrepopulatedTemplate(TemplateURL* url); |
| 82 | 82 |
| 83 void OnTemplateURLServiceLoaded(); | 83 void OnTemplateURLServiceLoaded(); |
| 84 | 84 |
| 85 // TemplateUrlServiceObserver: | 85 // TemplateUrlServiceObserver: |
| 86 void OnTemplateURLServiceChanged() override; | 86 void OnTemplateURLServiceChanged() override; |
| 87 | 87 |
| 88 JavaObjectWeakGlobalRef weak_java_obj_; | 88 JavaObjectWeakGlobalRef weak_java_obj_; |
| 89 | 89 |
| 90 // Pointer to the TemplateUrlService for the main profile. | 90 // Pointer to the TemplateUrlService for the main profile. |
| 91 TemplateURLService* template_url_service_; | 91 TemplateURLService* template_url_service_; |
| 92 | 92 |
| 93 std::unique_ptr<TemplateURLService::Subscription> template_url_subscription_; | 93 std::unique_ptr<TemplateURLService::Subscription> template_url_subscription_; |
| 94 | 94 |
| 95 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); | 95 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); |
| 96 | |
| 97 std::vector<TemplateURL*> template_url_list; | |
|
Ian Wen
2016/10/17 23:32:21
In C++, class member variable should end with "_".
ltian
2016/10/18 01:01:55
Done.
| |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ | 100 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| OLD | NEW |