| 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 COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ | 5 #ifndef COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ |
| 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ | 6 #define COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/task/cancelable_task_tracker.h" | |
| 14 #include "components/history/core/browser/history_types.h" | 13 #include "components/history/core/browser/history_types.h" |
| 15 #include "components/history/core/browser/top_sites_observer.h" | 14 #include "components/history/core/browser/top_sites_observer.h" |
| 16 #include "components/history/core/common/thumbnail_score.h" | 15 #include "components/history/core/common/thumbnail_score.h" |
| 17 #include "components/keyed_service/core/refcounted_keyed_service.h" | 16 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 20 | 19 |
| 21 class GURL; | 20 class GURL; |
| 22 | 21 |
| 23 namespace base { | 22 namespace base { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 TopSites(); | 57 TopSites(); |
| 59 | 58 |
| 60 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 59 // Sets the given thumbnail for the given URL. Returns true if the thumbnail |
| 61 // was updated. False means either the URL wasn't known to us, or we felt | 60 // was updated. False means either the URL wasn't known to us, or we felt |
| 62 // that our current thumbnail was superior to the given one. Should be called | 61 // that our current thumbnail was superior to the given one. Should be called |
| 63 // from the UI thread. | 62 // from the UI thread. |
| 64 virtual bool SetPageThumbnail(const GURL& url, | 63 virtual bool SetPageThumbnail(const GURL& url, |
| 65 const gfx::Image& thumbnail, | 64 const gfx::Image& thumbnail, |
| 66 const ThumbnailScore& score) = 0; | 65 const ThumbnailScore& score) = 0; |
| 67 | 66 |
| 68 // While testing the history system, we want to set the thumbnail to a piece | |
| 69 // of static memory. | |
| 70 virtual bool SetPageThumbnailToJPEGBytes(const GURL& url, | |
| 71 const base::RefCountedMemory* memory, | |
| 72 const ThumbnailScore& score) = 0; | |
| 73 | |
| 74 typedef base::Callback<void(const MostVisitedURLList&)> | 67 typedef base::Callback<void(const MostVisitedURLList&)> |
| 75 GetMostVisitedURLsCallback; | 68 GetMostVisitedURLsCallback; |
| 76 | 69 |
| 77 // Returns a list of most visited URLs via a callback, if | 70 // Returns a list of most visited URLs via a callback, if |
| 78 // |include_forced_urls| is false includes only non-forced URLs. This may be | 71 // |include_forced_urls| is false includes only non-forced URLs. This may be |
| 79 // invoked on any thread. NOTE: the callback is called immediately if we have | 72 // invoked on any thread. NOTE: the callback is called immediately if we have |
| 80 // the data cached. If data is not available yet, callback will later be | 73 // the data cached. If data is not available yet, callback will later be |
| 81 // posted to the thread called this function. | 74 // posted to the thread called this function. |
| 82 virtual void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, | 75 virtual void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, |
| 83 bool include_forced_urls) = 0; | 76 bool include_forced_urls) = 0; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // Removes a URL from the blacklist. Should be called from the UI thread. | 114 // Removes a URL from the blacklist. Should be called from the UI thread. |
| 122 virtual void RemoveBlacklistedURL(const GURL& url) = 0; | 115 virtual void RemoveBlacklistedURL(const GURL& url) = 0; |
| 123 | 116 |
| 124 // Returns true if the URL is blacklisted. Should be called from the UI | 117 // Returns true if the URL is blacklisted. Should be called from the UI |
| 125 // thread. | 118 // thread. |
| 126 virtual bool IsBlacklisted(const GURL& url) = 0; | 119 virtual bool IsBlacklisted(const GURL& url) = 0; |
| 127 | 120 |
| 128 // Clear the blacklist. Should be called from the UI thread. | 121 // Clear the blacklist. Should be called from the UI thread. |
| 129 virtual void ClearBlacklistedURLs() = 0; | 122 virtual void ClearBlacklistedURLs() = 0; |
| 130 | 123 |
| 131 // Query history service for the list of available thumbnails. Returns the | |
| 132 // task id for the request, or |base::CancelableTaskTracker::kBadTaskId| if a | |
| 133 // request could not be made. Public only for testing purposes. | |
| 134 virtual base::CancelableTaskTracker::TaskId StartQueryForMostVisited() = 0; | |
| 135 | |
| 136 // Returns true if the given URL is known to the top sites service. | 124 // Returns true if the given URL is known to the top sites service. |
| 137 // This function also returns false if TopSites isn't loaded yet. | 125 // This function also returns false if TopSites isn't loaded yet. |
| 138 virtual bool IsKnownURL(const GURL& url) = 0; | 126 virtual bool IsKnownURL(const GURL& url) = 0; |
| 139 | 127 |
| 140 // Follows the cached redirect chain to convert any URL to its | |
| 141 // canonical version. If no redirect chain is known for the URL, | |
| 142 // return it without modification. | |
| 143 virtual const std::string& GetCanonicalURLString(const GURL& url) const = 0; | |
| 144 | |
| 145 // Returns true if the top sites list of non-forced URLs is full (i.e. we | 128 // Returns true if the top sites list of non-forced URLs is full (i.e. we |
| 146 // already have the maximum number of non-forced top sites). This function | 129 // already have the maximum number of non-forced top sites). This function |
| 147 // also returns false if TopSites isn't loaded yet. | 130 // also returns false if TopSites isn't loaded yet. |
| 148 virtual bool IsNonForcedFull() = 0; | 131 virtual bool IsNonForcedFull() = 0; |
| 149 | 132 |
| 150 // Returns true if the top sites list of forced URLs is full (i.e. we already | 133 // Returns true if the top sites list of forced URLs is full (i.e. we already |
| 151 // have the maximum number of forced top sites). This function also returns | 134 // have the maximum number of forced top sites). This function also returns |
| 152 // false if TopSites isn't loaded yet. | 135 // false if TopSites isn't loaded yet. |
| 153 virtual bool IsForcedFull() = 0; | 136 virtual bool IsForcedFull() = 0; |
| 154 | 137 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 182 friend class base::RefCountedThreadSafe<TopSites>; | 165 friend class base::RefCountedThreadSafe<TopSites>; |
| 183 | 166 |
| 184 base::ObserverList<TopSitesObserver, true> observer_list_; | 167 base::ObserverList<TopSitesObserver, true> observer_list_; |
| 185 | 168 |
| 186 DISALLOW_COPY_AND_ASSIGN(TopSites); | 169 DISALLOW_COPY_AND_ASSIGN(TopSites); |
| 187 }; | 170 }; |
| 188 | 171 |
| 189 } // namespace history | 172 } // namespace history |
| 190 | 173 |
| 191 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ | 174 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ |
| OLD | NEW |