OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
| 7 |
| 8 #include "base/android/jni_helper.h" |
| 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" |
| 12 |
| 13 class TemplateURL; |
| 14 class TemplateURLService; |
| 15 |
| 16 |
| 17 // Android wrapper of the TemplateUrlService which provides access from the Java |
| 18 // layer. Note that on Android, there's only a single profile, and therefore |
| 19 // a single instance of this wrapper. |
| 20 class TemplateUrlServiceAndroid : public content::NotificationObserver { |
| 21 public: |
| 22 TemplateUrlServiceAndroid(JNIEnv* env, jobject obj); |
| 23 |
| 24 void Load(JNIEnv* env, jobject obj); |
| 25 void SetDefaultSearchProvider(JNIEnv* env, jobject obj, jint selected_index); |
| 26 jint GetDefaultSearchProvider(JNIEnv* env, jobject obj); |
| 27 jint GetTemplateUrlCount(JNIEnv* env, jobject obj); |
| 28 jboolean IsLoaded(JNIEnv* env, jobject obj); |
| 29 base::android::ScopedJavaLocalRef<jobject> |
| 30 GetPrepopulatedTemplateUrlAt(JNIEnv* env, jobject obj, jint index); |
| 31 |
| 32 // NotificationObserver: |
| 33 virtual void Observe(int type, |
| 34 const content::NotificationSource& source, |
| 35 const content::NotificationDetails& details) OVERRIDE; |
| 36 |
| 37 static bool Register(JNIEnv* env); |
| 38 |
| 39 private: |
| 40 virtual ~TemplateUrlServiceAndroid(); |
| 41 |
| 42 bool IsPrepopulatedTemplate(TemplateURL* url); |
| 43 |
| 44 JavaObjectWeakGlobalRef weak_java_obj_; |
| 45 content::NotificationRegistrar registrar_; |
| 46 |
| 47 // Pointer to the TemplateUrlService for the main profile. |
| 48 TemplateURLService* template_url_service_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ |
OLD | NEW |