Commit e470d005 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Create BrowserContainerCoordinator.

This coordinator manages the BrowserContainerViewController, which
displays the main web page content view.  This is in preparation for
a new fullscreen implementation experiment where the container will
conform to FullscreenUIElement.  The coordinator can setup and tear
down FullscreenUIUpdaters for the BrowserContainerViewController upon
starting/stopping.

Bug: 836400
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I4054c279dcabe2a8f88ebb769ae40d1d15f07b67
Reviewed-on: https://chromium-review.googlesource.com/1026564Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553864}
parent a2f44cbe
...@@ -99,7 +99,6 @@ source_set("unit_tests") { ...@@ -99,7 +99,6 @@ source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
"browser_container_view_controller_unittest.mm",
"browser_view_controller_helper_unittest.mm", "browser_view_controller_helper_unittest.mm",
"browser_view_controller_unittest.mm", "browser_view_controller_unittest.mm",
"chrome_web_view_factory_unittest.mm", "chrome_web_view_factory_unittest.mm",
...@@ -263,8 +262,6 @@ source_set("external_files") { ...@@ -263,8 +262,6 @@ source_set("external_files") {
source_set("ui_internal") { source_set("ui_internal") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"browser_container_view_controller.h",
"browser_container_view_controller.mm",
"browser_view_controller.h", "browser_view_controller.h",
"browser_view_controller.mm", "browser_view_controller.mm",
"browser_view_controller_dependency_factory.h", "browser_view_controller_dependency_factory.h",
...@@ -352,6 +349,8 @@ source_set("ui_internal") { ...@@ -352,6 +349,8 @@ source_set("ui_internal") {
"//ios/chrome/browser/ui/app_launcher", "//ios/chrome/browser/ui/app_launcher",
"//ios/chrome/browser/ui/authentication", "//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/bookmarks", "//ios/chrome/browser/ui/bookmarks",
"//ios/chrome/browser/ui/browser_container",
"//ios/chrome/browser/ui/browser_container:ui",
"//ios/chrome/browser/ui/bubble", "//ios/chrome/browser/ui/bubble",
"//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
......
# 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.
source_set("browser_container") {
sources = [
"browser_container_coordinator.h",
"browser_container_coordinator.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":ui",
"//base",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
]
}
source_set("ui") {
sources = [
"browser_container_view_controller.h",
"browser_container_view_controller.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
"//base",
"//ios/chrome/browser/ui/fullscreen:ui",
"//ios/chrome/browser/ui/util",
]
}
source_set("unit_tests") {
testonly = true
sources = [
"browser_container_view_controller_unittest.mm",
]
configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":ui",
"//base",
"//testing/gtest",
]
}
eugenebut@chromium.org
kkhorimoto@chromium.org
// 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_BROWSER_CONTAINER_BROWSER_CONTAINER_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_BROWSER_CONTAINER_COORDINATOR_H_
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
#import <UIKit/UIKit.h>
@class BrowserContainerViewController;
// A coordinator that creates a container UIViewController that displays the
// web contents of the browser view.
@interface BrowserContainerCoordinator : ChromeCoordinator
// The view controller managing the container view.
@property(nonatomic, strong, readonly)
BrowserContainerViewController* viewController;
@end
#endif // IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_BROWSER_CONTAINER_COORDINATOR_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/browser_container/browser_container_coordinator.h"
#import "base/logging.h"
#import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation BrowserContainerCoordinator
@synthesize viewController = _viewController;
#pragma mark - ChromeCoordinator
- (void)start {
DCHECK(self.browserState);
DCHECK(!_viewController);
_viewController = [[BrowserContainerViewController alloc] init];
[super start];
}
- (void)stop {
_viewController = nil;
[super stop];
}
@end
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_VIEW_CONTROLLER_H_ #ifndef IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_BROWSER_CONTAINER_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_VIEW_CONTROLLER_H_ #define IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_BROWSER_CONTAINER_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
@end @end
#endif // IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_BROWSER_CONTAINER_BROWSER_CONTAINER_VIEW_CONTROLLER_H_
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/browser_container_view_controller.h" #import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h"
#include "base/logging.h" #include "base/logging.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -31,6 +30,8 @@ ...@@ -31,6 +30,8 @@
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
} }
#pragma mark - Public
- (void)displayContentView:(UIView*)contentView { - (void)displayContentView:(UIView*)contentView {
if (_contentView == contentView) if (_contentView == contentView)
return; return;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/browser_container_view_controller.h" #import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
......
...@@ -120,7 +120,8 @@ ...@@ -120,7 +120,8 @@
#import "ios/chrome/browser/ui/background_generator.h" #import "ios/chrome/browser/ui/background_generator.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h"
#include "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h" #include "ios/chrome/browser/ui/bookmarks/bookmark_model_bridge_observer.h"
#import "ios/chrome/browser/ui/browser_container_view_controller.h" #import "ios/chrome/browser/ui/browser_container/browser_container_coordinator.h"
#import "ios/chrome/browser/ui/browser_container/browser_container_view_controller.h"
#import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
#import "ios/chrome/browser/ui/browser_view_controller_helper.h" #import "ios/chrome/browser/ui/browser_view_controller_helper.h"
#import "ios/chrome/browser/ui/bubble/bubble_util.h" #import "ios/chrome/browser/ui/bubble/bubble_util.h"
...@@ -616,8 +617,8 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -616,8 +617,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// or not. // or not.
BOOL _insertedTabWasPrerenderedTab; BOOL _insertedTabWasPrerenderedTab;
// View Controller for container view. // The coordinator managing the container view controller.
BrowserContainerViewController* _browserContainerViewController; BrowserContainerCoordinator* _browserContainerCoordinator;
} }
// The browser's side swipe controller. Lazily instantiated on the first call. // The browser's side swipe controller. Lazily instantiated on the first call.
...@@ -1081,7 +1082,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1081,7 +1082,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
} }
- (UIView*)contentArea { - (UIView*)contentArea {
return _browserContainerViewController.view; return _browserContainerCoordinator.viewController.view;
} }
- (void)setActive:(BOOL)active { - (void)setActive:(BOOL)active {
...@@ -1623,9 +1624,13 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1623,9 +1624,13 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// The WebView is overflowing its bounds to be displayed below the toolbars. // The WebView is overflowing its bounds to be displayed below the toolbars.
self.view.clipsToBounds = YES; self.view.clipsToBounds = YES;
_browserContainerViewController = _browserContainerCoordinator = [[BrowserContainerCoordinator alloc]
[[BrowserContainerViewController alloc] init]; initWithBaseViewController:self
[self addChildViewController:_browserContainerViewController]; browserState:self.browserState];
[_browserContainerCoordinator start];
UIViewController* containerViewController =
_browserContainerCoordinator.viewController;
[self addChildViewController:containerViewController];
self.contentArea.frame = initialViewsRect; self.contentArea.frame = initialViewsRect;
self.typingShield = [[UIButton alloc] initWithFrame:initialViewsRect]; self.typingShield = [[UIButton alloc] initWithFrame:initialViewsRect];
self.typingShield.autoresizingMask = initialViewAutoresizing; self.typingShield.autoresizingMask = initialViewAutoresizing;
...@@ -1638,7 +1643,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1638,7 +1643,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
self.view.autoresizingMask = initialViewAutoresizing; self.view.autoresizingMask = initialViewAutoresizing;
self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0]; self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0];
[self.view addSubview:self.contentArea]; [self.view addSubview:self.contentArea];
[_browserContainerViewController didMoveToParentViewController:self]; [containerViewController didMoveToParentViewController:self];
[self.view addSubview:self.typingShield]; [self.view addSubview:self.typingShield];
[super viewDidLoad]; [super viewDidLoad];
...@@ -1761,7 +1766,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -1761,7 +1766,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
if (![self isViewLoaded]) { if (![self isViewLoaded]) {
// Do not release |_infoBarContainer|, as this must have the same lifecycle // Do not release |_infoBarContainer|, as this must have the same lifecycle
// as the BrowserViewController. // as the BrowserViewController.
_browserContainerViewController = nil; [_browserContainerCoordinator stop];
_browserContainerCoordinator = nil;
self.typingShield = nil; self.typingShield = nil;
if (_voiceSearchController) if (_voiceSearchController)
_voiceSearchController->SetDelegate(nil); _voiceSearchController->SetDelegate(nil);
...@@ -2399,7 +2405,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint { ...@@ -2399,7 +2405,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
// Make new content visible, resizing it first as the orientation may // Make new content visible, resizing it first as the orientation may
// have changed from the last time it was displayed. // have changed from the last time it was displayed.
tab.view.frame = self.contentArea.bounds; tab.view.frame = self.contentArea.bounds;
[_browserContainerViewController displayContentView:tab.view]; [_browserContainerCoordinator.viewController displayContentView:tab.view];
} }
[self updateToolbar]; [self updateToolbar];
...@@ -3845,7 +3851,7 @@ bubblePresenterForFeature:(const base::Feature&)feature ...@@ -3845,7 +3851,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
browserState:_browserState browserState:_browserState
toolbarDelegate:self.toolbarInterface toolbarDelegate:self.toolbarInterface
tabModel:_model tabModel:_model
parentViewController:_browserContainerViewController parentViewController:_browserContainerCoordinator.viewController
dispatcher:self.dispatcher dispatcher:self.dispatcher
safeAreaInset:safeAreaInset]; safeAreaInset:safeAreaInset];
pageController.swipeRecognizerProvider = self.sideSwipeController; pageController.swipeRecognizerProvider = self.sideSwipeController;
...@@ -5237,7 +5243,7 @@ bubblePresenterForFeature:(const base::Feature&)feature ...@@ -5237,7 +5243,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
- (void)tabModel:(TabModel*)model willRemoveTab:(Tab*)tab { - (void)tabModel:(TabModel*)model willRemoveTab:(Tab*)tab {
if (tab == [model currentTab]) { if (tab == [model currentTab]) {
[_browserContainerViewController displayContentView:nil]; [_browserContainerCoordinator.viewController displayContentView:nil];
} }
[_paymentRequestManager stopTrackingWebState:tab.webState]; [_paymentRequestManager stopTrackingWebState:tab.webState];
......
...@@ -176,6 +176,7 @@ test("ios_chrome_unittests") { ...@@ -176,6 +176,7 @@ test("ios_chrome_unittests") {
"//ios/chrome/browser/ui/bookmarks:unit_tests", "//ios/chrome/browser/ui/bookmarks:unit_tests",
"//ios/chrome/browser/ui/bookmarks/cells:unit_tests", "//ios/chrome/browser/ui/bookmarks/cells:unit_tests",
"//ios/chrome/browser/ui/broadcaster:unit_tests", "//ios/chrome/browser/ui/broadcaster:unit_tests",
"//ios/chrome/browser/ui/browser_container:unit_tests",
"//ios/chrome/browser/ui/browser_list:unit_tests", "//ios/chrome/browser/ui/browser_list:unit_tests",
"//ios/chrome/browser/ui/bubble:unit_tests", "//ios/chrome/browser/ui/bubble:unit_tests",
"//ios/chrome/browser/ui/collection_view:unit_tests", "//ios/chrome/browser/ui/collection_view:unit_tests",
......
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