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

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

Issue 2145813002: Clear old ARC instance before opt-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use prefs() from PrefMember instead of passing a new parameter Created 4 years, 5 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
6 #define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ 6 #define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "components/arc/arc_bridge_service.h" 12 #include "components/arc/arc_bridge_service.h"
13 #include "components/arc/arc_service.h" 13 #include "components/arc/arc_service.h"
14 #include "components/prefs/pref_change_registrar.h"
14 #include "components/prefs/pref_member.h" 15 #include "components/prefs/pref_member.h"
15 #include "components/signin/core/account_id/account_id.h" 16 #include "components/signin/core/account_id/account_id.h"
16 17
18 class PrefService;
hidehiko 2016/07/19 02:08:29 Unused.
dspaid 2016/07/19 02:11:17 Done.
19
17 namespace arc { 20 namespace arc {
18 21
19 class ArcBridgeService; 22 class ArcBridgeService;
20 23
21 // This class controls the lifecycle of ARC user data, removing it when 24 // This class controls the lifecycle of ARC user data, removing it when
22 // necessary. 25 // necessary.
23 class ArcUserDataService : public ArcService, 26 class ArcUserDataService : public ArcService,
24 public ArcBridgeService::Observer { 27 public ArcBridgeService::Observer {
25 public: 28 public:
26 explicit ArcUserDataService( 29 explicit ArcUserDataService(
27 ArcBridgeService* arc_bridge_service, 30 ArcBridgeService* arc_bridge_service,
28 std::unique_ptr<BooleanPrefMember> arc_enabled_pref, 31 std::unique_ptr<BooleanPrefMember> arc_enabled_pref,
29 const AccountId& account_id); 32 const AccountId& account_id);
30 ~ArcUserDataService() override; 33 ~ArcUserDataService() override;
31 34
32 // ArcBridgeService::Observer: 35 // ArcBridgeService::Observer:
33 // Called whenever the arc bridge is stopped to potentially remove data if 36 // Called whenever the arc bridge is stopped to potentially remove data if
34 // the user has not opted in. 37 // the user has not opted in.
35 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; 38 void OnBridgeStopped(ArcBridgeService::StopReason reason) override;
36 39
37 private: 40 private:
38 base::ThreadChecker thread_checker_; 41 base::ThreadChecker thread_checker_;
39 42
40 // Checks if ARC is both stopped and disabled (not opt-in) and triggers 43 // Checks if ARC is both stopped and disabled (not opt-in) and triggers
41 // removal of user data if both conditions are true. 44 // removal of user data if both conditions are true.
42 void ClearIfDisabled(); 45 void ClearIfDisabled();
43 46
47 // Callback when the kArcEnabled preference changes. It watches for instances
48 // where the preference is disabled and remembers this so that it can wipe
49 // user data once the bridge has stopped.
50 void OnOptInPreferenceChanged();
51
44 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; 52 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_;
45 53
46 // Account ID for the account for which we currently have opt-in information. 54 // Account ID for the account for which we currently have opt-in information.
47 AccountId primary_user_account_id_; 55 AccountId primary_user_account_id_;
48 56
57 // Registrar used to monitor ARC enabled state.
58 PrefChangeRegistrar pref_change_registrar_;
59
60 // Set to true when kArcEnabled goes from true to false and set to false
61 // again after user data has been wiped. This ensures data is wiped even if
62 // the user tries to enable ARC before the bridge has shut down.
63 bool arc_disabled_ = false;
64
65 base::WeakPtrFactory<ArcUserDataService> weak_ptr_factory_;
hidehiko 2016/07/19 02:08:29 Could you add #include?
dspaid 2016/07/19 02:11:17 Done.
66
49 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); 67 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService);
50 }; 68 };
51 69
52 } // namespace arc 70 } // namespace arc
53 71
54 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ 72 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.cc ('k') | components/arc/user_data/arc_user_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698