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

Unified Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 102010: Implement dropping of tabs into an existing tab strip from another window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months 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/cocoa/tab_strip_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/browser_window_controller.mm
===================================================================
--- chrome/browser/cocoa/browser_window_controller.mm (revision 14839)
+++ chrome/browser/cocoa/browser_window_controller.mm (working copy)
@@ -275,18 +275,54 @@
return [tabStripController_ selectedTabGrowBoxRect];
}
-- (void)dropTabView:(NSView *)view atIndex:(NSUInteger)index {
- [tabStripController_ dropTabView:view atIndex:index];
+// Drop a given tab view at the location of the current placeholder. If there
+// is no placeholder, it will go at the end. |dragController| is the window
+// controller of a tab being dropped from a different window. It will be nil
+// if the drag is within the window. The implementation will call
+// |-removePlaceholder| since the drag is now complete. This also calls
+// |-layoutTabs| internally so clients do not need to call it again. When
+// dragging tabs between windows, this should be called *before*
+// |-detachTabView| on the source window since it needs to still be in the
+// source window's tab model for this method to find the information it needs
+// to complete the drop.
+- (void)dropTabView:(NSView*)view
+ fromController:(TabWindowController*)dragController {
+ if (dragController) {
+ // Moving between windows. Figure out the TabContents to drop into our tab
+ // model from the source window's model.
+ BrowserWindowController* dragBWC = (BrowserWindowController*)dragController;
TVL 2009/04/29 19:42:01 nit: maybe do the cast after the class check, just
+ BOOL isBrowser =
+ [dragBWC isKindOfClass:[BrowserWindowController class]];
+ DCHECK(isBrowser);
+ if (!isBrowser) return;
+ int index = [dragBWC->tabStripController_ indexForTabView:view];
+ TabContents* contents =
+ dragBWC->browser_->tabstrip_model()->GetTabContentsAt(index);
+
+ // Deposit it into our model at the appropriate location (it already knows
+ // where it should go from tracking the drag).
+ [tabStripController_ dropTabContents:contents];
+ } else {
+ // Moving within a window.
+ int index = [tabStripController_ indexForTabView:view];
+ [tabStripController_ moveTabFromIndex:index];
+ }
+
+ // Remove the placeholder since the drag is now complete.
+ [self removePlaceholder];
}
+// Tells the tab strip to forget about this tab in preparation for it being
+// put into a different tab strip, such as during a drop on another window.
+- (void)detachTabView:(NSView*)view {
+ int index = [tabStripController_ indexForTabView:view];
+ browser_->tabstrip_model()->DetachTabContentsAt(index);
+}
+
- (NSView *)selectedTabView {
return [tabStripController_ selectedTabView];
}
-- (TabStripController *)tabStripController {
- return tabStripController_;
-}
-
- (void)setIsLoading:(BOOL)isLoading {
[toolbarController_ setIsLoading:isLoading];
}
« no previous file with comments | « no previous file | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698