OLD | NEW |
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 "base/strings/string_util.h" |
10 #include "components/dom_distiller/core/dom_distiller_switches.h" | 10 #include "components/dom_distiller/core/dom_distiller_switches.h" |
11 | 11 |
12 namespace dom_distiller { | 12 namespace dom_distiller { |
13 DistillerHeuristicsType GetDistillerHeuristicsType() { | 13 DistillerHeuristicsType GetDistillerHeuristicsType() { |
14 // 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. |
15 const std::string group_name = | 15 const std::string group_name = |
16 base::FieldTrialList::FindFullName("ReaderModeUI"); | 16 base::FieldTrialList::FindFullName("ReaderModeUI"); |
17 const std::string switch_value = | 17 const std::string switch_value = |
18 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 18 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
19 switches::kReaderModeHeuristics); | 19 switches::kReaderModeHeuristics); |
20 if (switch_value != "") { | 20 if (switch_value != "") { |
21 if (switch_value == switches::reader_mode_heuristics::kAdaBoost) { | 21 if (switch_value == switches::reader_mode_heuristics::kAdaBoost) { |
22 return DistillerHeuristicsType::ADABOOST_MODEL; | 22 return DistillerHeuristicsType::ADABOOST_MODEL; |
23 } | 23 } |
| 24 if (switch_value == switches::reader_mode_heuristics::kAllArticles) { |
| 25 return DistillerHeuristicsType::ALL_ARTICLES; |
| 26 } |
24 if (switch_value == switches::reader_mode_heuristics::kOGArticle) { | 27 if (switch_value == switches::reader_mode_heuristics::kOGArticle) { |
25 return DistillerHeuristicsType::OG_ARTICLE; | 28 return DistillerHeuristicsType::OG_ARTICLE; |
26 } | 29 } |
27 if (switch_value == switches::reader_mode_heuristics::kAlwaysTrue) { | 30 if (switch_value == switches::reader_mode_heuristics::kAlwaysTrue) { |
28 return DistillerHeuristicsType::ALWAYS_TRUE; | 31 return DistillerHeuristicsType::ALWAYS_TRUE; |
29 } | 32 } |
30 if (switch_value == switches::reader_mode_heuristics::kNone) { | 33 if (switch_value == switches::reader_mode_heuristics::kNone) { |
31 return DistillerHeuristicsType::NONE; | 34 return DistillerHeuristicsType::NONE; |
32 } | 35 } |
33 NOTREACHED() << "Invalid value for " << switches::kReaderModeHeuristics; | 36 NOTREACHED() << "Invalid value for " << switches::kReaderModeHeuristics; |
34 } else { | 37 } else { |
35 if (base::StartsWith(group_name, "AdaBoost", | 38 if (base::StartsWith(group_name, "AdaBoost", |
36 base::CompareCase::INSENSITIVE_ASCII)) { | 39 base::CompareCase::INSENSITIVE_ASCII)) { |
37 return DistillerHeuristicsType::ADABOOST_MODEL; | 40 return DistillerHeuristicsType::ADABOOST_MODEL; |
38 } | 41 } |
| 42 if (base::StartsWith(group_name, "AllArticles", |
| 43 base::CompareCase::INSENSITIVE_ASCII)) { |
| 44 return DistillerHeuristicsType::ALL_ARTICLES; |
| 45 } |
39 if (base::StartsWith(group_name, "OGArticle", | 46 if (base::StartsWith(group_name, "OGArticle", |
40 base::CompareCase::INSENSITIVE_ASCII)) { | 47 base::CompareCase::INSENSITIVE_ASCII)) { |
41 return DistillerHeuristicsType::OG_ARTICLE; | 48 return DistillerHeuristicsType::OG_ARTICLE; |
42 } | 49 } |
43 if (base::StartsWith(group_name, "Disabled", | 50 if (base::StartsWith(group_name, "Disabled", |
44 base::CompareCase::INSENSITIVE_ASCII)) { | 51 base::CompareCase::INSENSITIVE_ASCII)) { |
45 return DistillerHeuristicsType::NONE; | 52 return DistillerHeuristicsType::NONE; |
46 } | 53 } |
47 } | 54 } |
48 return DistillerHeuristicsType::ADABOOST_MODEL; | 55 return DistillerHeuristicsType::ADABOOST_MODEL; |
49 } | 56 } |
50 } | 57 } |
OLD | NEW |