| 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/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/task/cancelable_task_tracker.h" | 13 #include "base/task/cancelable_task_tracker.h" |
| 13 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 14 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 14 #include "components/history/core/android/android_history_types.h" | 15 #include "components/history/core/android/android_history_types.h" |
| 16 #include "components/history/core/browser/history_service_observer.h" |
| 15 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 17 | 19 |
| 18 class AndroidHistoryProviderService; | 20 class AndroidHistoryProviderService; |
| 19 class FaviconService; | 21 class FaviconService; |
| 20 class Profile; | 22 class Profile; |
| 21 | 23 |
| 22 namespace history { | 24 namespace history { |
| 23 class TopSites; | 25 class TopSites; |
| 24 } | 26 } |
| 25 | 27 |
| 26 namespace sql { | 28 namespace sql { |
| 27 class Statement; | 29 class Statement; |
| 28 } | 30 } |
| 29 | 31 |
| 30 // This class implements the native methods of ChromeBrowserProvider.java | 32 // This class implements the native methods of ChromeBrowserProvider.java |
| 31 class ChromeBrowserProvider : public BaseBookmarkModelObserver, | 33 class ChromeBrowserProvider : public BaseBookmarkModelObserver, |
| 32 public content::NotificationObserver { | 34 public content::NotificationObserver, |
| 35 public history::HistoryServiceObserver { |
| 33 public: | 36 public: |
| 34 ChromeBrowserProvider(JNIEnv* env, jobject obj); | 37 ChromeBrowserProvider(JNIEnv* env, jobject obj); |
| 35 void Destroy(JNIEnv*, jobject); | 38 void Destroy(JNIEnv*, jobject); |
| 36 | 39 |
| 37 // JNI registration. | 40 // JNI registration. |
| 38 static bool RegisterChromeBrowserProvider(JNIEnv* env); | 41 static bool RegisterChromeBrowserProvider(JNIEnv* env); |
| 39 | 42 |
| 40 // Adds either a new bookmark or bookmark folder based on |is_folder|. The | 43 // 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 | 44 // 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 | 45 // parent ID is not valid (i.e. < 0) then it will be added to the bookmark |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 jstring url); | 175 jstring url); |
| 173 | 176 |
| 174 private: | 177 private: |
| 175 virtual ~ChromeBrowserProvider(); | 178 virtual ~ChromeBrowserProvider(); |
| 176 | 179 |
| 177 // Override BaseBookmarkModelObserver. | 180 // Override BaseBookmarkModelObserver. |
| 178 virtual void BookmarkModelChanged() override; | 181 virtual void BookmarkModelChanged() override; |
| 179 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) override; | 182 virtual void ExtensiveBookmarkChangesBeginning(BookmarkModel* model) override; |
| 180 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) override; | 183 virtual void ExtensiveBookmarkChangesEnded(BookmarkModel* model) override; |
| 181 | 184 |
| 185 // Deals with updates to the history service. |
| 186 void OnHistoryChanged(); |
| 187 |
| 188 // Override HistoryServiceObserver. |
| 189 virtual void OnURLVisited(HistoryService* history_service, |
| 190 ui::PageTransition transition, |
| 191 const history::URLRow& row, |
| 192 const history::RedirectList& redirects, |
| 193 base::Time visit_time) override; |
| 194 |
| 182 // Override NotificationObserver. | 195 // Override NotificationObserver. |
| 183 virtual void Observe(int type, | 196 virtual void Observe(int type, |
| 184 const content::NotificationSource& source, | 197 const content::NotificationSource& source, |
| 185 const content::NotificationDetails& details) override; | 198 const content::NotificationDetails& details) override; |
| 186 | 199 |
| 187 JavaObjectWeakGlobalRef weak_java_provider_; | 200 JavaObjectWeakGlobalRef weak_java_provider_; |
| 188 | 201 |
| 202 // Profile must outlive this object. |
| 203 // |
| 204 // BookmarkModel, HistoryService and history::TopSites lifetime is bound to |
| 205 // the lifetime of Profile, they are safe to use as long as the Profile is |
| 206 // alive. |
| 189 Profile* profile_; | 207 Profile* profile_; |
| 190 BookmarkModel* bookmark_model_; | 208 BookmarkModel* bookmark_model_; |
| 191 history::TopSites* top_sites_; | 209 history::TopSites* top_sites_; |
| 192 | 210 |
| 193 scoped_ptr<AndroidHistoryProviderService> service_; | 211 scoped_ptr<AndroidHistoryProviderService> service_; |
| 194 scoped_ptr<FaviconService> favicon_service_; | 212 scoped_ptr<FaviconService> favicon_service_; |
| 195 | 213 |
| 196 base::CancelableTaskTracker cancelable_task_tracker_; | 214 base::CancelableTaskTracker cancelable_task_tracker_; |
| 197 | 215 |
| 198 // Used to register/unregister notification observer. | 216 // Used to register/unregister notification observer. |
| 199 content::NotificationRegistrar notification_registrar_; | 217 content::NotificationRegistrar notification_registrar_; |
| 218 ScopedObserver<HistoryService, HistoryServiceObserver> |
| 219 history_service_observer_; |
| 200 | 220 |
| 201 bool handling_extensive_changes_; | 221 bool handling_extensive_changes_; |
| 202 | 222 |
| 203 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProvider); | 223 DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProvider); |
| 204 }; | 224 }; |
| 205 | 225 |
| 206 #endif // CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ | 226 #endif // CHROME_BROWSER_ANDROID_PROVIDER_CHROME_BROWSER_PROVIDER_H_ |
| OLD | NEW |