OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 |
| 5 #ifndef COMPONENTS_USER_MANAGER_KNOWN_USER_H_ |
| 6 #define COMPONENTS_USER_MANAGER_KNOWN_USER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "components/user_manager/user_manager_export.h" |
| 11 |
| 12 class AccountId; |
| 13 class PrefRegistrySimple; |
| 14 |
| 15 namespace base { |
| 16 class DictionaryValue; |
| 17 class ListValue; |
| 18 class TaskRunner; |
| 19 } |
| 20 |
| 21 namespace user_manager { |
| 22 namespace known_user { |
| 23 // Methods for storage/retrieval of per-user properties in Local State. |
| 24 |
| 25 // Performs a lookup of properties associated with |account_id|. If found, |
| 26 // returns |true| and fills |out_value|. |out_value| can be NULL, if |
| 27 // only existence check is required. |
| 28 bool USER_MANAGER_EXPORT FindPrefs(const AccountId& account_id, |
| 29 const base::DictionaryValue** out_value); |
| 30 |
| 31 // Updates (or creates) properties associated with |account_id| based |
| 32 // on |values|. |clear| defines if existing properties are cleared (|true|) |
| 33 // or if it is just a incremental update (|false|). |
| 34 void USER_MANAGER_EXPORT UpdatePrefs(const AccountId& account_id, |
| 35 const base::DictionaryValue& values, |
| 36 bool clear); |
| 37 |
| 38 // Returns true if |account_id| preference by |path| does exist, |
| 39 // fills in |out_value|. Otherwise returns false. |
| 40 bool USER_MANAGER_EXPORT GetStringPref(const AccountId& account_id, |
| 41 const std::string& path, |
| 42 std::string* out_value); |
| 43 |
| 44 // Updates user's identified by |account_id| string preference |path|. |
| 45 void USER_MANAGER_EXPORT SetStringPref(const AccountId& account_id, |
| 46 const std::string& path, |
| 47 const std::string& in_value); |
| 48 |
| 49 // Returns true if |account_id| preference by |path| does exist, |
| 50 // fills in |out_value|. Otherwise returns false. |
| 51 bool USER_MANAGER_EXPORT GetBooleanPref(const AccountId& account_id, |
| 52 const std::string& path, |
| 53 bool* out_value); |
| 54 |
| 55 // Updates user's identified by |account_id| boolean preference |path|. |
| 56 void USER_MANAGER_EXPORT SetBooleanPref(const AccountId& account_id, |
| 57 const std::string& path, |
| 58 const bool in_value); |
| 59 |
| 60 // Returns true if |account_id| preference by |path| does exist, |
| 61 // fills in |out_value|. Otherwise returns false. |
| 62 bool USER_MANAGER_EXPORT GetIntegerPref(const AccountId& account_id, |
| 63 const std::string& path, |
| 64 int* out_value); |
| 65 |
| 66 // Updates user's identified by |account_id| integer preference |path|. |
| 67 void USER_MANAGER_EXPORT SetIntegerPref(const AccountId& account_id, |
| 68 const std::string& path, |
| 69 const int in_value); |
| 70 |
| 71 // This call forms full account id of a known user by email and (optionally) |
| 72 // gaia_id. |
| 73 // This is a temporary call while migrating to AccountId. |
| 74 AccountId USER_MANAGER_EXPORT GetAccountId(const std::string& user_email, |
| 75 const std::string& gaia_id); |
| 76 |
| 77 // Updates |gaia_id| for user with |account_id|. |
| 78 // TODO(alemate): Update this once AccountId contains GAIA ID |
| 79 // (crbug.com/548926). |
| 80 void USER_MANAGER_EXPORT UpdateGaiaID(const AccountId& account_id, |
| 81 const std::string& gaia_id); |
| 82 |
| 83 // Find GAIA ID for user with |account_id|, fill in |out_value| and return |
| 84 // true |
| 85 // if GAIA ID was found or false otherwise. |
| 86 // TODO(antrim): Update this once AccountId contains GAIA ID |
| 87 // (crbug.com/548926). |
| 88 bool USER_MANAGER_EXPORT FindGaiaID(const AccountId& account_id, |
| 89 std::string* out_value); |
| 90 |
| 91 // Setter and getter for DeviceId known user string preference. |
| 92 void USER_MANAGER_EXPORT SetDeviceId(const AccountId& account_id, |
| 93 const std::string& device_id); |
| 94 |
| 95 std::string USER_MANAGER_EXPORT GetDeviceId(const AccountId& account_id); |
| 96 |
| 97 // Setter and getter for GAPSCookie known user string preference. |
| 98 void USER_MANAGER_EXPORT SetGAPSCookie(const AccountId& account_id, |
| 99 const std::string& gaps_cookie); |
| 100 |
| 101 std::string USER_MANAGER_EXPORT GetGAPSCookie(const AccountId& account_id); |
| 102 |
| 103 // Saves whether the user authenticates using SAML. |
| 104 void USER_MANAGER_EXPORT UpdateUsingSAML(const AccountId& account_id, |
| 105 const bool using_saml); |
| 106 |
| 107 // Returns if SAML needs to be used for authentication of the user with |
| 108 // |account_id|, if it is known (was set by a |UpdateUsingSaml| call). |
| 109 // Otherwise |
| 110 // returns false. |
| 111 bool USER_MANAGER_EXPORT IsUsingSAML(const AccountId& account_id); |
| 112 |
| 113 // Saves why the user has to go through re-auth flow. |
| 114 void USER_MANAGER_EXPORT UpdateReauthReason(const AccountId& account_id, |
| 115 const int reauth_reason); |
| 116 |
| 117 // Returns the reason why the user with |account_id| has to go through the |
| 118 // re-auth flow. Returns true if such a reason was recorded or false |
| 119 // otherwise. |
| 120 bool USER_MANAGER_EXPORT FindReauthReason(const AccountId& account_id, |
| 121 int* out_value); |
| 122 |
| 123 // Removes all user preferences associated with |account_id|. |
| 124 // (This one used by user_manager only and thus not exported.) |
| 125 void RemovePrefs(const AccountId& account_id); |
| 126 |
| 127 // Register known user prefs. |
| 128 void USER_MANAGER_EXPORT RegisterPrefs(PrefRegistrySimple* registry); |
| 129 } |
| 130 } // namespace user_manager |
| 131 |
| 132 #endif // COMPONENTS_USER_MANAGER_KNOWN_USER_H_ |
OLD | NEW |