| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_ANDROID_MOST_VISITED_SITES_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
| 6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ | 6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 10 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 13 #include "base/scoped_observer.h" | 17 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 15 #include "components/history/core/browser/history_types.h" | 19 #include "components/history/core/browser/history_types.h" |
| 16 #include "components/history/core/browser/top_sites_observer.h" | 20 #include "components/history/core/browser/top_sites_observer.h" |
| 17 #include "components/suggestions/proto/suggestions.pb.h" | 21 #include "components/suggestions/proto/suggestions.pb.h" |
| 18 #include "components/sync_driver/sync_service_observer.h" | 22 #include "components/sync_driver/sync_service_observer.h" |
| 19 | 23 |
| 20 namespace suggestions { | 24 namespace suggestions { |
| 21 class SuggestionsService; | 25 class SuggestionsService; |
| 22 } | 26 } |
| 23 | 27 |
| 28 class GURL; |
| 29 class PopularSites; |
| 30 |
| 24 // Provides the list of most visited sites and their thumbnails to Java. | 31 // Provides the list of most visited sites and their thumbnails to Java. |
| 25 class MostVisitedSites : public sync_driver::SyncServiceObserver, | 32 class MostVisitedSites : public sync_driver::SyncServiceObserver, |
| 26 public history::TopSitesObserver { | 33 public history::TopSitesObserver { |
| 27 public: | 34 public: |
| 28 explicit MostVisitedSites(Profile* profile); | 35 explicit MostVisitedSites(Profile* profile); |
| 29 void Destroy(JNIEnv* env, jobject obj); | 36 void Destroy(JNIEnv* env, jobject obj); |
| 30 void OnLoadingComplete(JNIEnv* env, jobject obj); | 37 void OnLoadingComplete(JNIEnv* env, jobject obj); |
| 31 void SetMostVisitedURLsObserver(JNIEnv* env, | 38 void SetMostVisitedURLsObserver(JNIEnv* env, |
| 32 jobject obj, | 39 jobject obj, |
| 33 jobject j_observer, | 40 jobject j_observer, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 void InitiateTopSitesQuery(); | 68 void InitiateTopSitesQuery(); |
| 62 | 69 |
| 63 // Callback for when data is available from TopSites. | 70 // Callback for when data is available from TopSites. |
| 64 void OnMostVisitedURLsAvailable( | 71 void OnMostVisitedURLsAvailable( |
| 65 const history::MostVisitedURLList& visited_list); | 72 const history::MostVisitedURLList& visited_list); |
| 66 | 73 |
| 67 // Callback for when data is available from the SuggestionsService. | 74 // Callback for when data is available from the SuggestionsService. |
| 68 void OnSuggestionsProfileAvailable( | 75 void OnSuggestionsProfileAvailable( |
| 69 const suggestions::SuggestionsProfile& suggestions_profile); | 76 const suggestions::SuggestionsProfile& suggestions_profile); |
| 70 | 77 |
| 78 void AddPopularSites(std::vector<base::string16>* titles, |
| 79 std::vector<std::string>* urls); |
| 80 |
| 71 // Notify the Java side observer about the availability of Most Visited Urls. | 81 // Notify the Java side observer about the availability of Most Visited Urls. |
| 72 void NotifyMostVisitedURLsObserver(const std::vector<base::string16>& titles, | 82 void NotifyMostVisitedURLsObserver(const std::vector<base::string16>& titles, |
| 73 const std::vector<std::string>& urls); | 83 const std::vector<std::string>& urls); |
| 74 | 84 |
| 85 void OnPopularSitesAvailable(bool success); |
| 86 |
| 75 // Runs on the UI Thread. | 87 // Runs on the UI Thread. |
| 76 void OnLocalThumbnailFetched( | 88 void OnLocalThumbnailFetched( |
| 77 const GURL& url, | 89 const GURL& url, |
| 78 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback, | 90 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback, |
| 79 scoped_ptr<SkBitmap> bitmap); | 91 scoped_ptr<SkBitmap> bitmap); |
| 80 | 92 |
| 81 // Callback for when the thumbnail lookup is complete. | 93 // Callback for when the thumbnail lookup is complete. |
| 82 // Runs on the UI Thread. | 94 // Runs on the UI Thread. |
| 83 void OnObtainedThumbnail( | 95 void OnObtainedThumbnail( |
| 84 bool is_local_thumbnail, | 96 bool is_local_thumbnail, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // In this case a gray tile is used as the main tile. | 128 // In this case a gray tile is used as the main tile. |
| 117 int num_empty_thumbs_; | 129 int num_empty_thumbs_; |
| 118 | 130 |
| 119 // Copy of the server suggestions (if enabled). Used for logging. | 131 // Copy of the server suggestions (if enabled). Used for logging. |
| 120 suggestions::SuggestionsProfile server_suggestions_; | 132 suggestions::SuggestionsProfile server_suggestions_; |
| 121 | 133 |
| 122 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; | 134 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; |
| 123 | 135 |
| 124 MostVisitedSource mv_source_; | 136 MostVisitedSource mv_source_; |
| 125 | 137 |
| 138 scoped_ptr<PopularSites> popular_sites_; |
| 139 |
| 126 // For callbacks may be run after destruction. | 140 // For callbacks may be run after destruction. |
| 127 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 141 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
| 128 | 142 |
| 129 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 143 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
| 130 }; | 144 }; |
| 131 | 145 |
| 132 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ | 146 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
| OLD | NEW |