Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3954)

Unified Diff: chrome/browser/chromeos/arc/arc_session_manager.cc

Issue 2541173002: arc: Make request to remove Android's data folder persistent. (Closed)
Patch Set: browser tests extended/updated Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8fdcd5a3bca94a718992fed817e0506bacf53c43 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,13 @@ void ArcSessionManager::RemoveArcData() {
void ArcSessionManager::OnArcDataRemoved(bool success) {
LOG_IF(ERROR, !success) << "Required ARC user data wipe failed.";
+ // In case data removal completed between shutdown and deleting this manager.
+ // It happens at least in browser tests.
+ if (!IsAllowed())
+ return;
+
+ 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 +271,9 @@ void ArcSessionManager::OnProvisioningFinished(ProvisioningResult result) {
if (support_host_)
support_host_->Close();
+ // Make sure request to remove data folder is off.
+ profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false);
+
if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn))
return;
@@ -565,6 +578,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)) {
+ reenable_arc_ = true;
+ RemoveArcData();
+ return;
+ }
+
arc_bridge_service()->RequestStart();
SetState(State::ACTIVE);
}

Powered by Google App Engine
This is Rietveld 408576698