| 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 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/memory/weak_ptr.h" |
| 11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 12 #include "components/arc/arc_bridge_service.h" | 13 #include "components/arc/arc_bridge_service.h" |
| 13 #include "components/arc/arc_service.h" | 14 #include "components/arc/arc_service.h" |
| 15 #include "components/prefs/pref_change_registrar.h" |
| 14 #include "components/prefs/pref_member.h" | 16 #include "components/prefs/pref_member.h" |
| 15 #include "components/signin/core/account_id/account_id.h" | 17 #include "components/signin/core/account_id/account_id.h" |
| 16 | 18 |
| 17 namespace arc { | 19 namespace arc { |
| 18 | 20 |
| 19 class ArcBridgeService; | 21 class ArcBridgeService; |
| 20 | 22 |
| 21 // 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 |
| 22 // necessary. | 24 // necessary. |
| 23 class ArcUserDataService : public ArcService, | 25 class ArcUserDataService : public ArcService, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 // the user has not opted in. | 36 // the user has not opted in. |
| 35 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; | 37 void OnBridgeStopped(ArcBridgeService::StopReason reason) override; |
| 36 | 38 |
| 37 private: | 39 private: |
| 38 base::ThreadChecker thread_checker_; | 40 base::ThreadChecker thread_checker_; |
| 39 | 41 |
| 40 // Checks if ARC is both stopped and disabled (not opt-in) and triggers | 42 // Checks if ARC is both stopped and disabled (not opt-in) and triggers |
| 41 // removal of user data if both conditions are true. | 43 // removal of user data if both conditions are true. |
| 42 void ClearIfDisabled(); | 44 void ClearIfDisabled(); |
| 43 | 45 |
| 46 // Callback when the kArcEnabled preference changes. It watches for instances |
| 47 // where the preference is disabled and remembers this so that it can wipe |
| 48 // user data once the bridge has stopped. |
| 49 void OnOptInPreferenceChanged(); |
| 50 |
| 44 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; | 51 const std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; |
| 45 | 52 |
| 46 // Account ID for the account for which we currently have opt-in information. | 53 // Account ID for the account for which we currently have opt-in information. |
| 47 AccountId primary_user_account_id_; | 54 AccountId primary_user_account_id_; |
| 48 | 55 |
| 56 // Registrar used to monitor ARC enabled state. |
| 57 PrefChangeRegistrar pref_change_registrar_; |
| 58 |
| 59 // Set to true when kArcEnabled goes from true to false and set to false |
| 60 // again after user data has been wiped. This ensures data is wiped even if |
| 61 // the user tries to enable ARC before the bridge has shut down. |
| 62 bool arc_disabled_ = false; |
| 63 |
| 64 base::WeakPtrFactory<ArcUserDataService> weak_ptr_factory_; |
| 65 |
| 49 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); | 66 DISALLOW_COPY_AND_ASSIGN(ArcUserDataService); |
| 50 }; | 67 }; |
| 51 | 68 |
| 52 } // namespace arc | 69 } // namespace arc |
| 53 | 70 |
| 54 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ | 71 #endif // COMPONENTS_ARC_USER_DATA_ARC_USER_DATA_SERVICE_H_ |
| OLD | NEW |