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

Side by Side Diff: components/dom_distiller/core/experiments.cc

Issue 2210683002: Do prefix matching for ReaderModeUI finch group (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/dom_distiller/core/experiments.h" 5 #include "components/dom_distiller/core/experiments.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/strings/string_util.h"
9 #include "components/dom_distiller/core/dom_distiller_switches.h" 10 #include "components/dom_distiller/core/dom_distiller_switches.h"
10 11
11 namespace dom_distiller { 12 namespace dom_distiller {
12 DistillerHeuristicsType GetDistillerHeuristicsType() { 13 DistillerHeuristicsType GetDistillerHeuristicsType() {
13 // Get the field trial name first to ensure the experiment is initialized. 14 // Get the field trial name first to ensure the experiment is initialized.
14 const std::string group_name = 15 const std::string group_name =
15 base::FieldTrialList::FindFullName("ReaderModeUI"); 16 base::FieldTrialList::FindFullName("ReaderModeUI");
16 const std::string switch_value = 17 const std::string switch_value =
17 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 18 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
18 switches::kReaderModeHeuristics); 19 switches::kReaderModeHeuristics);
19 if (switch_value != "") { 20 if (switch_value != "") {
20 if (switch_value == switches::reader_mode_heuristics::kAdaBoost) { 21 if (switch_value == switches::reader_mode_heuristics::kAdaBoost) {
21 return DistillerHeuristicsType::ADABOOST_MODEL; 22 return DistillerHeuristicsType::ADABOOST_MODEL;
22 } 23 }
23 if (switch_value == switches::reader_mode_heuristics::kOGArticle) { 24 if (switch_value == switches::reader_mode_heuristics::kOGArticle) {
24 return DistillerHeuristicsType::OG_ARTICLE; 25 return DistillerHeuristicsType::OG_ARTICLE;
25 } 26 }
26 if (switch_value == switches::reader_mode_heuristics::kAlwaysTrue) { 27 if (switch_value == switches::reader_mode_heuristics::kAlwaysTrue) {
27 return DistillerHeuristicsType::ALWAYS_TRUE; 28 return DistillerHeuristicsType::ALWAYS_TRUE;
28 } 29 }
29 if (switch_value == switches::reader_mode_heuristics::kNone) { 30 if (switch_value == switches::reader_mode_heuristics::kNone) {
30 return DistillerHeuristicsType::NONE; 31 return DistillerHeuristicsType::NONE;
31 } 32 }
32 NOTREACHED() << "Invalid value for " << switches::kReaderModeHeuristics; 33 NOTREACHED() << "Invalid value for " << switches::kReaderModeHeuristics;
33 } else { 34 } else {
34 if (group_name == "AdaBoost") { 35 if (base::StartsWith(group_name, "AdaBoost",
36 base::CompareCase::INSENSITIVE_ASCII)) {
35 return DistillerHeuristicsType::ADABOOST_MODEL; 37 return DistillerHeuristicsType::ADABOOST_MODEL;
36 } 38 }
37 if (group_name == "OGArticle") { 39 if (base::StartsWith(group_name, "OGArticle",
40 base::CompareCase::INSENSITIVE_ASCII)) {
38 return DistillerHeuristicsType::OG_ARTICLE; 41 return DistillerHeuristicsType::OG_ARTICLE;
39 } 42 }
40 } 43 }
41 return DistillerHeuristicsType::NONE; 44 return DistillerHeuristicsType::NONE;
42 } 45 }
43 46
44 bool ShouldShowFeedbackForm() { 47 bool ShouldShowFeedbackForm() {
45 const std::string group_name = 48 const std::string group_name =
46 base::FieldTrialList::FindFullName("ReaderModeUIFeedback"); 49 base::FieldTrialList::FindFullName("ReaderModeUIFeedback");
47 const std::string switch_value = 50 const std::string switch_value =
(...skipping 11 matching lines...) Expand all
59 if (group_name == "DoNotShow") { 62 if (group_name == "DoNotShow") {
60 return false; 63 return false;
61 } 64 }
62 if (group_name == "Show") { 65 if (group_name == "Show") {
63 return true; 66 return true;
64 } 67 }
65 } 68 }
66 return false; 69 return false;
67 } 70 }
68 } 71 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698