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

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 TODO to rename OnStateChanged 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
« no previous file with comments | « components/arc/user_data/arc_user_data_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dbus/dbus_thread_manager.h"
8 #include "chromeos/dbus/session_manager_client.h"
9 #include "components/arc/arc_service_manager.h"
10 #include "components/signin/core/account_id/account_id.h"
11 #include "components/user_manager/user_manager.h"
12
13 namespace arc {
14
15 ArcUserDataService::ArcUserDataService(
16 const ArcServiceManager* arc_service_manager)
17 : arc_service_manager_(arc_service_manager) {
18 ArcBridgeService::Get()->AddObserver(this);
19 }
20
21 ArcUserDataService::~ArcUserDataService() {
22 DCHECK(thread_checker_.CalledOnValidThread());
23 ArcBridgeService::Get()->RemoveObserver(this);
24 }
25
26 void ArcUserDataService::OnBridgeStopped() {
27 DCHECK(thread_checker_.CalledOnValidThread());
28 const AccountId& account_id =
29 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
30 if (account_id != primary_user_account_id_) {
31 LOG(ERROR) << "User preferences not loaded for "
32 << primary_user_account_id_.GetUserEmail()
33 << ", but current primary user is " << account_id.GetUserEmail();
34 primary_user_account_id_ = EmptyAccountId();
35 return;
36 }
37 ClearIfDisabled();
38 }
39
40 void ArcUserDataService::OnPrimaryUserProfilePrepared(
41 const AccountId& account_id) {
42 primary_user_account_id_ = account_id;
43 ClearIfDisabled();
44 }
45
46 void ArcUserDataService::ClearIfDisabled() {
47 DCHECK(thread_checker_.CalledOnValidThread());
48 if (ArcBridgeService::Get()->state() != ArcBridgeService::State::STOPPED) {
Daniel Erat 2016/05/25 02:55:26 is the bridge always expected to be stopped when t
dspaid 2016/05/26 05:04:45 Yes
49 LOG(ERROR) << "ARC instance not stopped, user data can't be cleared";
50 return;
51 }
52 if (arc_service_manager_->IsArcEnabled()) {
53 return;
54 }
stevenjb 2016/06/08 03:38:48 nit: no {}
dspaid 2016/06/08 03:48:02 Done.
55 chromeos::SessionManagerClient* session_manager_client =
56 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
57 session_manager_client->RemoveArcData();
58 }
59
60 } // namespace arc
OLDNEW
« 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