Commit 84853003 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Beginnings of tab grid mediator

Bug: 804496
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ifed54179a9f9ffb5e61f270664af35a3f86c9deb
Reviewed-on: https://chromium-review.googlesource.com/924532Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537509}
parent f344088f
......@@ -901,8 +901,11 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
if (!_mainCoordinator) {
// Lazily create the main coordinator.
if (IsTabSwitcherTabGridEnabled()) {
_mainCoordinator =
TabGridCoordinator* tabGridCoordinator =
[[TabGridCoordinator alloc] initWithWindow:self.window];
tabGridCoordinator.regularTabModel = self.mainTabModel;
tabGridCoordinator.incognitoTabModel = self.otrTabModel;
_mainCoordinator = tabGridCoordinator;
} else {
_mainCoordinator = [[MainCoordinator alloc] initWithWindow:self.window];
}
......
......@@ -10,6 +10,8 @@ source_set("tab_grid") {
"tab_grid_adaptor.mm",
"tab_grid_coordinator.h",
"tab_grid_coordinator.mm",
"tab_grid_mediator.h",
"tab_grid_mediator.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
......@@ -17,6 +19,7 @@ source_set("tab_grid") {
deps = [
":tab_grid_ui",
"//base",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/main",
"//ios/chrome/browser/ui/tab_switcher",
......
......@@ -10,12 +10,16 @@
#import "ios/chrome/browser/ui/main/main_coordinator.h"
#import "ios/chrome/browser/ui/main/view_controller_swapping.h"
@class TabModel;
@protocol TabSwitcher;
@interface TabGridCoordinator : MainCoordinator<ViewControllerSwapping>
@property(nonatomic, readonly) id<TabSwitcher> tabSwitcher;
@property(nonatomic, weak) TabModel* regularTabModel;
@property(nonatomic, weak) TabModel* incognitoTabModel;
// If this property is YES, calls to |showTabSwitcher:completion:| and
// |showTabViewController:completion:| will present the given view controllers
// without animation. This should only be used by unittests.
......
......@@ -4,9 +4,10 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_coordinator.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_adaptor.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_mediator.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -19,6 +20,8 @@
// Container view controller for the BVC to live in; this class's view
// controller will present this.
@property(nonatomic, strong) BVCContainerViewController* bvcContainer;
// Mediates between the model layer and the tab grid UI layer.
@property(nonatomic, strong) TabGridMediator* mediator;
@end
@implementation TabGridCoordinator
......@@ -26,9 +29,12 @@
@synthesize mainViewController = _mainViewController;
// Public properties.
@synthesize animationsDisabledForTesting = _animationsDisabledForTesting;
@synthesize regularTabModel = _regularTabModel;
@synthesize incognitoTabModel = _incognitoTabModel;
// Private properties.
@synthesize adaptor = _adaptor;
@synthesize bvcContainer = _bvcContainer;
@synthesize mediator = _mediator;
#pragma mark - Public properties
......@@ -51,6 +57,10 @@
self.window.rootViewController = self.mainViewController;
self.adaptor = [[TabGridAdaptor alloc] init];
self.adaptor.tabGridViewController = self.mainViewController;
self.mediator = [[TabGridMediator alloc] init];
self.mediator.regularTabModel = self.regularTabModel;
self.mediator.incognitoTabModel = self.incognitoTabModel;
}
#pragma mark - UIViewControllerTransitioningDelegate
......
// Copyright 2018 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_TAB_GRID_TAB_GRID_MEDIATOR_H_
#define IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_MEDIATOR_H_
#import <Foundation/Foundation.h>
@class TabModel;
// Mediates between model layer and tab grid UI layer.
@interface TabGridMediator : NSObject
@property(nonatomic, weak) TabModel* regularTabModel;
@property(nonatomic, weak) TabModel* incognitoTabModel;
@end
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_TAB_GRID_MEDIATOR_H_
// Copyright 2018 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/tab_grid/tab_grid_mediator.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation TabGridMediator
@synthesize regularTabModel = _regularTabModel;
@synthesize incognitoTabModel = _incognitoTabModel;
@end
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