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 21effca88e1741d7f087ae3c547c954e774f4945..68a22081a69af563c422ac064f96674b3836666c 100644 |
| --- a/chrome/browser/chromeos/arc/arc_session_manager.cc |
| +++ b/chrome/browser/chromeos/arc/arc_session_manager.cc |
| @@ -110,6 +110,7 @@ void ArcSessionManager::RegisterProfilePrefs( |
| user_prefs::PrefRegistrySyncable* registry) { |
| // TODO(dspaid): Implement a mechanism to allow this to sync on first boot |
| // only. |
| + registry->RegisterBooleanPref(prefs::kArcDataRemoveRequested, false); |
| registry->RegisterBooleanPref(prefs::kArcEnabled, false); |
| registry->RegisterBooleanPref(prefs::kArcSignedIn, false); |
| registry->RegisterBooleanPref(prefs::kArcTermsAccepted, false); |
| @@ -188,7 +189,7 @@ void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) { |
| OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); |
| } |
| - if (clear_required_) { |
| + if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { |
| // This should be always true, but just in case as this is looked at |
| // inside RemoveArcData() at first. |
| DCHECK(arc_bridge_service()->stopped()); |
| @@ -205,13 +206,15 @@ void ArcSessionManager::OnBridgeStopped(ArcBridgeService::StopReason reason) { |
| } |
| void ArcSessionManager::RemoveArcData() { |
| + // OnArcDataRemoved resets this flag. |
| + profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, true); |
| + |
| if (!arc_bridge_service()->stopped()) { |
| // Just set a flag. On bridge stopped, this will be re-called, |
| // then session manager should remove the data. |
| - clear_required_ = true; |
| return; |
| } |
| - clear_required_ = false; |
| + |
| chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveArcData( |
| cryptohome::Identification( |
| multi_user_util::GetAccountIdFromProfile(profile_)), |
| @@ -222,6 +225,8 @@ void ArcSessionManager::RemoveArcData() { |
| void ArcSessionManager::OnArcDataRemoved(bool success) { |
| LOG_IF(ERROR, !success) << "Required ARC user data wipe failed."; |
| + profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false); |
| + |
| // Here check if |reenable_arc_| is marked or not. |
| // The only case this happens should be in the special case for enterprise |
| // "on managed lost" case. In that case, OnBridgeStopped() should trigger |
| @@ -261,6 +266,9 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) { |
| if (support_host_) |
| support_host_->Close(); |
| + // Make sure request to remove data folder is off. |
|
hidehiko
2016/12/01 00:58:02
Better to comment an example case that this actual
khmel
2016/12/01 03:12:20
I don't see any use case. Probably we can change i
hidehiko
2016/12/01 16:15:03
After some more investigation I found a case that
khmel
2016/12/01 17:18:59
Replaced by DCHECK
|
| + profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false); |
| + |
| if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
| return; |
| @@ -565,6 +573,15 @@ void ArcSessionManager::StopAndEnableArc() { |
| void ArcSessionManager::StartArc() { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + |
| + // Don't start ARC if there is a pending request to remove the data. Restart |
| + // ARC once data removal finishes. |
| + if (profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)) { |
|
hidehiko
2016/12/01 00:58:02
Should this be in OnPrimaryUserProfilePrepared() ?
khmel
2016/12/01 03:12:21
I think this is more reliable point to handle this
hidehiko
2016/12/01 16:15:03
Good example scenario. I think, in that case, we s
khmel
2016/12/01 17:18:59
I moved this check to upper level OnOptInPreferenc
|
| + reenable_arc_ = true; |
|
hidehiko
2016/12/01 00:58:02
This has an edge case:
Remove request is set in p
khmel
2016/12/01 03:12:20
Good catch. I think in this case we can reset reen
hidehiko
2016/12/01 16:15:03
IsAllowed() check looks not the one we need here?
khmel
2016/12/01 17:18:59
IsAllowed is required to safely reset request. It
|
| + RemoveArcData(); |
| + return; |
| + } |
| + |
| arc_bridge_service()->RequestStart(); |
| SetState(State::ACTIVE); |
| } |