profile_management_switches.cc revision 0529e5d033099cbfc42635f6f6183833b09dff6e
1// Copyright 2014 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.
4
5#include "components/signin/core/common/profile_management_switches.h"
6
7#include "base/command_line.h"
8#include "base/metrics/field_trial.h"
9#include "components/signin/core/common/signin_switches.h"
10
11namespace {
12
13const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
14
15bool CheckProfileManagementFlag(std::string command_switch, bool active_state) {
16  // Individiual flag settings take precedence.
17  if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) {
18    return true;
19  }
20
21  // --new-profile-management flag always affects all switches.
22  if (CommandLine::ForCurrentProcess()->HasSwitch(
23        switches::kNewProfileManagement)) {
24    return active_state;
25  }
26
27  // NewProfileManagement experiment acts like above flag.
28  std::string trial_type =
29      base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
30  if (!trial_type.empty()) {
31    if (trial_type == "Enabled")
32      return active_state;
33    if (trial_type == "Disabled")
34      return !active_state;
35  }
36
37  return false;
38}
39
40}  // namespace
41
42namespace switches {
43
44bool IsEnableWebBasedSignin() {
45  return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false);
46}
47
48bool IsFastUserSwitching() {
49  bool use_mirror_promo_menu =
50      CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu) &&
51      !IsNewProfileManagement();
52  return CommandLine::ForCurrentProcess()->HasSwitch(
53      switches::kFastUserSwitching) || use_mirror_promo_menu;
54}
55
56bool IsGoogleProfileInfo() {
57  return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true);
58}
59
60bool IsNewAvatarMenu() {
61  bool is_new_avatar_menu =
62      CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
63  return is_new_avatar_menu || IsNewProfileManagement();
64}
65
66bool IsNewProfileManagement() {
67  return CheckProfileManagementFlag(switches::kNewProfileManagement, true);
68}
69
70bool IsNewProfileManagementPreviewEnabled() {
71  bool is_new_avatar_menu =
72      CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
73  return is_new_avatar_menu && IsNewProfileManagement();
74}
75
76}  // namespace switches
77