Chromium Code Reviews| 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_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_USER_DATA_SERVICE_H_ |
| 6 #define COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_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/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
| 14 #include "components/arc/arc_service.h" | 14 #include "components/arc/arc_service.h" |
| 15 #include "components/arc/instance_holder.h" | |
| 15 #include "components/prefs/pref_change_registrar.h" | 16 #include "components/prefs/pref_change_registrar.h" |
| 16 #include "components/prefs/pref_member.h" | 17 #include "components/prefs/pref_member.h" |
| 17 #include "components/signin/core/account_id/account_id.h" | 18 #include "components/signin/core/account_id/account_id.h" |
| 19 #include "mojo/public/cpp/bindings/binding.h" | |
| 18 | 20 |
| 19 namespace arc { | 21 namespace arc { |
| 20 | 22 |
| 21 class ArcBridgeService; | |
| 22 | |
| 23 // This class controls the lifecycle of ARC user data, removing it when | 23 // This class controls the lifecycle of ARC user data, removing it when |
| 24 // necessary. | 24 // necessary. |
| 25 class ArcUserDataService : public ArcService, | 25 class ArcUserDataService |
| 26 public ArcBridgeService::Observer { | 26 : public ArcService, |
| 27 public ArcBridgeService::Observer, | |
| 28 public InstanceHolder<mojom::EnterpriseReportingInstance>::Observer, | |
|
Luis Héctor Chávez
2016/07/22 15:51:42
I am a bit worried about the mismatch between the
Polina Bondarenko
2016/07/22 16:41:19
ArcEnterpriseReportingService?
| |
| 29 public mojom::EnterpriseReportingHost { | |
| 27 public: | 30 public: |
| 28 explicit ArcUserDataService( | 31 explicit ArcUserDataService( |
| 29 ArcBridgeService* arc_bridge_service, | 32 ArcBridgeService* arc_bridge_service, |
| 30 std::unique_ptr<BooleanPrefMember> arc_enabled_pref, | 33 std::unique_ptr<BooleanPrefMember> arc_enabled_pref, |
| 31 const AccountId& account_id); | 34 const AccountId& account_id); |
| 32 ~ArcUserDataService() override; | 35 ~ArcUserDataService() override; |
| 33 | 36 |
| 34 // ArcBridgeService::Observer: | 37 // ArcBridgeService::Observer: |
| 35 // Called whenever the arc bridge is stopped to potentially remove data if | 38 // Called whenever the arc bridge is stopped to potentially remove data if |
| 36 // the user has not opted in. | 39 // the user has not opted in. |
| 37 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 40 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| 38 | 41 |
| 42 // InstanceHolder<mojom::EnterpriseReportingInstance>::Observer overrides: | |
| 43 void OnInstanceReady() override; | |
| 44 | |
| 45 // mojom::EnterpriseReportingHost overrides: | |
| 46 void ReportManagementState(mojom::ManagementState state) override; | |
| 47 | |
| 39 private: | 48 private: |
| 40 base::ThreadChecker thread_checker_; | 49 base::ThreadChecker thread_checker_; |
| 41 | 50 |
| 42 // Checks if ARC is both stopped and disabled (not opt-in) and triggers | 51 // Checks if ARC is both stopped and disabled (not opt-in) or a data clean is |
| 43 // removal of user data if both conditions are true. | 52 // required and triggers removal of user data if conditions are true. |
| 44 void ClearIfDisabled(); | 53 void ClearIfRequired(); |
| 45 | 54 |
| 46 // Callback when the kArcEnabled preference changes. It watches for instances | 55 // Callback when the kArcEnabled preference changes. It watches for instances |
| 47 // where the preference is disabled and remembers this so that it can wipe | 56 // where the preference is disabled and remembers this so that it can wipe |
| 48 // user data once the bridge has stopped. | 57 // user data once the bridge has stopped. |
| 49 void OnOptInPreferenceChanged(); | 58 void OnOptInPreferenceChanged(); |
| 50 | 59 |
| 60 void RestartArc(); | |
| 61 | |
| 51 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; | 62 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; |
| 52 | 63 |
| 53 // Account ID for the account for which we currently have opt-in information. | 64 // Account ID for the account for which we currently have opt-in information. |
| 54 AccountId primary_user_account_id_; | 65 AccountId primary_user_account_id_; |
| 55 | 66 |
| 56 // Registrar used to monitor ARC enabled state. | 67 // Registrar used to monitor ARC enabled state. |
| 57 PrefChangeRegistrar pref_change_registrar_; | 68 PrefChangeRegistrar pref_change_registrar_; |
| 58 | 69 |
| 59 // Set to true when kArcEnabled goes from true to false and set to false | 70 // Set to true when kArcEnabled goes from true to false or data remove is |
| 60 // again after user data has been wiped. This ensures data is wiped even if | 71 // requested by mojom::EnterpriseReportingInstance and set to false again |
| 61 // the user tries to enable ARC before the bridge has shut down. | 72 // after user data has been wiped. This ensures data is wiped even if the |
| 62 bool arc_disabled_ = false; | 73 // user tries to enable ARC before the bridge has shut down. |
| 74 bool clean_required_ = false; | |
|
Luis Héctor Chávez
2016/07/22 15:51:42
We use a lot of names to refer to this operation:
Polina Bondarenko
2016/07/25 16:17:59
Done.
| |
| 75 | |
| 76 // Set to true, when ARC should be restarted. | |
| 77 bool restart_required_ = false; | |
| 78 | |
| 79 mojo::Binding<mojom::EnterpriseReportingHost> binding_; | |
| 63 | 80 |
| 64 base::WeakPtrFactory<ArcUserDataService> weak_ptr_factory_; | 81 base::WeakPtrFactory<ArcUserDataService> weak_ptr_factory_; |
| 65 | 82 |
| 66 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); | 83 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); |
| 67 }; | 84 }; |
| 68 | 85 |
| 69 } // namespace arc | 86 } // namespace arc |
| 70 | 87 |
| 71 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_USER_DATA_SERVICE_H_ |
| OLD | NEW |