Commit 0b405995 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Chromium LUCI CQ

[iOS] Add 'userGivenName' property to ChromeIdentity.

In order to unify the Identity communication across Chrome platforms
we expose the user's given name as an Identity property.

Bug: 1148764
Change-Id: I96eb98e1ab6ce5f5f2fe5a01cb68b3e9744e63ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2615158
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841438}
parent 9e49cecd
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
// Could be nil if no full name has been fetched for this account yet. // Could be nil if no full name has been fetched for this account yet.
@property(strong, nonatomic, readonly) NSString* userFullName; @property(strong, nonatomic, readonly) NSString* userFullName;
// Returns the primary given name of the identity, usually the user's first
// name. Could be nil if no name has been fetched for this account yet.
@property(strong, nonatomic, readonly) NSString* userGivenName;
// Cached Hashed Gaia ID. This is used to pass the currently signed in account // Cached Hashed Gaia ID. This is used to pass the currently signed in account
// between apps. // between apps.
@property(strong, nonatomic, readonly) NSString* hashedGaiaID; @property(strong, nonatomic, readonly) NSString* hashedGaiaID;
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
return nil; return nil;
} }
- (NSString*)userGivenName {
NOTREACHED();
return nil;
}
- (NSString*)hashedGaiaID { - (NSString*)hashedGaiaID {
NOTREACHED(); NOTREACHED();
return nil; return nil;
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
// Returns a ChromeIdentity based on |email|, |gaiaID| and |name|. // Returns a ChromeIdentity based on |email|, |gaiaID| and |name|.
// The |hashedGaiaID| property will be derived from |name|. // The |hashedGaiaID| property will be derived from |name|.
// For simplicity, both |userGivenName| and |userFullName| properties use
// |name|.
+ (FakeChromeIdentity*)identityWithEmail:(NSString*)email + (FakeChromeIdentity*)identityWithEmail:(NSString*)email
gaiaID:(NSString*)gaiaID gaiaID:(NSString*)gaiaID
name:(NSString*)name; name:(NSString*)name;
......
...@@ -14,6 +14,7 @@ namespace { ...@@ -14,6 +14,7 @@ namespace {
NSString* const kCoderUserEmailKey = @"UserEmail"; NSString* const kCoderUserEmailKey = @"UserEmail";
NSString* const kCoderGaiaIDKey = @"GaiaID"; NSString* const kCoderGaiaIDKey = @"GaiaID";
NSString* const kCoderUserFullNameKey = @"UserFullName"; NSString* const kCoderUserFullNameKey = @"UserFullName";
NSString* const kCoderUserGivenNameKey = @"UserGivenName";
NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
} // namespace } // namespace
...@@ -21,6 +22,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -21,6 +22,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
NSString* _userEmail; NSString* _userEmail;
NSString* _gaiaID; NSString* _gaiaID;
NSString* _userFullName; NSString* _userFullName;
NSString* _userGivenName;
NSString* _hashedGaiaID; NSString* _hashedGaiaID;
} }
...@@ -40,6 +42,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -40,6 +42,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
_userEmail = [email copy]; _userEmail = [email copy];
_gaiaID = [gaiaID copy]; _gaiaID = [gaiaID copy];
_userFullName = [name copy]; _userFullName = [name copy];
_userGivenName = [name copy];
_hashedGaiaID = [NSString stringWithFormat:@"%@_hashID", name]; _hashedGaiaID = [NSString stringWithFormat:@"%@_hashID", name];
} }
return self; return self;
...@@ -57,6 +60,10 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -57,6 +60,10 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
return _userFullName; return _userFullName;
} }
- (NSString*)userGivenName {
return _userGivenName;
}
- (NSString*)hashedGaiaID { - (NSString*)hashedGaiaID {
return _hashedGaiaID; return _hashedGaiaID;
} }
...@@ -79,6 +86,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -79,6 +86,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
return [_userEmail isEqualToString:other.userEmail] && return [_userEmail isEqualToString:other.userEmail] &&
[_gaiaID isEqualToString:other.gaiaID] && [_gaiaID isEqualToString:other.gaiaID] &&
[_userFullName isEqualToString:other.userFullName] && [_userFullName isEqualToString:other.userFullName] &&
[_userGivenName isEqualToString:other.userGivenName] &&
[_hashedGaiaID isEqualToString:other.hashedGaiaID]; [_hashedGaiaID isEqualToString:other.hashedGaiaID];
} }
return NO; return NO;
...@@ -94,6 +102,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -94,6 +102,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
[coder encodeObject:_userEmail forKey:kCoderUserEmailKey]; [coder encodeObject:_userEmail forKey:kCoderUserEmailKey];
[coder encodeObject:_gaiaID forKey:kCoderGaiaIDKey]; [coder encodeObject:_gaiaID forKey:kCoderGaiaIDKey];
[coder encodeObject:_userFullName forKey:kCoderUserFullNameKey]; [coder encodeObject:_userFullName forKey:kCoderUserFullNameKey];
[coder encodeObject:_userGivenName forKey:kCoderUserGivenNameKey];
[coder encodeObject:_hashedGaiaID forKey:kCoderHashedGaiaIDKey]; [coder encodeObject:_hashedGaiaID forKey:kCoderHashedGaiaIDKey];
} }
...@@ -105,6 +114,8 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID"; ...@@ -105,6 +114,8 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
forKey:kCoderGaiaIDKey]; forKey:kCoderGaiaIDKey];
_userFullName = [coder decodeObjectOfClass:[NSString class] _userFullName = [coder decodeObjectOfClass:[NSString class]
forKey:kCoderUserFullNameKey]; forKey:kCoderUserFullNameKey];
_userGivenName = [coder decodeObjectOfClass:[NSString class]
forKey:kCoderUserGivenNameKey];
_hashedGaiaID = [coder decodeObjectOfClass:[NSString class] _hashedGaiaID = [coder decodeObjectOfClass:[NSString class]
forKey:kCoderHashedGaiaIDKey]; forKey:kCoderHashedGaiaIDKey];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment