OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ |
6 #define CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ | 6 #define CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ |
7 | 7 |
8 #include "base/android/jni_weak_ref.h" | 8 #include "base/android/jni_weak_ref.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
14 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 14 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
15 #include "components/history/core/browser/android/android_history_types.h" | 15 #include "components/history/core/browser/android/android_history_types.h" |
16 #include "components/history/core/browser/history_service_observer.h" | 16 #include "components/history/core/browser/history_service_observer.h" |
17 #include "content/public/browser/notification_observer.h" | |
18 #include "content/public/browser/notification_registrar.h" | |
19 | 17 |
20 class AndroidHistoryProviderService; | 18 class AndroidHistoryProviderService; |
21 class FaviconService; | 19 class FaviconService; |
22 class Profile; | 20 class Profile; |
23 | 21 |
24 namespace history { | 22 namespace history { |
25 class TopSites; | 23 class TopSites; |
26 } | 24 } |
27 | 25 |
28 namespace sql { | 26 namespace sql { |
29 class Statement; | 27 class Statement; |
30 } | 28 } |
31 | 29 |
32 // This class implements the native methods of ChromeBrowserProvider.java | 30 // This class implements the native methods of ChromeBrowserProvider.java |
33 class ChromeBrowserProvider : public bookmarks::BaseBookmarkModelObserver, | 31 class ChromeBrowserProvider : public bookmarks::BaseBookmarkModelObserver, |
34 public content::NotificationObserver, | |
35 public history::HistoryServiceObserver { | 32 public history::HistoryServiceObserver { |
36 public: | 33 public: |
37 ChromeBrowserProvider(JNIEnv* env, jobject obj); | 34 ChromeBrowserProvider(JNIEnv* env, jobject obj); |
38 void Destroy(JNIEnv*, jobject); | 35 void Destroy(JNIEnv*, jobject); |
39 | 36 |
40 // JNI registration. | 37 // JNI registration. |
41 static bool RegisterChromeBrowserProvider(JNIEnv* env); | 38 static bool RegisterChromeBrowserProvider(JNIEnv* env); |
42 | 39 |
43 // Adds either a new bookmark or bookmark folder based on |is_folder|. The | 40 // Adds either a new bookmark or bookmark folder based on |is_folder|. The |
44 // bookmark is added to the beginning of the specified parent and if the | 41 // bookmark is added to the beginning of the specified parent and if the |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 183 |
187 // Deals with updates to the history service. | 184 // Deals with updates to the history service. |
188 void OnHistoryChanged(); | 185 void OnHistoryChanged(); |
189 | 186 |
190 // Override history::HistoryServiceObserver. | 187 // Override history::HistoryServiceObserver. |
191 void OnURLVisited(HistoryService* history_service, | 188 void OnURLVisited(HistoryService* history_service, |
192 ui::PageTransition transition, | 189 ui::PageTransition transition, |
193 const history::URLRow& row, | 190 const history::URLRow& row, |
194 const history::RedirectList& redirects, | 191 const history::RedirectList& redirects, |
195 base::Time visit_time) override; | 192 base::Time visit_time) override; |
| 193 void OnURLsDeleted(HistoryService* history_service, |
| 194 bool all_history, |
| 195 bool expired, |
| 196 const history::URLRows& deleted_rows, |
| 197 const std::set<GURL>& favicon_urls) override; |
196 void OnKeywordSearchTermUpdated(HistoryService* history_service, | 198 void OnKeywordSearchTermUpdated(HistoryService* history_service, |
197 const history::URLRow& row, | 199 const history::URLRow& row, |
198 history::KeywordID keyword_id, | 200 history::KeywordID keyword_id, |
199 const base::string16& term) override; | 201 const base::string16& term) override; |
200 void OnKeywordSearchTermDeleted(HistoryService* history_service, | 202 void OnKeywordSearchTermDeleted(HistoryService* history_service, |
201 history::URLID url_id) override; | 203 history::URLID url_id) override; |
202 | 204 |
203 // Override content::NotificationObserver. | |
204 virtual void Observe(int type, | |
205 const content::NotificationSource& source, | |
206 const content::NotificationDetails& details) override; | |
207 | |
208 JavaObjectWeakGlobalRef weak_java_provider_; | 205 JavaObjectWeakGlobalRef weak_java_provider_; |
209 | 206 |
210 // Profile must outlive this object. | 207 // Profile must outlive this object. |
211 // | 208 // |
212 // BookmarkModel, HistoryService and history::TopSites lifetime is bound to | 209 // BookmarkModel, HistoryService and history::TopSites lifetime is bound to |
213 // the lifetime of Profile, they are safe to use as long as the Profile is | 210 // the lifetime of Profile, they are safe to use as long as the Profile is |
214 // alive. | 211 // alive. |
215 Profile* profile_; | 212 Profile* profile_; |
216 bookmarks::BookmarkModel* bookmark_model_; | 213 bookmarks::BookmarkModel* bookmark_model_; |
217 history::TopSites* top_sites_; | 214 history::TopSites* top_sites_; |
218 FaviconService* favicon_service_; | 215 FaviconService* favicon_service_; |
219 | 216 |
220 scoped_ptr<AndroidHistoryProviderService> service_; | 217 scoped_ptr<AndroidHistoryProviderService> service_; |
221 | 218 |
222 base::CancelableTaskTracker cancelable_task_tracker_; | 219 base::CancelableTaskTracker cancelable_task_tracker_; |
223 | 220 |
224 // Used to register/unregister notification observer. | |
225 content::NotificationRegistrar notification_registrar_; | |
226 ScopedObserver<HistoryService, HistoryServiceObserver> | 221 ScopedObserver<HistoryService, HistoryServiceObserver> |
227 history_service_observer_; | 222 history_service_observer_; |
228 | 223 |
229 bool handling_extensive_changes_; | 224 bool handling_extensive_changes_; |
230 | 225 |
231 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProvider); | 226 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProvider); |
232 }; | 227 }; |
233 | 228 |
234 #endif // CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ | 229 #endif // CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ |
OLD | NEW |