proximity_auth_local_state_pref_manager.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2017 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. #ifndef ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_LOCAL_STATE_PREF_MANAGER_H_
  5. #define ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_LOCAL_STATE_PREF_MANAGER_H_
  6. #include "ash/components/proximity_auth/proximity_auth_pref_manager.h"
  7. #include "base/values.h"
  8. #include "components/account_id/account_id.h"
  9. class PrefRegistrySimple;
  10. class PrefService;
  11. namespace proximity_auth {
  12. // Implementation of ProximityAuthPrefManager based on the device's local state,
  13. // used before the user logs in. After login, ProximityAuthProfilePrefManager is
  14. // used to manage prefs inside the user session.
  15. // Note: All prefs managed by this class are read-only. These prefs are synced
  16. // from each of the user's profile prefs. For privacy reasons, only a subset of
  17. // all prefs are accessible from the local state.
  18. class ProximityAuthLocalStatePrefManager : public ProximityAuthPrefManager {
  19. public:
  20. explicit ProximityAuthLocalStatePrefManager(PrefService* local_state);
  21. ProximityAuthLocalStatePrefManager(
  22. const ProximityAuthLocalStatePrefManager&) = delete;
  23. ProximityAuthLocalStatePrefManager& operator=(
  24. const ProximityAuthLocalStatePrefManager&) = delete;
  25. ~ProximityAuthLocalStatePrefManager() override;
  26. // Registers the prefs used by this class to the given |pref_service|.
  27. static void RegisterPrefs(PrefRegistrySimple* registry);
  28. // Changes the current user for whom to fetch prefs, i.e. when the focused
  29. // user pod changes.
  30. void SetActiveUser(const AccountId& active_user);
  31. AccountId active_user() { return active_user_; }
  32. // ProximityAuthPrefManager:
  33. bool IsEasyUnlockAllowed() const override;
  34. bool IsEasyUnlockEnabled() const override;
  35. bool IsEasyUnlockEnabledStateSet() const override;
  36. bool IsChromeOSLoginAllowed() const override;
  37. bool IsChromeOSLoginEnabled() const override;
  38. private:
  39. // ProximityAuthPrefManager:
  40. void SetIsEasyUnlockEnabled(bool is_easy_unlock_enabled) const override;
  41. void SetEasyUnlockEnabledStateSet() const override;
  42. void SetLastPromotionCheckTimestampMs(int64_t timestamp_ms) override;
  43. int64_t GetLastPromotionCheckTimestampMs() const override;
  44. void SetPromotionShownCount(int count) override;
  45. int GetPromotionShownCount() const override;
  46. void SetIsChromeOSLoginEnabled(bool is_enabled) override;
  47. void SetHasShownLoginDisabledMessage(bool has_shown) override;
  48. bool HasShownLoginDisabledMessage() const override;
  49. const base::Value::Dict* GetActiveUserPrefsDictionary() const;
  50. // Contains local state preferences that outlive the lifetime of this object
  51. // and across process restarts. Not owned and must outlive this instance.
  52. PrefService* local_state_;
  53. // The account id of the active user for which to fetch the prefs.
  54. AccountId active_user_;
  55. };
  56. } // namespace proximity_auth
  57. #endif // ASH_COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_LOCAL_STATE_PREF_MANAGER_H_