Chromium Code Reviews| 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..b1557c05a1f6dbc88ea09fe6dcfc47efc8aeca3c 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.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; |
| } |
| +bool IsFirstRunForOobeEnabledUser() { |
| + // ARC OOBE OptIn is optional for now. Test if it exists and current user is |
| + // first time user. |
| + 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,6 +455,11 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) { |
| g_enable_check_android_management_for_testing) { |
| ArcAndroidManagementChecker::StartClient(); |
| } |
| + |
| + const bool first_run_oobe_enabled_user = IsFirstRunForOobeEnabledUser(); |
| + if (first_run_oobe_enabled_user) |
| + StartTermsOfServiceNegotiation(NegotiatorType::OOBE); |
|
hidehiko
2016/12/15 03:04:07
For the record;
As we discussed offline, could yo
khmel
2016/12/16 01:43:34
Done.
|
| + |
| pref_change_registrar_.Init(profile_->GetPrefs()); |
| pref_change_registrar_.Add( |
| prefs::kArcEnabled, |
| @@ -461,7 +475,8 @@ void ArcSessionManager::OnPrimaryUserProfilePrepared(Profile* profile) { |
| OnOptInPreferenceChanged(); |
| } |
| } else { |
| - RemoveArcData(); |
| + if (!first_run_oobe_enabled_user) |
|
khmel
2016/12/14 01:27:59
It is quite tricky to sync two processes which cha
|
| + RemoveArcData(); |
| PrefServiceSyncableFromProfile(profile_)->AddObserver(this); |
| OnIsSyncingChanged(); |
| } |
| @@ -550,7 +565,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 +620,17 @@ 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(); |
| + // Don't show UI for this progress if it was not shown. |
| + if (support_host_->has_message_host()) |
| + support_host_->ShowArcLoading(); |
| StartArcAndroidManagementCheck(); |
| return; |
| } |
| - // Need user's explicit Terms Of Service agreement. |
| - StartTermsOfServiceNegotiation(); |
| + // Need user's explicit Terms Of Service agreement. There is the case when Arc |
| + // is managed on and we have OOBE negotiator already set. |
| + if (!terms_of_service_negotiator_) |
| + StartTermsOfServiceNegotiation(NegotiatorType::DEFAULT); |
| } |
| void ArcSessionManager::ShutdownBridge() { |
| @@ -648,7 +667,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; |
| @@ -736,7 +755,7 @@ void ArcSessionManager::RecordArcState() { |
| UpdateEnabledStateUMA(IsArcEnabled()); |
| } |
| -void ArcSessionManager::StartTermsOfServiceNegotiation() { |
| +void ArcSessionManager::StartTermsOfServiceNegotiation(NegotiatorType type) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| DCHECK(!terms_of_service_negotiator_); |
| @@ -752,9 +771,21 @@ void ArcSessionManager::StartTermsOfServiceNegotiation() { |
| SetState(State::SHOWING_TERMS_OF_SERVICE); |
| if (support_host_) { |
| - terms_of_service_negotiator_ = |
| - base::MakeUnique<ArcTermsOfServiceNegotiator>(profile_->GetPrefs(), |
| - support_host_.get()); |
| + switch (type) { |
| + case NegotiatorType::DEFAULT: |
| + terms_of_service_negotiator_ = |
| + base::MakeUnique<ArcTermsOfServiceDefaultNegotiator>( |
| + profile_->GetPrefs(), support_host_.get()); |
| + break; |
| + case NegotiatorType::OOBE: |
| + terms_of_service_negotiator_ = |
| + base::MakeUnique<ArcTermsOfServiceOOBENegotiator>( |
| + profile_->GetPrefs()); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + return; |
| + } |
| terms_of_service_negotiator_->StartNegotiation( |
| base::Bind(&ArcSessionManager::OnTermsOfServiceNegotiated, |
| weak_ptr_factory_.GetWeakPtr())); |
| @@ -775,7 +806,9 @@ void ArcSessionManager::OnTermsOfServiceNegotiated(bool accepted) { |
| // Terms were accepted. |
| profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
| - support_host_->ShowArcLoading(); |
| + // Don't show UI for this progress if it was not shown. |
| + if (support_host_->has_message_host()) |
| + support_host_->ShowArcLoading(); |
| StartArcAndroidManagementCheck(); |
| } |
| @@ -783,7 +816,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 +908,7 @@ void ArcSessionManager::OnRetryClicked() { |
| // Currently Terms of service is shown. ArcTermsOfServiceNegotiator should |
| // handle this. |
| } else if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { |
| - StartTermsOfServiceNegotiation(); |
| + StartTermsOfServiceNegotiation(NegotiatorType::DEFAULT); |
| } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR && |
| !arc_bridge_service()->stopped()) { |
| // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping |