Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 2502483002: Fixed dragging a folder from bookmark manager to open all elements in new tabs (Closed)
Patch Set: Replace c-style cast with static_cast for drag/drop bookmarks over tab strip Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46ee02b7bd2c0a85e26e76dfee4ce049c59e82e4..e7bad4b7bd4785c9408900f4007cd2fd493f93bb 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -179,7 +179,8 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
- (void)setTabTrackingAreasEnabled:(BOOL)enabled;
- (void)droppingURLsAt:(NSPoint)point
givesIndex:(NSInteger*)index
- disposition:(WindowOpenDisposition*)disposition;
+ disposition:(WindowOpenDisposition*)disposition
+ activateTab:(BOOL)activateTab;
- (void)setNewTabButtonHoverState:(BOOL)showHover;
- (void)themeDidChangeNotification:(NSNotification*)notification;
- (BOOL)doesAnyOtherWebContents:(content::WebContents*)selected
@@ -2038,7 +2039,8 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
// 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)activateTab {
// Proportion of the tab which is considered the "middle" (and causes things
// to drop on that tab).
const double kMiddleProportion = 0.5;
@@ -2069,7 +2071,11 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
// Drop in a new tab before tab |i|?
if (isRTL ? point.x > rightEdge : point.x < leftEdge) {
*index = i;
- *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ if (activateTab) {
+ *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ } else {
+ *disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB;
+ }
return;
}
@@ -2087,10 +2093,17 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
// If we've made it here, we want to append a new tab to the end.
*index = -1;
- *disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
+ if (activateTab) {
+ *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)activateTab {
// Security: Block JavaScript to prevent self-XSS.
if (url->SchemeIs(url::kJavaScriptScheme))
return;
@@ -2100,11 +2113,13 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
WindowOpenDisposition disposition;
[self droppingURLsAt:point
givesIndex:&index
- disposition:&disposition];
+ disposition:&disposition
+ activateTab:activateTab];
// 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);
@@ -2137,19 +2152,22 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
return;
}
- //TODO(viettrungluu): dropping multiple URLs.
- if ([urls count] > 1)
- NOTIMPLEMENTED();
-
- // Get the first URL and fix it up.
- GURL url(GURL(url_formatter::FixupURL(
- base::SysNSStringToUTF8([urls objectAtIndex:0]), std::string())));
+ for (NSInteger index = [urls count] - 1; index >= 0; index--) {
+ // Refactor this code.
+ // https://crbug.com/665261.
+ GURL url = url_formatter::FixupURL(
+ base::SysNSStringToUTF8([urls objectAtIndex:index]), 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 (index == static_cast<NSInteger>([urls count]) - 1) {
+ [self openURL:&url inView:view at:point activateTab:YES];
+ } else {
+ [self openURL:&url inView:view at:point activateTab:NO];
+ }
+ }
}
// (URLDropTargetController protocol)
@@ -2163,7 +2181,7 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
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)
@@ -2178,7 +2196,8 @@ NSRect FlipRectInView(NSView* view, NSRect rect) {
WindowOpenDisposition disposition;
[self droppingURLsAt:point
givesIndex:&index
- disposition:&disposition];
+ disposition:&disposition
+ activateTab:YES];
NSPoint arrowPos = NSMakePoint(0, arrowBaseY);
if (index == -1) {
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698