Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_util.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_util.cc b/chrome/browser/chromeos/arc/arc_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1c7489a9a3339076d11891137cbdf7caaf0108a8 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/arc_util.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/arc/arc_util.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome/browser/chromeos/login/user_flow.h" |
| +#include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| +#include "chrome/browser/chromeos/profiles/profile_helper.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/arc/arc_util.h" |
| +#include "components/user_manager/user.h" |
| +#include "components/user_manager/user_manager.h" |
| + |
| +namespace arc { |
| +namespace util { |
| + |
| +bool IsArcAllowedForProfile(const Profile* profile) { |
| + if (!IsArcEnabled()) { |
| + VLOG(1) << "Arc is not enabled."; |
|
Luis Héctor Chávez
2017/01/19 18:09:15
nit: s/Arc/ARC/g
hidehiko
2017/01/24 17:46:11
Done.
|
| + return false; |
| + } |
| + |
| + if (!profile) { |
| + VLOG(1) << "ARC is not supported for systems without profile."; |
| + return false; |
| + } |
| + |
| + if (!chromeos::ProfileHelper::IsPrimaryProfile(profile)) { |
| + VLOG(1) << "Non-primary users are not supported in ARC."; |
| + return false; |
| + } |
| + |
| + // IsPrimaryProfile can return true for an incognito profile corresponding |
|
Yusuke Sato
2017/01/19 22:39:31
This type of comment looks useful. Can you add com
hidehiko
2017/01/24 17:46:11
Added to L54. However, as for L47 and L61, I'm not
|
| + // to the primary profile, but ARC does not support it. |
| + if (profile->IsOffTheRecord()) { |
| + VLOG(1) << "Incognito profile is not supported in ARC."; |
| + return false; |
| + } |
| + |
| + if (profile->IsLegacySupervised()) { |
| + VLOG(1) << "Supervised users are not supported in ARC."; |
| + return false; |
| + } |
| + |
| + const user_manager::User* user = |
| + chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| + if ((!user || !user->HasGaiaAccount()) && !IsArcKioskMode()) { |
| + VLOG(1) << "Users without GAIA accounts are not supported in ARC."; |
| + return false; |
| + } |
| + |
| + chromeos::UserFlow* user_flow = |
| + chromeos::ChromeUserManager::Get()->GetUserFlow(user->GetAccountId()); |
| + if (!user_flow || !user_flow->CanStartArc()) { |
| + VLOG(1) << "ARC is not allowed in the current user flow."; |
| + return false; |
| + } |
| + |
| + if (user_manager::UserManager::Get() |
| + ->IsCurrentUserCryptohomeDataEphemeral()) { |
| + VLOG(1) << "Users with ephemeral data are not supported in Arc."; |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +} // namespace util |
| +} // namespace arc |