Commit 782db57a authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS][Passwords] Showing "signed in with" for federation credential

This change adds "Signed in with" row for federation credential on the
Password Details screen.

Bug: 1137807
Change-Id: Ie9e6d8b78eef253098111904306fbffe4262f897
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467937
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821660}
parent 8ae44865
......@@ -23,6 +23,9 @@
// Associated username.
@property(nonatomic, copy) NSString* username;
// The federation providing this credential, if any.
@property(nonatomic, copy, readonly) NSString* federation;
// Associated password.
@property(nonatomic, copy) NSString* password;
......
......@@ -39,7 +39,12 @@
_changePasswordURL = password_manager::CreateChangePasswordUrl(form.url);
}
_username = base::SysUTF16ToNSString(form.username_value);
_password = base::SysUTF16ToNSString(form.password_value);
if (form.federation_origin.opaque()) {
_password = base::SysUTF16ToNSString(form.password_value);
} else {
_federation = base::SysUTF8ToNSString(form.federation_origin.host());
}
}
return self;
}
......
......@@ -58,6 +58,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeWebsite = kItemTypeEnumZero,
ItemTypeUsername,
ItemTypePassword,
ItemTypeFederation,
ItemTypeChangePasswordButton,
ItemTypeChangePasswordRecommendation,
};
......@@ -178,6 +179,9 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
[model addItem:[self changePasswordRecommendationItem]
toSectionWithIdentifier:SectionIdentifierCompromisedInfo];
}
} else if ([self.password.federation length]) {
[model addItem:[self federationItem]
toSectionWithIdentifier:SectionIdentifierPassword];
}
}
......@@ -243,6 +247,17 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
return item;
}
- (TableViewTextEditItem*)federationItem {
TableViewTextEditItem* item =
[[TableViewTextEditItem alloc] initWithType:ItemTypeFederation];
item.textFieldName =
l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_FEDERATION);
item.textFieldValue = self.password.federation;
item.textFieldEnabled = NO;
item.hideIcon = YES;
return item;
}
- (TableViewTextItem*)changePasswordItem {
TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeChangePasswordButton];
......@@ -270,6 +285,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
NSInteger itemType = [model itemTypeForIndexPath:indexPath];
switch (itemType) {
case ItemTypeWebsite:
case ItemTypeFederation:
[self ensureContextMenuShownForItemType:itemType
tableView:tableView
atIndexPath:indexPath];
......@@ -388,6 +404,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
break;
case ItemTypeWebsite:
case ItemTypeFederation:
case ItemTypeChangePasswordRecommendation:
break;
}
......@@ -399,6 +416,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
NSInteger itemType = [self.tableViewModel itemTypeForIndexPath:indexPath];
switch (itemType) {
case ItemTypeWebsite:
case ItemTypeFederation:
return NO;
case ItemTypeUsername:
return base::FeatureList::IsEnabled(
......@@ -596,6 +614,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
case ItemTypePassword:
return YES;
case ItemTypeWebsite:
case ItemTypeFederation:
case ItemTypeChangePasswordButton:
case ItemTypeChangePasswordRecommendation:
return NO;
......@@ -704,6 +723,9 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
message =
l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE);
break;
case ItemTypeFederation:
generalPasteboard.string = self.password.federation;
return;
case ItemTypePassword:
[self attemptToShowPasswordFor:ReauthenticationReasonCopy];
return;
......
......@@ -406,10 +406,11 @@ TEST_F(PasswordDetailsTableViewControllerTest,
TEST_F(PasswordDetailsTableViewControllerTest, TestFederatedCredential) {
SetFederatedPassword();
EXPECT_EQ(1, NumberOfSections());
EXPECT_EQ(2, NumberOfItemsInSection(0));
EXPECT_EQ(3, NumberOfItemsInSection(0));
CheckEditCellText(@"http://www.example.com/", 0, 0);
CheckEditCellText(@"test@egmail.com", 0, 1);
CheckEditCellText(@"www.example.com", 0, 2);
reauth().expectedResult = ReauthenticationResult::kFailure;
PasswordDetailsTableViewController* passwordDetails =
......
......@@ -134,21 +134,28 @@ GREYLayoutConstraint* Below() {
constant:0.0];
}
// Matcher for the Copy site button in Password Details view.
// Matcher for the website in Password Details view.
id<GREYMatcher> PasswordDetailWebsite() {
return TextFieldForCellWithLabelId(IDS_IOS_SHOW_PASSWORD_VIEW_SITE);
}
// Matcher for the Copy username button in Password Details view.
// Matcher for the username in Password Details view.
id<GREYMatcher> PasswordDetailUsername() {
return TextFieldForCellWithLabelId(IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME);
}
// Matcher for the Copy password button in Password Details view.
// Matcher for the password in Password Details view.
id<GREYMatcher> PasswordDetailPassword() {
return TextFieldForCellWithLabelId(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD);
}
// Matcher for the federation details in Password Details view.
id<GREYMatcher> PasswordDetailFederation() {
return grey_allOf(grey_accessibilityID(GetTextFieldForID(
IDS_IOS_SHOW_PASSWORD_VIEW_FEDERATION)),
grey_kindOfClassName(@"UITextField"), nil);
}
// Matcher for the Show password button in Password Details view.
id<GREYMatcher> ShowPasswordButton() {
return grey_allOf(ButtonWithAccessibilityLabel(l10n_util::GetNSString(
......@@ -815,6 +822,8 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_textFieldValue(@"https://example.com/")];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
assertWithMatcher:grey_textFieldValue(@"federated username")];
[[EarlGrey selectElementWithMatcher:PasswordDetailFederation()]
assertWithMatcher:grey_textFieldValue(@"famous.provider.net")];
// Check that the password is not present.
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
......@@ -855,6 +864,10 @@ void CopyPasswordDetailWithID(int detail_id) {
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
assertWithMatcher:grey_textFieldValue(kMaskedPassword)];
// Check that the federation origin is not present.
[[EarlGrey selectElementWithMatcher:PasswordDetailFederation()]
assertWithMatcher:grey_nil()];
[GetInteractionForPasswordDetailItem(PasswordDetailPassword())
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailUsername())];
[GetInteractionForPasswordDetailItem(PasswordDetailUsername())
......@@ -885,6 +898,8 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailFederation()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
......@@ -912,11 +927,15 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_textFieldValue(@"https://example.com/")];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
assertWithMatcher:grey_textFieldValue(@"federated username")];
[[EarlGrey selectElementWithMatcher:PasswordDetailFederation()]
assertWithMatcher:grey_textFieldValue(@"famous.provider.net")];
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
assertWithMatcher:grey_nil()];
[GetInteractionForPasswordDetailItem(PasswordDetailUsername())
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailWebsite())];
[[EarlGrey selectElementWithMatcher:PasswordDetailFederation()]
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailUsername())];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
......
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