Make ToolbarCoordinator conforms to LocationBarDelegate

This CL adds a LocationBar to the ToolbarCoordinator. The
ToolbarCoordinator is the delegate for the LocationBar so it needs to
conforms to the LocationBarDelegate protocol.

Bug: 784911
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I1b7d2aa2c7813f5d50622594a8922beacb62e6f6
Reviewed-on: https://chromium-review.googlesource.com/771693
Commit-Queue: Gauthier Ambard <[email protected]>
Reviewed-by: Mark Cogan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#517404}
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm
index cc65178..6bdafcc2 100644
--- a/ios/chrome/browser/ui/browser_view_controller.mm
+++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -4120,7 +4120,7 @@
 
 #pragma mark - WebToolbarDelegate methods
 
-- (IBAction)locationBarDidBecomeFirstResponder:(id)sender {
+- (void)locationBarDidBecomeFirstResponder {
   if (_locationBarHasFocus)
     return;  // TODO(crbug.com/244366): This should not be necessary.
   _locationBarHasFocus = YES;
@@ -4141,7 +4141,7 @@
       locationBarDidBecomeFirstResponder:_browserState];
 }
 
-- (IBAction)locationBarDidResignFirstResponder:(id)sender {
+- (void)locationBarDidResignFirstResponder {
   if (!_locationBarHasFocus)
     return;  // TODO(crbug.com/244366): This should not be necessary.
   _locationBarHasFocus = NO;
@@ -4177,7 +4177,7 @@
   }
 }
 
