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

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

Issue 1966133002: Run RemoveArcData after a user has opted out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed comments Created 4 years, 6 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
new file mode 100644
index 0000000000000000000000000000000000000000..27d42d729bc0b27044c87efc9241460aa2916e5c
--- /dev/null
+++ b/components/arc/user_data/arc_user_data_service.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/arc/user_data/arc_user_data_service.h"
+
+#include "chromeos/cryptohome/cryptohome_parameters.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/session_manager_client.h"
+#include "components/prefs/pref_member.h"
+#include "components/signin/core/account_id/account_id.h"
+#include "components/user_manager/user_manager.h"
+
+namespace arc {
+
+ArcUserDataService::ArcUserDataService(
+ ArcBridgeService* bridge_service,
+ std::unique_ptr<BooleanPrefMember> arc_enabled_pref,
+ const AccountId& account_id)
+ : ArcService(bridge_service),
+ arc_enabled_pref_(std::move(arc_enabled_pref)),
+ primary_user_account_id_(account_id) {
+ arc_bridge_service()->AddObserver(this);
+ ClearIfDisabled();
+}
+
+ArcUserDataService::~ArcUserDataService() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ arc_bridge_service()->RemoveObserver(this);
+}
+
+void ArcUserDataService::OnBridgeStopped() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ const AccountId& account_id =
+ user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
+ if (account_id != primary_user_account_id_) {
+ LOG(ERROR) << "User preferences not loaded for "
+ << primary_user_account_id_.GetUserEmail()
+ << ", but current primary user is " << account_id.GetUserEmail();
+ primary_user_account_id_ = EmptyAccountId();
+ return;
+ }
+ ClearIfDisabled();
+}
+
+void ArcUserDataService::ClearIfDisabled() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (arc_bridge_service()->state() != ArcBridgeService::State::STOPPED) {
+ LOG(ERROR) << "ARC instance not stopped, user data can't be cleared";
+ return;
+ }
+ if (arc_enabled_pref_->GetValue())
+ return;
+ const cryptohome::Identification cryptohome_id(primary_user_account_id_);
+ chromeos::SessionManagerClient* session_manager_client =
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
+ session_manager_client->RemoveArcData(cryptohome_id);
+}
+
+} // 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