| 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" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 JNIEnv* env, | 69 JNIEnv* env, |
| 70 const base::android::JavaParamRef<jobject>& obj, | 70 const base::android::JavaParamRef<jobject>& obj, |
| 71 const base::android::JavaParamRef<jstring>& jquery, | 71 const base::android::JavaParamRef<jstring>& jquery, |
| 72 const base::android::JavaParamRef<jstring>& jalternate_term, | 72 const base::android::JavaParamRef<jstring>& jalternate_term, |
| 73 jboolean jshould_prefetch, | 73 jboolean jshould_prefetch, |
| 74 const base::android::JavaParamRef<jstring>& jprotocol_version); | 74 const base::android::JavaParamRef<jstring>& jprotocol_version); |
| 75 base::android::ScopedJavaLocalRef<jstring> GetSearchEngineUrlFromTemplateUrl( | 75 base::android::ScopedJavaLocalRef<jstring> GetSearchEngineUrlFromTemplateUrl( |
| 76 JNIEnv* env, | 76 JNIEnv* env, |
| 77 const base::android::JavaParamRef<jobject>& obj, | 77 const base::android::JavaParamRef<jobject>& obj, |
| 78 const base::android::JavaParamRef<jstring>& jkeyword); | 78 const base::android::JavaParamRef<jstring>& jkeyword); |
| 79 base::android::ScopedJavaLocalRef<jstring> AddSearchEngineForTesting( |
| 80 JNIEnv* env, |
| 81 const base::android::JavaParamRef<jobject>& obj, |
| 82 const base::android::JavaParamRef<jstring>& jkeyword, |
| 83 jint age_in_days); |
| 84 base::android::ScopedJavaLocalRef<jstring> UpdateLastVisitedForTesting( |
| 85 JNIEnv* env, |
| 86 const base::android::JavaParamRef<jobject>& obj, |
| 87 const base::android::JavaParamRef<jstring>& jkeyword); |
| 79 | 88 |
| 80 static bool Register(JNIEnv* env); | 89 static bool Register(JNIEnv* env); |
| 81 | 90 |
| 82 private: | 91 private: |
| 83 ~TemplateUrlServiceAndroid() override; | 92 ~TemplateUrlServiceAndroid() override; |
| 84 | 93 |
| 85 void OnTemplateURLServiceLoaded(); | 94 void OnTemplateURLServiceLoaded(); |
| 86 | 95 |
| 87 // TemplateUrlServiceObserver: | 96 // TemplateUrlServiceObserver: |
| 88 void OnTemplateURLServiceChanged() override; | 97 void OnTemplateURLServiceChanged() override; |
| 89 | 98 |
| 90 // Updates |template_urls_| to contain all TemplateURLs. It sorts this list | 99 // Updates |template_urls_| to contain all TemplateURLs. It sorts this list |
| 91 // with prepopulated engines first, then any default non-prepopulated engine, | 100 // with prepopulated engines first, then any default non-prepopulated engine, |
| 92 // then other non-prepopulated engines. | 101 // then other non-prepopulated engines based on last_visited in descending |
| 102 // order. |
| 93 void LoadTemplateURLs(); | 103 void LoadTemplateURLs(); |
| 94 | 104 |
| 95 JavaObjectWeakGlobalRef weak_java_obj_; | 105 JavaObjectWeakGlobalRef weak_java_obj_; |
| 96 | 106 |
| 97 // Pointer to the TemplateUrlService for the main profile. | 107 // Pointer to the TemplateUrlService for the main profile. |
| 98 TemplateURLService* template_url_service_; | 108 TemplateURLService* template_url_service_; |
| 99 | 109 |
| 100 std::unique_ptr<TemplateURLService::Subscription> template_url_subscription_; | 110 std::unique_ptr<TemplateURLService::Subscription> template_url_subscription_; |
| 101 | 111 |
| 102 // Caches the up-to-date TemplateURL list so that calls from Android could | 112 // Caches the up-to-date TemplateURL list so that calls from Android could |
| 103 // directly get data from it. | 113 // directly get data from it. |
| 104 std::vector<TemplateURL*> template_urls_; | 114 std::vector<TemplateURL*> template_urls_; |
| 105 | 115 |
| 106 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); | 116 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); |
| 107 }; | 117 }; |
| 108 | 118 |
| 109 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ | 119 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| OLD | NEW |