| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chromeos/login/user_flow.h" |
| 9 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "components/arc/arc_util.h" |
| 13 #include "components/user_manager/user.h" |
| 14 #include "components/user_manager/user_manager.h" |
| 15 |
| 16 namespace arc { |
| 17 |
| 18 namespace { |
| 19 |
| 20 // Let IsAllowedForProfile() return "false" for any profile. |
| 21 bool g_disallow_for_testing = false; |
| 22 |
| 23 } // namespace |
| 24 |
| 25 bool IsArcAllowedForProfile(const Profile* profile) { |
| 26 if (g_disallow_for_testing) { |
| 27 VLOG(1) << "ARC is disallowed for testing."; |
| 28 return false; |
| 29 } |
| 30 |
| 31 if (!IsArcAvailable()) { |
| 32 VLOG(1) << "ARC is not available."; |
| 33 return false; |
| 34 } |
| 35 |
| 36 if (!profile) { |
| 37 VLOG(1) << "ARC is not supported for systems without profile."; |
| 38 return false; |
| 39 } |
| 40 |
| 41 if (!chromeos::ProfileHelper::IsPrimaryProfile(profile)) { |
| 42 VLOG(1) << "Non-primary users are not supported in ARC."; |
| 43 return false; |
| 44 } |
| 45 |
| 46 // IsPrimaryProfile can return true for an incognito profile corresponding |
| 47 // to the primary profile, but ARC does not support it. |
| 48 if (profile->IsOffTheRecord()) { |
| 49 VLOG(1) << "Incognito profile is not supported in ARC."; |
| 50 return false; |
| 51 } |
| 52 |
| 53 if (profile->IsLegacySupervised()) { |
| 54 VLOG(1) << "Supervised users are not supported in ARC."; |
| 55 return false; |
| 56 } |
| 57 |
| 58 // Do not allow for public session. Communicating with Play Store requires |
| 59 // GAIA account. An exception is Kiosk mode, which uses different application |
| 60 // install mechanism. cf) crbug.com/605545 |
| 61 const user_manager::User* user = |
| 62 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 63 if ((!user || !user->HasGaiaAccount()) && !IsArcKioskMode()) { |
| 64 VLOG(1) << "Users without GAIA accounts are not supported in ARC."; |
| 65 return false; |
| 66 } |
| 67 |
| 68 // Do not run ARC instance when supervised user is being created. |
| 69 // Otherwise noisy notification may be displayed. |
| 70 chromeos::UserFlow* user_flow = |
| 71 chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId()); |
| 72 if (!user_flow || !user_flow->CanStartArc()) { |
| 73 VLOG(1) << "ARC is not allowed in the current user flow."; |
| 74 return false; |
| 75 } |
| 76 |
| 77 // Do not allow for Ephemeral data user. cf) b/26402681 |
| 78 if (user_manager::UserManager::Get() |
| 79 ->IsCurrentUserCryptohomeDataEphemeral()) { |
| 80 VLOG(1) << "Users with ephemeral data are not supported in ARC."; |
| 81 return false; |
| 82 } |
| 83 |
| 84 return true; |
| 85 } |
| 86 |
| 87 void DisallowArcForTesting() { |
| 88 g_disallow_for_testing = true; |
| 89 } |
| 90 |
| 91 } // namespace arc |
| OLD | NEW |