| 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_HISTORY_TOP_SITES_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
| 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 6 #define CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 13 #include "base/task/cancelable_task_tracker.h" | 12 #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" |
| 16 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.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 class Profile; | 22 class Profile; |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class FilePath; | 25 class FilePath; |
| 26 class RefCountedBytes; | 26 class RefCountedBytes; |
| 27 class RefCountedMemory; | 27 class RefCountedMemory; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace history { | 30 namespace history { |
| 31 | 31 |
| 32 class TopSitesCache; | 32 class TopSitesCache; |
| 33 | 33 |
| 34 // Interface for TopSites, which stores the data for the top "most visited" | 34 // Interface for TopSites, which stores the data for the top "most visited" |
| 35 // sites. This includes a cache of the most visited data from history, as well | 35 // sites. This includes a cache of the most visited data from history, as well |
| 36 // as the corresponding thumbnails of those sites. | 36 // as the corresponding thumbnails of those sites. |
| 37 // | 37 // |
| 38 // Some methods should only be called from the UI thread (see method | 38 // Some methods should only be called from the UI thread (see method |
| 39 // descriptions below). All others are assumed to be threadsafe. | 39 // descriptions below). All others are assumed to be threadsafe. |
| 40 class TopSites | 40 class TopSites : public RefcountedKeyedService, |
| 41 : public base::RefCountedThreadSafe<TopSites>, | 41 public content::NotificationObserver { |
| 42 public content::NotificationObserver { | |
| 43 public: | 42 public: |
| 44 TopSites(); | 43 TopSites(); |
| 45 | 44 |
| 46 // Initializes TopSites. | 45 // Initializes TopSites. |
| 47 static TopSites* Create(Profile* profile, const base::FilePath& db_name); | 46 static TopSites* Create(Profile* profile, const base::FilePath& db_name); |
| 48 | 47 |
| 49 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 48 // Sets the given thumbnail for the given URL. Returns true if the thumbnail |
| 50 // was updated. False means either the URL wasn't known to us, or we felt | 49 // was updated. False means either the URL wasn't known to us, or we felt |
| 51 // that our current thumbnail was superior to the given one. Should be called | 50 // that our current thumbnail was superior to the given one. Should be called |
| 52 // from the UI thread. | 51 // from the UI thread. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Removes a URL from the blacklist. Should be called from the UI thread. | 111 // Removes a URL from the blacklist. Should be called from the UI thread. |
| 113 virtual void RemoveBlacklistedURL(const GURL& url) = 0; | 112 virtual void RemoveBlacklistedURL(const GURL& url) = 0; |
| 114 | 113 |
| 115 // Returns true if the URL is blacklisted. Should be called from the UI | 114 // Returns true if the URL is blacklisted. Should be called from the UI |
| 116 // thread. | 115 // thread. |
| 117 virtual bool IsBlacklisted(const GURL& url) = 0; | 116 virtual bool IsBlacklisted(const GURL& url) = 0; |
| 118 | 117 |
| 119 // Clear the blacklist. Should be called from the UI thread. | 118 // Clear the blacklist. Should be called from the UI thread. |
| 120 virtual void ClearBlacklistedURLs() = 0; | 119 virtual void ClearBlacklistedURLs() = 0; |
| 121 | 120 |
| 122 // Shuts down top sites. | |
| 123 virtual void Shutdown() = 0; | |
| 124 | |
| 125 // Query history service for the list of available thumbnails. Returns the | 121 // Query history service for the list of available thumbnails. Returns the |
| 126 // task id for the request, or |base::CancelableTaskTracker::kBadTaskId| if a | 122 // task id for the request, or |base::CancelableTaskTracker::kBadTaskId| if a |
| 127 // request could not be made. Public only for testing purposes. | 123 // request could not be made. Public only for testing purposes. |
| 128 virtual base::CancelableTaskTracker::TaskId StartQueryForMostVisited() = 0; | 124 virtual base::CancelableTaskTracker::TaskId StartQueryForMostVisited() = 0; |
| 129 | 125 |
| 130 // Returns true if the given URL is known to the top sites service. | 126 // Returns true if the given URL is known to the top sites service. |
| 131 // This function also returns false if TopSites isn't loaded yet. | 127 // This function also returns false if TopSites isn't loaded yet. |
| 132 virtual bool IsKnownURL(const GURL& url) = 0; | 128 virtual bool IsKnownURL(const GURL& url) = 0; |
| 133 | 129 |
| 134 // Follows the cached redirect chain to convert any URL to its | 130 // Follows the cached redirect chain to convert any URL to its |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const int kPrepopulatedPagesCount = 0; | 187 const int kPrepopulatedPagesCount = 0; |
| 192 #else | 188 #else |
| 193 const int kPrepopulatedPagesCount = 2; | 189 const int kPrepopulatedPagesCount = 2; |
| 194 #endif | 190 #endif |
| 195 extern const TopSites::PrepopulatedPage | 191 extern const TopSites::PrepopulatedPage |
| 196 kPrepopulatedPages[kPrepopulatedPagesCount]; | 192 kPrepopulatedPages[kPrepopulatedPagesCount]; |
| 197 | 193 |
| 198 } // namespace history | 194 } // namespace history |
| 199 | 195 |
| 200 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 196 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
| OLD | NEW |