OLD | NEW |
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 | 5 #ifndef COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE |
6 #define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE | 6 #define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "chromeos/dbus/session_manager_client.h" |
10 #include "components/arc/arc_bridge_service.h" | 11 #include "components/arc/arc_bridge_service.h" |
11 #include "components/arc/arc_service.h" | 12 #include "components/arc/arc_service.h" |
12 #include "components/prefs/pref_member.h" | 13 #include "components/prefs/pref_member.h" |
13 #include "components/signin/core/account_id/account_id.h" | 14 #include "components/signin/core/account_id/account_id.h" |
14 | 15 |
15 namespace arc { | 16 namespace arc { |
16 | 17 |
17 class ArcBridgeService; | 18 class ArcBridgeService; |
18 | 19 |
19 // This class controls the lifecycle of ARC user data, removing it when | 20 // This class controls the lifecycle of ARC user data, removing it when |
20 // necessary. | 21 // necessary. |
21 class ArcUserDataService : public ArcService, | 22 class ArcUserDataService : public ArcService, |
22 public ArcBridgeService::Observer { | 23 public ArcBridgeService::Observer { |
23 public: | 24 public: |
24 explicit ArcUserDataService( | 25 explicit ArcUserDataService( |
25 ArcBridgeService* arc_bridge_service, | 26 ArcBridgeService* arc_bridge_service, |
26 std::unique_ptr<BooleanPrefMember> arc_enabled_pref, | 27 std::unique_ptr<BooleanPrefMember> arc_enabled_pref, |
27 const AccountId& account_id); | 28 const AccountId& account_id); |
28 ~ArcUserDataService() override; | 29 ~ArcUserDataService() override; |
29 | 30 |
| 31 using ArcDataCallback = chromeos::SessionManagerClient::ArcCallback; |
| 32 |
30 // ArcBridgeService::Observer: | 33 // ArcBridgeService::Observer: |
31 // Called whenever the arc bridge is stopped to potentially remove data if | 34 // Called whenever the arc bridge is stopped to potentially wipe data if |
32 // the user has not opted in. | 35 // the user has not opted in or it is required. |
33 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 36 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
34 | 37 |
| 38 // Requires to wipe ARC user data after the next ARC bridge shutdown and call |
| 39 // |callback| with an operation result. |
| 40 void RequireUserDataWiped(const ArcDataCallback& callback); |
| 41 |
35 private: | 42 private: |
36 base::ThreadChecker thread_checker_; | 43 base::ThreadChecker thread_checker_; |
37 | 44 |
38 // Checks if ARC is both stopped and disabled (not opt-in) and triggers | 45 // Checks if ARC is both stopped and disabled (not opt-in) or data wipe is |
39 // removal of user data if both conditions are true. | 46 // required and triggers removal of user data. |
40 void ClearIfDisabled(); | 47 void WipeIfRequired(); |
41 | 48 |
42 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; | 49 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; |
43 | 50 |
44 // Account ID for the account for which we currently have opt-in information. | 51 // Account ID for the account for which we currently have opt-in information. |
45 AccountId primary_user_account_id_; | 52 AccountId primary_user_account_id_; |
46 | 53 |
| 54 // Set to true when user data wipe is required and set to false again after |
| 55 // user data has been wiped. |
| 56 // This ensures data is wiped even if the user tries to enable ARC before the |
| 57 // bridge has shut down. |
| 58 bool arc_user_data_wipe_required_ = false; |
| 59 |
| 60 // Callback object that is passed to RemoveArcData to be invoked with a |
| 61 // result of ARC user data wipe. |
| 62 // Set when ARC user data wipe is required by RequireUserDataWiped. |
| 63 ArcDataCallback callback_; |
| 64 |
47 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); | 65 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); |
48 }; | 66 }; |
49 | 67 |
50 } // namespace arc | 68 } // namespace arc |
51 | 69 |
52 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE | 70 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE |
OLD | NEW |