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

Unified Diff: components/arc/user_data/arc_user_data_service.cc

Issue 2145813002: Clear old ARC instance before opt-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Comments Created 4 years, 5 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
« no previous file with comments | « components/arc/user_data/arc_user_data_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/user_data/arc_user_data_service.cc
diff --git a/components/arc/user_data/arc_user_data_service.cc b/components/arc/user_data/arc_user_data_service.cc
index cb9559575c1e612d6c1871c1ba9835f13c90a615..524c5023270d86b40bd04e02dd912b4ff9142c47 100644
--- a/components/arc/user_data/arc_user_data_service.cc
+++ b/components/arc/user_data/arc_user_data_service.cc
@@ -23,8 +23,14 @@ ArcUserDataService::ArcUserDataService(
const AccountId& account_id)
: ArcService(bridge_service),
arc_enabled_pref_(std::move(arc_enabled_pref)),
- primary_user_account_id_(account_id) {
+ primary_user_account_id_(account_id),
+ weak_ptr_factory_(this) {
arc_bridge_service()->AddObserver(this);
+ pref_change_registrar_.Init(arc_enabled_pref_->prefs());
+ pref_change_registrar_.Add(
+ arc_enabled_pref_->GetPrefName(),
+ base::Bind(&ArcUserDataService::OnOptInPreferenceChanged,
+ weak_ptr_factory_.GetWeakPtr()));
ClearIfDisabled();
}
@@ -53,15 +59,21 @@ void ArcUserDataService::ClearIfDisabled() {
LOG(ERROR) << "ARC instance not stopped, user data can't be cleared";
return;
}
- if (arc_enabled_pref_->GetValue() ||
+ if ((arc_enabled_pref_->GetValue() && !arc_disabled_) ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kDisableArcDataWipe)) {
return;
}
+ arc_disabled_ = false;
const cryptohome::Identification cryptohome_id(primary_user_account_id_);
chromeos::SessionManagerClient* session_manager_client =
chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
session_manager_client->RemoveArcData(cryptohome_id);
}
+void ArcUserDataService::OnOptInPreferenceChanged() {
+ if (!arc_enabled_pref_->GetValue())
+ arc_disabled_ = true;
+}
+
} // namespace arc
« no previous file with comments | « components/arc/user_data/arc_user_data_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698