Commit b3d5e26b authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Create SceneState and Controller in AppDelegate.

On iOS 12, and on iOS 13 with no multiwindow plist keys, iOS doesn't
create a SceneDelegate, which would normally take care of creating a
SceneState and a SceneController. Do this in AppDelegate.

Bug: none
Change-Id: Iaa3f505bbe588f75a9fe1c3728c773ba82e32162
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1789536
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700167}
parent 6ea22f56
......@@ -239,6 +239,7 @@ source_set("app_internal") {
"//ios/chrome/browser/ui/toolbar:toolbar_ui",
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/browser/ui/webui:webui_internal",
"//ios/chrome/browser/upgrade",
"//ios/chrome/browser/url_loading",
......
......@@ -4,6 +4,7 @@
#import "ios/chrome/app/main_application_delegate.h"
#include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h"
#import "ios/chrome/app/application_delegate/app_navigation.h"
#import "ios/chrome/app/application_delegate/app_state.h"
......@@ -18,6 +19,9 @@
#import "ios/chrome/app/chrome_overlay_window.h"
#import "ios/chrome/app/main_application_delegate_testing.h"
#import "ios/chrome/app/main_controller.h"
#import "ios/chrome/browser/ui/main/scene_controller.h"
#import "ios/chrome/browser/ui/main/scene_state.h"
#include "ios/chrome/browser/ui/util/multi_window_support.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
#import "ios/testing/perf/startupLoggers.h"
......@@ -47,6 +51,14 @@
id<TabSwitching> _tabSwitcherProtocol;
}
// The state representing the only "scene" on iOS 12. On iOS 13, only created
// temporarily before multiwindow is fully implemented to also represent the
// only scene.
@property(nonatomic, strong) SceneState* sceneState;
// The controller for |sceneState|.
@property(nonatomic, strong) SceneController* sceneController;
@end
@implementation MainApplicationDelegate
......@@ -66,6 +78,15 @@
_tabSwitcherProtocol = _mainController;
_appNavigation = _mainController;
[_mainController setAppState:_appState];
if (!IsMultiwindowSupported()) {
// When multiwindow is not supported, this object holds a "scene" state
// and a "scene" controller. This allows the rest of the app to be mostly
// multiwindow-agnostic.
_sceneState = [[SceneState alloc] init];
_sceneController =
[[SceneController alloc] initWithSceneState:_sceneState];
}
}
return self;
}
......
......@@ -2,6 +2,29 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//ios/build/chrome_build.gni")
buildflag_header("ios_multi_window_buildflags") {
header = "multi_window_buildflags.h"
header_dir = "ios/chrome/browser/ui/util"
flags = [ "IOS_MULTIWINDOW_ENABLED=$ios_enable_multi_window" ]
}
source_set("multiwindow_util") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"multi_window_support.h",
"multi_window_support.mm",
]
deps = [
":ios_multi_window_buildflags",
"//base",
]
}
source_set("util") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
......
// Copyright 2019 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_UTIL_MULTI_WINDOW_SUPPORT_H_
#define IOS_CHROME_BROWSER_UI_UTIL_MULTI_WINDOW_SUPPORT_H_
// Returns true if multiwindow is supported on this OS version and is enabled in
// the current build configuration. Does not check if this device can actually
// show multiple windows (e.g. on iPhone): use [UIApplication
// supportsMultipleScenes] instead.
bool IsMultiwindowSupported();
#endif // IOS_CHROME_BROWSER_UI_UTIL_MULTI_WINDOW_SUPPORT_H_
// Copyright 2019 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/util/multi_window_support.h"
#include "base/ios/ios_util.h"
#include "ios/chrome/browser/ui/util/multi_window_buildflags.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
bool IsMultiwindowSupported() {
return BUILDFLAG(IOS_MULTIWINDOW_ENABLED) &&
base::ios::IsRunningOnIOS13OrLater();
}
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