Commit 6c33e7e9 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Make SceneDelegate create and update SceneState.

Creates SceneActivityState enum to list possible scene states and
makes the scene delegate create and update the scene state.

Bug: none
Change-Id: I45932fefcff42828a761b6d4d53fc1c034a3102e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1789524
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695117}
parent 39ad8600
......@@ -7,11 +7,16 @@
#import <UIKit/UIKit.h>
// An object acting as a scene delegate for UIKit. Updates the window state.
#import "ios/chrome/browser/ui/main/scene_state.h"
// An object acting as a scene delegate for UIKit. Updates the scene state.
@interface SceneDelegate : NSObject <UIWindowSceneDelegate>
@property(nonatomic, strong) UIWindow* window;
// The object that holds the state of the scene associated with this delegate.
@property(nonatomic, strong) SceneState* sceneState;
@end
#endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_DELEGATE_H_
......@@ -10,4 +10,46 @@
@implementation SceneDelegate
- (SceneState*)sceneState {
if (!_sceneState) {
_sceneState = [[SceneState alloc] init];
}
return _sceneState;
}
#pragma mark - UISceneDelegate
#pragma mark Connecting and Disconnecting the Scene
- (void)scene:(UIScene*)scene
willConnectToSession:(UISceneSession*)session
options:(UISceneConnectionOptions*)connectionOptions
API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelBackground;
}
- (void)sceneDidDisconnect:(UIScene*)scene API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelUnattached;
}
#pragma mark Transitioning to the Foreground
- (void)sceneWillEnterForeground:(UIScene*)scene API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelForegroundInactive;
}
- (void)sceneDidBecomeActive:(UIScene*)scene API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelForegroundActive;
}
#pragma mark Transitioning to the Background
- (void)sceneWillResignActive:(UIScene*)scene API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelForegroundInactive;
}
- (void)sceneDidEnterBackground:(UIScene*)scene API_AVAILABLE(ios(13)) {
self.sceneState.activationLevel = SceneActivationLevelBackground;
}
@end
......@@ -7,9 +7,32 @@
#import <UIKit/UIKit.h>
// Describes the possible scene states.
// This is an iOS 12 compatible version of UISceneActivationState enum.
typedef NS_ENUM(NSUInteger, SceneActivationLevel) {
// The scene is not connected and has no window.
SceneActivationLevelUnattached = 0,
// The scene is connected, and has a window associated with it. The window is
// not visible to the user, except possibly in the app switcher.
SceneActivationLevelBackground,
// The scene is connected, and its window is on screen, but it's not active
// for user input. For example, keyboard events would not be sent to this
// window.
SceneActivationLevelForegroundInactive,
// The scene is connected, has a window, and receives user events.
SceneActivationLevelForegroundActive
};
// An object containing the state of a UIWindowScene. One state object
// corresponds to one scene.
@interface SceneState : NSObject
// The current activation level.
@property(nonatomic, assign) SceneActivationLevel activationLevel;
// Window for the associated scene, if any.
@property(nonatomic, weak) UIWindow* window;
@end
#endif // IOS_CHROME_BROWSER_UI_MAIN_SCENE_STATE_H_
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