summaryrefslogtreecommitdiffstats
path: root/components/offline_pages/offline_page_feature.cc
blob: 8d51f527564137aff2d33e4f89293572ae5c2f54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/offline_pages/offline_page_feature.h"

#include <string>

#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "components/offline_pages/offline_page_switches.h"

#if defined(OS_ANDROID)

namespace offline_pages {

namespace {
const char kOfflinePagesFieldTrialName[] = "OfflinePages";
const char kOfflinePagesFieldTrialEnabledGroupName[] = "Enabled";
}  // namespace

bool IsOfflinePagesEnabled() {
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kEnableOfflinePages)) {
    return true;
  }
  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kDisableOfflinePages)) {
    return false;
  }

  std::string group_name =
      base::FieldTrialList::FindFullName(kOfflinePagesFieldTrialName);
  return group_name == kOfflinePagesFieldTrialEnabledGroupName;
}

}  // namespace offline_pages

#endif