Commit 5a6e3d0b authored by edchin's avatar edchin Committed by Commit Bot

[ios] [BVC refactor] Move -setActive: to coordinator

This CL moves the method -setActive: to the coordinator layer since
it deals with many child coordinators.

Change-Id: I8e61ece1380169ffc10e9e00bccaa68dbde7d4d4
Reviewed-on: https://chromium-review.googlesource.com/c/1355924Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613219}
parent 40695472
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h" #import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/main/browser_coordinator.h"
#import "ios/chrome/browser/ui/main/browser_view_information.h" #import "ios/chrome/browser/ui/main/browser_view_information.h"
#import "ios/chrome/browser/ui/safe_mode/safe_mode_coordinator.h" #import "ios/chrome/browser/ui/safe_mode/safe_mode_coordinator.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
...@@ -402,7 +403,8 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher ...@@ -402,7 +403,8 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
if ([_browserLauncher browserInitializationStage] >= if ([_browserLauncher browserInitializationStage] >=
INITIALIZATION_STAGE_FOREGROUND) { INITIALIZATION_STAGE_FOREGROUND) {
[[_browserLauncher browserViewInformation] haltAllTabs]; [[_browserLauncher browserViewInformation] haltAllTabs];
[_browserLauncher browserViewInformation].currentBVC.active = NO; _browserLauncher.browserViewInformation.currentBrowserCoordinator.active =
NO;
} }
// TODO(crbug.com/585700): remove this. // TODO(crbug.com/585700): remove this.
......
...@@ -885,8 +885,8 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -885,8 +885,8 @@ enum class ShowTabSwitcherSnapshotResult {
if (browsingDataRemover && browsingDataRemover->IsRemoving()) if (browsingDataRemover && browsingDataRemover->IsRemoving())
return; return;
[self.mainBVC setActive:YES]; [self.mainBrowserCoordinator setActive:YES];
[self.otrBVC setActive:YES]; [self.incognitoBrowserCoordinator setActive:YES];
[self.currentBVC setPrimary:YES]; [self.currentBVC setPrimary:YES];
} }
...@@ -2163,8 +2163,8 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -2163,8 +2163,8 @@ enum class ShowTabSwitcherSnapshotResult {
// Disables browsing and purges web views. // Disables browsing and purges web views.
// Must be called only on the main thread. // Must be called only on the main thread.
DCHECK([NSThread isMainThread]); DCHECK([NSThread isMainThread]);
[self.mainBVC setActive:NO]; [self.mainBrowserCoordinator setActive:NO];
[self.otrBVC setActive:NO]; [self.incognitoBrowserCoordinator setActive:NO];
} }
BrowsingDataRemoverFactory::GetForBrowserState(browserState) BrowsingDataRemoverFactory::GetForBrowserState(browserState)
...@@ -2172,8 +2172,8 @@ enum class ShowTabSwitcherSnapshotResult { ...@@ -2172,8 +2172,8 @@ enum class ShowTabSwitcherSnapshotResult {
// Activates browsing and enables web views. // Activates browsing and enables web views.
// Must be called only on the main thread. // Must be called only on the main thread.
DCHECK([NSThread isMainThread]); DCHECK([NSThread isMainThread]);
[self.mainBVC setActive:YES]; [self.mainBrowserCoordinator setActive:YES];
[self.otrBVC setActive:YES]; [self.incognitoBrowserCoordinator setActive:YES];
[self.currentBVC setPrimary:YES]; [self.currentBVC setPrimary:YES];
if (completionBlock) if (completionBlock)
......
...@@ -24,6 +24,12 @@ ...@@ -24,6 +24,12 @@
// The model. // The model.
@property(nonatomic, weak) TabModel* tabModel; @property(nonatomic, weak) TabModel* tabModel;
// Activates/deactivates the object. This will enable/disable the ability for
// this object to browse, and to have live UIWebViews associated with it. While
// not active, the UI will not react to changes in the tab model, so generally
// an inactive BVC should not be visible.
@property(nonatomic, assign, getter=isActive) BOOL active;
// Clears any presented state on BVC. // Clears any presented state on BVC.
- (void)clearPresentedStateWithCompletion:(ProceduralBlock)completion - (void)clearPresentedStateWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox; dismissOmnibox:(BOOL)dismissOmnibox;
......
...@@ -140,6 +140,16 @@ ...@@ -140,6 +140,16 @@
#pragma mark - Public #pragma mark - Public
- (void)setActive:(BOOL)active {
DCHECK_EQ(_active, self.viewController.active);
if (_active == active) {
return;
}
_active = active;
self.viewController.active = active;
}
- (void)clearPresentedStateWithCompletion:(ProceduralBlock)completion - (void)clearPresentedStateWithCompletion:(ProceduralBlock)completion
dismissOmnibox:(BOOL)dismissOmnibox { dismissOmnibox:(BOOL)dismissOmnibox {
[self.passKitCoordinator stop]; [self.passKitCoordinator stop];
......
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