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

Side by Side Diff: chrome/browser/android/provider/chrome_browser_provider.h

Issue 10912172: [Android] Upstream ChromeBrowserProvider, the Android port ContentProvider implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: temporarily removing tests until we can compile and run them (soon) Created 8 years, 3 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
(Empty)
1 // Copyright (c) 2012 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_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_
6 #define CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_
7
8 #include "base/android/jni_helper.h"
9 #include "base/android/scoped_java_ref.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
13 #include "chrome/browser/cancelable_request.h"
14 #include "chrome/browser/history/android/android_history_types.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
17
18 class AndroidHistoryProviderService;
19 class FaviconService;
20 class Profile;
21
22 namespace history {
23 class TopSites;
24 }
25
26 namespace sql {
27 class Statement;
28 }
29
30 // This class implements the native methods of ChromeBrowserProvider.java
31 class ChromeBrowserProvider : public BaseBookmarkModelObserver,
32 public content::NotificationObserver {
33 public:
34 ChromeBrowserProvider(JNIEnv* env, jobject obj);
35 void Destroy(JNIEnv*, jobject);
36
37 // JNI registration.
38 static bool RegisterChromeBrowserProvider(JNIEnv* env);
39
40 // Adds either a new bookmark or bookmark folder based on |is_folder|. The
41 // bookmark is added to the beginning of the specified parent and if the
42 // parent ID is not valid (i.e. < 0) then it will be added to the bookmark
43 // bar.
44 jlong AddBookmark(JNIEnv* env, jobject,
45 jstring jurl,
46 jstring jtitle,
47 jboolean is_folder,
48 jlong parent_id);
49
50 // Removes a bookmark (or folder) with the specified ID.
51 jint RemoveBookmark(JNIEnv*, jobject, jlong id);
52
53 // Updates a bookmark (or folder) with the the new title and new URL.
54 // The |url| field will be ignored if the bookmark node is a folder.
55 // If a valid |parent_id| (>= 0) different from the currently specified
56 // parent is given, the node will be moved to that folder as the first
57 // child.
58 jint UpdateBookmark(JNIEnv* env,
59 jobject,
60 jlong id,
61 jstring url,
62 jstring title,
63 jlong parent_id);
64
65 // The below are methods to support Android public API.
66 // Bookmark and history APIs. -----------------------------------------------
67 jlong AddBookmarkFromAPI(JNIEnv* env,
68 jobject obj,
69 jstring url,
70 jobject created,
71 jobject isBookmark,
72 jobject date,
73 jbyteArray favicon,
74 jstring title,
75 jobject visits,
76 jlong parent_id);
77
78 base::android::ScopedJavaLocalRef<jobject> QueryBookmarkFromAPI(
79 JNIEnv* env,
80 jobject obj,
81 jobjectArray projection,
82 jstring selections,
83 jobjectArray selection_args,
84 jstring sort_order);
85
86 jint UpdateBookmarkFromAPI(JNIEnv* env,
87 jobject obj,
88 jstring url,
89 jobject created,
90 jobject isBookmark,
91 jobject date,
92 jbyteArray favicon,
93 jstring title,
94 jobject visits,
95 jlong parent_id,
96 jstring selections,
97 jobjectArray selection_args);
98
99 jint RemoveBookmarkFromAPI(JNIEnv* env,
100 jobject obj,
101 jstring selections,
102 jobjectArray selection_args);
103
104 jint RemoveHistoryFromAPI(JNIEnv* env,
105 jobject obj,
106 jstring selections,
107 jobjectArray selection_args);
108
109 jlong AddSearchTermFromAPI(JNIEnv* env,
110 jobject obj,
111 jstring search_term,
112 jobject date);
113
114 base::android::ScopedJavaLocalRef<jobject> QuerySearchTermFromAPI(
115 JNIEnv* env,
116 jobject obj,
117 jobjectArray projection,
118 jstring selections,
119 jobjectArray selection_args,
120 jstring sort_order);
121
122 jint RemoveSearchTermFromAPI(JNIEnv* env,
123 jobject obj,
124 jstring selections,
125 jobjectArray selection_args);
126
127 jint UpdateSearchTermFromAPI(JNIEnv* env,
128 jobject obj,
129 jstring search_term,
130 jobject date,
131 jstring selections,
132 jobjectArray selection_args);
133
134 // Custom provider API methods. ---------------------------------------------
135 jlong CreateBookmarksFolderOnce(JNIEnv* env,
136 jobject obj,
137 jstring title,
138 jlong parent_id);
139
140 base::android::ScopedJavaLocalRef<jobject> GetAllBookmarkFolders(JNIEnv* env,
141 jobject obj);
142
143 base::android::ScopedJavaLocalRef<jobject> GetBookmarkNode(
144 JNIEnv* env,
145 jobject obj,
146 jlong id,
147 jboolean get_parent,
148 jboolean get_children);
149
150 base::android::ScopedJavaLocalRef<jobject> GetMobileBookmarksFolder(
151 JNIEnv* env,
152 jobject obj);
153
154 jboolean IsBookmarkInMobileBookmarksBranch(JNIEnv* env,
155 jobject obj,
156 jlong id);
157
158 jboolean BookmarkNodeExists(JNIEnv* env,
159 jobject obj,
160 jlong id);
161
162 base::android::ScopedJavaLocalRef<jbyteArray> GetFaviconOrTouchIcon(
163 JNIEnv* env,
164 jobject obj,
165 jstring url);
166
167 base::android::ScopedJavaLocalRef<jbyteArray> GetThumbnail(JNIEnv* env,
168 jobject obj,
169 jstring url);
170
171 private:
172 virtual ~ChromeBrowserProvider();
173
174 // Override BaseBookmarkModelObserver.
175 virtual void BookmarkModelChanged() OVERRIDE;
176
177 // Override NotificationObserver.
178 virtual void Observe(int type,
179 const content::NotificationSource& source,
180 const content::NotificationDetails& details) OVERRIDE;
181
182 JavaObjectWeakGlobalRef weak_java_provider_;
183
184 Profile* profile_;
185 BookmarkModel* bookmark_model_;
186 history::TopSites* top_sites_;
187
188 scoped_ptr<AndroidHistoryProviderService> service_;
189 scoped_ptr<FaviconService> favicon_service_;
190
191 // Different cancelable request consumers must be used for each service.
192 // This because a synchronization issue that could lead to flaky assertion
193 // failures otherwise.
194 // TODO(leandrogracia): use a single consumer once http://crbug.com/85970
195 // is fixed.
196 CancelableRequestConsumer android_history_consumer_;
197 CancelableRequestConsumer favicon_consumer_;
198
199 // Used to register/unregister notification observer.
200 content::NotificationRegistrar notification_registrar_;
201
202 // Signaled if TemplateURLModel has been loaded.
203 base::WaitableEvent template_loaded_event_;
204
205 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProvider);
206 };
207
208 #endif // CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698