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/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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 const std::string value = | 77 const std::string value = |
78 command_line->GetSwitchValueASCII(chromeos::switches::kArcAvailability); | 78 command_line->GetSwitchValueASCII(chromeos::switches::kArcAvailability); |
79 | 79 |
80 return value == kAvailabilityNone; | 80 return value == kAvailabilityNone; |
81 } | 81 } |
82 return true; | 82 return true; |
83 } | 83 } |
84 | 84 |
85 bool IsPlayStoreAvailable() { | 85 bool IsPlayStoreAvailable() { |
86 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 86 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
87 if (!command_line->HasSwitch(chromeos::switches::kArcStartMode)) | 87 if (!command_line->HasSwitch(chromeos::switches::kArcStartMode) && |
88 !IsRobotAccountMode()) { | |
khmel
2017/09/26 17:58:26
nit: I would prefer
if (IsRobotAccountMode())
| |
88 return true; | 89 return true; |
90 } | |
89 | 91 |
90 const std::string value = | 92 const std::string value = |
91 command_line->GetSwitchValueASCII(chromeos::switches::kArcStartMode); | 93 command_line->GetSwitchValueASCII(chromeos::switches::kArcStartMode); |
92 return value != kAlwaysStartWithNoPlayStore; | 94 return value != kAlwaysStartWithNoPlayStore && !IsRobotAccountMode(); |
93 } | 95 } |
94 | 96 |
95 bool ShouldArcAlwaysStart() { | 97 bool ShouldArcAlwaysStart() { |
96 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 98 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
97 if (!command_line->HasSwitch(chromeos::switches::kArcStartMode)) | 99 if (!command_line->HasSwitch(chromeos::switches::kArcStartMode)) |
98 return false; | 100 return false; |
99 const std::string value = | 101 const std::string value = |
100 command_line->GetSwitchValueASCII(chromeos::switches::kArcStartMode); | 102 command_line->GetSwitchValueASCII(chromeos::switches::kArcStartMode); |
101 return value == kAlwaysStartWithNoPlayStore || value == kAlwaysStart; | 103 return value == kAlwaysStartWithNoPlayStore || value == kAlwaysStart; |
102 } | 104 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 140 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
139 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, | 141 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
140 kAvailabilityOfficiallySupported); | 142 kAvailabilityOfficiallySupported); |
141 } | 143 } |
142 | 144 |
143 bool IsArcKioskMode() { | 145 bool IsArcKioskMode() { |
144 return user_manager::UserManager::IsInitialized() && | 146 return user_manager::UserManager::IsInitialized() && |
145 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 147 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
146 } | 148 } |
147 | 149 |
150 bool IsRobotAccountMode() { | |
151 return user_manager::UserManager::IsInitialized() && | |
152 (user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp() || | |
153 user_manager::UserManager::Get()->IsLoggedInAsPublicAccount()); | |
154 } | |
155 | |
148 bool IsArcAllowedForUser(const user_manager::User* user) { | 156 bool IsArcAllowedForUser(const user_manager::User* user) { |
149 if (!user) { | 157 if (!user) { |
150 VLOG(1) << "No ARC for nullptr user."; | 158 VLOG(1) << "No ARC for nullptr user."; |
151 return false; | 159 return false; |
152 } | 160 } |
153 | 161 |
154 // ARC is only supported for the following cases: | 162 // ARC is only supported for the following cases: |
155 // - Users have Gaia accounts; | 163 // - Users have Gaia accounts; |
156 // - Active directory users; | 164 // - Active directory users; |
157 // - ARC kiosk session; | 165 // - ARC kiosk session; |
166 // - Public Session users; | |
158 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() | 167 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() |
159 // above because ARC kiosk user is always the primary/active user of a | 168 // above because ARC kiosk user is always the primary/active user of a |
160 // user session. | 169 // user session. The same for USER_TYPE_PUBLIC_ACCOUNT. |
161 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && | 170 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && |
162 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) { | 171 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP && |
172 user->GetType() != user_manager::USER_TYPE_PUBLIC_ACCOUNT) { | |
163 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " | 173 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " |
164 "not supported in ARC."; | 174 "not supported in ARC."; |
165 return false; | 175 return false; |
166 } | 176 } |
167 | 177 |
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; | 178 return true; |
176 } | 179 } |
177 | 180 |
178 bool IsArcOptInVerificationDisabled() { | 181 bool IsArcOptInVerificationDisabled() { |
179 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 182 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
180 return command_line->HasSwitch( | 183 return command_line->HasSwitch( |
181 chromeos::switches::kDisableArcOptInVerification); | 184 chromeos::switches::kDisableArcOptInVerification); |
182 } | 185 } |
183 | 186 |
184 bool IsArcAppWindow(aura::Window* window) { | 187 bool IsArcAppWindow(aura::Window* window) { |
(...skipping 11 matching lines...) Expand all Loading... | |
196 return; | 199 return; |
197 } | 200 } |
198 const login_manager::ContainerCpuRestrictionState state = | 201 const login_manager::ContainerCpuRestrictionState state = |
199 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND | 202 do_restrict ? login_manager::CONTAINER_CPU_RESTRICTION_BACKGROUND |
200 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; | 203 : login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND; |
201 session_manager_client->SetArcCpuRestriction( | 204 session_manager_client->SetArcCpuRestriction( |
202 state, base::Bind(SetArcCpuRestrictionCallback, state)); | 205 state, base::Bind(SetArcCpuRestrictionCallback, state)); |
203 } | 206 } |
204 | 207 |
205 } // namespace arc | 208 } // namespace arc |
OLD | NEW |