Commit 6bdafce4 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Pass current tab as opener when opening new tab

Pass the current tab as the opener when opening a new tab.
This allow selection the previous current tab when the
tab is closed via "pull-to-close" action or via the new
"close" action in the UI refresh.

The current tab is passed when tab is opened via ([*]
denotes that this behaviour is added by this CL):
- open tab in background
- "New Tab" menu action [*]
- captive portal detection [*]
- search by image [*]

Bug: 661988
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iecf41a8c0b3cfe465b3ff95a1061c97739b4ed79
Reviewed-on: https://chromium-review.googlesource.com/1068680Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561427}
parent fca1f01a
......@@ -54,7 +54,8 @@ typedef Tab* (^mock_gurl_nsuinteger_pagetransition)(const GURL&,
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition {
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab {
static_cast<mock_gurl_nsuinteger_pagetransition>(
[self blockForSelector:_cmd])(url, position, transition);
id mockTab = [OCMockObject mockForClass:[Tab class]];
......@@ -78,6 +79,7 @@ typedef Tab* (^mock_gurl_nsuinteger_pagetransition)(const GURL&,
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)completion;
- (void)expectNewForegroundTab;
- (void)setActive:(BOOL)active;
......@@ -97,6 +99,7 @@ typedef Tab* (^mock_gurl_nsuinteger_pagetransition)(const GURL&,
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)completion {
self.tabURL = url;
self.position = position;
......
......@@ -2169,6 +2169,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return [targetBVC addSelectedTabWithURL:URL
atIndex:NSNotFound
transition:transition
opener:nil
tabAddedCompletion:tabOpenedCompletion];
}
......@@ -2265,6 +2266,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
tab = [targetBVC addSelectedTabWithURL:url
atIndex:tabIndex
transition:transition
opener:nil
tabAddedCompletion:tabOpenedCompletion];
} else {
// Voice search, QRScanner and the omnibox are presented by the BVC.
......
......@@ -113,14 +113,16 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
// Add a new tab with the given url, appends it to the end of the model,
// and makes it the selected tab. The selected tab is returned.
- (Tab*)addSelectedTabWithURL:(const GURL&)url
transition:(ui::PageTransition)transition;
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab;
// Add a new tab with the given url, at the given |position|,
// and makes it the selected tab. The selected tab is returned.
// If |position| == NSNotFound the tab will be added at the end of the stack.
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition;
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab;
// Add a new tab with the given url, at the given |position|,
// and makes it the selected tab. The selected tab is returned.
......@@ -129,6 +131,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)tabAddedCompletion;
// Informs the BVC that a new foreground tab is about to be opened. This is
......
......@@ -882,7 +882,8 @@ bubblePresenterForFeature:(const base::Feature&)feature
// the selected tab and return it.
- (Tab*)addSelectedTabWithURL:(const GURL&)url
postData:(TemplateURLRef::PostContent*)postData
transition:(ui::PageTransition)transition;
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab;
// Internal method that all of the similar public and private methods call.
// Adds a new tab with |url| and |postData| (if not null) at |position| in the
// tab model (or at the end if |position is NSNotFound|, with |transition| as
......@@ -892,6 +893,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
postData:(TemplateURLRef::PostContent*)postData
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)tabAddedCompletion;
// Whether the given tab's URL is an application specific URL.
- (BOOL)isTabNativePage:(Tab*)tab;
......@@ -1423,29 +1425,35 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
}
- (Tab*)addSelectedTabWithURL:(const GURL&)url
transition:(ui::PageTransition)transition {
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab {
return [self addSelectedTabWithURL:url
atIndex:[_model count]
transition:transition];
transition:transition
opener:parentTab];
}
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition {
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab {
return [self addSelectedTabWithURL:url
atIndex:position
transition:transition
opener:parentTab
tabAddedCompletion:nil];
}
- (Tab*)addSelectedTabWithURL:(const GURL&)url
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)tabAddedCompletion {
return [self addSelectedTabWithURL:url
postData:NULL
atIndex:position
transition:transition
opener:parentTab
tabAddedCompletion:tabAddedCompletion];
}
......@@ -2969,11 +2977,13 @@ bubblePresenterForFeature:(const base::Feature&)feature
- (Tab*)addSelectedTabWithURL:(const GURL&)url
postData:(TemplateURLRef::PostContent*)postData
transition:(ui::PageTransition)transition {
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab {
return [self addSelectedTabWithURL:url
postData:postData
atIndex:[_model count]
transition:transition
opener:(Tab*)parentTab
tabAddedCompletion:nil];
}
......@@ -2981,6 +2991,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
postData:(TemplateURLRef::PostContent*)postData
atIndex:(NSUInteger)position
transition:(ui::PageTransition)transition
opener:(Tab*)parentTab
tabAddedCompletion:(ProceduralBlock)tabAddedCompletion {
if (position == NSNotFound)
position = [_model count];
......@@ -3012,7 +3023,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
}
Tab* tab = [_model insertTabWithLoadParams:params
opener:nil
opener:parentTab
openedByDOM:NO
atIndex:position
inBackground:NO];
......@@ -3775,7 +3786,8 @@ bubblePresenterForFeature:(const base::Feature&)feature
search_args, templateUrlService->search_terms_data(), &post_content));
[self addSelectedTabWithURL:result
postData:&post_content
transition:ui::PAGE_TRANSITION_TYPED];
transition:ui::PAGE_TRANSITION_TYPED
opener:[_model currentTab]];
}
// Saves the image at the given URL on the system's album. The referrer is used
......@@ -4691,7 +4703,8 @@ bubblePresenterForFeature:(const base::Feature&)feature
->UpdateSnapshot(/*with_overlays=*/true, /*visible_frame_only=*/true);
}
[self addSelectedTabWithURL:GURL(kChromeUINewTabURL)
transition:ui::PAGE_TRANSITION_TYPED];
transition:ui::PAGE_TRANSITION_TYPED
opener:currentTab];
}
- (void)printTab {
......@@ -5673,7 +5686,9 @@ nativeContentHeaderHeightForPreloadController:(PreloadController*)controller
- (void)captivePortalDetectorTabHelper:
(CaptivePortalDetectorTabHelper*)tabHelper
connectWithLandingURL:(const GURL&)landingURL {
[self addSelectedTabWithURL:landingURL transition:ui::PAGE_TRANSITION_TYPED];
[self addSelectedTabWithURL:landingURL
transition:ui::PAGE_TRANSITION_TYPED
opener:[_model currentTab]];
}
#pragma mark - PageInfoPresentation
......
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