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

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
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..a540fb640e58f46be344832b6342089a7844669c 100644
--- a/components/signin/core/account_id/account_id.h
+++ b/components/signin/core/account_id/account_id.h
@@ -10,6 +10,8 @@
#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
@@ -31,7 +33,7 @@ class AccountId {
bool is_valid() const;
void clear();
- const std::string& GetAccountType() const;
+ const AccountType& GetAccountType() const;
Roger Tawa OOO till Jul 10th 2016/12/05 16:34:31 Is there reason to keep this as a const &? I woul
Alexander Alekseev 2016/12/06 02:21:14 The reason was "it's better to return a reference
Roger Tawa OOO till Jul 10th 2016/12/07 22:09:37 My 2 cents: given C++11 move semantics and return
Roman Sorokin (ftl) 2016/12/13 13:45:59 Done.
Roman Sorokin (ftl) 2016/12/13 13:45:59 Done.
const std::string& GetGaiaId() 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)
@@ -44,6 +46,7 @@ class AccountId {
void SetGaiaId(const std::string& gaia_id);
void SetUserEmail(const std::string& email);
+ void SetAccountType(const AccountType& account_type);
// This method is to be used during transition period only.
static AccountId FromUserEmail(const std::string& user_email);
@@ -53,6 +56,19 @@ class AccountId {
// full account information.
static AccountId FromUserEmailGaiaId(const std::string& user_email,
const std::string& gaia_id);
+ // This method is used to construct AccountId with specific types.
+ static AccountId FromUserEmailGaiaIdAccountType(
+ const std::string& email,
+ const std::string& gaia_id,
+ const AccountType& account_type);
+ static AccountId FromGaiaIdAccountType(const std::string& gaia_id,
+ const AccountType& account_type);
+
+ // 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.
@@ -65,9 +81,13 @@ class AccountId {
private:
AccountId();
AccountId(const std::string& gaia_id, const std::string& user_email);
+ AccountId(const std::string& gaia_id,
+ const std::string& user_email,
+ const AccountType& account_type);
std::string gaia_id_;
std::string user_email_;
+ AccountType account_type_ = AccountType::GOOGLE;
};
// Returns a reference to a singleton.

Powered by Google App Engine
This is Rietveld 408576698