Commit 376aaade authored by Ewann's avatar Ewann Committed by Commit Bot

Fixing Omnibox action buttons

Fixing action buttons:
- Check if the location bar is in steady state.
  If yes, the Copy button is displayed.
  If not, if there is selected text the Copy button is displayed.
  In other cases, the Copy button is hidden.
- display Paste & Search for Copied Text buttons when omnibox is empty.
- hide Select & Select All buttons when omnibox is empty.
- display Select All button when selected text and hide Select button.

Corresponding integration tests dded.


Bug: 864984

Change-Id: I321546571272235eac0b749753f041bff0922608
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786639
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705068}
parent dbf8f01a
......@@ -482,7 +482,8 @@ const double kFullscreenProgressBadgeViewThreshold = 0.85;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(copy:)) {
// Allow copying if the steady location bar is visible.
if (!self.locationBarSteadyView.hidden && action == @selector(copy:)) {
return YES;
}
......
......@@ -616,15 +616,22 @@ NSString* const kOmniboxFadeAnimationKey = @"OmniboxFadeAnimation";
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
// If there is selected text, show copy and cut.
// If the text is not empty and there is selected text, show copy and cut.
if ([self textInRange:self.selectedTextRange].length > 0 &&
(action == @selector(cut:) || action == @selector(copy:))) {
return YES;
}
// If there is no selected text, show select and selectAll.
if ([self textInRange:self.selectedTextRange].length == 0 &&
(action == @selector(select:) || action == @selector(selectAll:))) {
// If the text is not empty and there is no selected text, show select
if (self.text.length > 0 &&
[self textInRange:self.selectedTextRange].length == 0 &&
action == @selector(select:)) {
return YES;
}
// If selected text is les than the text length, show selectAll.
if ([self textInRange:self.selectedTextRange].length != self.text.length &&
action == @selector(selectAll:)) {
return YES;
}
......
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