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 "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
17 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.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. Note: the experiment targets only the top-level of sites i.e. | |
54 // if www.foo.com/bar is open in browser, and www.foo.com is a recommended | |
55 // URL, www.foo.com will still appear on the next NTP open. The experiment | |
56 // will not remove a URL if doing so would cause the number of Most Visited | |
57 // recommendations to drop below eight. | |
58 static bool IsClientInTabsGroup(); | |
sky
2013/07/16 21:15:07
tabs group? I think this method is poorly named.
annark1
2013/07/17 17:45:52
Done. Renamed to DontShowOpenURLsEnabled
| |
59 | |
60 // Removes URLs already open in browser, for 1993 clients, if part of | |
61 // experiment described for IsClientInTabsGroup(). | |
62 static void RemoveItemsMatchingOpenTabs( | |
63 const std::set<std::string>& open_urls, | |
64 std::vector<InstantMostVisitedItem>* items); | |
65 | |
66 // Removes URLs already open in browser, for non-1993 clients, if part of | |
67 // experiment described for IsClientInTabsGroup(). | |
68 static void RemovePageValuesMatchingOpenTabs( | |
69 const std::set<std::string>& open_urls, | |
70 base::ListValue* pages_value); | |
71 | |
50 // Sets the given thumbnail for the given URL. Returns true if the thumbnail | 72 // 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 | 73 // 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 | 74 // that our current thumbnail was superior to the given one. Should be called |
53 // from the UI thread. | 75 // from the UI thread. |
54 virtual bool SetPageThumbnail(const GURL& url, | 76 virtual bool SetPageThumbnail(const GURL& url, |
55 const gfx::Image& thumbnail, | 77 const gfx::Image& thumbnail, |
56 const ThumbnailScore& score) = 0; | 78 const ThumbnailScore& score) = 0; |
57 | 79 |
58 // While testing the history system, we want to set the thumbnail to a piece | 80 // While testing the history system, we want to set the thumbnail to a piece |
59 // of static memory. | 81 // of static memory. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // The raw data resource for the thumbnail. | 187 // The raw data resource for the thumbnail. |
166 int thumbnail_id; | 188 int thumbnail_id; |
167 // The best color to highlight the page (should roughly match favicon). | 189 // The best color to highlight the page (should roughly match favicon). |
168 SkColor color; | 190 SkColor color; |
169 }; | 191 }; |
170 protected: | 192 protected: |
171 virtual ~TopSites() {} | 193 virtual ~TopSites() {} |
172 | 194 |
173 private: | 195 private: |
174 friend class base::RefCountedThreadSafe<TopSites>; | 196 friend class base::RefCountedThreadSafe<TopSites>; |
197 | |
198 // This enum is also defined in histograms.xml. These values represent the | |
199 // types of actions carried out by the Most Visited Tile Placement experiment. | |
200 enum NtpTileExperimentActions { | |
201 NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL = 0, | |
202 NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL = 1, | |
203 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8 = 2, | |
204 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4 = 3, | |
205 NTP_TILE_EXPERIMENT_ACTION_NO_URL_TO_FLIP = 4, | |
206 // The number of Most Visited Tile Placement experiment actions logged. | |
207 NUM_NTP_TILE_EXPERIMENT_ACTIONS | |
208 }; | |
209 | |
210 // Helper method to log the actions carried out by the Most Visited Tile | |
211 // Placement experiment. | |
212 static void LogInHistogram(NtpTileExperimentActions action); | |
213 | |
175 }; | 214 }; |
176 | 215 |
177 #if defined(OS_ANDROID) | 216 #if defined(OS_ANDROID) |
178 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; | 217 extern const TopSites::PrepopulatedPage kPrepopulatedPages[1]; |
179 #else | 218 #else |
180 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; | 219 extern const TopSites::PrepopulatedPage kPrepopulatedPages[2]; |
181 #endif | 220 #endif |
182 | 221 |
183 } // namespace history | 222 } // namespace history |
184 | 223 |
185 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ | 224 #endif // CHROME_BROWSER_HISTORY_TOP_SITES_H_ |
OLD | NEW |