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