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

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

Issue 2926893002: arc: Start ARC for Public Session users.
Patch Set: Fix missed IsPublicSessionMode() checks. Created 3 years, 3 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 "ash/public/cpp/app_types.h" 9 #include "ash/public/cpp/app_types.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { 138 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) {
139 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, 139 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability,
140 kAvailabilityOfficiallySupported); 140 kAvailabilityOfficiallySupported);
141 } 141 }
142 142
143 bool IsArcKioskMode() { 143 bool IsArcKioskMode() {
144 return user_manager::UserManager::IsInitialized() && 144 return user_manager::UserManager::IsInitialized() &&
145 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); 145 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
146 } 146 }
147 147
148 bool IsPublicSessionMode() {
149 return user_manager::UserManager::IsInitialized() &&
150 user_manager::UserManager::Get()->IsLoggedInAsPublicAccount();
151 }
152
148 bool IsArcAllowedForUser(const user_manager::User* user) { 153 bool IsArcAllowedForUser(const user_manager::User* user) {
149 if (!user) { 154 if (!user) {
150 VLOG(1) << "No ARC for nullptr user."; 155 VLOG(1) << "No ARC for nullptr user.";
151 return false; 156 return false;
152 } 157 }
153 158
154 // ARC is only supported for the following cases: 159 // ARC is only supported for the following cases:
155 // - Users have Gaia accounts; 160 // - Users have Gaia accounts;
156 // - Active directory users; 161 // - Active directory users;
157 // - ARC kiosk session; 162 // - ARC kiosk session;
163 // - Public Session users;
158 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() 164 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode()
159 // above because ARC kiosk user is always the primary/active user of a 165 // above because ARC kiosk user is always the primary/active user of a
160 // user session. 166 // user session. The same for USER_TYPE_PUBLIC_ACCOUNT.
161 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && 167 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() &&
162 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) { 168 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP &&
169 user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) {
163 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " 170 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are "
164 "not supported in ARC."; 171 "not supported in ARC.";
165 return false; 172 return false;
166 } 173 }
167 174
168 // Do not allow for ephemeral data user. cf) b/26402681
169 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral(
170 user->GetAccountId())) {
171 VLOG(1) << "Users with ephemeral data are not supported in ARC.";
172 return false;
173 }
174
175 return true; 175 return true;
176 } 176 }
177 177
178 bool IsArcOptInVerificationDisabled() { 178 bool IsArcOptInVerificationDisabled() {
179 const auto* command_line = base::CommandLine::ForCurrentProcess(); 179 const auto* command_line = base::CommandLine::ForCurrentProcess();
180 return command_line->HasSwitch( 180 return command_line->HasSwitch(
181 chromeos::switches::kDisableArcOptInVerification); 181 chromeos::switches::kDisableArcOptInVerification);
182 } 182 }
183 183
184 bool IsArcAppWindow(aura::Window* window) { 184 bool IsArcAppWindow(aura::Window* window) {
(...skipping 11 matching lines...) Expand all
196 return; 196 return;
197 } 197 }
198 const login_manager::ContainerCpuRestrictionState state = 198 const login_manager::ContainerCpuRestrictionState state =
199 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND 199 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND
200 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; 200 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND;
201 session_manager_client->SetArcCpuRestriction( 201 session_manager_client->SetArcCpuRestriction(
202 state, base::Bind(SetArcCpuRestrictionCallback, state)); 202 state, base::Bind(SetArcCpuRestrictionCallback, state));
203 } 203 }
204 204
205 } // namespace arc 205 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698