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 @@ ...@@ -44,6 +44,8 @@
return BadgeType::kBadgeTypePasswordSave; return BadgeType::kBadgeTypePasswordSave;
case InfobarType::kInfobarTypePasswordUpdate: case InfobarType::kInfobarTypePasswordUpdate:
return BadgeType::kBadgeTypePasswordUpdate; return BadgeType::kBadgeTypePasswordUpdate;
case InfobarType::kInfobarTypeSaveCard:
return BadgeType::kBadgeTypeSaveCard;
default: default:
NOTREACHED() << "This infobar should not have a badge"; NOTREACHED() << "This infobar should not have a badge";
return BadgeType::kBadgeTypeNone; return BadgeType::kBadgeTypeNone;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
break; break;
case BadgeType::kBadgeTypePasswordUpdate: case BadgeType::kBadgeTypePasswordUpdate:
return [self passwordsUpdateBadgeButton]; return [self passwordsUpdateBadgeButton];
case BadgeType::kBadgeTypeSaveCard:
return [self saveCardBadgeButton];
case BadgeType::kBadgeTypeIncognito: case BadgeType::kBadgeTypeIncognito:
return [self incognitoBadgeButton]; return [self incognitoBadgeButton];
case BadgeType::kBadgeTypeOverflow: case BadgeType::kBadgeTypeOverflow:
...@@ -68,6 +70,19 @@ ...@@ -68,6 +70,19 @@
return button; 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*)incognitoBadgeButton {
BadgeButton* button = BadgeButton* button =
[self createButtonForType:BadgeType::kBadgeTypeIncognito [self createButtonForType:BadgeType::kBadgeTypeIncognito
......
...@@ -12,6 +12,7 @@ extern NSString* const kBadgeButtonSavePasswordAccessibilityIdentifier; ...@@ -12,6 +12,7 @@ extern NSString* const kBadgeButtonSavePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier; extern NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonIncognitoAccessibilityIdentifier; extern NSString* const kBadgeButtonIncognitoAccessibilityIdentifier;
extern NSString* const kBadgeButtonOverflowAccessibilityIdentifier; extern NSString* const kBadgeButtonOverflowAccessibilityIdentifier;
extern NSString* const kBadgeButtonSaveCardAccessibilityIdentifier;
// A11y identifier for the Badge Popup Menu Table View. // A11y identifier for the Badge Popup Menu Table View.
extern NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier; extern NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier;
......
...@@ -20,6 +20,9 @@ NSString* const kBadgeButtonIncognitoAccessibilityIdentifier = ...@@ -20,6 +20,9 @@ NSString* const kBadgeButtonIncognitoAccessibilityIdentifier =
NSString* const kBadgeButtonOverflowAccessibilityIdentifier = NSString* const kBadgeButtonOverflowAccessibilityIdentifier =
@"badgeButtonOverflowAXID"; @"badgeButtonOverflowAXID";
NSString* const kBadgeButtonSaveCardAccessibilityIdentifier =
@"badgeButtonSaveCardAXID";
NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier = NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier =
@"badgePopupMenuOverflowAXID"; @"badgePopupMenuOverflowAXID";
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
// Action when a Passwords badge is tapped. // Action when a Passwords badge is tapped.
- (void)passwordsBadgeButtonTapped:(id)sender; - (void)passwordsBadgeButtonTapped:(id)sender;
// Action when a Save Card badge is tapped.
- (void)saveCardBadgeButtonTapped:(id)sender;
// Action when the overflow badge is tapped. // Action when the overflow badge is tapped.
- (void)overflowBadgeButtonTapped:(id)sender; - (void)overflowBadgeButtonTapped:(id)sender;
@end @end
......
...@@ -140,6 +140,10 @@ const int kMinimumNonFullScreenBadgesForOverflow = 2; ...@@ -140,6 +140,10 @@ const int kMinimumNonFullScreenBadgesForOverflow = 2;
[metricsRecorder recordBadgeTappedInState:state]; [metricsRecorder recordBadgeTappedInState:state];
} }
- (void)saveCardBadgeButtonTapped:(id)sender {
// TODO(crbug.com/1014652): Implement.
}
- (void)overflowBadgeButtonTapped:(id)sender { - (void)overflowBadgeButtonTapped:(id)sender {
NSMutableArray<id<BadgeItem>>* popupMenuBadges = NSMutableArray<id<BadgeItem>>* popupMenuBadges =
[[NSMutableArray alloc] init]; [[NSMutableArray alloc] init];
......
...@@ -55,6 +55,12 @@ const CGFloat kBadgeCornerRadius = 5.0; ...@@ -55,6 +55,12 @@ const CGFloat kBadgeCornerRadius = 5.0;
_actionIdentifier = PopupMenuActionShowUpdatePasswordOptions; _actionIdentifier = PopupMenuActionShowUpdatePasswordOptions;
_title = @"Update Password"; _title = @"Update Password";
break; 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: case BadgeType::kBadgeTypeIncognito:
NOTREACHED() << "A BadgePopupMenuItem should not be an Incognito badge"; NOTREACHED() << "A BadgePopupMenuItem should not be an Incognito badge";
break; break;
...@@ -81,6 +87,10 @@ const CGFloat kBadgeCornerRadius = 5.0; ...@@ -81,6 +87,10 @@ const CGFloat kBadgeCornerRadius = 5.0;
badgeImage = [[UIImage imageNamed:@"infobar_passwords_icon"] badgeImage = [[UIImage imageNamed:@"infobar_passwords_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break; break;
case BadgeType::kBadgeTypeSaveCard:
badgeImage = [[UIImage imageNamed:@"infobar_save_card_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break;
case BadgeType::kBadgeTypeIncognito: case BadgeType::kBadgeTypeIncognito:
NOTREACHED() NOTREACHED()
<< "A popup menu item should not be of type kBadgeTypeIncognito"; << "A popup menu item should not be of type kBadgeTypeIncognito";
......
...@@ -19,6 +19,8 @@ enum class BadgeType { ...@@ -19,6 +19,8 @@ enum class BadgeType {
kBadgeTypeIncognito = 3, kBadgeTypeIncognito = 3,
// Badge type for when there are more than one badge to be displayed. // Badge type for when there are more than one badge to be displayed.
kBadgeTypeOverflow = 4, kBadgeTypeOverflow = 4,
// Badge type for Save Credit Card Infobar.
kBadgeTypeSaveCard = 5,
}; };
#endif // IOS_CHROME_BROWSER_UI_BADGES_BADGE_TYPE_H_ #endif // IOS_CHROME_BROWSER_UI_BADGES_BADGE_TYPE_H_
...@@ -51,6 +51,7 @@ typedef NS_ENUM(NSInteger, PopupMenuAction) { ...@@ -51,6 +51,7 @@ typedef NS_ENUM(NSInteger, PopupMenuAction) {
// Badge overflow popup menu // Badge overflow popup menu
PopupMenuActionShowSavePasswordOptions, PopupMenuActionShowSavePasswordOptions,
PopupMenuActionShowUpdatePasswordOptions, PopupMenuActionShowUpdatePasswordOptions,
PopupMenuActionShowSaveCardOptions,
}; };
// Protocol defining a popup item. // Protocol defining a popup item.
......
...@@ -115,6 +115,9 @@ NSString* const kSCDisplayedBadgeToggleButton = ...@@ -115,6 +115,9 @@ NSString* const kSCDisplayedBadgeToggleButton =
- (void)passwordsBadgeButtonTapped:(id)sender { - (void)passwordsBadgeButtonTapped:(id)sender {
} }
- (void)saveCardBadgeButtonTapped:(id)sender {
}
- (void)overflowBadgeButtonTapped:(id)sender { - (void)overflowBadgeButtonTapped:(id)sender {
self.badgePopupMenuCoordinator = [[BadgePopupMenuCoordinator alloc] self.badgePopupMenuCoordinator = [[BadgePopupMenuCoordinator alloc]
initWithBaseViewController:self.containerViewController]; 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