Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/browser/search_engines/template_url_service_android.h

Issue 23710022: Convert NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: oops Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/android/jni_helper.h" 8 #include "base/android/jni_helper.h"
9 #include "base/android/scoped_java_ref.h" 9 #include "base/android/scoped_java_ref.h"
10 #include "content/public/browser/notification_observer.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/notification_registrar.h" 11 #include "chrome/browser/search_engines/template_url_service.h"
12 12
13 class TemplateURL; 13 class TemplateURL;
14 class TemplateURLService; 14 class TemplateURLService;
Lei Zhang 2013/10/08 00:25:20 fwd-decl no longer needed
Cait (Slow) 2013/10/08 15:09:32 Done.
15 15
16 16
17 // Android wrapper of the TemplateUrlService which provides access from the Java 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 18 // layer. Note that on Android, there's only a single profile, and therefore
19 // a single instance of this wrapper. 19 // a single instance of this wrapper.
20 class TemplateUrlServiceAndroid : public content::NotificationObserver { 20 class TemplateUrlServiceAndroid {
21 public: 21 public:
22 TemplateUrlServiceAndroid(JNIEnv* env, jobject obj); 22 TemplateUrlServiceAndroid(JNIEnv* env, jobject obj);
23 23
24 void Load(JNIEnv* env, jobject obj); 24 void Load(JNIEnv* env, jobject obj);
25 void SetDefaultSearchProvider(JNIEnv* env, jobject obj, jint selected_index); 25 void SetDefaultSearchProvider(JNIEnv* env, jobject obj, jint selected_index);
26 jint GetDefaultSearchProvider(JNIEnv* env, jobject obj); 26 jint GetDefaultSearchProvider(JNIEnv* env, jobject obj);
27 jint GetTemplateUrlCount(JNIEnv* env, jobject obj); 27 jint GetTemplateUrlCount(JNIEnv* env, jobject obj);
28 jboolean IsLoaded(JNIEnv* env, jobject obj); 28 jboolean IsLoaded(JNIEnv* env, jobject obj);
29 base::android::ScopedJavaLocalRef<jobject> 29 base::android::ScopedJavaLocalRef<jobject>
30 GetPrepopulatedTemplateUrlAt(JNIEnv* env, jobject obj, jint index); 30 GetPrepopulatedTemplateUrlAt(JNIEnv* env, jobject obj, jint index);
31 jboolean IsSearchProviderManaged(JNIEnv* env, jobject obj); 31 jboolean IsSearchProviderManaged(JNIEnv* env, jobject obj);
32 jboolean IsSearchByImageAvailable(JNIEnv* env, jobject obj); 32 jboolean IsSearchByImageAvailable(JNIEnv* env, jobject obj);
33 jboolean IsDefaultSearchEngineGoogle(JNIEnv* env, jobject obj); 33 jboolean IsDefaultSearchEngineGoogle(JNIEnv* env, jobject obj);
34 base::android::ScopedJavaLocalRef<jstring> GetUrlForSearchQuery( 34 base::android::ScopedJavaLocalRef<jstring> GetUrlForSearchQuery(
35 JNIEnv* env, 35 JNIEnv* env,
36 jobject obj, 36 jobject obj,
37 jstring jquery); 37 jstring jquery);
38 base::android::ScopedJavaLocalRef<jstring> ReplaceSearchTermsInUrl( 38 base::android::ScopedJavaLocalRef<jstring> ReplaceSearchTermsInUrl(
39 JNIEnv* env, 39 JNIEnv* env,
40 jobject obj, 40 jobject obj,
41 jstring jquery, 41 jstring jquery,
42 jstring jcurrent_url); 42 jstring jcurrent_url);
43 43
44 // NotificationObserver:
45 virtual void Observe(int type,
46 const content::NotificationSource& source,
47 const content::NotificationDetails& details) OVERRIDE;
48
49 static bool Register(JNIEnv* env); 44 static bool Register(JNIEnv* env);
50 45
51 private: 46 private:
52 virtual ~TemplateUrlServiceAndroid(); 47 virtual ~TemplateUrlServiceAndroid();
Lei Zhang 2013/10/08 00:25:20 no longer need to be virtual
Cait (Slow) 2013/10/08 15:09:32 Done.
53 48
54 bool IsPrepopulatedTemplate(TemplateURL* url); 49 bool IsPrepopulatedTemplate(TemplateURL* url);
55 50
51 void OnTemplateURLServiceLoaded();
52
56 JavaObjectWeakGlobalRef weak_java_obj_; 53 JavaObjectWeakGlobalRef weak_java_obj_;
57 content::NotificationRegistrar registrar_;
58 54
59 // Pointer to the TemplateUrlService for the main profile. 55 // Pointer to the TemplateUrlService for the main profile.
60 TemplateURLService* template_url_service_; 56 TemplateURLService* template_url_service_;
61 57
58 scoped_ptr<TemplateURLService::Subscription> template_url_subscription_;
59
62 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid); 60 DISALLOW_COPY_AND_ASSIGN(TemplateUrlServiceAndroid);
63 }; 61 };
64 62
65 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_ 63 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698