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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/mac_util.h" 5 #include "base/mac_util.h"
6 #include "base/sys_string_conversions.h" 6 #include "base/sys_string_conversions.h"
7 #include "chrome/app/chrome_dll_resource.h" // IDC_* 7 #include "chrome/app/chrome_dll_resource.h" // IDC_*
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/tab_contents/web_contents.h" 10 #include "chrome/browser/tab_contents/web_contents.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 [toolbarController_ setStarredState:isStarred]; 268 [toolbarController_ setStarredState:isStarred];
269 } 269 }
270 270
271 // Return the rect, in WebKit coordinates (flipped), of the window's grow box 271 // Return the rect, in WebKit coordinates (flipped), of the window's grow box
272 // in the coordinate system of the content area of the currently selected tab. 272 // in the coordinate system of the content area of the currently selected tab.
273 // |windowGrowBox| needs to be in the window's coordinate system. 273 // |windowGrowBox| needs to be in the window's coordinate system.
274 - (NSRect)selectedTabGrowBoxRect { 274 - (NSRect)selectedTabGrowBoxRect {
275 return [tabStripController_ selectedTabGrowBoxRect]; 275 return [tabStripController_ selectedTabGrowBoxRect];
276 } 276 }
277 277
278 - (void)dropTabView:(NSView *)view atIndex:(NSUInteger)index { 278 // Drop a given tab view at the location of the current placeholder. If there
279 [tabStripController_ dropTabView:view atIndex:index]; 279 // is no placeholder, it will go at the end. |dragController| is the window
280 // controller of a tab being dropped from a different window. It will be nil
281 // if the drag is within the window. The implementation will call
282 // |-removePlaceholder| since the drag is now complete. This also calls
283 // |-layoutTabs| internally so clients do not need to call it again. When
284 // dragging tabs between windows, this should be called *before*
285 // |-detachTabView| on the source window since it needs to still be in the
286 // source window's tab model for this method to find the information it needs
287 // to complete the drop.
288 - (void)dropTabView:(NSView*)view
289 fromController:(TabWindowController*)dragController {
290 if (dragController) {
291 // Moving between windows. Figure out the TabContents to drop into our tab
292 // model from the source window's model.
293 BrowserWindowController* dragBWC = (BrowserWindowController*)dragController;
TVL 2009/04/29 19:42:01 nit: maybe do the cast after the class check, just
294 BOOL isBrowser =
295 [dragBWC isKindOfClass:[BrowserWindowController class]];
296 DCHECK(isBrowser);
297 if (!isBrowser) return;
298 int index = [dragBWC->tabStripController_ indexForTabView:view];
299 TabContents* contents =
300 dragBWC->browser_->tabstrip_model()->GetTabContentsAt(index);
301
302 // Deposit it into our model at the appropriate location (it already knows
303 // where it should go from tracking the drag).
304 [tabStripController_ dropTabContents:contents];
305 } else {
306 // Moving within a window.
307 int index = [tabStripController_ indexForTabView:view];
308 [tabStripController_ moveTabFromIndex:index];
309 }
310
311 // Remove the placeholder since the drag is now complete.
312 [self removePlaceholder];
313 }
314
315 // Tells the tab strip to forget about this tab in preparation for it being
316 // put into a different tab strip, such as during a drop on another window.
317 - (void)detachTabView:(NSView*)view {
318 int index = [tabStripController_ indexForTabView:view];
319 browser_->tabstrip_model()->DetachTabContentsAt(index);
280 } 320 }
281 321
282 - (NSView *)selectedTabView { 322 - (NSView *)selectedTabView {
283 return [tabStripController_ selectedTabView]; 323 return [tabStripController_ selectedTabView];
284 } 324 }
285 325
286 - (TabStripController *)tabStripController {
287 return tabStripController_;
288 }
289
290 - (void)setIsLoading:(BOOL)isLoading { 326 - (void)setIsLoading:(BOOL)isLoading {
291 [toolbarController_ setIsLoading:isLoading]; 327 [toolbarController_ setIsLoading:isLoading];
292 } 328 }
293 329
294 // Called to start/stop the loading animations. 330 // Called to start/stop the loading animations.
295 - (void)updateLoadingAnimations:(BOOL)animate { 331 - (void)updateLoadingAnimations:(BOOL)animate {
296 if (animate) { 332 if (animate) {
297 // TODO(pinkerton): determine what throbber animation is necessary and 333 // TODO(pinkerton): determine what throbber animation is necessary and
298 // start a timer to periodically update. Windows tells the tab strip to 334 // start a timer to periodically update. Windows tells the tab strip to
299 // do this. It uses a single timer to coalesce the multiple things that 335 // do this. It uses a single timer to coalesce the multiple things that
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 535
500 - (NSRect)window:(NSWindow *)window 536 - (NSRect)window:(NSWindow *)window
501 willPositionSheet:(NSWindow *)sheet 537 willPositionSheet:(NSWindow *)sheet
502 usingRect:(NSRect)defaultSheetRect { 538 usingRect:(NSRect)defaultSheetRect {
503 NSRect windowFrame = [window frame]; 539 NSRect windowFrame = [window frame];
504 defaultSheetRect.origin.y = windowFrame.size.height - 10; 540 defaultSheetRect.origin.y = windowFrame.size.height - 10;
505 return defaultSheetRect; 541 return defaultSheetRect;
506 } 542 }
507 543
508 @end 544 @end
OLDNEW
« 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