Commit 60dc7fa7 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Move ApplicationCommands to SceneController.

Introduces a temporary interface connecting the Scene and the Main
controllers, and exposes a bunch of internals of MainController through
a MainControllerGuts protocol (obviously temporary).

Uses this interface to implement ApplicationCommands in SceneController
and updates the use of the commands endpoint to be SceneController.

Note also:
- Updates a bunch of ivar use in MainController to properties.
- Moves a Deferred Initialization constant to a shared file as it's
used in both SceneCtrl and MainCtrl. It seems like this is semantically
correct for it to be used in both places, so it probably is a permanent
change.
- Removes a DCHECK(_localStatePrefObserverBridge) in
showSettingsFromViewController, as keeping it would mean exposing MainController->_localStatePrefObserverBridge to SceneController.

Bug: None
Change-Id: Idd45bc0850eaabca068e59e3843d901c9a0c780b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845976
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709497}
parent f81687c7
......@@ -9,6 +9,9 @@
#include "base/ios/block_types.h"
// Constants for deferred initialization of preferences observer.
extern NSString* const kPrefObserverInit;
// A singleton object to run initialization code asynchronously. Blocks are
// scheduled to be run after a delay. The block is named when added to the
// singleton so that other code can force a deferred block to be run
......
......@@ -13,6 +13,8 @@
#error "This file requires ARC support."
#endif
NSString* const kPrefObserverInit = @"PrefObserverInit";
// An object encapsulating the deferred execution of a block of initialization
// code.
@interface DeferredInitializationBlock : NSObject
......
......@@ -86,6 +86,10 @@
_sceneState = [[SceneState alloc] init];
_sceneController =
[[SceneController alloc] initWithSceneState:_sceneState];
// This is temporary plumbing that's not supposed to be here.
_sceneController.mainController = (id<MainControllerGuts>)_mainController;
_mainController.sceneController = _sceneController;
}
}
return self;
......@@ -117,8 +121,14 @@
BOOL inBackground =
[application applicationState] == UIApplicationStateBackground;
return [_appState requiresHandlingAfterLaunchWithOptions:launchOptions
stateBackground:inBackground];
BOOL requiresHandling =
[_appState requiresHandlingAfterLaunchWithOptions:launchOptions
stateBackground:inBackground];
if (!IsMultiwindowSupported()) {
self.sceneState.activationLevel = SceneActivationLevelForegroundInactive;
}
return requiresHandling;
}
- (void)applicationDidBecomeActive:(UIApplication*)application {
......@@ -152,10 +162,10 @@
self.sceneState.activationLevel = SceneActivationLevelBackground;
}
[_appState
applicationDidEnterBackground:application
memoryHelper:_memoryHelper
incognitoContentVisible:_mainController.incognitoContentVisible];
[_appState applicationDidEnterBackground:application
memoryHelper:_memoryHelper
incognitoContentVisible:self.sceneController
.incognitoContentVisible];
}
// Called when returning to the foreground.
......
......@@ -24,8 +24,7 @@
//
// By design, it has no public API of its own. Anything interacting with
// MainController should be doing so through a specific protocol.
@interface MainController : NSObject <ApplicationCommands,
AppNavigation,
@interface MainController : NSObject <AppNavigation,
BrowserLauncher,
MainControllerGuts,
StartupInformation,
......@@ -43,9 +42,8 @@
// to the user preferences.
@property(nonatomic, weak) MetricsMediator* metricsMediator;
// Returns whether the app is showing or partially showing the
// incognito panel.
@property(nonatomic, assign, readonly) BOOL incognitoContentVisible;
// For temporary plumbing only.
@property(nonatomic, weak) id<ApplicationCommands> sceneController;
@end
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/public/provider/chrome/browser/user_feedback/user_feedback_provider.h"
@class BrowserViewController;
@class HistoryCoordinator;
@class SigninInteractionCoordinator;
@class TabGridCoordinator;
......
......@@ -80,7 +80,7 @@ bool OpenNewIncognitoTabUsingUIAndEvictMainTabs() {
bool RemoveBrowsingCacheForMainTabs() {
__block BOOL caches_cleared = NO;
[chrome_test_util::GetMainController()
[chrome_test_util::GetMainController().sceneController
removeBrowsingDataForBrowserState:chrome_test_util::
GetOriginalBrowserState()
timePeriod:browsing_data::TimePeriod::ALL_TIME
......
......@@ -18,10 +18,22 @@ source_set("scene") {
deps = [
":main",
"//base",
"//ios/chrome/app:app",
"//ios/chrome/app/application_delegate:application_delegate_internal",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/browsing_data",
"//ios/chrome/browser/browsing_data",
"//ios/chrome/browser/snapshots",
"//ios/chrome/browser/tabs:tabs",
"//ios/chrome/browser/ui/browser_view",
"//ios/chrome/browser/ui/commands:commands",
"//ios/chrome/browser/ui/history",
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/signin_interaction",
"//ios/chrome/browser/ui/tab_grid",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/browser/url_loading",
"//ios/chrome/browser/web_state_list",
]
libs = [ "UIKit.framework" ]
......
......@@ -7,10 +7,13 @@
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/main/scene_state.h"
@protocol MainControllerGuts;
// The controller object for a scene. Reacts to scene state changes.
@interface SceneController : NSObject <SceneStateObserver>
@interface SceneController : NSObject <SceneStateObserver, ApplicationCommands>
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithSceneState:(SceneState*)sceneState
......@@ -19,6 +22,13 @@
// The state of the scene controlled by this object.
@property(nonatomic, weak, readonly) SceneState* sceneState;
// Returns whether the scene is showing or partially showing the
// incognito panel.
@property(nonatomic, assign, readonly) BOOL incognitoContentVisible;
// A temporary pointer to MainController.
@property(nonatomic, weak) id<MainControllerGuts> mainController;
@end
#endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_CONTROLLER_H_
......@@ -79,7 +79,7 @@ void TapOnPrimarySignInButtonInRecentTabs() {
// Removes all browsing data.
void RemoveBrowsingData() {
__block BOOL browsing_data_removed = NO;
[chrome_test_util::GetMainController()
[chrome_test_util::GetMainController().sceneController
removeBrowsingDataForBrowserState:chrome_test_util::
GetOriginalBrowserState()
timePeriod:browsing_data::TimePeriod::ALL_TIME
......
......@@ -32,7 +32,7 @@ bool ClearBrowsingData(bool off_the_record, BrowsingDataRemoveMask mask) {
: chrome_test_util::GetOriginalBrowserState();
__block bool did_complete = false;
[chrome_test_util::GetMainController()
[chrome_test_util::GetMainController().sceneController
removeBrowsingDataForBrowserState:browser_state
timePeriod:browsing_data::TimePeriod::ALL_TIME
removeMask:mask
......
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