blob: 67761267c3165ae194c11808ca1fdcd9503dcdd3 [file] [log] [blame]
// Copyright 2021 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/start_surface/start_surface_scene_agent.h"
#import "ios/chrome/browser/ui/start_surface/start_surface_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@interface StartSurfaceSceneAgent ()
// Caches the previous activation level.
@property(nonatomic, assign) SceneActivationLevel previousActivationLevel;
@implementation StartSurfaceSceneAgent
- (id)init {
self = [super init];
if (self) {
self.previousActivationLevel = SceneActivationLevelUnattached;
return self;
#pragma mark - SceneStateObserver
- (void)sceneState:(SceneState*)sceneState
transitionedToActivationLevel:(SceneActivationLevel)level {
if (level != SceneActivationLevelForegroundActive &&
self.previousActivationLevel == SceneActivationLevelForegroundActive) {
// TODO( Consider when to clear the session object since
// Chrome may be closed without transiting to inactive, e.g. device power
// off, then the previous session object is staled.
self.previousActivationLevel = level;