OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_ | |
6 #define CHROME_BROWSER_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_ | |
7 | |
8 #include "base/values.h" | |
9 #include "chrome/browser/history/history_types.h" | |
10 #include "chrome/common/instant_types.h" | |
11 | |
12 namespace history { | |
13 | |
14 // This enum is also defined in histograms.xml. These values represent the | |
15 // types of actions carried out by the Most Visited Tile Placement experiment. | |
16 enum NtpTileExperimentActions { | |
17 NTP_TILE_EXPERIMENT_ACTION_REMOVED_URL = 0, | |
18 NTP_TILE_EXPERIMENT_ACTION_DID_NOT_REMOVE_URL = 1, | |
19 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_8 = 2, | |
20 NTP_TILE_EXPERIMENT_ACTION_TOO_FEW_URLS_TILES_1_4 = 3, | |
21 // The number of Most Visited Tile Placement experiment actions logged. | |
22 NUM_NTP_TILE_EXPERIMENT_ACTIONS | |
23 }; | |
24 | |
25 // Class for implementing the Most Visited Tile Placement experiment. | |
26 class MostVisitedTilesExperiment { | |
27 public: | |
28 // Helper method to shuffle MostVisited tiles for A/B testing purposes. | |
29 static void MaybeShuffle(MostVisitedURLList* data); | |
30 | |
31 // Returns true if this user is part of the Most Visited Tile Placement | |
32 // experiment group where URLs currently open in another browser tab are not | |
33 // displayed on an NTP tile. Note: the experiment targets only the top-level | |
34 // of sites i.e. if www.foo.com/bar is open in browser, and www.foo.com is a | |
35 // recommended URL, www.foo.com will still appear on the next NTP open. The | |
36 // experiment will not remove a URL if doing so would cause the number of Most | |
37 // Visited recommendations to drop below eight. | |
38 static bool IsDontShowOpenURLsEnabled(); | |
39 | |
40 // Removes URLs already open in browser, for 1993 clients, if part of | |
41 // experiment described for IsDontShowOpenURLsEnabled(). | |
42 static void RemoveItemsMatchingOpenTabs( | |
43 const std::set<std::string>& open_urls, | |
44 std::vector<InstantMostVisitedItem>* items); | |
45 | |
46 // Removes URLs already open in browser, for non-1993 clients, if part of | |
47 // experiment described for IsDontShowOpenURLsEnabled(). | |
48 static void RemovePageValuesMatchingOpenTabs( | |
49 const std::set<std::string>& open_urls, | |
50 base::ListValue* pages_value); | |
51 | |
52 private: | |
53 // Helper method to log the actions carried out by the Most Visited Tile | |
54 // Placement experiment. | |
55 static void LogInHistogram(NtpTileExperimentActions action); | |
56 | |
57 // Helper method to determine whether |url| is in |open_urls|. | |
58 static bool ShouldRemoveURL(const std::set<std::string>& open_urls, | |
59 const std::string& url, | |
60 const size_t size); | |
61 | |
62 DISALLOW_IMPLICIT_CONSTRUCTORS(MostVisitedTilesExperiment); | |
63 }; | |
64 | |
65 } // namespace history | |
66 | |
67 #endif // CHROME_BROWSER_HISTORY_MOST_VISITED_TILES_EXPERIMENT_H_ | |
OLD | NEW |