Commit 9bad137f authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS] Fix shutdown crash in BVC.

Plumbs dispatcher to BVC. Makes the browser coordinator zero it out
during shutdown before stopping child coordinators to avoid a crash.

Bug: 1137686
Test: No repro steps available.
Change-Id: Ica001018459d3667c53f010487292ffae774d8ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2471737Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817453}
parent 5d42411a
......@@ -123,7 +123,8 @@ void PerfTestWithBVC::SetUp() {
initWithBrowser:browser_.get()
dependencyFactory:bvc_factory_
browserContainerViewController:[[BrowserContainerViewController alloc]
init]];
init]
dispatcher:browser_->GetCommandDispatcher()];
[bvc_ setActive:YES];
// Create a real window to give to the browser view controller.
......
......@@ -242,6 +242,7 @@
[self removeWebStateListObserver];
[self uninstallDelegatesForBrowser];
[self uninstallDelegatesForAllWebStates];
self.viewController.commandDispatcher = nil;
[self.dispatcher stopDispatchingToTarget:self];
[self stopChildCoordinators];
[self destroyViewController];
......@@ -305,7 +306,8 @@
initWithBrowser:self.browser
dependencyFactory:factory
browserContainerViewController:self.browserContainerCoordinator
.viewController];
.viewController
dispatcher:self.dispatcher];
}
// Shuts down the BrowserViewController.
......
......@@ -20,6 +20,7 @@
class Browser;
@class BrowserContainerViewController;
@class BrowserViewControllerDependencyFactory;
@class CommandDispatcher;
@class ToolbarAccessoryPresenter;
// The top-level view controller for the browser UI. Manages other controllers
......@@ -42,6 +43,7 @@ class Browser;
(BrowserViewControllerDependencyFactory*)factory
browserContainerViewController:
(BrowserContainerViewController*)browserContainerViewController
dispatcher:(CommandDispatcher*)dispatcher
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
......@@ -49,6 +51,9 @@ class Browser;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
// Command dispatcher.
@property(nonatomic, weak) CommandDispatcher* commandDispatcher;
// Returns whether or not text to speech is playing.
@property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS;
......
......@@ -480,8 +480,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
BrowserContainerViewController* browserContainerViewController;
// Invisible button used to dismiss the keyboard.
@property(nonatomic, strong) UIButton* typingShield;
// Command dispatcher.
@property(nonatomic, weak) CommandDispatcher* commandDispatcher;
// The browser's side swipe controller. Lazily instantiated on the first call.
@property(nonatomic, strong, readonly) SideSwipeController* sideSwipeController;
// The object that manages keyboard commands on behalf of the BVC.
......@@ -717,14 +715,15 @@ NSString* const kBrowserViewControllerSnackbarCategory =
dependencyFactory:
(BrowserViewControllerDependencyFactory*)factory
browserContainerViewController:
(BrowserContainerViewController*)browserContainerViewController {
(BrowserContainerViewController*)browserContainerViewController
dispatcher:(CommandDispatcher*)dispatcher {
self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()];
if (self) {
DCHECK(factory);
_commandDispatcher = dispatcher;
_browserContainerViewController = browserContainerViewController;
_dependencyFactory = factory;
self.commandDispatcher = browser->GetCommandDispatcher();
self.textZoomHandler =
HandlerForProtocol(self.commandDispatcher, TextZoomCommands);
[self.commandDispatcher
......
......@@ -164,9 +164,11 @@ class BrowserViewControllerTest : public BlockCleanupTest {
std::make_unique<FakeClipboardRecentContent>());
container_ = [[BrowserContainerViewController alloc] init];
bvc_ = [[BrowserViewController alloc] initWithBrowser:browser_.get()
dependencyFactory:factory
browserContainerViewController:container_];
bvc_ = [[BrowserViewController alloc]
initWithBrowser:browser_.get()
dependencyFactory:factory
browserContainerViewController:container_
dispatcher:browser_->GetCommandDispatcher()];
// Force the view to load.
UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectZero];
......
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