Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_auth_service.cc |
| diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc |
| index 105058e76429c0910ea60c7fddb1e9116abed216..da55f71ece8b5974f3037ad79a70f454f6ce7e10 100644 |
| --- a/chrome/browser/chromeos/arc/arc_auth_service.cc |
| +++ b/chrome/browser/chromeos/arc/arc_auth_service.cc |
| @@ -234,13 +234,49 @@ void ArcAuthService::OnBridgeStopped(ArcBridgeService::StopReason reason) { |
| // user noticing. |
| OnSignInFailedInternal(ProvisioningResult::ARC_STOPPED); |
| } |
| - if (!clear_required_) |
| + |
| + if (clear_required_) { |
| + clear_required_ = false; |
|
Luis Héctor Chávez
2016/08/09 16:40:02
This is not needed, since it's the first thing Rem
hidehiko
2016/08/10 05:41:18
Done.
|
| + RemoveArcData(); |
| + } else { |
| + // To support special "Reenable ARC" procedure for enterprise, here call |
| + // OnArcDataRemoved(true) as if the data removal is successfully done. |
| + // TODO(hidehiko): Restructure the code. |
| + OnArcDataRemoved(true); |
| + } |
| +} |
| + |
| +void ArcAuthService::RemoveArcData() { |
| + 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_)), |
| - chromeos::SessionManagerClient::ArcCallback()); |
| + base::Bind(&ArcAuthService::OnArcDataRemoved, |
| + weak_ptr_factory_.GetWeakPtr())); |
| +} |
| + |
| +void ArcAuthService::OnArcDataRemoved(bool success) { |
| + LOG_IF(ERROR, !success) << "Required ARC user data wipe failed."; |
| + |
| + // 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 |
| + // the RemoveArcData(), then this. |
| + // TODO(hidehiko): Restructure the code. |
| + if (!reenable_arc_) |
| + return; |
| + |
| + // Restart ARC anyway. Let the enterprise reporting instance decide whether |
| + // the ARC user data wipe is still required or not. |
| + reenable_arc_ = false; |
| + VLOG(1) << "Reenable ARC"; |
| + EnableArc(); |
| } |
| std::string ArcAuthService::GetAndResetAuthCode() { |
| @@ -352,7 +388,7 @@ void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { |
| result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || |
| result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || |
| result == ProvisioningResult::UNKNOWN_ERROR) |
| - clear_required_ = true; |
| + RemoveArcData(); |
| // We'll delay shutting down the bridge in this case to allow people to send |
| // feedback. |
| @@ -524,6 +560,7 @@ void ArcAuthService::OnOptInPreferenceChanged() { |
| if (!arc_enabled) { |
| StopArc(); |
| + RemoveArcData(); |
| return; |
| } |
| @@ -594,6 +631,15 @@ void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) { |
| OnOptInUIShowPage(ui_page_, ui_page_status_)); |
| } |
| +// This is the special method to support enterprise mojo API. |
| +// TODO(hidehiko): Remove this. |
| +void ArcAuthService::ReenableArc() { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DCHECK(!arc_bridge_service()->stopped()); |
| + reenable_arc_ = true; |
| + StopArc(); |
| +} |
| + |
| void ArcAuthService::StartArc() { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| arc_bridge_service()->HandleStartup(); |