Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Unified Diff: components/signin/core/account_id/account_id.h

Issue 2529103002: Add account_type into AccountId (Closed)
Patch Set: more tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/signin/core/account_id/account_id.h
diff --git a/components/signin/core/account_id/account_id.h b/components/signin/core/account_id/account_id.h
index 7cba697805da512d5819523cd8998bffad5b3de3..6183db4c98874ac22c3051edf1f935da49bbe562 100644
--- a/components/signin/core/account_id/account_id.h
+++ b/components/signin/core/account_id/account_id.h
@@ -10,12 +10,16 @@
#include <string>
#include "base/containers/hash_tables.h"
+enum class AccountType { UNKNOWN, GOOGLE, ACTIVE_DIRECTORY };
+
// Type that contains enough information to identify user.
//
// TODO(alemate): we are in the process of moving away from std::string as a
// type for storing user identifier to AccountId. At this time GaiaId is mostly
// empty, so this type is used as a replacement for e-mail string.
// But in near future AccountId will become full feature user identifier.
+// TODO(alemate): Rename functions and fields to reflect different types of
+// accounts. (see crbug.com/672253)
class AccountId {
public:
struct EmptyAccountId;
@@ -31,28 +35,45 @@ class AccountId {
bool is_valid() const;
void clear();
- const std::string& GetAccountType() const;
+ AccountType GetAccountType() const;
const std::string& GetGaiaId() const;
+ const std::string& GetObjGuid() const;
// Users of AccountId should make no assumptions on the format of email.
// I.e. it cannot be used as account identifier, because it is (in general)
// non-comparable.
const std::string& GetUserEmail() const;
+ // Returns true if |GetAccountIdKey| would return valid key.
+ bool HasAccountIdKey() const;
// This returns prefixed some string that can be used as a storage key.
// You should make no assumptions on the format of this string.
const std::string GetAccountIdKey() const;
- void SetGaiaId(const std::string& gaia_id);
void SetUserEmail(const std::string& email);
// This method is to be used during transition period only.
+ // AccountId with UNKNOWN AccountType;
static AccountId FromUserEmail(const std::string& user_email);
+ // AccountId with GOOGLE AccountType;
// This method is to be used during transition period only.
static AccountId FromGaiaId(const std::string& gaia_id);
// This method is the preferred way to construct AccountId if you have
// full account information.
+ // AccountId with GOOGLE AccountType;
static AccountId FromUserEmailGaiaId(const std::string& user_email,
const std::string& gaia_id);
+ // These methods are used to construct Active Directory AccountIds.
+ // AccountId with ACTIVE_DIRECTORY AccountType;
+ static AccountId AdFromUserEmailObjGuid(const std::string& email,
+ const std::string& obj_guid);
+ // AccountId with ACTIVE_DIRECTORY AccountType;
+ static AccountId AdFromObjGuid(const std::string& obj_guid);
+
+ // Translation functions between AccountType and std::string. Used for
+ // serialization.
+ static AccountType StringToAccountType(
+ const std::string& account_type_string);
+ static std::string AccountTypeToString(const AccountType& account_type);
// These are (for now) unstable and cannot be used to store serialized data to
// persistent storage. Only in-memory storage is safe.
@@ -64,10 +85,13 @@ class AccountId {
private:
AccountId();
- AccountId(const std::string& gaia_id, const std::string& user_email);
+ AccountId(const std::string& id,
+ const std::string& user_email,
+ const AccountType& account_type);
- std::string gaia_id_;
+ std::string id_;
std::string user_email_;
+ AccountType account_type_ = AccountType::UNKNOWN;
};
// Returns a reference to a singleton.

Powered by Google App Engine
This is Rietveld 408576698