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 @@
// Could be nil if no full name has been fetched for this account yet.
@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
// between apps.
@property(strong, nonatomic, readonly) NSString* hashedGaiaID;
......
......@@ -27,6 +27,11 @@
return nil;
}
- (NSString*)userGivenName {
NOTREACHED();
return nil;
}
- (NSString*)hashedGaiaID {
NOTREACHED();
return nil;
......
......@@ -12,6 +12,8 @@
// Returns a ChromeIdentity based on |email|, |gaiaID| and |name|.
// The |hashedGaiaID| property will be derived from |name|.
// For simplicity, both |userGivenName| and |userFullName| properties use
// |name|.
+ (FakeChromeIdentity*)identityWithEmail:(NSString*)email
gaiaID:(NSString*)gaiaID
name:(NSString*)name;
......
......@@ -14,6 +14,7 @@ namespace {
NSString* const kCoderUserEmailKey = @"UserEmail";
NSString* const kCoderGaiaIDKey = @"GaiaID";
NSString* const kCoderUserFullNameKey = @"UserFullName";
NSString* const kCoderUserGivenNameKey = @"UserGivenName";
NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
} // namespace
......@@ -21,6 +22,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
NSString* _userEmail;
NSString* _gaiaID;
NSString* _userFullName;
NSString* _userGivenName;
NSString* _hashedGaiaID;
}
......@@ -40,6 +42,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
_userEmail = [email copy];
_gaiaID = [gaiaID copy];
_userFullName = [name copy];
_userGivenName = [name copy];
_hashedGaiaID = [NSString stringWithFormat:@"%@_hashID", name];
}
return self;
......@@ -57,6 +60,10 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
return _userFullName;
}
- (NSString*)userGivenName {
return _userGivenName;
}
- (NSString*)hashedGaiaID {
return _hashedGaiaID;
}
......@@ -79,6 +86,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
return [_userEmail isEqualToString:other.userEmail] &&
[_gaiaID isEqualToString:other.gaiaID] &&
[_userFullName isEqualToString:other.userFullName] &&
[_userGivenName isEqualToString:other.userGivenName] &&
[_hashedGaiaID isEqualToString:other.hashedGaiaID];
}
return NO;
......@@ -94,6 +102,7 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
[coder encodeObject:_userEmail forKey:kCoderUserEmailKey];
[coder encodeObject:_gaiaID forKey:kCoderGaiaIDKey];
[coder encodeObject:_userFullName forKey:kCoderUserFullNameKey];
[coder encodeObject:_userGivenName forKey:kCoderUserGivenNameKey];
[coder encodeObject:_hashedGaiaID forKey:kCoderHashedGaiaIDKey];
}
......@@ -105,6 +114,8 @@ NSString* const kCoderHashedGaiaIDKey = @"HashedGaiaID";
forKey:kCoderGaiaIDKey];
_userFullName = [coder decodeObjectOfClass:[NSString class]
forKey:kCoderUserFullNameKey];
_userGivenName = [coder decodeObjectOfClass:[NSString class]
forKey:kCoderUserGivenNameKey];
_hashedGaiaID = [coder decodeObjectOfClass:[NSString class]
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