Commit 216559ba authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS][Password Check] Hostname truncate on the leading end

This change adds the same long hostname handling as on desktop, by
truncating it on the leading end instead of trailing.

Bug: 1075494
Change-Id: I1012ba35e8b1074da448329ac7e1fabadb38a672
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2325732
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793106}
parent c44e3dd3
...@@ -82,6 +82,13 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -82,6 +82,13 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
[super viewDidLoad]; [super viewDidLoad];
self.tableView.accessibilityIdentifier = kPasswordDetailsViewControllerId; self.tableView.accessibilityIdentifier = kPasswordDetailsViewControllerId;
self.tableView.allowsSelectionDuringEditing = YES; self.tableView.allowsSelectionDuringEditing = YES;
UILabel* titleLabel = [[UILabel alloc] init];
titleLabel.lineBreakMode = NSLineBreakByTruncatingHead;
titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
titleLabel.adjustsFontForContentSizeCategory = YES;
titleLabel.text = self.password.origin;
self.navigationItem.titleView = titleLabel;
} }
- (void)viewDidDisappear:(BOOL)animated { - (void)viewDidDisappear:(BOOL)animated {
...@@ -112,7 +119,6 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -112,7 +119,6 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
- (void)loadModel { - (void)loadModel {
[super loadModel]; [super loadModel];
self.title = self.password.origin;
TableViewModel* model = self.tableViewModel; TableViewModel* model = self.tableViewModel;
[model addSectionWithIdentifier:SectionIdentifierPassword]; [model addSectionWithIdentifier:SectionIdentifierPassword];
......
...@@ -152,7 +152,6 @@ TEST_F(PasswordDetailsViewControllerTest, TestPassword) { ...@@ -152,7 +152,6 @@ TEST_F(PasswordDetailsViewControllerTest, TestPassword) {
EXPECT_EQ(1, NumberOfSections()); EXPECT_EQ(1, NumberOfSections());
EXPECT_EQ(3, NumberOfItemsInSection(0)); EXPECT_EQ(3, NumberOfItemsInSection(0));
EXPECT_NSEQ(@"example.com", controller().title);
CheckEditCellText(@"http://www.example.com/", 0, 0); CheckEditCellText(@"http://www.example.com/", 0, 0);
CheckEditCellText(@"test@egmail.com", 0, 1); CheckEditCellText(@"test@egmail.com", 0, 1);
CheckEditCellText(kMaskedPassword, 0, 2); CheckEditCellText(kMaskedPassword, 0, 2);
...@@ -165,7 +164,6 @@ TEST_F(PasswordDetailsViewControllerTest, TestCompromisedPassword) { ...@@ -165,7 +164,6 @@ TEST_F(PasswordDetailsViewControllerTest, TestCompromisedPassword) {
EXPECT_EQ(3, NumberOfItemsInSection(0)); EXPECT_EQ(3, NumberOfItemsInSection(0));
EXPECT_EQ(2, NumberOfItemsInSection(1)); EXPECT_EQ(2, NumberOfItemsInSection(1));
EXPECT_NSEQ(@"example.com", controller().title);
CheckEditCellText(@"http://www.example.com/", 0, 0); CheckEditCellText(@"http://www.example.com/", 0, 0);
CheckEditCellText(@"test@egmail.com", 0, 1); CheckEditCellText(@"test@egmail.com", 0, 1);
CheckEditCellText(kMaskedPassword, 0, 2); CheckEditCellText(kMaskedPassword, 0, 2);
......
...@@ -116,6 +116,21 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -116,6 +116,21 @@ typedef NS_ENUM(NSInteger, ItemType) {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView deselectRowAtIndexPath:indexPath animated:YES];
} }
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell* cell = [super tableView:tableView
cellForRowAtIndexPath:indexPath];
switch ([self.tableViewModel itemTypeForIndexPath:indexPath]) {
case ItemTypePassword: {
TableViewDetailTextCell* textCell =
base::mac::ObjCCastStrict<TableViewDetailTextCell>(cell);
textCell.textLabel.lineBreakMode = NSLineBreakByTruncatingHead;
break;
}
}
return cell;
}
#pragma mark - PasswordIssuesConsumer #pragma mark - PasswordIssuesConsumer
- (void)setPasswordIssues:(NSArray<id<PasswordIssue>>*)passwords { - (void)setPasswordIssues:(NSArray<id<PasswordIssue>>*)passwords {
......
...@@ -1405,6 +1405,13 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1405,6 +1405,13 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
break; break;
} }
case ItemTypeSavedPassword:
case ItemTypeBlocked: {
TableViewDetailTextCell* textCell =
base::mac::ObjCCastStrict<TableViewDetailTextCell>(cell);
textCell.textLabel.lineBreakMode = NSLineBreakByTruncatingHead;
break;
}
} }
return cell; return cell;
} }
......
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