| 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 "components/history/core/browser/history_types.h" | 13 #include "components/history/core/browser/history_types.h" |
| 14 #include "components/history/core/browser/top_sites_observer.h" | 14 #include "components/history/core/browser/top_sites_observer.h" |
| 15 #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" | 16 #include "components/keyed_service/core/refcounted_keyed_service.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class RefCountedMemory; | 23 class RefCountedMemory; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace history { | 26 namespace history { |
| 27 | 27 |
| 28 class TopSitesObserver; | |
| 29 | |
| 30 // PrepopulatedPage stores information for prepopulated page for the | 28 // PrepopulatedPage stores information for prepopulated page for the |
| 31 // initial run. | 29 // initial run. |
| 32 struct PrepopulatedPage { | 30 struct PrepopulatedPage { |
| 33 PrepopulatedPage(); | 31 PrepopulatedPage(); |
| 34 PrepopulatedPage(const GURL& url, | 32 PrepopulatedPage(const GURL& url, |
| 35 const base::string16& title, | 33 const base::string16& title, |
| 36 int favicon_id, | 34 int favicon_id, |
| 37 int thumbnail_id, | 35 int thumbnail_id, |
| 38 SkColor color); | 36 SkColor color); |
| 39 | 37 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // false if TopSites isn't loaded yet. | 133 // false if TopSites isn't loaded yet. |
| 136 virtual bool IsForcedFull() = 0; | 134 virtual bool IsForcedFull() = 0; |
| 137 | 135 |
| 138 virtual bool loaded() const = 0; | 136 virtual bool loaded() const = 0; |
| 139 | 137 |
| 140 // Returns the set of prepopulate pages. | 138 // Returns the set of prepopulate pages. |
| 141 virtual PrepopulatedPageList GetPrepopulatedPages() = 0; | 139 virtual PrepopulatedPageList GetPrepopulatedPages() = 0; |
| 142 | 140 |
| 143 // Adds or updates a |url| for which we should force the capture of a | 141 // Adds or updates a |url| for which we should force the capture of a |
| 144 // thumbnail next time it's visited. If there is already a non-forced URL | 142 // thumbnail next time it's visited. If there is already a non-forced URL |
| 145 // matching this |url| this call has no effect. Indicate this URL was laste | 143 // matching this |url| this call has no effect. Indicate this URL was last |
| 146 // forced at |time| so we can evict the older URLs when needed. Should be | 144 // forced at |time| so we can evict the older URLs when needed. Should be |
| 147 // called from the UI thread. | 145 // called from the UI thread. |
| 148 virtual bool AddForcedURL(const GURL& url, const base::Time& time) = 0; | 146 virtual bool AddForcedURL(const GURL& url, const base::Time& time) = 0; |
| 149 | 147 |
| 150 // Called when user has navigated to |url|. | 148 // Called when user has navigated to |url|. |
| 151 virtual void OnNavigationCommitted(const GURL& url) = 0; | 149 virtual void OnNavigationCommitted(const GURL& url) = 0; |
| 152 | 150 |
| 153 // Add Observer to the list. | 151 // Add Observer to the list. |
| 154 void AddObserver(TopSitesObserver* observer); | 152 void AddObserver(TopSitesObserver* observer); |
| 155 | 153 |
| 156 // Remove Observer from the list. | 154 // Remove Observer from the list. |
| 157 void RemoveObserver(TopSitesObserver* observer); | 155 void RemoveObserver(TopSitesObserver* observer); |
| 158 | 156 |
| 159 protected: | 157 protected: |
| 160 void NotifyTopSitesLoaded(); | 158 void NotifyTopSitesLoaded(); |
| 161 void NotifyTopSitesChanged(const TopSitesObserver::ChangeReason reason); | 159 void NotifyTopSitesChanged(const TopSitesObserver::ChangeReason reason); |
| 162 ~TopSites() override; | 160 ~TopSites() override; |
| 163 | 161 |
| 164 private: | 162 private: |
| 165 friend class base::RefCountedThreadSafe<TopSites>; | 163 friend class base::RefCountedThreadSafe<TopSites>; |
| 166 | 164 |
| 167 base::ObserverList<TopSitesObserver, true> observer_list_; | 165 base::ObserverList<TopSitesObserver, true> observer_list_; |
| 168 | 166 |
| 169 DISALLOW_COPY_AND_ASSIGN(TopSites); | 167 DISALLOW_COPY_AND_ASSIGN(TopSites); |
| 170 }; | 168 }; |
| 171 | 169 |
| 172 } // namespace history | 170 } // namespace history |
| 173 | 171 |
| 174 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ | 172 #endif // COMPONENTS_HISTORY_CORE_BROWSER_TOP_SITES_H_ |
| OLD | NEW |