Commit 28a0ed1f authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[multiball] Remove sceneShowingBlockingUI property.

This property was replaced with the UI blocker abstracted in a protocol
in crrev/2288853 but it was still used in a few places, thus that CL
introduced bugs, including potentially showing sign in promo when the
blocking UI is shown, and switch-to-open-window button never working.

Remove this property and replace it by extending UIBlocking* protocols.

Bug: 1103565
Change-Id: Ib79d2968c1fe545ef5cd87cc196802ad6097345c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398684Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805270}
parent 7e458c67
...@@ -64,11 +64,6 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher ...@@ -64,11 +64,6 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
// by the app delegate. // by the app delegate.
@property(nonatomic, strong) SceneState* mainSceneState; @property(nonatomic, strong) SceneState* mainSceneState;
// When a modal UI (that requires user to interact with it before any further
// interaction with the app is allowed) is shown, this tracks the scene where it
// is shown. When there is no blocking UI shown in any scene, this is nil.
@property(nonatomic, weak, readonly) SceneState* sceneShowingBlockingUI;
// Indicates that this app launch is one after a crash. // Indicates that this app launch is one after a crash.
@property(nonatomic, assign) BOOL postCrashLaunch; @property(nonatomic, assign) BOOL postCrashLaunch;
......
...@@ -698,6 +698,10 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher ...@@ -698,6 +698,10 @@ initWithBrowserLauncher:(id<BrowserLauncher>)browserLauncher
} }
} }
- (id<UIBlockerTarget>)currentUIBlocker {
return self.uiBlockerTarget;
}
#pragma mark - Scene notifications #pragma mark - Scene notifications
// Handler for UISceneDidActivateNotification. // Handler for UISceneDidActivateNotification.
......
...@@ -1239,24 +1239,12 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1239,24 +1239,12 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
- (void)activateBlockingScene:(UIScene*)requestingScene - (void)activateBlockingScene:(UIScene*)requestingScene
API_AVAILABLE(ios(13.0)) { API_AVAILABLE(ios(13.0)) {
if (@available(iOS 13, *)) { id<UIBlockerTarget> uiBlocker = self.appState.currentUIBlocker;
UISceneActivationRequestOptions* options = if (!uiBlocker) {
[[UISceneActivationRequestOptions alloc] init]; return;
options.requestingScene = requestingScene;
UIScene* blockingScene = self.appState.sceneShowingBlockingUI.scene;
if (!blockingScene) {
return;
}
[[UIApplication sharedApplication]
requestSceneSessionActivation:blockingScene.session
userActivity:nil
options:options
errorHandler:^(NSError* error) {
LOG(ERROR) << base::SysNSStringToUTF8(
error.localizedDescription);
NOTREACHED();
}];
} }
[uiBlocker bringBlockerToFront:requestingScene];
} }
@end @end
......
...@@ -769,7 +769,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] = ...@@ -769,7 +769,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
} }
} }
// Don't show the promo if there is a blocking task in process. // Don't show the promo if there is a blocking task in process.
if (self.sceneState.appState.sceneShowingBlockingUI) if (self.sceneState.appState.currentUIBlocker)
return NO; return NO;
// Don't show the promo in Incognito mode. // Don't show the promo in Incognito mode.
if (self.currentInterface == self.incognitoInterface) if (self.currentInterface == self.incognitoInterface)
......
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
#import "ios/chrome/browser/ui/main/scene_state.h" #import "ios/chrome/browser/ui/main/scene_state.h"
#import "base/ios/crb_protocol_observers.h" #import "base/ios/crb_protocol_observers.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/app/application_delegate/app_state.h" #import "ios/chrome/app/application_delegate/app_state.h"
#import "ios/chrome/app/chrome_overlay_window.h" #import "ios/chrome/app/chrome_overlay_window.h"
#import "ios/chrome/browser/ui/main/scene_controller.h" #import "ios/chrome/browser/ui/main/scene_controller.h"
...@@ -128,10 +131,33 @@ ...@@ -128,10 +131,33 @@
[self.observers sceneState:self receivedUserActivity:pendingUserActivity]; [self.observers sceneState:self receivedUserActivity:pendingUserActivity];
} }
#pragma mark - UIBlockerTarget
- (id<UIBlockerManager>)uiBlockerManager { - (id<UIBlockerManager>)uiBlockerManager {
return _appState; return _appState;
} }
- (void)bringBlockerToFront:(UIScene*)requestingScene API_AVAILABLE(ios(13)) {
if (!IsMultipleScenesSupported()) {
return;
}
if (@available(iOS 13, *)) {
UISceneActivationRequestOptions* options =
[[UISceneActivationRequestOptions alloc] init];
options.requestingScene = requestingScene;
[[UIApplication sharedApplication]
requestSceneSessionActivation:self.scene.session
userActivity:nil
options:options
errorHandler:^(NSError* error) {
LOG(ERROR) << base::SysNSStringToUTF8(
error.localizedDescription);
NOTREACHED();
}];
}
}
#pragma mark - debug #pragma mark - debug
- (NSString*)description { - (NSString*)description {
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
// Manager in charge to block and unblock all UI. // Manager in charge to block and unblock all UI.
@protocol UIBlockerManager <NSObject> @protocol UIBlockerManager <NSObject>
// The current UI blocker, if any.
- (id<UIBlockerTarget>)currentUIBlocker;
// Call this when showing a new blocking UI in |target|. // Call this when showing a new blocking UI in |target|.
// It is an error to call this for target A when target B is already showing one // It is an error to call this for target A when target B is already showing one
// or more blocking UI. // or more blocking UI.
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
@protocol UIBlockerManager; @protocol UIBlockerManager;
@class UIScene;
// Target to block all UI. // Target to block all UI.
@protocol UIBlockerTarget <NSObject> @protocol UIBlockerTarget <NSObject>
...@@ -15,6 +16,10 @@ ...@@ -15,6 +16,10 @@
// Returns UI blocker manager. // Returns UI blocker manager.
@property(nonatomic, weak, readonly) id<UIBlockerManager> uiBlockerManager; @property(nonatomic, weak, readonly) id<UIBlockerManager> uiBlockerManager;
// Force the blocking UI to appear. Specifically, bring the blocking UI window
// forward.
- (void)bringBlockerToFront:(UIScene*)requestingScene API_AVAILABLE(ios(13));
@end @end
#endif // IOS_CHROME_BROWSER_UI_SCOPED_UI_BLOCKER_UI_BLOCKER_TARGET_H_ #endif // IOS_CHROME_BROWSER_UI_SCOPED_UI_BLOCKER_UI_BLOCKER_TARGET_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