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

Side by Side Diff: components/ntp_snippets/features.cc

Issue 2595883002: [NTP::SectionOrder] Add a flag to choose category ranker. (Closed)
Patch Set: jkrcal@ nit. Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ntp_snippets/features.h" 5 #include "components/ntp_snippets/features.h"
6 6
7 #include "components/variations/variations_associated_data.h" 7 #include "components/variations/variations_associated_data.h"
8 8
9 namespace ntp_snippets { 9 namespace ntp_snippets {
10 10
(...skipping 26 matching lines...) Expand all
37 37
38 const base::Feature kForeignSessionsSuggestionsFeature{ 38 const base::Feature kForeignSessionsSuggestionsFeature{
39 "NTPForeignSessionsSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; 39 "NTPForeignSessionsSuggestions", base::FEATURE_DISABLED_BY_DEFAULT};
40 40
41 const base::Feature kFetchMoreFeature{"NTPSuggestionsFetchMore", 41 const base::Feature kFetchMoreFeature{"NTPSuggestionsFetchMore",
42 base::FEATURE_ENABLED_BY_DEFAULT}; 42 base::FEATURE_ENABLED_BY_DEFAULT};
43 43
44 const base::Feature kPreferAmpUrlsFeature{"NTPPreferAmpUrls", 44 const base::Feature kPreferAmpUrlsFeature{"NTPPreferAmpUrls",
45 base::FEATURE_ENABLED_BY_DEFAULT}; 45 base::FEATURE_ENABLED_BY_DEFAULT};
46 46
47 const base::Feature kCategoryRanker{"NTPCategoryRanker",
48 base::FEATURE_ENABLED_BY_DEFAULT};
49
50 const char kCategoryRankerParameter[] = "category_ranker";
51 const char kCategoryRankerConstantRanker[] = "constant";
52 const char kCategoryRankerClickBasedRanker[] = "click_based";
53
54 CategoryRankerChoice GetSelectedCategoryRanker() {
55 std::string category_ranker_value =
56 variations::GetVariationParamValueByFeature(kCategoryRanker,
57 kCategoryRankerParameter);
58
59 if (category_ranker_value.empty()) {
60 // Default, Enabled or Disabled.
61 return CategoryRankerChoice::CONSTANT;
62 }
63 if (category_ranker_value == kCategoryRankerConstantRanker) {
64 return CategoryRankerChoice::CONSTANT;
65 }
66 if (category_ranker_value == kCategoryRankerClickBasedRanker) {
67 return CategoryRankerChoice::CLICK_BASED;
68 }
69
70 NOTREACHED() << "The " << kCategoryRankerParameter << " parameter value is '"
71 << category_ranker_value << "'";
72 return CategoryRankerChoice::CONSTANT;
73 }
74
47 } // namespace ntp_snippets 75 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698