| 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 28c084946b2528ad274f6ab4826f4dfd1a820c3d..00cace858f7d5907271b2a79fc61a14a62844640 100644
|
| --- a/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc
|
| @@ -17,7 +17,8 @@
|
| #include "chrome/browser/chromeos/arc/arc_auth_context.h"
|
| #include "chrome/browser/chromeos/arc/arc_optin_uma.h"
|
| #include "chrome/browser/chromeos/arc/arc_support_host.h"
|
| -#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_negotiator.h"
|
| +#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_default_negotiator.h"
|
| +#include "chrome/browser/chromeos/arc/optin/arc_terms_of_service_oobe_negotiator_for_managed_user.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"
|
| @@ -78,6 +79,14 @@ ash::ShelfDelegate* GetShelfDelegate() {
|
| return nullptr;
|
| }
|
|
|
| +// Returns true if this is the first user's login session and Arc OOBE is
|
| +// enabled.
|
| +bool IsFirstRunForOobeEnabledUser() {
|
| + return user_manager::UserManager::Get()->IsCurrentUserNew() &&
|
| + base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + chromeos::switches::kEnableArcOOBEOptIn);
|
| +}
|
| +
|
| } // namespace
|
|
|
| ArcSessionManager::ArcSessionManager(ArcBridgeService* bridge_service)
|
| @@ -271,7 +280,7 @@ void ArcSessionManager::MaybeReenableArc() {
|
| void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| - // Due asynchronous nature of stopping Arc bridge, OnProvisioningFinished may
|
| + // Due asynchronous nature of stopping ARC bridge, OnProvisioningFinished may
|
| // arrive after setting the |State::STOPPED| state and |State::Active| is not
|
| // guaranty set here. prefs::kArcDataRemoveRequested is also can be active
|
| // for now.
|
| @@ -446,11 +455,12 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
|
| g_enable_check_android_management_for_testing) {
|
| ArcAndroidManagementChecker::StartClient();
|
| }
|
| +
|
| pref_change_registrar_.Init(profile_->GetPrefs());
|
| pref_change_registrar_.Add(
|
| prefs::kArcEnabled,
|
| base::Bind(&ArcSessionManager::OnOptInPreferenceChanged,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| + weak_ptr_factory_.GetWeakPtr(), false /* initial_run */));
|
| if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
|
| // Don't start ARC if there is a pending request to remove the data. Restart
|
| // ARC once data removal finishes.
|
| @@ -458,7 +468,7 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) {
|
| reenable_arc_ = true;
|
| RemoveArcData();
|
| } else {
|
| - OnOptInPreferenceChanged();
|
| + OnOptInPreferenceChanged(true /* initial_run */);
|
| }
|
| } else {
|
| RemoveArcData();
|
| @@ -476,7 +486,7 @@ void ArcSessionManager::OnIsSyncingChanged() {
|
| pref_service_syncable->RemoveObserver(this);
|
|
|
| if (IsArcEnabled())
|
| - OnOptInPreferenceChanged();
|
| + OnOptInPreferenceChanged(false);
|
| }
|
|
|
| void ArcSessionManager::Shutdown() {
|
| @@ -527,7 +537,7 @@ void ArcSessionManager::StopArc() {
|
| support_host_->Close();
|
| }
|
|
|
| -void ArcSessionManager::OnOptInPreferenceChanged() {
|
| +void ArcSessionManager::OnOptInPreferenceChanged(bool initial_run) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| DCHECK(profile_);
|
|
|
| @@ -550,7 +560,7 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
|
| return;
|
|
|
| if (state_ == State::REMOVING_DATA_DIR) {
|
| - // Data removal request is in progress. Set flag to re-enable Arc once it is
|
| + // Data removal request is in progress. Set flag to re-enable ARC once it is
|
| // finished.
|
| reenable_arc_ = true;
|
| return;
|
| @@ -605,13 +615,12 @@ void ArcSessionManager::OnOptInPreferenceChanged() {
|
| // 2) User accepted the Terms of service on Opt-in flow, but logged out
|
| // before ARC sign in procedure was done. Then, logs in again.
|
| if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
|
| - support_host_->ShowArcLoading();
|
| StartArcAndroidManagementCheck();
|
| return;
|
| }
|
|
|
| // Need user's explicit Terms Of Service agreement.
|
| - StartTermsOfServiceNegotiation();
|
| + StartTermsOfServiceNegotiation(initial_run);
|
| }
|
|
|
| void ArcSessionManager::ShutdownBridge() {
|
| @@ -648,7 +657,7 @@ void ArcSessionManager::StopAndEnableArc() {
|
| void ArcSessionManager::StartArc() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| - // Arc must be started only if no pending data removal request exists.
|
| + // ARC must be started only if no pending data removal request exists.
|
| DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested));
|
|
|
| provisioning_reported_ = false;
|
| @@ -715,7 +724,7 @@ void ArcSessionManager::EnableArc() {
|
| DCHECK(profile_);
|
|
|
| if (IsArcEnabled()) {
|
| - OnOptInPreferenceChanged();
|
| + OnOptInPreferenceChanged(false);
|
| return;
|
| }
|
|
|
| @@ -736,7 +745,7 @@ void ArcSessionManager::RecordArcState() {
|
| UpdateEnabledStateUMA(IsArcEnabled());
|
| }
|
|
|
| -void ArcSessionManager::StartTermsOfServiceNegotiation() {
|
| +void ArcSessionManager::StartTermsOfServiceNegotiation(bool initial_run) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| DCHECK(!terms_of_service_negotiator_);
|
|
|
| @@ -751,14 +760,21 @@ void ArcSessionManager::StartTermsOfServiceNegotiation() {
|
| }
|
|
|
| SetState(State::SHOWING_TERMS_OF_SERVICE);
|
| - if (support_host_) {
|
| + if (initial_run && IsFirstRunForOobeEnabledUser() && IsArcManaged()) {
|
| + terms_of_service_negotiator_ = base::MakeUnique<
|
| + ArcTermsOfServiceInitialOobeNegotiatorForManagedUser>();
|
| + } else if (support_host_) {
|
| terms_of_service_negotiator_ =
|
| - base::MakeUnique<ArcTermsOfServiceNegotiator>(profile_->GetPrefs(),
|
| - support_host_.get());
|
| - terms_of_service_negotiator_->StartNegotiation(
|
| - base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
|
| - weak_ptr_factory_.GetWeakPtr()));
|
| + base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>(
|
| + profile_->GetPrefs(), support_host_.get());
|
| + } else {
|
| + // Happens in unit tests.
|
| + return;
|
| }
|
| +
|
| + terms_of_service_negotiator_->StartNegotiation(
|
| + base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
|
| @@ -775,7 +791,8 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) {
|
| // Terms were accepted.
|
| profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true);
|
|
|
| - support_host_->ShowArcLoading();
|
| + if (support_host_ && support_host_->has_message_host())
|
| + support_host_->ShowArcLoading();
|
| StartArcAndroidManagementCheck();
|
| }
|
|
|
| @@ -783,7 +800,9 @@ void ArcSessionManager::StartArcAndroidManagementCheck() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| DCHECK(arc_bridge_service()->stopped());
|
| DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE ||
|
| - state_ == State::CHECKING_ANDROID_MANAGEMENT);
|
| + state_ == State::CHECKING_ANDROID_MANAGEMENT ||
|
| + (state_ == State::STOPPED &&
|
| + profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)));
|
| SetState(State::CHECKING_ANDROID_MANAGEMENT);
|
|
|
| android_management_checker_.reset(new ArcAndroidManagementChecker(
|
| @@ -873,7 +892,7 @@ void ArcSessionManager::OnRetryClicked() {
|
| // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should
|
| // handle this.
|
| } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) {
|
| - StartTermsOfServiceNegotiation();
|
| + StartTermsOfServiceNegotiation(false);
|
| } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR &&
|
| !arc_bridge_service()->stopped()) {
|
| // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping
|
|
|