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

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

Issue 2885933003: arc: Consolidate IsArcAllowedForUser logic (Closed)
Patch Set: fix #2 Created 3 years, 7 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
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"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { 87 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) {
88 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, 88 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability,
89 kAvailabilityOfficiallySupported); 89 kAvailabilityOfficiallySupported);
90 } 90 }
91 91
92 bool IsArcKioskMode() { 92 bool IsArcKioskMode() {
93 return user_manager::UserManager::IsInitialized() && 93 return user_manager::UserManager::IsInitialized() &&
94 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 94 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
95 } 95 }
96 96
97 bool IsArcAllowedForUser(const user_manager::User* user) {
98 if (!user) {
99 VLOG(1) << "No ARC for nullptr user.";
100 return false;
101 }
102
103 if (!user->HasGaiaAccount() && !(user->IsActiveDirectoryUser() &&
104 IsArcAllowedForActiveDirectoryUsers())) {
105 VLOG(1) << "Users without GAIA or active directory users without support"
106 " are not supported in ARC.";
107 return false;
108 }
109
110 // Do not allow for ephemeral data user. cf) b/26402681
111 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral(
112 user->GetAccountId())) {
113 VLOG(1) << "Users with ephemeral data are not supported in ARC.";
114 return false;
115 }
116
117 return true;
118 }
119
97 bool IsArcAllowedForActiveDirectoryUsers() { 120 bool IsArcAllowedForActiveDirectoryUsers() {
98 const auto* command_line = base::CommandLine::ForCurrentProcess(); 121 const auto* command_line = base::CommandLine::ForCurrentProcess();
99 122
100 if (!command_line->HasSwitch(chromeos::switches::kArcAvailability)) 123 if (!command_line->HasSwitch(chromeos::switches::kArcAvailability))
101 return false; 124 return false;
102 125
103 return command_line->GetSwitchValueASCII( 126 return command_line->GetSwitchValueASCII(
104 chromeos::switches::kArcAvailability) == 127 chromeos::switches::kArcAvailability) ==
105 kAvailabilityOfficiallySupportedWithActiveDirectory; 128 kAvailabilityOfficiallySupportedWithActiveDirectory;
106 } 129 }
107 130
108 bool IsArcOptInVerificationDisabled() { 131 bool IsArcOptInVerificationDisabled() {
109 const auto* command_line = base::CommandLine::ForCurrentProcess(); 132 const auto* command_line = base::CommandLine::ForCurrentProcess();
110 return command_line->HasSwitch( 133 return command_line->HasSwitch(
111 chromeos::switches::kDisableArcOptInVerification); 134 chromeos::switches::kDisableArcOptInVerification);
112 } 135 }
113 136
114 } // namespace arc 137 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698