-- (IBAction)locationBarBeganEdit:(id)sender {
+- (void)locationBarBeganEdit {
   // On handsets, if a page is currently loading it should be stopped.
   if (!IsIPadIdiom() && _toolbarModelIOS->IsLoading()) {
     [self.dispatcher stopLoading];
diff --git a/ios/chrome/browser/ui/browser_view_controller_dependency_factory.mm b/ios/chrome/browser/ui/browser_view_controller_dependency_factory.mm
index fe6694d..fa213aa 100644
--- a/ios/chrome/browser/ui/browser_view_controller_dependency_factory.mm
+++ b/ios/chrome/browser/ui/browser_view_controller_dependency_factory.mm
@@ -20,6 +20,7 @@
 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h"
 #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h"
 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
+#import "ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h"
 #include "ios/chrome/grit/ios_strings.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/l10n/l10n_util_mac.h"
@@ -68,10 +69,13 @@
                           (id<ApplicationCommands, BrowserCommands>)dispatcher {
   id<Toolbar> toolbarController;
   if (base::FeatureList::IsEnabled(kPropertyAnimationsToolbar)) {
-    toolbarController = static_cast<id<Toolbar>>([[ToolbarAdapter alloc]
-        initWithDispatcher:dispatcher
-              browserState:browserState_
-              webStateList:webStateList_]);
+    ToolbarAdapter* adapter =
+        [[ToolbarAdapter alloc] initWithDispatcher:dispatcher
+                                      browserState:browserState_
+                                      webStateList:webStateList_];
+    adapter.delegate = delegate;
+    adapter.URLLoader = urlLoader;
+    toolbarController = static_cast<id<Toolbar>>(adapter);
 
   } else {
     toolbarController = static_cast<id<Toolbar>>([[WebToolbarController alloc]
diff --git a/ios/chrome/browser/ui/browser_view_controller_unittest.mm b/ios/chrome/browser/ui/browser_view_controller_unittest.mm
index fe243f5f..9e68552 100644
--- a/ios/chrome/browser/ui/browser_view_controller_unittest.mm
+++ b/ios/chrome/browser/ui/browser_view_controller_unittest.mm
@@ -449,7 +449,7 @@
   // The tab should only stop loading on handsets.
   if (!IsIPadIdiom())
     [[static_cast<OCMockObject*>(webController_) expect] stopLoading];
-  [bvc_ locationBarBeganEdit:nil];
+  [bvc_ locationBarBeganEdit];
 
   EXPECT_OCMOCK_VERIFY(static_cast<OCMockObject*>(webController_));
   EXPECT_OCMOCK_VERIFY(tabMock);
@@ -465,7 +465,7 @@
   static_cast<TestToolbarModelIOS*>(toolbarModelIOS_)->set_is_loading(false);
 
   // Don't set any expectation for stopLoading to be called on the mock tab.
-  [bvc_ locationBarBeganEdit:nil];
+  [bvc_ locationBarBeganEdit];
 
   EXPECT_OCMOCK_VERIFY(tabMock);
 }
diff --git a/ios/chrome/browser/ui/toolbar/BUILD.gn b/ios/chrome/browser/ui/toolbar/BUILD.gn
index e467d85..5a21cff0 100644
--- a/ios/chrome/browser/ui/toolbar/BUILD.gn
+++ b/ios/chrome/browser/ui/toolbar/BUILD.gn
@@ -110,6 +110,7 @@
   ]
   allow_circular_includes_from = [
     "//ios/chrome/browser/ui/side_swipe",
+    "//ios/chrome/browser/ui/toolbar/clean:toolbar",
     "//ios/chrome/browser/ui/ntp",
   ]
   libs = [
diff --git a/ios/chrome/browser/ui/toolbar/clean/BUILD.gn b/ios/chrome/browser/ui/toolbar/clean/BUILD.gn
index 17c6a19e7..8fa00b9 100644
--- a/ios/chrome/browser/ui/toolbar/clean/BUILD.gn
+++ b/ios/chrome/browser/ui/toolbar/clean/BUILD.gn
@@ -6,6 +6,7 @@
   sources = [
     "toolbar_coordinator.h",
     "toolbar_coordinator.mm",
+    "toolbar_coordinator_delegate.h",
     "toolbar_mediator.h",
     "toolbar_mediator.mm",
   ]
@@ -16,16 +17,22 @@
     ":toolbar_components_ui",
     ":toolbar_ui",
     "//base",
+    "//components/google/core/browser",
     "//ios/chrome/browser",
     "//ios/chrome/browser/browser_state",
+    "//ios/chrome/browser/ui",
     "//ios/chrome/browser/ui/broadcaster",
     "//ios/chrome/browser/ui/browser_list",
     "//ios/chrome/browser/ui/commands",
     "//ios/chrome/browser/ui/commands",
     "//ios/chrome/browser/ui/coordinators",
     "//ios/chrome/browser/ui/history_popup/requirements",
+    "//ios/chrome/browser/ui/omnibox",
+    "//ios/chrome/browser/ui/omnibox:omnibox_internal",
+    "//ios/chrome/browser/ui/toolbar/public",
     "//ios/chrome/browser/ui/tools_menu:configuration",
     "//ios/chrome/browser/web_state_list",
+    "//ios/third_party/material_components_ios",
     "//ios/web",
   ]
 }
diff --git a/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h
index 428a0b92..06aa6cf 100644
--- a/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h
+++ b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h
@@ -9,6 +9,8 @@
 
 @protocol ApplicationCommands;
 @protocol BrowserCommands;
+@protocol ToolbarCoordinatorDelegate;
+@protocol UrlLoader;
 class WebStateList;
 namespace ios {
 class ChromeBrowserState;
@@ -16,16 +18,23 @@
 
 // Coordinator to run a toolbar -- a UI element housing controls.
 @interface ToolbarCoordinator : NSObject
+
 // Weak reference to ChromeBrowserState;
 @property(nonatomic, assign) ios::ChromeBrowserState* browserState;
 // The dispatcher for this view controller.
 @property(nonatomic, weak) id<ApplicationCommands, BrowserCommands> dispatcher;
 // The web state list this ToolbarCoordinator is handling.
 @property(nonatomic, assign) WebStateList* webStateList;
+// Audience, notified of the
+@property(nonatomic, weak) id<ToolbarCoordinatorDelegate> delegate;
+// URL loader for the toolbar.
+@property(nonatomic, weak) id<UrlLoader> URLLoader;
+
 // Start this coordinator.
 - (void)start;
 // Stop this coordinator.
 - (void)stop;
+
 @end
 
 #endif  // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_COORDINATOR_H_
diff --git a/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.mm b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.mm
index 55eafcb..a611ece 100644
--- a/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.mm
+++ b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.mm
@@ -4,38 +4,56 @@
 
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h"
 
+#import <CoreLocation/CoreLocation.h>
+
+#include "base/metrics/histogram_macros.h"
+#include "base/metrics/user_metrics.h"
+#include "base/metrics/user_metrics_action.h"
+#include "base/strings/sys_string_conversions.h"
+#include "components/google/core/browser/google_util.h"
 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
 #include "ios/chrome/browser/chrome_url_constants.h"
-#import "ios/chrome/browser/ui/broadcaster/chrome_broadcaster.h"
-#import "ios/chrome/browser/ui/browser_list/browser.h"
-#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
-#import "ios/chrome/browser/ui/commands/history_popup_commands.h"
-#import "ios/chrome/browser/ui/coordinators/browser_coordinator+internal.h"
-#import "ios/chrome/browser/ui/history_popup/requirements/tab_history_constants.h"
+#include "ios/chrome/browser/ui/omnibox/location_bar_controller.h"
+#include "ios/chrome/browser/ui/omnibox/location_bar_controller_impl.h"
+#include "ios/chrome/browser/ui/omnibox/location_bar_delegate.h"
+#import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_button_factory.h"
-#import "ios/chrome/browser/ui/toolbar/clean/toolbar_configuration.h"
+#import "ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h"
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_mediator.h"
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_style.h"
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.h"
-#import "ios/chrome/browser/ui/tools_menu/tools_menu_configuration.h"
-#import "ios/web/public/navigation_manager.h"
+#import "ios/chrome/browser/ui/toolbar/public/web_toolbar_controller_constants.h"
+#include "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h"
+#import "ios/chrome/browser/ui/url_loader.h"
+#import "ios/chrome/browser/web_state_list/web_state_list.h"
+#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
 #import "ios/web/public/web_state/web_state.h"
 
 #if !defined(__has_feature) || !__has_feature(objc_arc)
 #error "This file requires ARC support."
 #endif
 
-@interface ToolbarCoordinator ()
+@interface ToolbarCoordinator ()<LocationBarDelegate> {
+  std::unique_ptr<LocationBarControllerImpl> _locationBar;
+}
+
 // The View Controller managed by this coordinator.
 @property(nonatomic, strong) ToolbarViewController* viewController;
 // The mediator owned by this coordinator.
 @property(nonatomic, strong) ToolbarMediator* mediator;
+// LocationBarView containing the omnibox. At some point, this property and the
+// |_locationBar| should become a LocationBarCoordinator.
+@property(nonatomic, strong) LocationBarView* locationBarView;
+
 @end
 
 @implementation ToolbarCoordinator
+@synthesize delegate = _delegate;
 @synthesize browserState = _browserState;
 @synthesize dispatcher = _dispatcher;
+@synthesize locationBarView = _locationBarView;
 @synthesize mediator = _mediator;
+@synthesize URLLoader = _URLLoader;
 @synthesize viewController = _viewController;
 @synthesize webStateList = _webStateList;
 
@@ -49,7 +67,24 @@
 #pragma mark - BrowserCoordinator
 
 - (void)start {
-  ToolbarStyle style = self.browserState->IsOffTheRecord() ? INCOGNITO : NORMAL;
+  BOOL isIncognito = self.browserState->IsOffTheRecord();
+  // TODO(crbug.com/785253): Move this to the LocationBarCoordinator once it is
+  // created.
+  UIColor* textColor =
+      isIncognito
+          ? [UIColor whiteColor]
+          : [UIColor colorWithWhite:0 alpha:[MDCTypography body1FontOpacity]];
+  UIColor* tintColor = isIncognito ? textColor : nil;
+  self.locationBarView =
+      [[LocationBarView alloc] initWithFrame:CGRectZero
+                                        font:[MDCTypography subheadFont]
+                                   textColor:textColor
+                                   tintColor:tintColor];
+  _locationBar = base::MakeUnique<LocationBarControllerImpl>(
+      self.locationBarView, self.browserState, self, self.dispatcher);
+  // End of TODO(crbug.com/785253):.
+
+  ToolbarStyle style = isIncognito ? INCOGNITO : NORMAL;
   ToolbarButtonFactory* factory =
       [[ToolbarButtonFactory alloc] initWithStyle:style];
 
@@ -63,6 +98,74 @@
 
 - (void)stop {
   [self.mediator disconnect];
+  _locationBar.reset();
+  self.locationBarView = nil;
+}
+
+#pragma mark - LocationBarDelegate
+
+- (void)loadGURLFromLocationBar:(const GURL&)url
+                     transition:(ui::PageTransition)transition {
+  if (url.SchemeIs(url::kJavaScriptScheme)) {
+    // Evaluate the URL as JavaScript if its scheme is JavaScript.
+    NSString* jsToEval = [base::SysUTF8ToNSString(url.GetContent())
+        stringByRemovingPercentEncoding];
+    [self.URLLoader loadJavaScriptFromLocationBar:jsToEval];
+  } else {
+    // When opening a URL, force the omnibox to resign first responder.  This
+    // will also close the popup.
+
+    // TODO(crbug.com/785244): Is it ok to call |cancelOmniboxEdit| after
+    // |loadURL|?  It doesn't seem to be causing major problems.  If we call
+    // cancel before load, then any prerendered pages get destroyed before the
+    // call to load.
+    [self.URLLoader loadURL:url
+                   referrer:web::Referrer()
+                 transition:transition
+          rendererInitiated:NO];
+
+    if (google_util::IsGoogleSearchUrl(url)) {
+      UMA_HISTOGRAM_ENUMERATION(
+          kOmniboxQueryLocationAuthorizationStatusHistogram,
+          [CLLocationManager authorizationStatus],
+          kLocationAuthorizationStatusCount);
+    }
+  }
+  [self cancelOmniboxEdit];
+}
+
+- (void)locationBarHasBecomeFirstResponder {
+  [self.delegate locationBarDidBecomeFirstResponder];
+  if (@available(iOS 10, *)) {
+    [self.viewController expandOmnibox];
+  }
+}
+
+- (void)locationBarHasResignedFirstResponder {
+  [self.delegate locationBarDidResignFirstResponder];
+  if (@available(iOS 10, *)) {
+    [self.viewController contractOmnibox];
+  }
+}
+
+- (void)locationBarBeganEdit {
+  [self.delegate locationBarBeganEdit];
+}
+
+- (web::WebState*)getWebState {
+  return self.webStateList->GetActiveWebState();
+}
+
+- (ToolbarModel*)toolbarModel {
+  ToolbarModelIOS* toolbarModelIOS = [self.delegate toolbarModelIOS];
+  return toolbarModelIOS ? toolbarModelIOS->GetToolbarModel() : nullptr;
+}
+
+// TODO(crbug.com/78911): implement this protocol.
+#pragma mark - OmniboxFocuser
+
+- (void)cancelOmniboxEdit {
+  // TODO(crbug.com/784911): Implement this.
 }
 
 @end
diff --git a/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h
new file mode 100644
index 0000000..01c6ec7
--- /dev/null
+++ b/ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h
@@ -0,0 +1,27 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_COORDINATOR_DELEGATE_H_
+#define IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_COORDINATOR_DELEGATE_H_
+
+#import <Foundation/Foundation.h>
+
+class ToolbarModelIOS;
+
+// Protocol receiving notification when the some events occur in the
+// ToolbarCoordinator
+@protocol ToolbarCoordinatorDelegate<NSObject>
+
+// Called when the location bar gains keyboard focus.
+- (void)locationBarDidBecomeFirstResponder;
+// Called when the location bar loses keyboard focus.
+- (void)locationBarDidResignFirstResponder;
+// Called when the location bar receives a key press.
+- (void)locationBarBeganEdit;
+// Returns the toolbar model.
+- (ToolbarModelIOS*)toolbarModelIOS;
+
+@end
+
+#endif  // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_COORDINATOR_DELEGATE_H_
diff --git a/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.h b/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.h
index 16d6be2..01eacc5 100644
--- a/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.h
+++ b/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.h
@@ -40,6 +40,11 @@
 
 @property(nonatomic, strong) UIViewController* locationBarViewController;
 
+// Animates the toolbar so the omnibox is shrinking to its standard state.
+- (void)contractOmnibox;
+// Animates the toolbar so the omnibox is expanding to its expanded state.
+- (void)expandOmnibox;
+
 @end
 
 #endif  // IOS_CHROME_BROWSER_UI_TOOLBAR_CLEAN_TOOLBAR_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.mm b/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.mm
index dec89a2..32ec7ef 100644
--- a/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.mm
+++ b/ios/chrome/browser/ui/toolbar/clean/toolbar_view_controller.mm
@@ -53,6 +53,8 @@
 @synthesize stopButton = _stopButton;
 @synthesize progressBar = _progressBar;
 
+#pragma mark - Public
+
 - (instancetype)initWithDispatcher:
                     (id<ApplicationCommands, BrowserCommands>)dispatcher
                      buttonFactory:(ToolbarButtonFactory*)buttonFactory {
@@ -67,6 +69,14 @@
   return self;
 }
 
+- (void)contractOmnibox {
+  // TODO(crbug.com/785210): Implement this.
+}
+
+- (void)expandOmnibox {
+  // TODO(crbug.com/785210): Implement this.
+}
+
 #pragma mark - View lifecyle
 
 - (void)viewDidLoad {
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_adapter.h b/ios/chrome/browser/ui/toolbar/toolbar_adapter.h
index 8e12c68..a94a30c 100644
--- a/ios/chrome/browser/ui/toolbar/toolbar_adapter.h
+++ b/ios/chrome/browser/ui/toolbar/toolbar_adapter.h
@@ -14,11 +14,14 @@
 #import "ios/chrome/browser/ui/toolbar/legacy_toolbar_coordinator.h"
 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_delegate.h"
 
-@protocol ApplicationCommands;
-@protocol BrowserCommands;
 namespace ios {
 class ChromeBrowserState;
 }
+
+@protocol ApplicationCommands;
+@protocol BrowserCommands;
+@protocol ToolbarCoordinatorDelegate;
+@protocol UrlLoader;
 class WebStateList;
 
 // Temporary Adapter so ToolbarCoordinator can work as a <Toolbar>
@@ -33,6 +36,8 @@
 
 - (instancetype)init NS_UNAVAILABLE;
 
+@property(nonatomic, weak) id<UrlLoader> URLLoader;
+
 @end
 
 #endif  // IOS_CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ADAPTER_H_
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_adapter.mm b/ios/chrome/browser/ui/toolbar/toolbar_adapter.mm
index d928c9ac..0247cd16 100644
--- a/ios/chrome/browser/ui/toolbar/toolbar_adapter.mm
+++ b/ios/chrome/browser/ui/toolbar/toolbar_adapter.mm
@@ -5,6 +5,7 @@
 #import "ios/chrome/browser/ui/toolbar/toolbar_adapter.h"
 
 #import "ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator.h"
+#import "ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h"
 
 @interface ToolbarAdapter ()
 @property(nonatomic, strong) ToolbarCoordinator* toolbarCoordinator;
@@ -15,6 +16,7 @@
 @synthesize toolbarCoordinator = _toolbarCoordinator;
 @synthesize delegate = _delegate;
 @synthesize toolsPopupController = _toolsPopupController;
+@synthesize URLLoader = _URLLoader;
 @synthesize viewController = _viewController;
 
 - (instancetype)initWithDispatcher:
@@ -31,6 +33,18 @@
   return self;
 }
 
+#pragma mark - Properties
+
+- (void)setDelegate:(id<WebToolbarDelegate>)delegate {
+  _delegate = delegate;
+  self.toolbarCoordinator.delegate = delegate;
+}
+
+- (void)setURLLoader:(id<UrlLoader>)URLLoader {
+  _URLLoader = URLLoader;
+  self.toolbarCoordinator.URLLoader = URLLoader;
+}
+
 #pragma mark - Abstract WebToolbar
 
 - (void)browserStateDestroyed {
diff --git a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
index 4c182dc..05344416 100644
--- a/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
+++ b/ios/chrome/browser/ui/toolbar/web_toolbar_controller.mm
@@ -895,7 +895,7 @@
 }
 
 - (void)locationBarHasBecomeFirstResponder {
-  [self.delegate locationBarDidBecomeFirstResponder:self];
+  [self.delegate locationBarDidBecomeFirstResponder];
   if (@available(iOS 10, *)) {
     if (base::FeatureList::IsEnabled(kPropertyAnimationsToolbar)) {
       [self expandOmnibox];
@@ -908,7 +908,7 @@
 }
 
 - (void)locationBarHasResignedFirstResponder {
-  [self.delegate locationBarDidResignFirstResponder:self];
+  [self.delegate locationBarDidResignFirstResponder];
   if (@available(iOS 10, *)) {
     if (base::FeatureList::IsEnabled(kPropertyAnimationsToolbar)) {
       [self contractOmnibox];
@@ -921,7 +921,7 @@
 }
 
 - (void)locationBarBeganEdit {
-  [self.delegate locationBarBeganEdit:self];
+  [self.delegate locationBarBeganEdit];
 }
 
 - (web::WebState*)getWebState {
diff --git a/ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h b/ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h
index 27b023e..ce212be 100644
--- a/ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h
+++ b/ios/chrome/browser/ui/toolbar/web_toolbar_delegate.h
@@ -5,7 +5,7 @@
 #ifndef IOS_CHROME_BROWSER_UI_TOOLBAR_WEB_TOOLBAR_DELEGATE_H_
 #define IOS_CHROME_BROWSER_UI_TOOLBAR_WEB_TOOLBAR_DELEGATE_H_
 
-#import <Foundation/Foundation.h>
+#import "ios/chrome/browser/ui/toolbar/clean/toolbar_coordinator_delegate.h"
 
 class ToolbarModelIOS;
 
@@ -14,17 +14,10 @@
 }
 
 // Delegate interface, to be implemented by the WebToolbarController's delegate.
-@protocol WebToolbarDelegate<NSObject>
+@protocol WebToolbarDelegate<ToolbarCoordinatorDelegate>
 @required
-// Called when the location bar gains keyboard focus.
-- (IBAction)locationBarDidBecomeFirstResponder:(id)sender;
-// Called when the location bar loses keyboard focus.
-- (IBAction)locationBarDidResignFirstResponder:(id)sender;
-// Called when the location bar receives a key press.
-- (IBAction)locationBarBeganEdit:(id)sender;
 // Returns the WebState.
 - (web::WebState*)currentWebState;
-- (ToolbarModelIOS*)toolbarModelIOS;
 @optional
 // Called before the toolbar screenshot gets updated.
 - (void)willUpdateToolbarSnapshot;