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/common/cancelable_request.h" | 12 #include "chrome/browser/common/cancelable_request.h" |
13 #include "chrome/browser/history/history_service.h" | 13 #include "chrome/browser/history/history_service.h" |
14 #include "chrome/browser/history/history_types.h" | 14 #include "chrome/browser/history/history_types.h" |
| 15 #include "chrome/common/instant_types.h" |
15 #include "chrome/common/thumbnail_score.h" | 16 #include "chrome/common/thumbnail_score.h" |
16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
19 | 20 |
20 class Profile; | 21 class Profile; |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class FilePath; | 24 class FilePath; |
24 class RefCountedBytes; | 25 class RefCountedBytes; |
(...skipping 15 matching lines...) Expand all Loading... |
40 public content::NotificationObserver { | 41 public content::NotificationObserver { |
41 public: | 42 public: |
42 TopSites() {} | 43 TopSites() {} |
43 | 44 |
44 // Initializes TopSites. | 45 // Initializes TopSites. |
45 static TopSites* Create(Profile* profile, const base::FilePath& db_name); | 46 static TopSites* Create(Profile* profile, const base::FilePath& db_name); |
46 | 47 |
47 // Helper method to shuffle MostVisited tiles for A/B testing purposes. | 48 // Helper method to shuffle MostVisited tiles for A/B testing purposes. |
48 static void MaybeShuffle(MostVisitedURLList* data); | 49 static void MaybeShuffle(MostVisitedURLList* data); |
49 | 50 |
| 51 // Returns true if this user is part of the Most Visited Tile Placement |
| 52 // experiment group where URLs currently open in the browser are not displayed |
| 53 // on the NTP. |
| 54 static bool IsClientInTabsGroup(); |
| 55 |
| 56 // Removes URLs already open in browser, for 1993 clients. |
| 57 static void RemoveItemsMatchingOpenTabs( |
| 58 const std::set<std::string>& open_urls, |
| 59 std::vector<InstantMostVisitedItem>* items); |
| 60 |
| 61 // Removes URLs already open in browser, for non-1993 clients. |
| 62 static void RemovePageValuesMatchingOpenTabs( |
| 63 const std::set<std::string>& open_urls, |
| 64 base::ListValue* pages_value); |
| 65 |
50 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 66 // Sets the given thumbnail for the given URL. Returns true if the thumbnail |
51 // was updated. False means either the URL wasn't known to us, or we felt | 67 // was updated. False means either the URL wasn't known to us, or we felt |
52 // that our current thumbnail was superior to the given one. Should be called | 68 // that our current thumbnail was superior to the given one. Should be called |
53 // from the UI thread. | 69 // from the UI thread. |
54 virtual bool SetPageThumbnail(const GURL& url, | 70 virtual bool SetPageThumbnail(const GURL& url, |
55 const gfx::Image& thumbnail, | 71 const gfx::Image& thumbnail, |
56 const ThumbnailScore& score) = 0; | 72 const ThumbnailScore& score) = 0; |
57 | 73 |
58 // While testing the history system, we want to set the thumbnail to a piece | 74 // While testing the history system, we want to set the thumbnail to a piece |
59 // of static memory. | 75 // of static memory. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // The raw data resource for the thumbnail. | 181 // The raw data resource for the thumbnail. |
166 int thumbnail_id; | 182 int thumbnail_id; |
167 // The best color to highlight the page (should roughly match favicon). | 183 // The best color to highlight the page (should roughly match favicon). |
168 SkColor color; | 184 SkColor color; |
169 }; | 185 }; |
170 protected: | 186 protected: |
171 virtual ~TopSites() {} | 187 virtual ~TopSites() {} |
172 | 188 |
173 private: | 189 private: |
174 friend class base::RefCountedThreadSafe<TopSites>; | 190 friend class base::RefCountedThreadSafe<TopSites>; |
| 191 |
| 192 // This enum is also defined in histograms.xml. These values represent the |
| 193 // types of actions carried out by the Most Visited Tile Placement experiment. |
| 194 enum NtpTileExperimentActions { |
| 195 NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL = 0, |
| 196 NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL = 1, |
| 197 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8 = 2, |
| 198 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4 = 3, |
| 199 NTP_TILE_EXPERIMENT_ACTION_NO_URL_TO_FLIP = 4, |
| 200 // The number of Most Visited Tile Placement experiment actions logged. |
| 201 NUM_NTP_TILE_EXPERIMENT_ACTIONS |
| 202 }; |
175 }; | 203 }; |
176 | 204 |
177 #if defined(OS_ANDROID) | 205 #if defined(OS_ANDROID) |
178 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; | 206 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; |
179 #else | 207 #else |
180 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; | 208 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; |
181 #endif | 209 #endif |
182 | 210 |
183 } // namespace history | 211 } // namespace history |
184 | 212 |
185 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 213 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
OLD | NEW |