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
3 // found in the LICENSE file.
5 #include "components/dom_distiller/core/experiments.h"
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "components/dom_distiller/core/dom_distiller_switches.h"
11 namespace dom_distiller
{
12 DistillerHeuristicsType
GetDistillerHeuristicsType() {
13 // Get the field trial name first to ensure the experiment is initialized.
14 const std::string group_name
=
15 base::FieldTrialList::FindFullName("ReaderModeUI");
16 const std::string switch_value
=
17 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
18 switches::kReaderModeHeuristics
);
19 if (switch_value
!= "") {
20 if (switch_value
== switches::reader_mode_heuristics::kAdaBoost
) {
21 return DistillerHeuristicsType::ADABOOST_MODEL
;
23 if (switch_value
== switches::reader_mode_heuristics::kOGArticle
) {
24 return DistillerHeuristicsType::OG_ARTICLE
;
26 if (switch_value
== switches::reader_mode_heuristics::kAlwaysTrue
) {
27 return DistillerHeuristicsType::ALWAYS_TRUE
;
29 if (switch_value
== switches::reader_mode_heuristics::kNone
) {
30 return DistillerHeuristicsType::NONE
;
32 NOTREACHED() << "Invalid value for " << switches::kReaderModeHeuristics
;
34 if (group_name
== "AdaBoost") {
35 return DistillerHeuristicsType::ADABOOST_MODEL
;
37 if (group_name
== "OGArticle") {
38 return DistillerHeuristicsType::OG_ARTICLE
;
41 return DistillerHeuristicsType::NONE
;
44 bool ShouldShowFeedbackForm() {
45 const std::string group_name
=
46 base::FieldTrialList::FindFullName("ReaderModeUIFeedback");
47 const std::string switch_value
=
48 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
49 switches::kReaderModeFeedback
);
50 if (switch_value
!= "") {
51 if (switch_value
== switches::reader_mode_feedback::kOn
) {
54 if (switch_value
== switches::reader_mode_feedback::kOff
) {
57 NOTREACHED() << "Invalid value for " << switches::kReaderModeFeedback
;
59 if (group_name
== "DoNotShow") {
62 if (group_name
== "Show") {