Commit c2d72665 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Creates BadgeTypeSaveCard and initial badge configuration.

Creates a new BadgeType for the Save Credit Card Infobar and setups the
initial configuration for the SaveCard badge:

Adds support for kBadgeTypeSaveCard on BadgePopupMenuItem.
Creates a BadgeButton in the factory for the Save Credit Card Infobar.
Creates a Popup menu option for the Badge Popup Menu.
Creates an A11y constant for SaveCard Infobar.


Bug: 1014652
Change-Id: Ic8b88961dfc701783aa72e8c0f1009fb7c721d18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1867273
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707447}
parent d382d0ea
......@@ -44,6 +44,8 @@
return BadgeType::kBadgeTypePasswordSave;
case InfobarType::kInfobarTypePasswordUpdate:
return BadgeType::kBadgeTypePasswordUpdate;
case InfobarType::kInfobarTypeSaveCard:
return BadgeType::kBadgeTypeSaveCard;
default:
NOTREACHED() << "This infobar should not have a badge";
return BadgeType::kBadgeTypeNone;
......
......@@ -26,6 +26,8 @@
break;
case BadgeType::kBadgeTypePasswordUpdate:
return [self passwordsUpdateBadgeButton];
case BadgeType::kBadgeTypeSaveCard:
return [self saveCardBadgeButton];
case BadgeType::kBadgeTypeIncognito:
return [self incognitoBadgeButton];
case BadgeType::kBadgeTypeOverflow:
......@@ -68,6 +70,19 @@
return button;
}
- (BadgeButton*)saveCardBadgeButton {
BadgeButton* button =
[self createButtonForType:BadgeType::kBadgeTypePasswordUpdate
imageNamed:@"infobar_save_card_icon"
renderingMode:UIImageRenderingModeAlwaysTemplate];
[button addTarget:self.delegate
action:@selector(saveCardBadgeButtonTapped:)
forControlEvents:UIControlEventTouchUpInside];
button.accessibilityIdentifier = kBadgeButtonSaveCardAccessibilityIdentifier;
// TODO(crbug.com/1014652): Create a11y label hint.
return button;
}
- (BadgeButton*)incognitoBadgeButton {
BadgeButton* button =
[self createButtonForType:BadgeType::kBadgeTypeIncognito
......
......@@ -12,6 +12,7 @@ extern NSString* const kBadgeButtonSavePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonIncognitoAccessibilityIdentifier;
extern NSString* const kBadgeButtonOverflowAccessibilityIdentifier;
extern NSString* const kBadgeButtonSaveCardAccessibilityIdentifier;
// A11y identifier for the Badge Popup Menu Table View.
extern NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier;
......
......@@ -20,6 +20,9 @@ NSString* const kBadgeButtonIncognitoAccessibilityIdentifier =
NSString* const kBadgeButtonOverflowAccessibilityIdentifier =
@"badgeButtonOverflowAXID";
NSString* const kBadgeButtonSaveCardAccessibilityIdentifier =
@"badgeButtonSaveCardAXID";
NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier =
@"badgePopupMenuOverflowAXID";
......
......@@ -10,6 +10,9 @@
// Action when a Passwords badge is tapped.
- (void)passwordsBadgeButtonTapped:(id)sender;
// Action when a Save Card badge is tapped.
- (void)saveCardBadgeButtonTapped:(id)sender;
// Action when the overflow badge is tapped.
- (void)overflowBadgeButtonTapped:(id)sender;
@end
......
......@@ -140,6 +140,10 @@ const int kMinimumNonFullScreenBadgesForOverflow = 2;
[metricsRecorder recordBadgeTappedInState:state];
}
- (void)saveCardBadgeButtonTapped:(id)sender {
// TODO(crbug.com/1014652): Implement.
}
- (void)overflowBadgeButtonTapped:(id)sender {
NSMutableArray<id<BadgeItem>>* popupMenuBadges =
[[NSMutableArray alloc] init];
......
......@@ -55,6 +55,12 @@ const CGFloat kBadgeCornerRadius = 5.0;
_actionIdentifier = PopupMenuActionShowUpdatePasswordOptions;
_title = @"Update Password";
break;
case BadgeType::kBadgeTypeSaveCard:
_actionIdentifier = PopupMenuActionShowSaveCardOptions;
// TODO(crbug.com/1014652): Replace with final String. Its currently
// "Save Card" on the delegate and "Save Credit Card on mocks.
_title = @"Save Credit Card";
break;
case BadgeType::kBadgeTypeIncognito:
NOTREACHED() << "A BadgePopupMenuItem should not be an Incognito badge";
break;
......@@ -81,6 +87,10 @@ const CGFloat kBadgeCornerRadius = 5.0;
badgeImage = [[UIImage imageNamed:@"infobar_passwords_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break;
case BadgeType::kBadgeTypeSaveCard:
badgeImage = [[UIImage imageNamed:@"infobar_save_card_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break;
case BadgeType::kBadgeTypeIncognito:
NOTREACHED()
<< "A popup menu item should not be of type kBadgeTypeIncognito";
......
......@@ -19,6 +19,8 @@ enum class BadgeType {
kBadgeTypeIncognito = 3,
// Badge type for when there are more than one badge to be displayed.
kBadgeTypeOverflow = 4,
// Badge type for Save Credit Card Infobar.
kBadgeTypeSaveCard = 5,
};
#endif // IOS_CHROME_BROWSER_UI_BADGES_BADGE_TYPE_H_
......@@ -51,6 +51,7 @@ typedef NS_ENUM(NSInteger, PopupMenuAction) {
// Badge overflow popup menu
PopupMenuActionShowSavePasswordOptions,
PopupMenuActionShowUpdatePasswordOptions,
PopupMenuActionShowSaveCardOptions,
};
// Protocol defining a popup item.
......
......@@ -115,6 +115,9 @@ NSString* const kSCDisplayedBadgeToggleButton =
- (void)passwordsBadgeButtonTapped:(id)sender {
}
- (void)saveCardBadgeButtonTapped:(id)sender {
}
- (void)overflowBadgeButtonTapped:(id)sender {
self.badgePopupMenuCoordinator = [[BadgePopupMenuCoordinator alloc]
initWithBaseViewController:self.containerViewController];
......
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