Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: chrome/browser/history/top_sites.cc

Issue 17114002: Field trial removing tiles from NTP if URL is already open - for 1993 clients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Consolidated GetOpenURLs and addressed comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "chrome/browser/history/top_sites.h" 5 #include "chrome/browser/history/top_sites.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/browser/history/top_sites_impl.h" 9 #include "chrome/browser/history/top_sites_impl.h"
10 #include "chrome/browser/history/top_sites_likely_impl.h" 10 #include "chrome/browser/history/top_sites_likely_impl.h"
11 #include "grit/chromium_strings.h" 11 #include "grit/chromium_strings.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "grit/locale_settings.h" 13 #include "grit/locale_settings.h"
14 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
15 15
16 namespace history { 16 namespace history {
17 17
18 namespace {
19
20 // Constants for the most visited tile placement field trial.
21 // ex:
22 // "OneEightGroup_Flipped" --> Will cause tile 1 and 8 to be flipped.
23 // "OneEightGroup_NoChange" --> Will not flip anything.
24 //
25 // See field trial config (MostVisitedTilePlacement.json) for details.
26 const char kMostVisitedFieldTrialName[] = "MostVisitedTilePlacement";
27 const char kOneEightGroupPrefix[] = "OneEight";
28 const char kOneFourGroupPrefix[] = "OneFour";
29 const char kFlippedSuffix[] = "Flipped";
30
31 } // namespace
32
33 const TopSites::PrepopulatedPage kPrepopulatedPages[] = { 18 const TopSites::PrepopulatedPage kPrepopulatedPages[] = {
34 #if defined(OS_ANDROID) 19 #if defined(OS_ANDROID)
35 { IDS_MOBILE_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE, 20 { IDS_MOBILE_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE,
36 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL, 21 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL,
37 SkColorSetRGB(0, 147, 60) } 22 SkColorSetRGB(0, 147, 60) }
38 #else 23 #else
39 { IDS_CHROME_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE, 24 { IDS_CHROME_WELCOME_URL, IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE,
40 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL, 25 IDR_PRODUCT_LOGO_16, IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL,
41 SkColorSetRGB(0, 147, 60) }, 26 SkColorSetRGB(0, 147, 60) },
42 #endif 27 #endif
(...skipping 10 matching lines...) Expand all
53 // Experimental group. Enabled through a command-line flag. 38 // Experimental group. Enabled through a command-line flag.
54 TopSitesLikelyImpl* top_sites_likely_impl = new TopSitesLikelyImpl(profile); 39 TopSitesLikelyImpl* top_sites_likely_impl = new TopSitesLikelyImpl(profile);
55 top_sites_likely_impl->Init(db_name); 40 top_sites_likely_impl->Init(db_name);
56 return top_sites_likely_impl; 41 return top_sites_likely_impl;
57 } 42 }
58 TopSitesImpl* top_sites_impl = new TopSitesImpl(profile); 43 TopSitesImpl* top_sites_impl = new TopSitesImpl(profile);
59 top_sites_impl->Init(db_name); 44 top_sites_impl->Init(db_name);
60 return top_sites_impl; 45 return top_sites_impl;
61 } 46 }
62 47
63 // static
64 void TopSites::MaybeShuffle(MostVisitedURLList* data) {
65 const std::string group_name =
66 base::FieldTrialList::FindFullName(kMostVisitedFieldTrialName);
67
68 // Depending on the study group of the client, we might flip the 1st and 4th
69 // tiles, or the 1st and 8th, or do nothing.
70 if (EndsWith(group_name, kFlippedSuffix, true)) {
71 size_t index_to_flip = 0;
72 if (StartsWithASCII(group_name, kOneEightGroupPrefix, true) &&
73 data->size() >= 8) {
74 index_to_flip = 7;
75 } else if (StartsWithASCII(group_name, kOneFourGroupPrefix, true) &&
76 data->size() >= 4) {
77 index_to_flip = 3;
78 }
79
80 if (data->empty() || (*data)[index_to_flip].url.is_empty())
81 return;
82 std::swap((*data)[0], (*data)[index_to_flip]);
83 }
84 }
85
86 } // namespace history 48 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698