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