| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { | 85 void SetArcAvailableCommandLineForTesting(base::CommandLine* command_line) { |
| 86 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, | 86 command_line->AppendSwitchASCII(chromeos::switches::kArcAvailability, |
| 87 kAvailabilityOfficiallySupported); | 87 kAvailabilityOfficiallySupported); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool IsArcKioskMode() { | 90 bool IsArcKioskMode() { |
| 91 return user_manager::UserManager::IsInitialized() && | 91 return user_manager::UserManager::IsInitialized() && |
| 92 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); | 92 user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool IsArcAllowedForUser(const user_manager::User* user) { |
| 96 if (!user) { |
| 97 VLOG(1) << "No ARC for nullptr user."; |
| 98 return false; |
| 99 } |
| 100 |
| 101 // ARC is only supported for the following cases: |
| 102 // - Users have Gaia accounts; |
| 103 // - Active directory users; |
| 104 // - ARC kiosk session; |
| 105 // USER_TYPE_ARC_KIOSK_APP check is compatible with IsArcKioskMode() |
| 106 // above because ARC kiosk user is always the primary/active user of a |
| 107 // user session. |
| 108 if (!user->HasGaiaAccount() && !user->IsActiveDirectoryUser() && |
| 109 user->GetType() != user_manager::USER_TYPE_ARC_KIOSK_APP) { |
| 110 VLOG(1) << "Users without GAIA or AD accounts, or not ARC kiosk apps are " |
| 111 "not supported in ARC."; |
| 112 return false; |
| 113 } |
| 114 |
| 115 // Do not allow for ephemeral data user. cf) b/26402681 |
| 116 if (user_manager::UserManager::Get()->IsUserCryptohomeDataEphemeral( |
| 117 user->GetAccountId())) { |
| 118 VLOG(1) << "Users with ephemeral data are not supported in ARC."; |
| 119 return false; |
| 120 } |
| 121 |
| 122 return true; |
| 123 } |
| 124 |
| 95 bool IsArcOptInVerificationDisabled() { | 125 bool IsArcOptInVerificationDisabled() { |
| 96 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 126 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
| 97 return command_line->HasSwitch( | 127 return command_line->HasSwitch( |
| 98 chromeos::switches::kDisableArcOptInVerification); | 128 chromeos::switches::kDisableArcOptInVerification); |
| 99 } | 129 } |
| 100 | 130 |
| 101 bool IsArcAppWindow(aura::Window* window) { | 131 bool IsArcAppWindow(aura::Window* window) { |
| 102 if (!window) | 132 if (!window) |
| 103 return false; | 133 return false; |
| 104 return window->GetProperty(aura::client::kAppType) == | 134 return window->GetProperty(aura::client::kAppType) == |
| 105 static_cast<int>(ash::AppType::ARC_APP); | 135 static_cast<int>(ash::AppType::ARC_APP); |
| 106 } | 136 } |
| 107 | 137 |
| 108 } // namespace arc | 138 } // namespace arc |
| OLD | NEW |