Commit d49c3fe0 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Add focus omnibox action to the omnibox button

This CL adds the action to focus the omnibox from the omnibox button in
the bottom toolbar.

Bug: 804717
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id03a2aea1572bb2b23b2aa6733a5cdc1b96ccc33
Reviewed-on: https://chromium-review.googlesource.com/888583Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532355}
parent 25559877
......@@ -12,6 +12,7 @@
@protocol BrowserCommands;
@class KeyCommandsProvider;
@class MessageBubbleView;
@protocol OmniboxFocuser;
@class PKPass;
@class PKAddPassesViewController;
@class TabModel;
......@@ -54,6 +55,7 @@ class ChromeBrowserState;
urlLoader:(id<UrlLoader>)urlLoader
dispatcher:(id<ApplicationCommands,
BrowserCommands,
OmniboxFocuser,
ToolbarCommands>)dispatcher;
// Returns a new keyboard commands coordinator to handle keyboard commands.
......
......@@ -67,6 +67,7 @@
dispatcher:
(id<ApplicationCommands,
BrowserCommands,
OmniboxFocuser,
ToolbarCommands>)dispatcher {
id<Toolbar> toolbarController;
if (base::FeatureList::IsEnabled(kCleanToolbar)) {
......
......@@ -20,7 +20,8 @@
@property(nonatomic, readonly) NewTabButton* openNewTabButton;
- (instancetype)initWithDispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)dispatcher;
(id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>)
dispatcher;
@end
......
......@@ -36,7 +36,8 @@ const CGFloat kBackgroundViewColorAlpha = 0.95;
}
- (instancetype)initWithDispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)dispatcher {
(id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>)
dispatcher {
self = [super initWithStyle:ToolbarControllerStyleDarkMode
dispatcher:dispatcher];
if (self) {
......
......@@ -13,6 +13,7 @@
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
@protocol OmniboxFocuser;
@class Tab;
@class TabModel;
@protocol TabSwitcher;
......@@ -67,7 +68,7 @@
// Dispatcher for anything that acts in a "browser" role.
@property(nonatomic, readonly)
id<ApplicationCommands, BrowserCommands, ToolbarCommands>
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>
dispatcher;
// Restores the internal state of the tab switcher with the given tab models,
......
......@@ -15,6 +15,7 @@
@class AdaptiveToolbarViewController;
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OmniboxFocuser;
class WebStateList;
// Coordinator for the adaptive toolbar. This Coordinator is the super class of
......@@ -39,7 +40,7 @@ class WebStateList;
// Dispatcher.
@property(nonatomic, weak)
id<ApplicationCommands, BrowserCommands, ToolbarCommands>
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>
dispatcher;
// The web state list this ToolbarCoordinator is handling.
@property(nonatomic, assign) WebStateList* webStateList;
......
......@@ -11,6 +11,7 @@
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OmniboxFocuser;
@class ToolbarButton;
@class ToolbarButtonVisibilityConfiguration;
@protocol ToolbarCommands;
......@@ -33,7 +34,7 @@
ToolbarConfiguration* toolbarConfiguration;
// Dispatcher used to initialize targets for the buttons.
@property(nonatomic, weak)
id<ApplicationCommands, BrowserCommands, ToolbarCommands>
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>
dispatcher;
// Configuration object for the visibility of the buttons.
@property(nonatomic, strong)
......
......@@ -16,6 +16,7 @@
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_tab_grid_button.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_tools_menu_button.h"
#import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_controller_base_feature.h"
#include "ios/chrome/browser/ui/toolbar/toolbar_resource_macros.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
......@@ -318,6 +319,10 @@ const int styleCount = 2;
imageForHighlightedState:NativeImage(IDR_IOS_OMNIBOX_SEARCH)
imageForDisabledState:nil];
[self configureButton:omniboxButton width:kToolbarButtonWidth];
[omniboxButton addTarget:self.dispatcher
action:@selector(focusOmnibox)
forControlEvents:UIControlEventTouchUpInside];
omniboxButton.visibilityMask =
self.visibilityConfiguration.omniboxButtonVisibility;
return omniboxButton;
......
......@@ -16,6 +16,7 @@
@protocol ActivityServicePositioner;
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OmniboxFocuser;
@class ToolbarButtonUpdater;
@protocol ToolbarCommands;
@protocol ToolbarCoordinatorDelegate;
......@@ -38,7 +39,7 @@ class WebState;
@property(nonatomic, assign) ios::ChromeBrowserState* browserState;
// The dispatcher for this view controller.
@property(nonatomic, weak)
id<ApplicationCommands, BrowserCommands, ToolbarCommands>
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>
dispatcher;
// The web state list this ToolbarCoordinator is handling.
@property(nonatomic, assign) WebStateList* webStateList;
......
......@@ -20,6 +20,7 @@ class ChromeBrowserState;
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OmniboxFocuser;
@protocol ToolbarCoordinatorDelegate;
@protocol ToolbarCommands;
@protocol UrlLoader;
......@@ -31,7 +32,8 @@ class WebStateList;
- (instancetype)
initWithDispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)dispatcher
(id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>)
dispatcher
browserState:(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList NS_DESIGNATED_INITIALIZER;
......
......@@ -18,11 +18,12 @@
@synthesize delegate = _delegate;
@synthesize URLLoader = _URLLoader;
- (instancetype)initWithDispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)
dispatcher
browserState:(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList {
- (instancetype)
initWithDispatcher:
(id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>)
dispatcher
browserState:(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList {
self = [super init];
if (self) {
_toolbarCoordinator = [[ToolbarCoordinator alloc] init];
......
......@@ -18,6 +18,7 @@
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol OmniboxFocuser;
class ReadingListModel;
@protocol ToolbarCommands;
......@@ -48,17 +49,18 @@ class ReadingListModel;
// The command dispatcher this and any subordinate objects should use.
@property(nonatomic, readonly, weak)
id<ApplicationCommands, BrowserCommands, ToolbarCommands>
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, ToolbarCommands>
dispatcher;
// Designated initializer.
// |style| determines how the toolbar draws itself.
// |dispatcher| is is the dispatcher for calling methods handled in other
// parts of the app.
- (instancetype)
initWithStyle:(ToolbarControllerStyle)style
dispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)dispatcher
- (instancetype)initWithStyle:(ToolbarControllerStyle)style
dispatcher:(id<ApplicationCommands,
BrowserCommands,
OmniboxFocuser,
ToolbarCommands>)dispatcher
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
......
......@@ -126,10 +126,11 @@ using ios::material::TimingFunction;
@synthesize trailingSafeAreaConstraint = _trailingSafeAreaConstraint;
@dynamic view;
- (instancetype)
initWithStyle:(ToolbarControllerStyle)style
dispatcher:
(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)dispatcher {
- (instancetype)initWithStyle:(ToolbarControllerStyle)style
dispatcher:(id<ApplicationCommands,
BrowserCommands,
OmniboxFocuser,
ToolbarCommands>)dispatcher {
self = [super initWithNibName:nil bundle:nil];
if (self) {
style_ = style;
......
......@@ -227,12 +227,13 @@ using ios::material::TimingFunction;
@synthesize animatingStop = _animatingStop;
@synthesize animatingPrerender = _animatingPrerender;
- (instancetype)
initWithDelegate:(id<WebToolbarDelegate>)delegate
urlLoader:(id<UrlLoader>)urlLoader
browserState:(ios::ChromeBrowserState*)browserState
dispatcher:(id<ApplicationCommands, BrowserCommands, ToolbarCommands>)
dispatcher {
- (instancetype)initWithDelegate:(id<WebToolbarDelegate>)delegate
urlLoader:(id<UrlLoader>)urlLoader
browserState:(ios::ChromeBrowserState*)browserState
dispatcher:(id<ApplicationCommands,
BrowserCommands,
OmniboxFocuser,
ToolbarCommands>)dispatcher {
DCHECK(delegate);
DCHECK(urlLoader);
DCHECK(browserState);
......
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