Skip to content

Commit

Permalink
[ios] Do not open an NTP when moving a tab to an empty window
Browse files Browse the repository at this point in the history
An NTP is normally created for a new empty window. However, this
is not necessary when dragging and dropping a tab into a new
window.

Bug: 1132293
Change-Id: I720979235fdb447a5270f81a4b0c8451343ce773
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438941
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: Mark Cogan <marq@chromium.org>
Auto-Submit: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812687}
  • Loading branch information
edx246 authored and Commit Bot committed Oct 1, 2020
1 parent 3ed3884 commit 8bf9a42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 6 additions & 2 deletions ios/chrome/browser/main/browser_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ void MoveTabToBrowser(NSString* tab_id,
MoveSnapshot(tab_id, source_browser, destination_browser);
std::unique_ptr<web::WebState> web_state =
source_browser->GetWebStateList()->DetachWebStateAt(source_tab_index);
int insertion_flags = WebStateList::INSERT_FORCE_INDEX;
if (destination_browser->GetWebStateList()->empty()) {
insertion_flags = WebStateList::INSERT_ACTIVATE;
}
destination_browser->GetWebStateList()->InsertWebState(
destination_tab_index, std::move(web_state),
WebStateList::INSERT_FORCE_INDEX, WebStateOpener());
destination_tab_index, std::move(web_state), insertion_flags,
WebStateOpener());
}
18 changes: 16 additions & 2 deletions ios/chrome/browser/ui/main/scene_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,21 @@ - (void)startUpChromeUI {
[self createInitialUI:(startInIncognito ? ApplicationMode::INCOGNITO
: ApplicationMode::NORMAL)];

if (!self.startupParameters) {
// 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.
Expand Down Expand Up @@ -1593,7 +1607,7 @@ - (BOOL)shouldOpenNTPTabOnActivationOfBrowser:(Browser*)browser {
if (@available(iOS 13, *)) {
for (NSUserActivity* activity in self.sceneState.connectionOptions
.userActivities) {
if (ActivityIsURLLoad(activity)) {
if (ActivityIsURLLoad(activity) || ActivityIsTabMove(activity)) {
return NO;
}
}
Expand Down

0 comments on commit 8bf9a42

Please sign in to comment.