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

Side by Side 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: Add cryptohome ID to dbus call 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/arc/user_data/arc_user_data_service.h"
6
7 #include "chromeos/cryptohome/cryptohome_parameters.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/session_manager_client.h"
10 #include "components/arc/arc_service_manager.h"
11 #include "components/signin/core/account_id/account_id.h"
12 #include "components/user_manager/user_manager.h"
13
14 namespace arc {
15
16 ArcUserDataService::ArcUserDataService(
17 const ArcServiceManager* arc_service_manager)
18 : arc_service_manager_(arc_service_manager) {
19 ArcBridgeService::Get()->AddObserver(this);
hidehiko 2016/06/13 09:05:04 Please use arc_bridge_service(), with inheriting A
dspaid 2016/06/14 00:38:17 Done.
20 }
21
22 ArcUserDataService::~ArcUserDataService() {
23 DCHECK(thread_checker_.CalledOnValidThread());
24 ArcBridgeService::Get()->RemoveObserver(this);
25 }
26
27 void ArcUserDataService::OnBridgeStopped() {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 const AccountId& account_id =
30 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
31 if (account_id != primary_user_account_id_) {
32 LOG(ERROR) << "User preferences not loaded for "
33 << primary_user_account_id_.GetUserEmail()
34 << ", but current primary user is " << account_id.GetUserEmail();
35 primary_user_account_id_ = EmptyAccountId();
36 return;
37 }
38 ClearIfDisabled();
39 }
40
41 void ArcUserDataService::OnPrimaryUserProfilePrepared(
42 const AccountId& account_id) {
43 primary_user_account_id_ = account_id;
44 ClearIfDisabled();
45 }
46
47 void ArcUserDataService::ClearIfDisabled() {
48 DCHECK(thread_checker_.CalledOnValidThread());
49 if (ArcBridgeService::Get()->state() != ArcBridgeService::State::STOPPED) {
hidehiko 2016/06/13 09:05:05 Ditto for arc_bridge_service().
dspaid 2016/06/14 00:38:17 Done.
50 LOG(ERROR) << "ARC instance not stopped, user data can't be cleared";
51 return;
52 }
53 if (arc_service_manager_->IsArcEnabled())
54 return;
55 const cryptohome::Identification cryptohome_id(primary_user_account_id_);
56 chromeos::SessionManagerClient* session_manager_client =
57 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
58 session_manager_client->RemoveArcData(cryptohome_id);
59 }
60
61 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698