Commit d1938285 authored by Mohammad Refaat's avatar Mohammad Refaat Committed by Commit Bot

Dont show restore prompt on openURL user activity for new window.

This fixes the problem when crash happens as there is no active webstate
when the new window opens. Also this is consistent with the behavior of
single window/multi-window when we don't show the restore prompt when
there is external intent (opening chrome from another app with url
parameter).

Bug: 1135459
Change-Id: Ia979db92f3d938f57a7b7a5f4821075a82b396fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454250
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815152}
parent b5839042
......@@ -558,6 +558,31 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
self.hasInitializedUI = YES;
}
// Returns YES if restore prompt can be shown.
// The restore prompt shouldn't appear if its appearance may be in conflict
// with the expected behavior by the user.
// The following cases will not show restore prompt:
// 1- New tab / Navigation startup parameters are specified.
// 2- Load URL User activity is queud.
// 3- Move tab user activity is queued.
// In these cases if a restore prompt was shown, it may be dismissed immediately
// and the user will not have a chance to restore the session.
- (BOOL)shouldShowRestorePrompt {
BOOL shouldShow = !self.startupParameters;
if (shouldShow && IsSceneStartupSupported()) {
if (@available(iOS 13, *)) {
for (NSUserActivity* activity in self.sceneState.connectionOptions
.userActivities) {
if (ActivityIsTabMove(activity) || ActivityIsURLLoad(activity)) {
shouldShow = NO;
break;
}
}
}
}
return shouldShow;
}
// Starts up a single chrome window and its UI.
- (void)startUpChromeUI {
DCHECK(!self.browserViewWrangler);
......@@ -616,24 +641,7 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
[self createInitialUI:(startInIncognito ? ApplicationMode::INCOGNITO
: ApplicationMode::NORMAL)];
// A pending tab move should not display the restore infobar since restoration
// will replace the moved tab.
BOOL pendingTabMove = NO;
if (IsSceneStartupSupported()) {
if (@available(iOS 13, *)) {
for (NSUserActivity* activity in self.sceneState.connectionOptions
.userActivities) {
if (ActivityIsTabMove(activity)) {
pendingTabMove = YES;
}
}
}
}
if (!self.startupParameters && !pendingTabMove) {
// The startup parameters may create new tabs or navigations. If the restore
// infobar is displayed now, it may be dismissed immediately and the user
// will never be able to restore the session.
if ([self shouldShowRestorePrompt]) {
[self.sceneState.appState.startupInformation
.restoreHelper showRestorePrompt];
self.sceneState.appState.startupInformation.restoreHelper = nil;
......
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