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

Side by Side Diff: components/arc/user_data/arc_user_data_service.cc

Issue 2573463002: Remove unused ArcUserDataService. (Closed)
Patch Set: Created 4 years 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 <utility>
8
9 #include "base/command_line.h"
10 #include "chromeos/chromeos_switches.h"
11 #include "chromeos/cryptohome/cryptohome_parameters.h"
12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "components/prefs/pref_member.h"
14 #include "components/signin/core/account_id/account_id.h"
15 #include "components/user_manager/user_manager.h"
16
17 namespace arc {
18
19 ArcUserDataService::ArcUserDataService(
20 ArcBridgeService* bridge_service,
21 std::unique_ptr<BooleanPrefMember> arc_enabled_pref,
22 const AccountId& account_id)
23 : ArcService(bridge_service),
24 arc_enabled_pref_(std::move(arc_enabled_pref)),
25 primary_user_account_id_(account_id),
26 weak_ptr_factory_(this) {
27 arc_bridge_service()->AddObserver(this);
28 pref_change_registrar_.Init(arc_enabled_pref_->prefs());
29 pref_change_registrar_.Add(
30 arc_enabled_pref_->GetPrefName(),
31 base::Bind(&ArcUserDataService::OnOptInPreferenceChanged,
32 weak_ptr_factory_.GetWeakPtr()));
33 WipeIfRequired();
34 }
35
36 ArcUserDataService::~ArcUserDataService() {
37 DCHECK(thread_checker_.CalledOnValidThread());
38 arc_bridge_service()->RemoveObserver(this);
39 }
40
41 void ArcUserDataService::OnBridgeStopped(ArcBridgeService::StopReason reason) {
42 DCHECK(thread_checker_.CalledOnValidThread());
43 const AccountId& account_id =
44 user_manager::UserManager::Get()->GetPrimaryUser()->GetAccountId();
45 if (account_id != primary_user_account_id_) {
46 LOG(ERROR) << "User preferences not loaded for "
47 << primary_user_account_id_.GetUserEmail()
48 << ", but current primary user is " << account_id.GetUserEmail();
49 primary_user_account_id_ = EmptyAccountId();
50 return;
51 }
52 WipeIfRequired();
53 }
54
55 void ArcUserDataService::RequireUserDataWiped(const ArcDataCallback& callback) {
56 VLOG(1) << "Require ARC user data to be wiped.";
57 arc_user_data_wipe_required_ = true;
58 callback_ = callback;
59 }
60
61 void ArcUserDataService::WipeIfRequired() {
62 DCHECK(thread_checker_.CalledOnValidThread());
63 if (!arc_bridge_service()->stopped()) {
64 LOG(ERROR) << "ARC instance not stopped, user data can't be wiped";
65 return;
66 }
67 if ((arc_enabled_pref_->GetValue() && !arc_user_data_wipe_required_) ||
68 base::CommandLine::ForCurrentProcess()->HasSwitch(
69 chromeos::switches::kDisableArcDataWipe)) {
70 return;
71 }
72 VLOG(1) << "Wipe ARC user data.";
73 arc_user_data_wipe_required_ = false;
74 const cryptohome::Identification cryptohome_id(primary_user_account_id_);
75 chromeos::SessionManagerClient* session_manager_client =
76 chromeos::DBusThreadManager::Get()->GetSessionManagerClient();
77 session_manager_client->RemoveArcData(cryptohome_id, callback_);
78 callback_.Reset();
79 }
80
81 void ArcUserDataService::OnOptInPreferenceChanged() {
82 if (!arc_enabled_pref_->GetValue())
83 arc_user_data_wipe_required_ = true;
84 }
85
86 } // 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