Commit 185b6bee authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Disable share menu when overlays are presented.

The share menu requires JavaScript execution to capture the page's
canonical URL, but script execution is halted when JavaScript dialogs
are running.  This CL adds LocationBarMediator as an
OverlayPresenterObserver and disables the button when a overlays are
displayed in OverlayModality::kWebContentArea.

To accomplish this, the mediator needs access to the OverlayPresenter
at that modality, which requires plumbing the Browser object through
BVC to the LocationBarCoordinator.

Bug: 987247
Change-Id: Ifccd68ae283e27c609e2204795be54cd0500516b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1742889
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692912}
parent c98d52e9
...@@ -17,6 +17,7 @@ source_set("perf_test_support") { ...@@ -17,6 +17,7 @@ source_set("perf_test_support") {
"//ios/chrome/browser/autocomplete", "//ios/chrome/browser/autocomplete",
"//ios/chrome/browser/bookmarks", "//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/main:test_support",
"//ios/chrome/browser/prerender", "//ios/chrome/browser/prerender",
"//ios/chrome/browser/search_engines", "//ios/chrome/browser/search_engines",
"//ios/chrome/browser/sessions", "//ios/chrome/browser/sessions",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h" #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager.h"
#include "ios/web/public/test/scoped_testing_web_client.h" #include "ios/web/public/test/scoped_testing_web_client.h"
class Browser;
@class BrowserViewController; @class BrowserViewController;
@class BrowserViewControllerDependencyFactory; @class BrowserViewControllerDependencyFactory;
@class CommandDispatcher; @class CommandDispatcher;
...@@ -54,6 +55,9 @@ class PerfTestWithBVC : public PerfTest { ...@@ -54,6 +55,9 @@ class PerfTestWithBVC : public PerfTest {
TabModel* tab_model_; TabModel* tab_model_;
TabModel* otr_tab_model_; TabModel* otr_tab_model_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<Browser> otr_browser_;
CommandDispatcher* command_dispatcher_; CommandDispatcher* command_dispatcher_;
BrowserViewControllerDependencyFactory* bvc_factory_; BrowserViewControllerDependencyFactory* bvc_factory_;
BrowserViewController* bvc_; BrowserViewController* bvc_;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h"
#import "ios/chrome/browser/main/test_browser.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/sessions/session_ios.h" #import "ios/chrome/browser/sessions/session_ios.h"
#import "ios/chrome/browser/sessions/session_service_ios.h" #import "ios/chrome/browser/sessions/session_service_ios.h"
...@@ -111,14 +112,18 @@ void PerfTestWithBVC::SetUp() { ...@@ -111,14 +112,18 @@ void PerfTestWithBVC::SetUp() {
[otr_tab_model_ restoreSessionWindow:session.sessionWindows[0] [otr_tab_model_ restoreSessionWindow:session.sessionWindows[0]
forInitialRestore:YES]; forInitialRestore:YES];
browser_ =
std::make_unique<TestBrowser>(chrome_browser_state_.get(), tab_model_);
otr_browser_ = std::make_unique<TestBrowser>(
incognito_chrome_browser_state_.get(), otr_tab_model_);
command_dispatcher_ = [[CommandDispatcher alloc] init]; command_dispatcher_ = [[CommandDispatcher alloc] init];
// Create the browser view controller with its testing factory. // Create the browser view controller with its testing factory.
bvc_factory_ = [[BrowserViewControllerDependencyFactory alloc] bvc_factory_ = [[BrowserViewControllerDependencyFactory alloc]
initWithBrowserState:chrome_browser_state_.get() initWithBrowserState:chrome_browser_state_.get()
webStateList:[tab_model_ webStateList]]; webStateList:[tab_model_ webStateList]];
bvc_ = [[BrowserViewController alloc] bvc_ = [[BrowserViewController alloc]
initWithTabModel:tab_model_ initWithBrowser:browser_.get()
browserState:chrome_browser_state_.get()
dependencyFactory:bvc_factory_ dependencyFactory:bvc_factory_
applicationCommandEndpoint:nil applicationCommandEndpoint:nil
commandDispatcher:command_dispatcher_ commandDispatcher:command_dispatcher_
......
...@@ -201,8 +201,7 @@ ...@@ -201,8 +201,7 @@
initWithBrowserState:self.browserState initWithBrowserState:self.browserState
webStateList:self.tabModel.webStateList]; webStateList:self.tabModel.webStateList];
_viewController = [[BrowserViewController alloc] _viewController = [[BrowserViewController alloc]
initWithTabModel:self.tabModel initWithBrowser:self.browser
browserState:self.browserState
dependencyFactory:factory dependencyFactory:factory
applicationCommandEndpoint:self.applicationCommandHandler applicationCommandEndpoint:self.applicationCommandHandler
commandDispatcher:self.dispatcher commandDispatcher:self.dispatcher
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h" #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h"
#import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h" #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h"
class Browser;
@protocol ApplicationCommands; @protocol ApplicationCommands;
@protocol BrowserCommands; @protocol BrowserCommands;
@class BrowserContainerViewController; @class BrowserContainerViewController;
...@@ -41,8 +42,8 @@ class ChromeBrowserState; ...@@ -41,8 +42,8 @@ class ChromeBrowserState;
// webUsageSuspended property for this BVC will be based on |model|, and future // webUsageSuspended property for this BVC will be based on |model|, and future
// changes to |model|'s suspension state should be made through this BVC // changes to |model|'s suspension state should be made through this BVC
// instead of directly on the model. // instead of directly on the model.
- (instancetype)initWithTabModel:(TabModel*)model // TODO(crbug.com/992582): Remove references to model objects from this class.
browserState:(ios::ChromeBrowserState*)browserState - (instancetype)initWithBrowser:(Browser*)browser
dependencyFactory: dependencyFactory:
(BrowserViewControllerDependencyFactory*)factory (BrowserViewControllerDependencyFactory*)factory
applicationCommandEndpoint: applicationCommandEndpoint:
...@@ -75,10 +76,10 @@ class ChromeBrowserState; ...@@ -75,10 +76,10 @@ class ChromeBrowserState;
// Returns whether or not text to speech is playing. // Returns whether or not text to speech is playing.
@property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS; @property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS;
// Returns the TabModel passed to the initializer. // The Browser's TabModel.
@property(nonatomic, weak, readonly) TabModel* tabModel; @property(nonatomic, weak, readonly) TabModel* tabModel;
// Returns the ios::ChromeBrowserState passed to the initializer. // The Browser's ChromeBrowserState.
@property(nonatomic, assign, readonly) ios::ChromeBrowserState* browserState; @property(nonatomic, assign, readonly) ios::ChromeBrowserState* browserState;
// Whether the receiver is currently the primary BVC. // Whether the receiver is currently the primary BVC.
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" #include "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h"
#import "ios/chrome/browser/main/test_browser.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
#import "ios/chrome/browser/tabs/tab_helper_util.h" #import "ios/chrome/browser/tabs/tab_helper_util.h"
...@@ -134,6 +135,9 @@ class BrowserViewControllerTest : public BlockCleanupTest { ...@@ -134,6 +135,9 @@ class BrowserViewControllerTest : public BlockCleanupTest {
[[tabModel stub] saveSessionImmediately:NO]; [[tabModel stub] saveSessionImmediately:NO];
[[tabModel stub] closeAllTabs]; [[tabModel stub] closeAllTabs];
browser_ =
std::make_unique<TestBrowser>(chrome_browser_state_.get(), tabModel_);
// Create three web states. // Create three web states.
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
web::WebState::CreateParams params(chrome_browser_state_.get()); web::WebState::CreateParams params(chrome_browser_state_.get());
...@@ -152,8 +156,7 @@ class BrowserViewControllerTest : public BlockCleanupTest { ...@@ -152,8 +156,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
// Instantiate the BVC. // Instantiate the BVC.
bvc_ = [[BrowserViewController alloc] bvc_ = [[BrowserViewController alloc]
initWithTabModel:tabModel_ initWithBrowser:browser_.get()
browserState:chrome_browser_state_.get()
dependencyFactory:factory dependencyFactory:factory
applicationCommandEndpoint:mockApplicationCommandHandler applicationCommandEndpoint:mockApplicationCommandHandler
commandDispatcher:command_dispatcher_ commandDispatcher:command_dispatcher_
...@@ -188,6 +191,7 @@ class BrowserViewControllerTest : public BlockCleanupTest { ...@@ -188,6 +191,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
IOSChromeScopedTestingLocalState local_state_; IOSChromeScopedTestingLocalState local_state_;
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
TabModel* tabModel_; TabModel* tabModel_;
std::unique_ptr<Browser> browser_;
BrowserViewControllerHelper* bvcHelper_; BrowserViewControllerHelper* bvcHelper_;
PKAddPassesViewController* passKitViewController_; PKAddPassesViewController* passKitViewController_;
OCMockObject* dependencyFactory_; OCMockObject* dependencyFactory_;
......
...@@ -40,7 +40,9 @@ source_set("location_bar") { ...@@ -40,7 +40,9 @@ source_set("location_bar") {
"//ios/chrome/browser/geolocation:geolocation_internal", "//ios/chrome/browser/geolocation:geolocation_internal",
"//ios/chrome/browser/infobars:badge", "//ios/chrome/browser/infobars:badge",
"//ios/chrome/browser/infobars:public", "//ios/chrome/browser/infobars:public",
"//ios/chrome/browser/main",
"//ios/chrome/browser/ntp", "//ios/chrome/browser/ntp",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/search_engines", "//ios/chrome/browser/search_engines",
"//ios/chrome/browser/ssl", "//ios/chrome/browser/ssl",
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
...@@ -143,6 +145,7 @@ source_set("unit_tests") { ...@@ -143,6 +145,7 @@ source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"location_bar_coordinator_unittest.mm", "location_bar_coordinator_unittest.mm",
"location_bar_mediator_unittest.mm",
] ]
deps = [ deps = [
":location_bar", ":location_bar",
...@@ -154,8 +157,13 @@ source_set("unit_tests") { ...@@ -154,8 +157,13 @@ source_set("unit_tests") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/autocomplete", "//ios/chrome/browser/autocomplete",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/main:test_support",
"//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/web_content_area",
"//ios/chrome/browser/overlays/test",
"//ios/chrome/browser/search_engines", "//ios/chrome/browser/search_engines",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/location_bar/test",
"//ios/chrome/browser/ui/toolbar", "//ios/chrome/browser/ui/toolbar",
"//ios/chrome/browser/ui/toolbar/test", "//ios/chrome/browser/ui/toolbar/test",
"//ios/chrome/browser/url_loading", "//ios/chrome/browser/url_loading",
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_CONSUMER_H_ #ifndef IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_CONSUMER_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_CONSUMER_H_ #define IOS_CHROME_BROWSER_UI_LOCATION_BAR_LOCATION_BAR_CONSUMER_H_
#import "ios/chrome/browser/infobars/infobar_type.h"
// Consumer for the location bar mediator. // Consumer for the location bar mediator.
@protocol LocationBarConsumer @protocol LocationBarConsumer
......
...@@ -11,12 +11,9 @@ ...@@ -11,12 +11,9 @@
#import "ios/chrome/browser/ui/omnibox/location_bar_delegate.h" #import "ios/chrome/browser/ui/omnibox/location_bar_delegate.h"
#import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h" #import "ios/chrome/browser/ui/toolbar/public/omnibox_focuser.h"
namespace ios {
class ChromeBrowserState;
}
class WebStateList;
@class CommandDispatcher; @class CommandDispatcher;
@protocol ApplicationCommands; @protocol ApplicationCommands;
class Browser;
@protocol BrowserCommands; @protocol BrowserCommands;
@protocol EditViewAnimatee; @protocol EditViewAnimatee;
@protocol LocationBarAnimatee; @protocol LocationBarAnimatee;
...@@ -32,15 +29,13 @@ class WebStateList; ...@@ -32,15 +29,13 @@ class WebStateList;
// View controller containing the omnibox. // View controller containing the omnibox.
@property(nonatomic, strong, readonly) @property(nonatomic, strong, readonly)
UIViewController* locationBarViewController; UIViewController* locationBarViewController;
// Weak reference to ChromeBrowserState; // The location bar's Browser.
@property(nonatomic, assign) ios::ChromeBrowserState* browserState; @property(nonatomic, assign) Browser* browser;
// The dispatcher for this view controller. // The dispatcher for this view controller.
@property(nonatomic, weak) CommandDispatcher* dispatcher; @property(nonatomic, weak) CommandDispatcher* dispatcher;
// Delegate for this coordinator. // Delegate for this coordinator.
// TODO(crbug.com/799446): Change this. // TODO(crbug.com/799446): Change this.
@property(nonatomic, weak) id<ToolbarCoordinatorDelegate> delegate; @property(nonatomic, weak) id<ToolbarCoordinatorDelegate> delegate;
// The web state list this ToolbarCoordinator is handling.
@property(nonatomic, assign) WebStateList* webStateList;
@property(nonatomic, weak) id<OmniboxPopupPresenterDelegate> @property(nonatomic, weak) id<OmniboxPopupPresenterDelegate>
popupPresenterDelegate; popupPresenterDelegate;
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h"
#include "ios/chrome/browser/infobars/infobar_metrics_recorder.h" #include "ios/chrome/browser/infobars/infobar_metrics_recorder.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ntp/new_tab_page_tab_helper.h" #import "ios/chrome/browser/ntp/new_tab_page_tab_helper.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/ui/badges/badge_button_action_handler.h" #import "ios/chrome/browser/ui/badges/badge_button_action_handler.h"
#import "ios/chrome/browser/ui/badges/badge_button_factory.h" #import "ios/chrome/browser/ui/badges/badge_button_factory.h"
...@@ -93,6 +95,8 @@ const int kLocationAuthorizationStatusCount = 5; ...@@ -93,6 +95,8 @@ const int kLocationAuthorizationStatusCount = 5;
@property(nonatomic, strong) OmniboxCoordinator* omniboxCoordinator; @property(nonatomic, strong) OmniboxCoordinator* omniboxCoordinator;
@property(nonatomic, strong) LocationBarMediator* mediator; @property(nonatomic, strong) LocationBarMediator* mediator;
@property(nonatomic, strong) LocationBarViewController* viewController; @property(nonatomic, strong) LocationBarViewController* viewController;
@property(nonatomic, readonly) ios::ChromeBrowserState* browserState;
@property(nonatomic, readonly) WebStateList* webStateList;
// Tracks calls in progress to -cancelOmniboxEdit to avoid calling it from // Tracks calls in progress to -cancelOmniboxEdit to avoid calling it from
// itself when -resignFirstResponder causes -textFieldWillResignFirstResponder // itself when -resignFirstResponder causes -textFieldWillResignFirstResponder
...@@ -102,16 +106,16 @@ const int kLocationAuthorizationStatusCount = 5; ...@@ -102,16 +106,16 @@ const int kLocationAuthorizationStatusCount = 5;
@end @end
@implementation LocationBarCoordinator @implementation LocationBarCoordinator
@synthesize commandDispatcher = _commandDispatcher;
@synthesize viewController = _viewController; #pragma mark - Accessors
@synthesize started = _started;
@synthesize mediator = _mediator; - (ios::ChromeBrowserState*)browserState {
@synthesize browserState = _browserState; return self.browser ? self.browser->GetBrowserState() : nullptr;
@synthesize dispatcher = _dispatcher; }
@synthesize delegate = _delegate;
@synthesize webStateList = _webStateList; - (WebStateList*)webStateList {
@synthesize omniboxPopupCoordinator = _omniboxPopupCoordinator; return self.browser ? self.browser->GetWebStateList() : nullptr;
@synthesize omniboxCoordinator = _omniboxCoordinator; }
#pragma mark - public #pragma mark - public
...@@ -121,6 +125,7 @@ const int kLocationAuthorizationStatusCount = 5; ...@@ -121,6 +125,7 @@ const int kLocationAuthorizationStatusCount = 5;
- (void)start { - (void)start {
DCHECK(self.commandDispatcher); DCHECK(self.commandDispatcher);
DCHECK(self.browser);
if (self.started) if (self.started)
return; return;
...@@ -195,6 +200,8 @@ const int kLocationAuthorizationStatusCount = 5; ...@@ -195,6 +200,8 @@ const int kLocationAuthorizationStatusCount = 5;
self.mediator = [[LocationBarMediator alloc] self.mediator = [[LocationBarMediator alloc]
initWithLocationBarModel:[self locationBarModel]]; initWithLocationBarModel:[self locationBarModel]];
self.mediator.webStateList = self.webStateList; self.mediator.webStateList = self.webStateList;
self.mediator.webContentAreaOverlayPresenter = OverlayPresenter::FromBrowser(
self.browser, OverlayModality::kWebContentArea);
self.mediator.templateURLService = self.mediator.templateURLService =
ios::TemplateURLServiceFactory::GetForBrowserState(self.browserState); ios::TemplateURLServiceFactory::GetForBrowserState(self.browserState);
self.mediator.consumer = self; self.mediator.consumer = self;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/variations/variations_http_header_provider.h" #include "components/variations/variations_http_header_provider.h"
#include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/main/test_browser.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h" #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_delegate.h"
...@@ -75,9 +76,11 @@ class LocationBarCoordinatorTest : public PlatformTest { ...@@ -75,9 +76,11 @@ class LocationBarCoordinatorTest : public PlatformTest {
test_cbs_builder.AddTestingFactory( test_cbs_builder.AddTestingFactory(
UrlLoadingServiceFactory::GetInstance(), UrlLoadingServiceFactory::GetInstance(),
UrlLoadingServiceFactory::GetDefaultFactory()); UrlLoadingServiceFactory::GetDefaultFactory());
browser_state_ = test_cbs_builder.Build(); browser_state_ = test_cbs_builder.Build();
browser_ =
std::make_unique<TestBrowser>(browser_state_.get(), &web_state_list_);
auto web_state = std::make_unique<web::TestWebState>(); auto web_state = std::make_unique<web::TestWebState>();
web_state->SetBrowserState(browser_state_.get()); web_state->SetBrowserState(browser_state_.get());
web_state->SetCurrentURL(GURL("http://test/")); web_state->SetCurrentURL(GURL("http://test/"));
...@@ -88,8 +91,7 @@ class LocationBarCoordinatorTest : public PlatformTest { ...@@ -88,8 +91,7 @@ class LocationBarCoordinatorTest : public PlatformTest {
delegate_ = [[TestToolbarCoordinatorDelegate alloc] init]; delegate_ = [[TestToolbarCoordinatorDelegate alloc] init];
coordinator_ = [[LocationBarCoordinator alloc] init]; coordinator_ = [[LocationBarCoordinator alloc] init];
coordinator_.browserState = browser_state_.get(); coordinator_.browser = browser_.get();
coordinator_.webStateList = &web_state_list_;
coordinator_.delegate = delegate_; coordinator_.delegate = delegate_;
coordinator_.commandDispatcher = [[CommandDispatcher alloc] init]; coordinator_.commandDispatcher = [[CommandDispatcher alloc] init];
} }
...@@ -108,6 +110,7 @@ class LocationBarCoordinatorTest : public PlatformTest { ...@@ -108,6 +110,7 @@ class LocationBarCoordinatorTest : public PlatformTest {
std::unique_ptr<TestChromeBrowserState> browser_state_; std::unique_ptr<TestChromeBrowserState> browser_state_;
FakeWebStateListDelegate web_state_list_delegate_; FakeWebStateListDelegate web_state_list_delegate_;
WebStateList web_state_list_; WebStateList web_state_list_;
std::unique_ptr<Browser> browser_;
TestToolbarCoordinatorDelegate* delegate_; TestToolbarCoordinatorDelegate* delegate_;
}; };
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
@protocol LocationBarConsumer; @protocol LocationBarConsumer;
class TemplateURLService; class TemplateURLService;
class WebStateList; class WebStateList;
class OverlayPresenter;
class LocationBarModel; class LocationBarModel;
// A mediator object that updates the mediator when the web state changes. // A mediator object that updates the mediator when the web state changes.
...@@ -23,6 +24,11 @@ class LocationBarModel; ...@@ -23,6 +24,11 @@ class LocationBarModel;
// state. // state.
@property(nonatomic, assign) WebStateList* webStateList; @property(nonatomic, assign) WebStateList* webStateList;
// The overlay presenter for OverlayModality::kWebContentArea. This mediator
// listens for overlay presentation events to determine whether the share button
// should be enabled.
@property(nonatomic, assign) OverlayPresenter* webContentAreaOverlayPresenter;
// The location bar model used by this mediator to extract the current URL and // The location bar model used by this mediator to extract the current URL and
// the security state. // the security state.
@property(nonatomic, assign, readonly) LocationBarModel* locationBarModel; @property(nonatomic, assign, readonly) LocationBarModel* locationBarModel;
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/omnibox/browser/location_bar_model.h" #include "components/omnibox/browser/location_bar_model.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter_observer_bridge.h"
#import "ios/chrome/browser/search_engines/search_engine_observer_bridge.h" #import "ios/chrome/browser/search_engines/search_engine_observer_bridge.h"
#import "ios/chrome/browser/search_engines/search_engines_util.h" #import "ios/chrome/browser/search_engines/search_engines_util.h"
#include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h"
...@@ -32,19 +34,26 @@ ...@@ -32,19 +34,26 @@
@interface LocationBarMediator () <CRWWebStateObserver, @interface LocationBarMediator () <CRWWebStateObserver,
SearchEngineObserving, SearchEngineObserving,
WebStateListObserving> WebStateListObserving,
OverlayPresenterObserving>
// The current web state associated with the toolbar. // The current web state associated with the toolbar.
@property(nonatomic, assign) web::WebState* webState; @property(nonatomic, assign) web::WebState* webState;
// Whether the current default search engine supports search by image. // Whether the current default search engine supports search by image.
@property(nonatomic, assign) BOOL searchEngineSupportsSearchByImage; @property(nonatomic, assign) BOOL searchEngineSupportsSearchByImage;
// Whether an overlay is currently presented over the web content area.
@property(nonatomic, assign, getter=isWebContentAreaShowingOverlay)
BOOL webContentAreaShowingOverlay;
@end @end
@implementation LocationBarMediator { @implementation LocationBarMediator {
std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
std::unique_ptr<WebStateListObserverBridge> _webStateListObserver; std::unique_ptr<WebStateListObserverBridge> _webStateListObserver;
std::unique_ptr<SearchEngineObserverBridge> _searchEngineObserver; std::unique_ptr<SearchEngineObserverBridge> _searchEngineObserver;
std::unique_ptr<OverlayPresenterObserverBridge> _overlayObserver;
} }
- (instancetype)initWithLocationBarModel:(LocationBarModel*)locationBarModel { - (instancetype)initWithLocationBarModel:(LocationBarModel*)locationBarModel {
...@@ -54,6 +63,7 @@ ...@@ -54,6 +63,7 @@
_locationBarModel = locationBarModel; _locationBarModel = locationBarModel;
_webStateObserver = std::make_unique<web::WebStateObserverBridge>(self); _webStateObserver = std::make_unique<web::WebStateObserverBridge>(self);
_webStateListObserver = std::make_unique<WebStateListObserverBridge>(self); _webStateListObserver = std::make_unique<WebStateListObserverBridge>(self);
_overlayObserver = std::make_unique<OverlayPresenterObserverBridge>(self);
_searchEngineSupportsSearchByImage = NO; _searchEngineSupportsSearchByImage = NO;
} }
return self; return self;
...@@ -66,17 +76,8 @@ ...@@ -66,17 +76,8 @@
#pragma mark - Public #pragma mark - Public
- (void)disconnect { - (void)disconnect {
if (_webStateList) { self.webStateList = nullptr;
_webStateList->RemoveObserver(_webStateListObserver.get()); self.webContentAreaOverlayPresenter = nullptr;
_webStateListObserver.reset();
_webStateList = nullptr;
}
if (_webState) {
_webState->RemoveObserver(_webStateObserver.get());
_webStateObserver.reset();
_webState = nullptr;
}
} }
#pragma mark - CRWWebStateObserver #pragma mark - CRWWebStateObserver
...@@ -135,6 +136,18 @@ ...@@ -135,6 +136,18 @@
_webState = nullptr; _webState = nullptr;
} }
#pragma mark - OverlayPresesenterObserving
- (void)overlayPresenter:(OverlayPresenter*)presenter
willShowOverlayForRequest:(OverlayRequest*)request {
self.webContentAreaShowingOverlay = YES;
}
- (void)overlayPresenter:(OverlayPresenter*)presenter
didHideOverlayForRequest:(OverlayRequest*)request {
self.webContentAreaShowingOverlay = NO;
}
#pragma mark - WebStateListObserver #pragma mark - WebStateListObserver
- (void)webStateList:(WebStateList*)webStateList - (void)webStateList:(WebStateList*)webStateList
...@@ -189,8 +202,24 @@ ...@@ -189,8 +202,24 @@
} }
_webStateList = webStateList; _webStateList = webStateList;
self.webState = self.webStateList->GetActiveWebState();
_webStateList->AddObserver(_webStateListObserver.get()); if (_webStateList) {
self.webState = self.webStateList->GetActiveWebState();
_webStateList->AddObserver(_webStateListObserver.get());
} else {
self.webState = nullptr;
}
}
- (void)setWebContentAreaOverlayPresenter:
(OverlayPresenter*)webContentAreaOverlayPresenter {
if (_webContentAreaOverlayPresenter)
_webContentAreaOverlayPresenter->RemoveObserver(_overlayObserver.get());
_webContentAreaOverlayPresenter = webContentAreaOverlayPresenter;
if (_webContentAreaOverlayPresenter)
_webContentAreaOverlayPresenter->AddObserver(_overlayObserver.get());
} }
- (void)setTemplateURLService:(TemplateURLService*)templateURLService { - (void)setTemplateURLService:(TemplateURLService*)templateURLService {
...@@ -212,6 +241,13 @@ ...@@ -212,6 +241,13 @@
} }
} }
- (void)setWebContentAreaShowingOverlay:(BOOL)webContentAreaShowingOverlay {
if (_webContentAreaShowingOverlay == webContentAreaShowingOverlay)
return;
_webContentAreaShowingOverlay = webContentAreaShowingOverlay;
[self.consumer updateLocationShareable:[self isSharingEnabled]];
}
#pragma mark - private #pragma mark - private
- (void)notifyConsumerOfChangedLocation { - (void)notifyConsumerOfChangedLocation {
...@@ -222,7 +258,7 @@ ...@@ -222,7 +258,7 @@
if (isNTP) { if (isNTP) {
[self.consumer updateAfterNavigatingToNTP]; [self.consumer updateAfterNavigatingToNTP];
} }
[self.consumer updateLocationShareable:[self isCurrentPageShareable]]; [self.consumer updateLocationShareable:[self isSharingEnabled]];
} }
- (void)notifyConsumerOfChangedSecurityIcon { - (void)notifyConsumerOfChangedSecurityIcon {
...@@ -269,7 +305,12 @@ ...@@ -269,7 +305,12 @@
#pragma mark Shareability helpers #pragma mark Shareability helpers
- (BOOL)isCurrentPageShareable { - (BOOL)isSharingEnabled {
// Page sharing requires JavaScript execution, which is paused while overlays
// are displayed over the web content area.
if (self.webContentAreaShowingOverlay)
return NO;
const GURL& URL = self.webState->GetLastCommittedURL(); const GURL& URL = self.webState->GetLastCommittedURL();
return URL.is_valid() && !web::GetWebClient()->IsAppSpecificURL(URL); return URL.is_valid() && !web::GetWebClient()->IsAppSpecificURL(URL);
} }
......
// Copyright 2019 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.
#import "ios/chrome/browser/ui/location_bar/location_bar_mediator.h"
#include "components/omnibox/browser/test_location_bar_model.h"
#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/main/test_browser.h"
#import "ios/chrome/browser/overlays/public/overlay_presenter.h"
#import "ios/chrome/browser/overlays/public/overlay_request.h"
#import "ios/chrome/browser/overlays/public/overlay_request_queue.h"
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_alert_overlay.h"
#include "ios/chrome/browser/overlays/test/fake_overlay_presentation_context.h"
#import "ios/chrome/browser/ui/location_bar/test/fake_location_bar_consumer.h"
#import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_opener.h"
#include "ios/web/public/test/fakes/test_web_state.h"
#include "ios/web/public/test/web_task_environment.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
// Test fixture for LocationBarMediator.
class LocationBarMediatorTest : public PlatformTest {
protected:
LocationBarMediatorTest()
: web_state_list_(&web_state_list_delegate_),
mediator_(
[[LocationBarMediator alloc] initWithLocationBarModel:&model_]),
consumer_([[FakeLocationBarConsumer alloc] init]) {
// Set up the TestBrowser.
TestChromeBrowserState::Builder browser_state_builder;
browser_state_ = browser_state_builder.Build();
browser_ =
std::make_unique<TestBrowser>(browser_state_.get(), &web_state_list_);
// Set up the OverlayPresenter.
OverlayPresenter* overlay_presenter = OverlayPresenter::FromBrowser(
browser_.get(), OverlayModality::kWebContentArea);
overlay_presenter->SetPresentationContext(&presentation_context_);
// Set up the mediator.
mediator_.webStateList = &web_state_list_;
mediator_.webContentAreaOverlayPresenter = overlay_presenter;
mediator_.consumer = consumer_;
}
~LocationBarMediatorTest() override { [mediator_ disconnect]; }
FakeOverlayPresentationContext presentation_context_;
web::WebTaskEnvironment task_environment_;
FakeWebStateListDelegate web_state_list_delegate_;
WebStateList web_state_list_;
std::unique_ptr<TestChromeBrowserState> browser_state_;
std::unique_ptr<Browser> browser_;
TestLocationBarModel model_;
LocationBarMediator* mediator_;
FakeLocationBarConsumer* consumer_;
};
// Tests that the share button is disabled while overlays are presented
// over the web content area.
TEST_F(LocationBarMediatorTest, DisableShareForOverlays) {
const GURL kUrl("https://chromium.test");
std::unique_ptr<web::TestWebState> passed_web_state =
std::make_unique<web::TestWebState>();
web::TestWebState* web_state = passed_web_state.get();
web_state->SetCurrentURL(kUrl);
web_state_list_.InsertWebState(0, std::move(passed_web_state),
WebStateList::INSERT_ACTIVATE,
WebStateOpener(nullptr));
ASSERT_TRUE(consumer_.locationShareable);
// Present a JavaScript alert over the WebState and verify that the page is no
// longer shareable.
JavaScriptDialogSource source(web_state, kUrl, /* is_main_frame= */ true);
const std::string kMessage("message");
OverlayRequestQueue* queue = OverlayRequestQueue::FromWebState(
web_state, OverlayModality::kWebContentArea);
queue->AddRequest(
OverlayRequest::CreateWithConfig<JavaScriptAlertOverlayRequestConfig>(
source, kMessage));
EXPECT_FALSE(consumer_.locationShareable);
// Cancel the request and verify that the location is shareable again.
queue->CancelAllRequests();
EXPECT_TRUE(consumer_.locationShareable);
}
// TODO(crbug.com/992578): Add more tests to this suite.
# Copyright 2019 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.
source_set("test") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"fake_location_bar_consumer.h",
"fake_location_bar_consumer.mm",
]
deps = [
"//ios/chrome/browser/ui/location_bar",
]
}
// Copyright 2019 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_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
#define IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/location_bar/location_bar_consumer.h"
@interface FakeLocationBarConsumer : NSObject <LocationBarConsumer>
@property(nonatomic, strong, readonly) NSString* locationText;
@property(nonatomic, assign, readonly) BOOL clipTail;
@property(nonatomic, strong, readonly) UIImage* icon;
@property(nonatomic, strong, readonly) NSString* statusText;
@property(nonatomic, assign, readonly, getter=isLocationShareable)
BOOL locationShareable;
@property(nonatomic, assign, readonly, getter=isSearchByImageSupported)
BOOL searchByImageSupported;
@end
#endif // IOS_CHROME_BROWSER_UI_LOCATION_BAR_TEST_FAKE_LOCATION_BAR_CONSUMER_H_
// Copyright 2019 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.
#import "ios/chrome/browser/ui/location_bar/test/fake_location_bar_consumer.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation FakeLocationBarConsumer
- (void)updateLocationText:(NSString*)string clipTail:(BOOL)clipTail {
_locationText = string;
_clipTail = clipTail;
}
- (void)updateLocationIcon:(UIImage*)icon
securityStatusText:(NSString*)statusText {
_icon = icon;
_statusText = statusText;
}
- (void)updateLocationShareable:(BOOL)shareable {
_locationShareable = shareable;
}
- (void)defocusOmnibox {
}
- (void)updateAfterNavigatingToNTP {
}
- (void)updateSearchByImageSupported:(BOOL)searchByImageSupported {
_searchByImageSupported = searchByImageSupported;
}
@end
...@@ -244,6 +244,7 @@ source_set("perf_tests") { ...@@ -244,6 +244,7 @@ source_set("perf_tests") {
"//components/omnibox/browser:test_support", "//components/omnibox/browser:test_support",
"//ios/chrome/browser/autocomplete", "//ios/chrome/browser/autocomplete",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/main:test_support",
"//ios/chrome/browser/search_engines", "//ios/chrome/browser/search_engines",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/tabs:tabs_internal", "//ios/chrome/browser/tabs:tabs_internal",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/omnibox/browser/test_location_bar_model.h" #include "components/omnibox/browser/test_location_bar_model.h"
#include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#import "ios/chrome/browser/main/test_browser.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h" #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#include "ios/chrome/browser/ui/location_bar/location_bar_model_delegate_ios.h" #include "ios/chrome/browser/ui/location_bar/location_bar_model_delegate_ios.h"
...@@ -94,6 +95,10 @@ class OmniboxPerfTest : public PerfTest { ...@@ -94,6 +95,10 @@ class OmniboxPerfTest : public PerfTest {
WebStateList::INSERT_FORCE_INDEX, WebStateList::INSERT_FORCE_INDEX,
WebStateOpener()); WebStateOpener());
// Create the Browser for the toolbar coordinator.
browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get(),
web_state_list_.get());
// Creates the Toolbar for testing and sizes it to the width of the screen. // Creates the Toolbar for testing and sizes it to the width of the screen.
location_bar_model_delegate_.reset( location_bar_model_delegate_.reset(
new LocationBarModelDelegateIOS(web_state_list_.get())); new LocationBarModelDelegateIOS(web_state_list_.get()));
...@@ -109,8 +114,8 @@ class OmniboxPerfTest : public PerfTest { ...@@ -109,8 +114,8 @@ class OmniboxPerfTest : public PerfTest {
CommandDispatcher* dispatcher = [[CommandDispatcher alloc] init]; CommandDispatcher* dispatcher = [[CommandDispatcher alloc] init];
coordinator_ = [[PrimaryToolbarCoordinator alloc] coordinator_ =
initWithBrowserState:chrome_browser_state_.get()]; [[PrimaryToolbarCoordinator alloc] initWithBrowser:browser_.get()];
coordinator_.delegate = toolbarDelegate; coordinator_.delegate = toolbarDelegate;
coordinator_.webStateList = web_state_list_.get(); coordinator_.webStateList = web_state_list_.get();
coordinator_.commandDispatcher = dispatcher; coordinator_.commandDispatcher = dispatcher;
...@@ -227,6 +232,7 @@ class OmniboxPerfTest : public PerfTest { ...@@ -227,6 +232,7 @@ class OmniboxPerfTest : public PerfTest {
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
FakeWebStateListDelegate web_state_list_delegate_; FakeWebStateListDelegate web_state_list_delegate_;
std::unique_ptr<WebStateList> web_state_list_; std::unique_ptr<WebStateList> web_state_list_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<LocationBarModelDelegateIOS> location_bar_model_delegate_; std::unique_ptr<LocationBarModelDelegateIOS> location_bar_model_delegate_;
std::unique_ptr<LocationBarModel> location_bar_model_; std::unique_ptr<LocationBarModel> location_bar_model_;
PrimaryToolbarCoordinator* coordinator_; PrimaryToolbarCoordinator* coordinator_;
......
...@@ -63,6 +63,7 @@ source_set("eg_tests") { ...@@ -63,6 +63,7 @@ source_set("eg_tests") {
"//ios/chrome/app:app_internal", "//ios/chrome/app:app_internal",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/main",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/icons", "//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/location_bar", "//ios/chrome/browser/ui/location_bar",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#import "ios/chrome/app/main_controller.h" #import "ios/chrome/app/main_controller.h"
#import "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/ui/icons/chrome_icon.h" #include "ios/chrome/browser/ui/icons/chrome_icon.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_coordinator.h" #import "ios/chrome/browser/ui/location_bar/location_bar_coordinator.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_url_loader.h" #import "ios/chrome/browser/ui/location_bar/location_bar_url_loader.h"
...@@ -423,7 +424,8 @@ void TapKeyboardReturnKeyInOmniboxWithText(std::string text) { ...@@ -423,7 +424,8 @@ void TapKeyboardReturnKeyInOmniboxWithText(std::string text) {
ui::PageTransition transition) { ui::PageTransition transition) {
web::NavigationManager::WebLoadParams params(replacementURL); web::NavigationManager::WebLoadParams params(replacementURL);
params.transition_type = transition; params.transition_type = transition;
UrlLoadingServiceFactory::GetForBrowserState(self.browserState) UrlLoadingServiceFactory::GetForBrowserState(
self.browser->GetBrowserState())
->Load(UrlLoadParams::InCurrentTab(params)); ->Load(UrlLoadParams::InCurrentTab(params));
[self cancelOmniboxEdit]; [self cancelOmniboxEdit];
}; };
......
...@@ -31,6 +31,7 @@ source_set("toolbar") { ...@@ -31,6 +31,7 @@ source_set("toolbar") {
"//ios/chrome/browser/autocomplete", "//ios/chrome/browser/autocomplete",
"//ios/chrome/browser/bookmarks", "//ios/chrome/browser/bookmarks",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/main",
"//ios/chrome/browser/reading_list", "//ios/chrome/browser/reading_list",
"//ios/chrome/browser/search_engines", "//ios/chrome/browser/search_engines",
"//ios/chrome/browser/ui/bookmarks", "//ios/chrome/browser/ui/bookmarks",
......
...@@ -23,9 +23,9 @@ class WebStateList; ...@@ -23,9 +23,9 @@ class WebStateList;
@interface AdaptiveToolbarCoordinator @interface AdaptiveToolbarCoordinator
: ChromeCoordinator<SideSwipeToolbarSnapshotProviding, ToolbarCoordinatee> : ChromeCoordinator<SideSwipeToolbarSnapshotProviding, ToolbarCoordinatee>
// Initializes this Coordinator with its |browserState|. // Initializes this Coordinator with its |browser| and a nil base view
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState // controller.
NS_DESIGNATED_INITIALIZER; - (instancetype)initWithBrowser:(Browser*)browser NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController - (instancetype)initWithBaseViewController:(UIViewController*)viewController
NS_UNAVAILABLE; NS_UNAVAILABLE;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController - (instancetype)initWithBaseViewController:(UIViewController*)viewController
......
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
#pragma mark - ChromeCoordinator #pragma mark - ChromeCoordinator
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState { - (instancetype)initWithBrowser:(Browser*)browser {
return [super initWithBaseViewController:nil browserState:browserState]; return [super initWithBaseViewController:nil browser:browser];
} }
- (void)start { - (void)start {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_controller_factory.h"
...@@ -221,12 +222,11 @@ ...@@ -221,12 +222,11 @@
- (void)setUpLocationBar { - (void)setUpLocationBar {
self.locationBarCoordinator = [[LocationBarCoordinator alloc] init]; self.locationBarCoordinator = [[LocationBarCoordinator alloc] init];
self.locationBarCoordinator.browserState = self.browserState; self.locationBarCoordinator.browser = self.browser;
self.locationBarCoordinator.dispatcher = self.locationBarCoordinator.dispatcher =
base::mac::ObjCCastStrict<CommandDispatcher>(self.dispatcher); base::mac::ObjCCastStrict<CommandDispatcher>(self.dispatcher);
self.locationBarCoordinator.commandDispatcher = self.commandDispatcher; self.locationBarCoordinator.commandDispatcher = self.commandDispatcher;
self.locationBarCoordinator.delegate = self.delegate; self.locationBarCoordinator.delegate = self.delegate;
self.locationBarCoordinator.webStateList = self.webStateList;
self.locationBarCoordinator.popupPresenterDelegate = self.locationBarCoordinator.popupPresenterDelegate =
self.popupPresenterDelegate; self.popupPresenterDelegate;
[self.locationBarCoordinator start]; [self.locationBarCoordinator start];
......
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