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

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

Issue 2529103002: Add account_type into AccountId (Closed)
Patch Set: Fix MultiUserWindowManagerChromeOSTest.* 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
« no previous file with comments | « chromeos/tpm/tpm_token_info_getter_unittest.cc ('k') | components/signin/core/account_id/account_id.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4bc02054a86caede0d828110db4523693b789483 100644
--- a/components/signin/core/account_id/account_id.h
+++ b/components/signin/core/account_id/account_id.h
@@ -10,18 +10,28 @@
#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;
AccountId(const AccountId& other);
+ // If any of the comparable AccountIds has AccountType == UNKNOWN then it
+ // compares emails.
+ // If both are not UNKNOWN and not equal then it returns false.
+ // If AccountType == GOOGLE then it checks if either ids or emails are equal.
+ // If AccountType == ACTIVE_DIRECTORY then it checks if ids and emails are
+ // equal.
bool operator==(const AccountId& other) const;
bool operator!=(const AccountId& other) const;
bool operator<(const AccountId& right) const;
@@ -31,28 +41,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 +91,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.
« no previous file with comments | « chromeos/tpm/tpm_token_info_getter_unittest.cc ('k') | components/signin/core/account_id/account_id.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698