Index: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm |
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm |
index 97eb5f57a8c69e4dc60dc633054ae5fa214548fe..d4ca3d5cf8271e2e0da2ec6f79a66b60bc39cb3e 100644 |
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm |
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm |
@@ -174,7 +174,8 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
- (void)setTabTrackingAreasEnabled:(BOOL)enabled; |
- (void)droppingURLsAt:(NSPoint)point |
givesIndex:(NSInteger*)index |
- disposition:(WindowOpenDisposition*)disposition; |
+ disposition:(WindowOpenDisposition*)disposition |
+ activateTab:(BOOL)enabled; |
erikchen
2016/11/21 18:28:40
for consistency, please use activateTab:(BOOL)acti
shahriar
2016/11/22 03:46:30
Done.
|
- (void)setNewTabButtonHoverState:(BOOL)showHover; |
- (void)themeDidChangeNotification:(NSNotification*)notification; |
- (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected |
@@ -2010,7 +2011,8 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
// to the left, it inserts to the left, and similarly for the right. |
- (void)droppingURLsAt:(NSPoint)point |
givesIndex:(NSInteger*)index |
- disposition:(WindowOpenDisposition*)disposition { |
+ disposition:(WindowOpenDisposition*)disposition |
+ activateTab:(BOOL)enabled { |
// Proportion of the tab which is considered the "middle" (and causes things |
// to drop on that tab). |
const double kMiddleProportion = 0.5; |
@@ -2037,7 +2039,10 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
// Drop in a new tab to the left of tab |i|? |
if (point.x < (frame.origin.x + kLRProportion * frame.size.width)) { |
*index = i; |
- *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
+ if (enabled) |
erikchen
2016/11/21 18:28:40
Chromium style requires that multi-line if stateme
shahriar
2016/11/22 03:46:30
I fixed it as you said. But I thought when neither
erikchen
2016/11/22 18:12:48
Hm. I reread the Google style guide and you're rig
|
+ *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
+ else |
+ *disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; |
return; |
} |
@@ -2056,10 +2061,16 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
// If we've made it here, we want to append a new tab to the end. |
*index = -1; |
- *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
+ if (enabled) |
+ *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
+ else |
+ *disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; |
} |
-- (void)openURL:(GURL*)url inView:(NSView*)view at:(NSPoint)point { |
+- (void)openURL:(GURL*)url |
+ inView:(NSView*)view |
+ at:(NSPoint)point |
+ activateTab:(BOOL)enabled { |
// Security: Block JavaScript to prevent self-XSS. |
if (url->SchemeIs(url::kJavaScriptScheme)) |
return; |
@@ -2069,11 +2080,13 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
WindowOpenDisposition disposition; |
[self droppingURLsAt:point |
givesIndex:&index |
- disposition:&disposition]; |
+ disposition:&disposition |
+ activateTab:enabled]; |
// Either insert a new tab or open in a current tab. |
switch (disposition) { |
- case WindowOpenDisposition::NEW_FOREGROUND_TAB: { |
+ case WindowOpenDisposition::NEW_FOREGROUND_TAB: |
+ case WindowOpenDisposition::NEW_BACKGROUND_TAB: { |
content::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs")); |
chrome::NavigateParams params(browser_, *url, |
ui::PAGE_TRANSITION_TYPED); |
@@ -2106,19 +2119,21 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
return; |
} |
- //TODO(viettrungluu): dropping multiple URLs. |
- if ([urls count] > 1) |
- NOTIMPLEMENTED(); |
+ for (id urlString in [urls reverseObjectEnumerator]) { |
+ // Refactor this code. |
+ // https://crbug.com/665261. |
+ GURL url = url_formatter::FixupURL(base::SysNSStringToUTF8(urlString), |
+ std::string()); |
- // Get the first URL and fix it up. |
- GURL url(GURL(url_formatter::FixupURL( |
- base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string()))); |
- |
- // If the URL isn't valid, don't bother. |
- if (!url.is_valid()) |
- return; |
+ // If the URL isn't valid, don't bother. |
+ if (!url.is_valid()) |
+ continue; |
- [self openURL:&url inView:view at:point]; |
+ if ([urls indexOfObject:urlString] == [urls count] - 1) |
erikchen
2016/11/21 18:28:40
This code makes the assumption that the urlString
shahriar
2016/11/22 03:46:30
Done.
|
+ [self openURL:&url inView:view at:point activateTab:YES]; |
+ else |
+ [self openURL:&url inView:view at:point activateTab:NO]; |
+ } |
} |
// (URLDropTargetController protocol) |
@@ -2132,7 +2147,7 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
metrics::OmniboxEventProto::BLANK, &match, NULL); |
GURL url(match.destination_url); |
- [self openURL:&url inView:view at:point]; |
+ [self openURL:&url inView:view at:point activateTab:YES]; |
} |
// (URLDropTargetController protocol) |
@@ -2147,7 +2162,8 @@ CGFloat FlipXInView(NSView* view, CGFloat width, CGFloat x) { |
WindowOpenDisposition disposition; |
[self droppingURLsAt:point |
givesIndex:&index |
- disposition:&disposition]; |
+ disposition:&disposition |
+ activateTab:YES]; |
NSPoint arrowPos = NSMakePoint(0, arrowBaseY); |
if (index == -1) { |