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" | 11 #include "base/memory/ref_counted.h" |
12 #include "chrome/browser/history/history_service.h" | 12 #include "chrome/browser/history/history_service.h" |
13 #include "chrome/browser/history/history_types.h" | 13 #include "chrome/browser/history/history_types.h" |
| 14 #include "components/history/core/browser/top_sites_observer.h" |
14 #include "components/history/core/common/thumbnail_score.h" | 15 #include "components/history/core/common/thumbnail_score.h" |
15 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
17 | 18 |
18 class GURL; | 19 class GURL; |
19 class Profile; | 20 class Profile; |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class FilePath; | 23 class FilePath; |
23 class RefCountedBytes; | 24 class RefCountedBytes; |
24 class RefCountedMemory; | 25 class RefCountedMemory; |
25 } | 26 } |
26 | 27 |
27 namespace history { | 28 namespace history { |
28 | 29 |
29 class TopSitesCache; | 30 class TopSitesCache; |
30 | 31 |
31 // Interface for TopSites, which stores the data for the top "most visited" | 32 // Interface for TopSites, which stores the data for the top "most visited" |
32 // sites. This includes a cache of the most visited data from history, as well | 33 // sites. This includes a cache of the most visited data from history, as well |
33 // as the corresponding thumbnails of those sites. | 34 // as the corresponding thumbnails of those sites. |
34 // | 35 // |
35 // Some methods should only be called from the UI thread (see method | 36 // Some methods should only be called from the UI thread (see method |
36 // descriptions below). All others are assumed to be threadsafe. | 37 // descriptions below). All others are assumed to be threadsafe. |
37 class TopSites | 38 class TopSites |
38 : public base::RefCountedThreadSafe<TopSites>, | 39 : public base::RefCountedThreadSafe<TopSites>, |
39 public content::NotificationObserver { | 40 public content::NotificationObserver { |
40 public: | 41 public: |
41 TopSites() {} | 42 TopSites(); |
42 | 43 |
43 // Initializes TopSites. | 44 // Initializes TopSites. |
44 static TopSites* Create(Profile* profile, const base::FilePath& db_name); | 45 static TopSites* Create(Profile* profile, const base::FilePath& db_name); |
45 | 46 |
46 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 47 // Sets the given thumbnail for the given URL. Returns true if the thumbnail |
47 // was updated. False means either the URL wasn't known to us, or we felt | 48 // was updated. False means either the URL wasn't known to us, or we felt |
48 // that our current thumbnail was superior to the given one. Should be called | 49 // that our current thumbnail was superior to the given one. Should be called |
49 // from the UI thread. | 50 // from the UI thread. |
50 virtual bool SetPageThumbnail(const GURL& url, | 51 virtual bool SetPageThumbnail(const GURL& url, |
51 const gfx::Image& thumbnail, | 52 const gfx::Image& thumbnail, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 int url_id; | 161 int url_id; |
161 // The string resource for the page title. | 162 // The string resource for the page title. |
162 int title_id; | 163 int title_id; |
163 // The raw data resource for the favicon. | 164 // The raw data resource for the favicon. |
164 int favicon_id; | 165 int favicon_id; |
165 // The raw data resource for the thumbnail. | 166 // The raw data resource for the thumbnail. |
166 int thumbnail_id; | 167 int thumbnail_id; |
167 // The best color to highlight the page (should roughly match favicon). | 168 // The best color to highlight the page (should roughly match favicon). |
168 SkColor color; | 169 SkColor color; |
169 }; | 170 }; |
| 171 |
| 172 // Add Observer to the list. |
| 173 void AddObserver(TopSitesObserver* observer); |
| 174 |
| 175 // Remove Observer from the list. |
| 176 void RemoveObserver(TopSitesObserver* observer); |
| 177 |
170 protected: | 178 protected: |
171 virtual ~TopSites() {} | 179 void NotifyTopSitesLoaded(); |
| 180 void NotifyTopSitesChanged(); |
| 181 virtual ~TopSites(); |
172 | 182 |
173 private: | 183 private: |
| 184 ObserverList<TopSitesObserver> observer_list_; |
174 friend class base::RefCountedThreadSafe<TopSites>; | 185 friend class base::RefCountedThreadSafe<TopSites>; |
175 }; | 186 }; |
176 | 187 |
177 #if defined(OS_ANDROID) | 188 #if defined(OS_ANDROID) |
178 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; | 189 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; |
179 #else | 190 #else |
180 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; | 191 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; |
181 #endif | 192 #endif |
182 | 193 |
183 } // namespace history | 194 } // namespace history |
184 | 195 |
185 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 196 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
OLD | NEW |