Commit a74ce2c2 authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

Handle OpenURLs when application is already active

Change-Id: Ice70e2f999ce75c0f7c931c321bd2a6a1938248e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218177
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774073}
parent 9576758b
...@@ -346,6 +346,21 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -346,6 +346,21 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
} }
} }
- (void)sceneState:(SceneState*)sceneState
hasPendingURLs:(NSSet<UIOpenURLContext*>*)URLContexts
API_AVAILABLE(ios(13)) {
if (URLContexts &&
sceneState.activationLevel == SceneActivationLevelForegroundActive) {
// It is necessary to reset the URLContextsToOpen after opening them.
// Handle the opening asynchronously to avoid interfering with potential
// other observers.
dispatch_async(dispatch_get_main_queue(), ^{
[self openURLContexts:sceneState.URLContextsToOpen];
self.sceneState.URLContextsToOpen = nil;
});
}
}
#pragma mark - AppStateObserver #pragma mark - AppStateObserver
- (void)appStateDidExitSafeMode:(AppState*)appState { - (void)appStateDidExitSafeMode:(AppState*)appState {
......
...@@ -41,6 +41,10 @@ typedef NS_ENUM(NSUInteger, SceneActivationLevel) { ...@@ -41,6 +41,10 @@ typedef NS_ENUM(NSUInteger, SceneActivationLevel) {
- (void)sceneStateWillShowModalOverlay:(SceneState*)sceneState; - (void)sceneStateWillShowModalOverlay:(SceneState*)sceneState;
// Notifies when presentingModalOverlay is being set to false. // Notifies when presentingModalOverlay is being set to false.
- (void)sceneStateWillHideModalOverlay:(SceneState*)sceneState; - (void)sceneStateWillHideModalOverlay:(SceneState*)sceneState;
// Notifies when URLContexts have been added to |URLContextsToOpen|.
- (void)sceneState:(SceneState*)sceneState
hasPendingURLs:(NSSet<UIOpenURLContext*>*)URLContexts
API_AVAILABLE(ios(13));
@end @end
...@@ -85,6 +89,8 @@ typedef NS_ENUM(NSUInteger, SceneActivationLevel) { ...@@ -85,6 +89,8 @@ typedef NS_ENUM(NSUInteger, SceneActivationLevel) {
// URLs passed to |UIWindowSceneDelegate scene:openURLContexts:| that needs to // URLs passed to |UIWindowSceneDelegate scene:openURLContexts:| that needs to
// be open next time the scene is activated. // be open next time the scene is activated.
// Setting the property to not nil will add the new URL contexts to the set.
// Setting the property to nil will clear the set.
@property(nonatomic) @property(nonatomic)
NSSet<UIOpenURLContext*>* URLContextsToOpen API_AVAILABLE(ios(13)); NSSet<UIOpenURLContext*>* URLContextsToOpen API_AVAILABLE(ios(13));
......
...@@ -112,6 +112,18 @@ ...@@ -112,6 +112,18 @@
_presentingModalOverlay = presentingModalOverlay; _presentingModalOverlay = presentingModalOverlay;
} }
- (void)setURLContextsToOpen:(NSSet<UIOpenURLContext*>*)URLContextsToOpen {
if (_URLContextsToOpen == nil || URLContextsToOpen == nil) {
_URLContextsToOpen = URLContextsToOpen;
} else {
_URLContextsToOpen =
[_URLContextsToOpen setByAddingObjectsFromSet:URLContextsToOpen];
}
if (_URLContextsToOpen) {
[self.observers sceneState:self hasPendingURLs:_URLContextsToOpen];
}
}
#pragma mark - debug #pragma mark - debug
- (NSString*)description { - (NSString*)description {
......
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