Chromium Code Reviews| 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 // TODO(hidehiko): Comment what situation this condition wants to support. | |
|
Yusuke Sato
2017/01/24 20:36:59
Then, probably TODO(hidehiko|xxx) would be better.
hidehiko
2017/01/31 13:07:51
Finding original author means I need to go deeper
| |
| 59 const user_manager::User* user = | |
| 60 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | |
| 61 if ((!user || !user->HasGaiaAccount()) && !IsArcKioskMode()) { | |
| 62 VLOG(1) << "Users without GAIA accounts are not supported in ARC."; | |
| 63 return false; | |
| 64 } | |
| 65 | |
| 66 // Do not run ARC instance when supervised user is being created. | |
| 67 // Otherwise noisy notification may be displayed. | |
| 68 chromeos::UserFlow* user_flow = | |
| 69 chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId()); | |
| 70 if (!user_flow || !user_flow->CanStartArc()) { | |
| 71 VLOG(1) << "ARC is not allowed in the current user flow."; | |
| 72 return false; | |
| 73 } | |
| 74 | |
| 75 // TODO(hidehiko): Comment what situation this condition wants to support. | |
|
Yusuke Sato
2017/01/24 20:36:59
same
hidehiko
2017/01/31 13:07:51
Done.
| |
| 76 if (user_manager::UserManager::Get() | |
| 77 ->IsCurrentUserCryptohomeDataEphemeral()) { | |
| 78 VLOG(1) << "Users with ephemeral data are not supported in ARC."; | |
| 79 return false; | |
| 80 } | |
| 81 | |
| 82 return true; | |
| 83 } | |
| 84 | |
| 85 void DisallowArcForTesting() { | |
| 86 g_disallow_for_testing = true; | |
| 87 } | |
| 88 | |
| 89 } // namespace arc | |
| OLD | NEW |