Commit 98c01698 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Creates LocationBar button for Passwords Infobar badge.

- Creates a leadingButton that will hold the Infobar badge.
- Adds the password icon resources.
- Sets the leadingButton to display the passwords badge if
IsInfobarUIRebootEnabled.

Screenshot:
https://drive.google.com/open?id=1I4kFr7sk1LZXQfFsJNUuebmtAG3kf59q

Bug: 911864
Change-Id: Id9851f2beb48dd1ed476d80dc729e6ab30e26f97
Reviewed-on: https://chromium-review.googlesource.com/c/1487149Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636105}
parent 5921be86
...@@ -65,6 +65,7 @@ source_set("infobars_ui") { ...@@ -65,6 +65,7 @@ source_set("infobars_ui") {
deps = [ deps = [
":public", ":public",
"resources:infobar_downloading", "resources:infobar_downloading",
"resources:infobar_passwords_icon",
"resources:infobar_popup_blocker", "resources:infobar_popup_blocker",
"resources:infobar_warning", "resources:infobar_warning",
"//base", "//base",
......
...@@ -30,3 +30,12 @@ imageset("infobar_popup_blocker") { ...@@ -30,3 +30,12 @@ imageset("infobar_popup_blocker") {
"infobar_popup_blocker.imageset/infobar_popup_blocker@3x.png", "infobar_popup_blocker.imageset/infobar_popup_blocker@3x.png",
] ]
} }
imageset("infobar_passwords_icon") {
sources = [
"infobar_passwords_icon.imageset/Contents.json",
"infobar_passwords_icon.imageset/infobar_passwords_icon.png",
"infobar_passwords_icon.imageset/infobar_passwords_icon@2x.png",
"infobar_passwords_icon.imageset/infobar_passwords_icon@3x.png",
]
}
{
"images": [
{
"idiom": "universal",
"scale": "1x",
"filename": "infobar_passwords_icon.png"
},
{
"idiom": "universal",
"scale": "2x",
"filename": "infobar_passwords_icon@2x.png"
},
{
"idiom": "universal",
"scale": "3x",
"filename": "infobar_passwords_icon@3x.png"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
...@@ -48,6 +48,7 @@ source_set("location_bar") { ...@@ -48,6 +48,7 @@ source_set("location_bar") {
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/ui/fullscreen",
"//ios/chrome/browser/ui/fullscreen:ui", "//ios/chrome/browser/ui/fullscreen:ui",
"//ios/chrome/browser/ui/infobars:feature_flags",
"//ios/chrome/browser/ui/ntp:util", "//ios/chrome/browser/ui/ntp:util",
"//ios/chrome/browser/ui/omnibox:omnibox", "//ios/chrome/browser/ui/omnibox:omnibox",
"//ios/chrome/browser/ui/omnibox:omnibox_internal", "//ios/chrome/browser/ui/omnibox:omnibox_internal",
......
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
@property(nonatomic, strong) UIButton* locationButton; @property(nonatomic, strong) UIButton* locationButton;
// The label displaying the current location URL. // The label displaying the current location URL.
@property(nonatomic, strong) UILabel* locationLabel; @property(nonatomic, strong) UILabel* locationLabel;
// The button displayed in the leading corner of the view, i.e. infobar badge.
// TODO(crbug.com/935804): This button is currently only being used in the
// Infobar redesign.
@property(nonatomic, strong) UIButton* leadingButton;
// The button displayed in the trailing corner of the view, i.e. share button. // The button displayed in the trailing corner of the view, i.e. share button.
@property(nonatomic, strong) UIButton* trailingButton; @property(nonatomic, strong) UIButton* trailingButton;
// The string that describes the current security level. Used for a11y. // The string that describes the current security level. Used for a11y.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/location_bar/location_bar_steady_view.h" #import "ios/chrome/browser/ui/location_bar/location_bar_steady_view.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
#import "ios/chrome/browser/ui/location_bar/extended_touch_target_button.h" #import "ios/chrome/browser/ui/location_bar/extended_touch_target_button.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
...@@ -245,6 +246,25 @@ const CGFloat kButtonTrailingSpacing = 10; ...@@ -245,6 +246,25 @@ const CGFloat kButtonTrailingSpacing = 10;
constant:-kButtonTrailingSpacing], constant:-kButtonTrailingSpacing],
]; ];
[NSLayoutConstraint activateConstraints:_showButtonConstraints]; [NSLayoutConstraint activateConstraints:_showButtonConstraints];
if (IsInfobarUIRebootEnabled()) {
// Setup leading button.
_leadingButton =
[ExtendedTouchTargetButton buttonWithType:UIButtonTypeSystem];
_leadingButton.translatesAutoresizingMaskIntoConstraints = NO;
[_locationButton addSubview:_leadingButton];
// Setup and activate the leading button constraints.
[NSLayoutConstraint activateConstraints:@[
[_leadingButton.widthAnchor constraintEqualToConstant:kButtonSize],
[_leadingButton.heightAnchor constraintEqualToConstant:kButtonSize],
[_leadingButton.leadingAnchor
constraintEqualToAnchor:self.leadingAnchor
constant:kButtonTrailingSpacing],
[_leadingButton.centerYAnchor
constraintEqualToAnchor:self.centerYAnchor],
]];
}
} }
// Setup accessibility. // Setup accessibility.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/load_query_commands.h" #import "ios/chrome/browser/ui/commands/load_query_commands.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
#include "ios/chrome/browser/ui/location_bar/location_bar_steady_view.h" #include "ios/chrome/browser/ui/location_bar/location_bar_steady_view.h"
#import "ios/chrome/browser/ui/orchestrator/location_bar_offset_provider.h" #import "ios/chrome/browser/ui/orchestrator/location_bar_offset_provider.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
...@@ -173,6 +174,10 @@ typedef NS_ENUM(int, TrailingButtonState) { ...@@ -173,6 +174,10 @@ typedef NS_ENUM(int, TrailingButtonState) {
AddSameConstraints(self.locationBarSteadyView, self.view); AddSameConstraints(self.locationBarSteadyView, self.view);
[self switchToEditing:NO]; [self switchToEditing:NO];
if (IsInfobarUIRebootEnabled()) {
[self updateInfobarButton];
}
} }
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
...@@ -420,6 +425,17 @@ typedef NS_ENUM(int, TrailingButtonState) { ...@@ -420,6 +425,17 @@ typedef NS_ENUM(int, TrailingButtonState) {
base::RecordAction(base::UserMetricsAction("MobileToolbarShareMenu")); base::RecordAction(base::UserMetricsAction("MobileToolbarShareMenu"));
} }
// TODO(crbug.com/935804): This method is currently only being used in the
// Infobar redesign.
- (void)updateInfobarButton {
DCHECK(IsInfobarUIRebootEnabled());
[self.locationBarSteadyView.leadingButton
setImage:[[UIImage imageNamed:@"infobar_passwords_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
self.locationBarSteadyView.leadingButton.tintColor = [UIColor lightGrayColor];
}
#pragma mark - UIMenu #pragma mark - UIMenu
- (void)showLongPressMenu:(UILongPressGestureRecognizer*)sender { - (void)showLongPressMenu:(UILongPressGestureRecognizer*)sender {
......
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