Chromium Code Reviews| 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" | 13 #include "base/task/cancelable_task_tracker.h" |
|
msw
2016/12/13 22:31:53
nit: remove (move to impl)
Marc Treib
2016/12/14 11:12:22
Done. (impl already included it)
| |
| 14 #include "components/history/core/browser/history_types.h" | 14 #include "components/history/core/browser/history_types.h" |
| 15 #include "components/history/core/browser/top_sites_observer.h" | 15 #include "components/history/core/browser/top_sites_observer.h" |
| 16 #include "components/history/core/common/thumbnail_score.h" | 16 #include "components/history/core/common/thumbnail_score.h" |
| 17 #include "components/keyed_service/core/refcounted_keyed_service.h" | 17 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 | 20 |
| 21 class GURL; | 21 class GURL; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 TopSites(); | 58 TopSites(); |
| 59 | 59 |
| 60 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 60 // 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 | 61 // 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 | 62 // that our current thumbnail was superior to the given one. Should be called |
| 63 // from the UI thread. | 63 // from the UI thread. |
| 64 virtual bool SetPageThumbnail(const GURL& url, | 64 virtual bool SetPageThumbnail(const GURL& url, |
| 65 const gfx::Image& thumbnail, | 65 const gfx::Image& thumbnail, |
| 66 const ThumbnailScore& score) = 0; | 66 const ThumbnailScore& score) = 0; |
| 67 | 67 |
| 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&)> | 68 typedef base::Callback<void(const MostVisitedURLList&)> |
| 75 GetMostVisitedURLsCallback; | 69 GetMostVisitedURLsCallback; |
| 76 | 70 |
| 77 // Returns a list of most visited URLs via a callback, if | 71 // 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 | 72 // |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 | 73 // 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 | 74 // the data cached. If data is not available yet, callback will later be |
| 81 // posted to the thread called this function. | 75 // posted to the thread called this function. |
| 82 virtual void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, | 76 virtual void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback, |
| 83 bool include_forced_urls) = 0; | 77 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. | 115 // Removes a URL from the blacklist. Should be called from the UI thread. |
| 122 virtual void RemoveBlacklistedURL(const GURL& url) = 0; | 116 virtual void RemoveBlacklistedURL(const GURL& url) = 0; |
| 123 | 117 |
| 124 // Returns true if the URL is blacklisted. Should be called from the UI | 118 // Returns true if the URL is blacklisted. Should be called from the UI |
| 125 // thread. | 119 // thread. |
| 126 virtual bool IsBlacklisted(const GURL& url) = 0; | 120 virtual bool IsBlacklisted(const GURL& url) = 0; |
| 127 | 121 |
| 128 // Clear the blacklist. Should be called from the UI thread. | 122 // Clear the blacklist. Should be called from the UI thread. |
| 129 virtual void ClearBlacklistedURLs() = 0; | 123 virtual void ClearBlacklistedURLs() = 0; |
| 130 | 124 |
| 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. | 125 // 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. | 126 // This function also returns false if TopSites isn't loaded yet. |
| 138 virtual bool IsKnownURL(const GURL& url) = 0; | 127 virtual bool IsKnownURL(const GURL& url) = 0; |
| 139 | 128 |
| 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 | 129 // 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 | 130 // already have the maximum number of non-forced top sites). This function |
| 147 // also returns false if TopSites isn't loaded yet. | 131 // also returns false if TopSites isn't loaded yet. |
| 148 virtual bool IsNonForcedFull() = 0; | 132 virtual bool IsNonForcedFull() = 0; |
| 149 | 133 |
| 150 // Returns true if the top sites list of forced URLs is full (i.e. we already | 134 // 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 | 135 // have the maximum number of forced top sites). This function also returns |
| 152 // false if TopSites isn't loaded yet. | 136 // false if TopSites isn't loaded yet. |
| 153 virtual bool IsForcedFull() = 0; | 137 virtual bool IsForcedFull() = 0; |
| 154 | 138 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 182 friend class base::RefCountedThreadSafe<TopSites>; | 166 friend class base::RefCountedThreadSafe<TopSites>; |
| 183 | 167 |
| 184 base::ObserverList<TopSitesObserver, true> observer_list_; | 168 base::ObserverList<TopSitesObserver, true> observer_list_; |
| 185 | 169 |
| 186 DISALLOW_COPY_AND_ASSIGN(TopSites); | 170 DISALLOW_COPY_AND_ASSIGN(TopSites); |
| 187 }; | 171 }; |
| 188 | 172 |
| 189 } // namespace history | 173 } // namespace history |
| 190 | 174 |
| 191 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ | 175 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ |
| OLD | NEW |