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

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

Issue 2248353002: [M53 cherry-pick] Migrate ArcUserDataService into ArcAuthService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months 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_auth_service.cc
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc
index 476ca3808a905c6d49cc96efc72cf765921277ab..d737405de594758883b6a65b24cdb9e41b4a3477 100644
--- a/chrome/browser/chromeos/arc/arc_auth_service.cc
+++ b/chrome/browser/chromeos/arc/arc_auth_service.cc
@@ -237,13 +237,52 @@ void ArcAuthService::OnBridgeStopped(ArcBridgeService::StopReason reason) {
// user noticing.
OnSignInFailedInternal(ProvisioningResult::ARC_STOPPED);
}
- if (!clear_required_)
+
+ if (clear_required_) {
+ // This should be always true, but just in case as this is looked at
+ // inside RemoveArcData() at first.
+ DCHECK(arc_bridge_service()->stopped());
+ RemoveArcData();
+ } else {
+ // To support special "Stop and enable 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() {
@@ -355,7 +394,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.
@@ -418,6 +457,7 @@ void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) {
if (profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled)) {
OnOptInPreferenceChanged();
} else {
+ RemoveArcData();
UpdateEnabledStateUMA(false);
PrefServiceSyncableFromProfile(profile_)->AddObserver(this);
OnIsSyncingChanged();
@@ -528,6 +568,7 @@ void ArcAuthService::OnOptInPreferenceChanged() {
if (!arc_enabled) {
StopArc();
+ RemoveArcData();
return;
}
@@ -598,6 +639,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::StopAndEnableArc() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(!arc_bridge_service()->stopped());
+ reenable_arc_ = true;
+ StopArc();
+}
+
void ArcAuthService::StartArc() {
DCHECK(thread_checker.Get().CalledOnValidThread());
arc_bridge_service()->HandleStartup();
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_auth_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698