OLD | NEW |
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/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 99 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
100 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, | 100 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
101 kAvailabilityOfficiallySupported); | 101 kAvailabilityOfficiallySupported); |
102 } | 102 } |
103 | 103 |
104 bool IsArcKioskMode() { | 104 bool IsArcKioskMode() { |
105 return user_manager::UserManager::IsInitialized() && | 105 return user_manager::UserManager::IsInitialized() && |
106 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 106 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
107 } | 107 } |
108 | 108 |
| 109 bool IsPublicSessionMode() { |
| 110 return user_manager::UserManager::IsInitialized() && |
| 111 user_manager::UserManager::Get()->IsLoggedInAsPublicAccount(); |
| 112 } |
| 113 |
109 bool IsArcAllowedForUser(const user_manager::User* user) { | 114 bool IsArcAllowedForUser(const user_manager::User* user) { |
110 if (!user) { | 115 if (!user) { |
111 VLOG(1) << "No ARC for nullptr user."; | 116 VLOG(1) << "No ARC for nullptr user."; |
112 return false; | 117 return false; |
113 } | 118 } |
114 | 119 |
115 // ARC is only supported for the following cases: | 120 // ARC is only supported for the following cases: |
116 // - Users have Gaia accounts; | 121 // - Users have Gaia accounts; |
117 // - Active directory users; | 122 // - Active directory users; |
118 // - ARC kiosk session; | 123 // - ARC kiosk session; |
| 124 // - Public Session users; |
119 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() | 125 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() |
120 // above because ARC kiosk user is always the primary/active user of a | 126 // above because ARC kiosk user is always the primary/active user of a |
121 // user session. | 127 // user session. The same for USER_TYPE_PUBLIC_ACCOUNT. |
122 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && | 128 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && |
123 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) { | 129 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP && |
| 130 user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { |
124 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " | 131 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " |
125 "not supported in ARC."; | 132 "not supported in ARC."; |
126 return false; | 133 return false; |
127 } | 134 } |
128 | 135 |
129 // Do not allow for ephemeral data user. cf) b/26402681 | |
130 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral( | |
131 user->GetAccountId())) { | |
132 VLOG(1) << "Users with ephemeral data are not supported in ARC."; | |
133 return false; | |
134 } | |
135 | |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 bool IsArcOptInVerificationDisabled() { | 139 bool IsArcOptInVerificationDisabled() { |
140 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 140 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
141 return command_line->HasSwitch( | 141 return command_line->HasSwitch( |
142 chromeos::switches::kDisableArcOptInVerification); | 142 chromeos::switches::kDisableArcOptInVerification); |
143 } | 143 } |
144 | 144 |
145 bool IsArcAppWindow(aura::Window* window) { | 145 bool IsArcAppWindow(aura::Window* window) { |
(...skipping 11 matching lines...) Expand all Loading... |
157 return; | 157 return; |
158 } | 158 } |
159 const login_manager::ContainerCpuRestrictionState state = | 159 const login_manager::ContainerCpuRestrictionState state = |
160 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND | 160 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND |
161 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; | 161 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; |
162 session_manager_client->SetArcCpuRestriction( | 162 session_manager_client->SetArcCpuRestriction( |
163 state, base::Bind(SetArcCpuRestrictionCallback, state)); | 163 state, base::Bind(SetArcCpuRestrictionCallback, state)); |
164 } | 164 } |
165 | 165 |
166 } // namespace arc | 166 } // namespace arc |
OLD | NEW |