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

Side by Side Diff: components/arc/arc_util.cc

Issue 2655873002: Get enrollment token from DMServer when an Active Directory user uses ARC (Closed)
Patch Set: Fix Luis's comments Created 3 years, 10 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 | « components/arc/arc_util.h ('k') | components/arc/arc_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/arc/arc_util.h" 5 #include "components/arc/arc_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "chromeos/chromeos_switches.h" 11 #include "chromeos/chromeos_switches.h"
12 #include "components/user_manager/user_manager.h" 12 #include "components/user_manager/user_manager.h"
13 13
14 namespace arc { 14 namespace arc {
15 15
16 namespace { 16 namespace {
17 17
18 // This is for finch. See also crbug.com/633704 for details. 18 // This is for finch. See also crbug.com/633704 for details.
19 // TODO(hidehiko): More comments of the intention how this works, when 19 // TODO(hidehiko): More comments of the intention how this works, when
20 // we unify the commandline flags. 20 // we unify the commandline flags.
21 const base::Feature kEnableArcFeature{"EnableARC", 21 const base::Feature kEnableArcFeature{"EnableARC",
22 base::FEATURE_DISABLED_BY_DEFAULT}; 22 base::FEATURE_DISABLED_BY_DEFAULT};
23 23
24 // Possible values for --arc-availability flag. 24 // Possible values for --arc-availability flag.
25 constexpr char kAvailabilityNone[] = "none"; 25 constexpr char kAvailabilityNone[] = "none";
26 constexpr char kAvailabilityInstalled[] = "installed"; 26 constexpr char kAvailabilityInstalled[] = "installed";
27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; 27 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported";
28 constexpr char kAvailabilityOfficiallySupportedWithActiveDirectory[] =
29 "officially-supported-with-active-directory";
28 30
29 } // namespace 31 } // namespace
30 32
31 bool IsArcAvailable() { 33 bool IsArcAvailable() {
32 const auto* command_line = base::CommandLine::ForCurrentProcess(); 34 const auto* command_line = base::CommandLine::ForCurrentProcess();
33 35
34 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { 36 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) {
35 std::string value = command_line->GetSwitchValueASCII( 37 std::string value = command_line->GetSwitchValueASCII(
36 chromeos::switches::kArcAvailability); 38 chromeos::switches::kArcAvailability);
37 DCHECK(value == kAvailabilityNone || 39 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled ||
38 value == kAvailabilityInstalled || 40 value == kAvailabilityOfficiallySupported ||
39 value == kAvailabilityOfficiallySupported) 41 value == kAvailabilityOfficiallySupportedWithActiveDirectory)
40 << "Unknown flag value: " << value; 42 << "Unknown flag value: " << value;
41 return value == kAvailabilityOfficiallySupported || 43 return value == kAvailabilityOfficiallySupported ||
42 (value == kAvailabilityInstalled && 44 value == kAvailabilityOfficiallySupportedWithActiveDirectory ||
43 base::FeatureList::IsEnabled(kEnableArcFeature)); 45 (value == kAvailabilityInstalled &&
46 base::FeatureList::IsEnabled(kEnableArcFeature));
44 } 47 }
45 48
46 // For transition, fallback to old flags. 49 // For transition, fallback to old flags.
47 // TODO(hidehiko): Remove this and clean up whole this function, when 50 // TODO(hidehiko): Remove this and clean up whole this function, when
48 // session_manager supports a new flag. 51 // session_manager supports a new flag.
49 return command_line->HasSwitch(chromeos::switches::kEnableArc) || 52 return command_line->HasSwitch(chromeos::switches::kEnableArc) ||
50 (command_line->HasSwitch(chromeos::switches::kArcAvailable) && 53 (command_line->HasSwitch(chromeos::switches::kArcAvailable) &&
51 base::FeatureList::IsEnabled(kEnableArcFeature)); 54 base::FeatureList::IsEnabled(kEnableArcFeature));
52 } 55 }
53 56
54 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { 57 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) {
55 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, 58 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability,
56 kAvailabilityOfficiallySupported); 59 kAvailabilityOfficiallySupported);
57 } 60 }
58 61
59 bool IsArcKioskMode() { 62 bool IsArcKioskMode() {
60 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 63 return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
61 } 64 }
62 65
66 bool IsArcAllowedForActiveDirectoryUsers() {
67 const auto* command_line = base::CommandLine::ForCurrentProcess();
68
69 if (!command_line->HasSwitch(chromeos::switches::kArcAvailability))
70 return false;
71
72 return command_line->GetSwitchValueASCII(
73 chromeos::switches::kArcAvailability) ==
74 kAvailabilityOfficiallySupportedWithActiveDirectory;
75 }
76
63 bool IsArcOptInVerificationDisabled() { 77 bool IsArcOptInVerificationDisabled() {
64 const auto* command_line = base::CommandLine::ForCurrentProcess(); 78 const auto* command_line = base::CommandLine::ForCurrentProcess();
65 return command_line->HasSwitch( 79 return command_line->HasSwitch(
66 chromeos::switches::kDisableArcOptInVerification); 80 chromeos::switches::kDisableArcOptInVerification);
67 } 81 }
68 82
69 } // namespace arc 83 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/arc_util.h ('k') | components/arc/arc_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698