Commit 3a42ed0d authored by Sebastien Lalancette's avatar Sebastien Lalancette Committed by Commit Bot

[iOS] Fix Tab Grid Recent Tabs Open in New Tab

The issue:
Triggering "Open in New Tab" from the tab grid recent tabs' context menu
did not navigate the user to that tab. The tab count was incremented,
but it was hard to tell from the UI that something happened.

The fix:
Navigate the user to the new tab.

Other fix:
- Added a similar solution for incognito. The issue didn't happen in
  incognito, but I found it awkward to not have a similar approach.

Bug: 1093302
Change-Id: I0513a1195b768bfaa802788443f411b8a24879c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359557Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Sebastien Lalancette <seblalancette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799130}
parent de95c6cd
...@@ -180,14 +180,17 @@ ...@@ -180,14 +180,17 @@
} }
- (void)dismissRecentTabs { - (void)dismissRecentTabs {
// Stopping this coordinator reveals the tab UI underneath.
self.completion = nil; self.completion = nil;
[self stop]; [self stop];
} }
- (void)showActiveRegularTabFromRecentTabs { - (void)showActiveRegularTabFromRecentTabs {
// Stopping this coordinator reveals the tab UI underneath. [self dismissRecentTabs];
self.completion = nil; }
[self stop];
- (void)showActiveIncognitoTabFromRecentTabs {
[self dismissRecentTabs];
} }
- (void)showHistoryFromRecentTabs { - (void)showHistoryFromRecentTabs {
......
...@@ -75,21 +75,23 @@ ...@@ -75,21 +75,23 @@
[[NSMutableArray alloc] init]; [[NSMutableArray alloc] init];
[menuElements [menuElements
addObject:[actionFactory addObject:
actionToOpenInNewTabWithURL:item.URL [actionFactory
completion:^{ actionToOpenInNewTabWithURL:item.URL
[self.recentTabsPresentationDelegate completion:^{
dismissRecentTabs]; [strongSelf.recentTabsPresentationDelegate
}]]; showActiveRegularTabFromRecentTabs];
}]];
ProceduralBlock incognitoCompletion = ^{
[strongSelf.recentTabsPresentationDelegate
showActiveIncognitoTabFromRecentTabs];
};
[menuElements [menuElements
addObject: addObject:
[actionFactory [actionFactory
actionToOpenInNewIncognitoTabWithURL:item.URL actionToOpenInNewIncognitoTabWithURL:item.URL
completion:^{ completion:incognitoCompletion]];
[self.recentTabsPresentationDelegate
dismissRecentTabs];
}]];
if (IsMultipleScenesSupported()) { if (IsMultipleScenesSupported()) {
[menuElements [menuElements
...@@ -98,8 +100,9 @@ ...@@ -98,8 +100,9 @@
actionToOpenInNewWindowWithURL:item.URL actionToOpenInNewWindowWithURL:item.URL
activityOrigin:WindowActivityRecentTabsOrigin activityOrigin:WindowActivityRecentTabsOrigin
completion:^{ completion:^{
[self.recentTabsPresentationDelegate [strongSelf
dismissRecentTabs]; .recentTabsPresentationDelegate
dismissRecentTabs];
}]]; }]];
} }
...@@ -133,11 +136,13 @@ ...@@ -133,11 +136,13 @@
return [UIMenu menuWithTitle:@"" children:@[]]; return [UIMenu menuWithTitle:@"" children:@[]];
} }
RecentTabsContextMenuHelper* strongSelf = weakSelf;
// Record that this context menu was shown to the user. // Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::kRecentTabsHeader); RecordMenuShown(MenuScenario::kRecentTabsHeader);
ActionFactory* actionFactory = [[ActionFactory alloc] ActionFactory* actionFactory = [[ActionFactory alloc]
initWithBrowser:self.browser initWithBrowser:strongSelf.browser
scenario:MenuScenario::kRecentTabsHeader]; scenario:MenuScenario::kRecentTabsHeader];
NSMutableArray<UIMenuElement*>* menuElements = NSMutableArray<UIMenuElement*>* menuElements =
...@@ -149,14 +154,14 @@ ...@@ -149,14 +154,14 @@
if (!session->tabs.empty()) { if (!session->tabs.empty()) {
[menuElements addObject:[actionFactory actionToOpenAllTabsWithBlock:^{ [menuElements addObject:[actionFactory actionToOpenAllTabsWithBlock:^{
[self.recentTabsPresentationDelegate [strongSelf.recentTabsPresentationDelegate
openAllTabsFromSession:session]; openAllTabsFromSession:session];
}]]; }]];
} }
[menuElements [menuElements
addObject:[actionFactory actionToHideWithBlock:^{ addObject:[actionFactory actionToHideWithBlock:^{
[weakSelf.recentTabsContextMenuDelegate [strongSelf.recentTabsContextMenuDelegate
removeSessionAtSessionSectionIdentifier:sectionIdentifier]; removeSessionAtSessionSectionIdentifier:sectionIdentifier];
}]]; }]];
......
...@@ -20,6 +20,9 @@ class DistantSession; ...@@ -20,6 +20,9 @@ class DistantSession;
// Tells the receiver to show the tab UI for regular tabs. NO-OP if the correct // Tells the receiver to show the tab UI for regular tabs. NO-OP if the correct
// tab UI is already visible. Receiver may also dismiss recent tabs. // tab UI is already visible. Receiver may also dismiss recent tabs.
- (void)showActiveRegularTabFromRecentTabs; - (void)showActiveRegularTabFromRecentTabs;
// Tells the receiver to show the tab UI for incognito tabs. NO-OP if the
// correct tab UI is already visible. Receiver may also dismiss recent tabs.
- (void)showActiveIncognitoTabFromRecentTabs;
// Tells the receiver to show the history UI. Receiver may also dismiss recent // Tells the receiver to show the history UI. Receiver may also dismiss recent
// tabs. // tabs.
- (void)showHistoryFromRecentTabs; - (void)showHistoryFromRecentTabs;
......
...@@ -407,6 +407,12 @@ ...@@ -407,6 +407,12 @@
focusOmnibox:NO]; focusOmnibox:NO];
} }
- (void)showActiveIncognitoTabFromRecentTabs {
[self.delegate tabGrid:self
shouldFinishWithBrowser:self.incognitoBrowser
focusOmnibox:NO];
}
#pragma mark - HistoryPresentationDelegate #pragma mark - HistoryPresentationDelegate
- (void)showActiveRegularTabFromHistory { - (void)showActiveRegularTabFromHistory {
......
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