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

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: Addressed 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
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..7af43642f2fc4622136650183b885e86b21b742e
--- /dev/null
+++ b/components/arc/user_data/arc_user_data_service.cc
@@ -0,0 +1,61 @@
+// 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)
+ : ArcService(bridge_service),
+ arc_enabled_pref_(std::move(arc_enabled_pref)) {}
hidehiko 2016/06/14 05:13:02 I think, you accidentally removed AddObserver from
dspaid 2016/06/14 05:40:54 Done.
+
+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::OnPrimaryUserProfilePrepared(
+ const AccountId& account_id) {
hidehiko 2016/06/14 05:13:01 Could you pass this to the ctor, too, to be aligne
dspaid 2016/06/14 05:40:54 Done.
+ primary_user_account_id_ = account_id;
+ ClearIfDisabled();
hidehiko 2016/06/14 05:13:01 nit: Maybe move this to ctor, too?
dspaid 2016/06/14 05:40:54 Done.
+}
+
+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
« components/arc/arc_service_manager.cc ('K') | « 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