| Index: chrome/browser/chromeos/arc/arc_session_manager.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_session_manager.cc b/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| index 4858e187b06495dc36b4f14436338ec23116974e..ffefa40fdb234b42e5809d81e0a73d3e9d1ef5f9 100644
|
| --- a/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| @@ -20,12 +20,10 @@
|
| #include "chrome/browser/chromeos/arc/arc_auth_notification.h"
|
| #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
|
| #include "chrome/browser/chromeos/arc/arc_support_host.h"
|
| +#include "chrome/browser/chromeos/arc/arc_util.h"
|
| #include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_negotiator.h"
|
| #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h"
|
| #include "chrome/browser/chromeos/arc/policy/arc_policy_util.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/lifetime/application_lifetime.h"
|
| #include "chrome/browser/policy/profile_policy_connector.h"
|
| #include "chrome/browser/policy/profile_policy_connector_factory.h"
|
| @@ -43,10 +41,10 @@
|
| #include "chromeos/dbus/session_manager_client.h"
|
| #include "components/arc/arc_bridge_service.h"
|
| #include "components/arc/arc_session_runner.h"
|
| +#include "components/arc/arc_util.h"
|
| #include "components/pref_registry/pref_registry_syncable.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "components/sync_preferences/pref_service_syncable.h"
|
| -#include "components/user_manager/user.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "extensions/browser/extension_prefs.h"
|
|
|
| @@ -136,73 +134,10 @@ void ArcSessionManager::SetShelfDelegateForTesting(
|
| }
|
|
|
| // static
|
| -bool ArcSessionManager::IsOptInVerificationDisabled() {
|
| - return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - chromeos::switches::kDisableArcOptInVerification);
|
| -}
|
| -
|
| -// static
|
| void ArcSessionManager::EnableCheckAndroidManagementForTesting() {
|
| g_enable_check_android_management_for_testing = true;
|
| }
|
|
|
| -// static
|
| -bool ArcSessionManager::IsAllowedForProfile(const Profile* profile) {
|
| - if (!ArcBridgeService::GetEnabled(base::CommandLine::ForCurrentProcess())) {
|
| - VLOG(1) << "Arc is not enabled.";
|
| - 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
|
| - // 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;
|
| - }
|
| -
|
| - user_manager::User const* const 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(2) << "Users with ephemeral data are not supported in Arc.";
|
| - return false;
|
| - }
|
| -
|
| - return true;
|
| -}
|
| -
|
| -// static
|
| -bool ArcSessionManager::IsArcKioskMode() {
|
| - return user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp();
|
| -}
|
| -
|
| void ArcSessionManager::OnSessionReady() {
|
| for (auto& observer : arc_session_observer_list_)
|
| observer.OnSessionReady();
|
| @@ -318,7 +253,7 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
|
| provisioning_reported_ = true;
|
|
|
| if (result == ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR) {
|
| - if (IsArcKioskMode()) {
|
| + if (util::IsArcKioskMode()) {
|
| VLOG(1) << "Robot account auth code fetching error";
|
| // Log out the user. All the cleanup will be done in Shutdown() method.
|
| // The callback is not called because auth code is empty.
|
| @@ -351,7 +286,7 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
|
| profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
|
| // Don't show Play Store app for ARC Kiosk because the only one UI in kiosk
|
| // mode must be the kiosk app and device is not needed for opt-in.
|
| - if (!IsOptInVerificationDisabled() && !IsArcKioskMode()) {
|
| + if (!util::IsOptInVerificationDisabled() && !util::IsArcKioskMode()) {
|
| playstore_launcher_.reset(
|
| new ArcAppLauncher(profile_, kPlayStoreAppId, true));
|
| }
|
| @@ -435,10 +370,10 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
|
|
|
| Shutdown();
|
|
|
| - if (!IsAllowedForProfile(profile))
|
| + if (!util::IsArcAllowedForProfile(profile))
|
| return;
|
|
|
| - // TODO(khmel): Move this to IsAllowedForProfile.
|
| + // TODO(khmel): Move this to IsArcAllowedForProfile.
|
| if (policy_util::IsArcDisabledForEnterprise() &&
|
| policy_util::IsAccountManaged(profile)) {
|
| VLOG(2) << "Enterprise users are not supported in ARC.";
|
| @@ -456,8 +391,8 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
|
| // be the kiosk app. In case of error the UI will be useless as well, because
|
| // in typical use case there will be no one nearby the kiosk device, who can
|
| // do some action to solve the problem be means of UI.
|
| - if (!g_disable_ui_for_testing && !IsOptInVerificationDisabled() &&
|
| - !IsArcKioskMode()) {
|
| + if (!g_disable_ui_for_testing && !util::IsOptInVerificationDisabled() &&
|
| + !util::IsArcKioskMode()) {
|
| DCHECK(!support_host_);
|
| support_host_ = base::MakeUnique<ArcSupportHost>(profile_);
|
| support_host_->AddObserver(this);
|
| @@ -609,7 +544,7 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
|
| // For ARC Kiosk we skip ToS because it is very likely that near the device
|
| // there will be no one who is eligible to accept them.
|
| // TODO(poromov): Move to more Kiosk dedicated set-up phase.
|
| - if (IsArcKioskMode())
|
| + if (util::IsArcKioskMode())
|
| profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
|
|
|
| // If it is marked that sign in has been successfully done, then directly
|
| @@ -618,13 +553,13 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
|
| // For backward compatibility, this check needs to be prior to the
|
| // kArcTermsAccepted check below.
|
| if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) ||
|
| - IsOptInVerificationDisabled() || IsArcKioskMode()) {
|
| + util::IsOptInVerificationDisabled() || util::IsArcKioskMode()) {
|
| StartArc();
|
|
|
| // Skip Android management check for testing.
|
| // We also skip if Android management check for Kiosk mode,
|
| // because there are no managed human users for Kiosk exist.
|
| - if (IsOptInVerificationDisabled() || IsArcKioskMode() ||
|
| + if (util::IsOptInVerificationDisabled() || util::IsArcKioskMode() ||
|
| (g_disable_ui_for_testing &&
|
| !g_enable_check_android_management_for_testing)) {
|
| return;
|
|
|