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

Side by Side Diff: chrome/browser/cocoa/tab_strip_controller.mm

Issue 115789: Fix issue where cmd-w was hard-coded to closing a browser tab regardless of t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
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 #import "chrome/browser/cocoa/tab_strip_controller.h" 5 #import "chrome/browser/cocoa/tab_strip_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/metrics/user_metrics.h" 11 #include "chrome/browser/metrics/user_metrics.h"
12 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
13 #import "chrome/browser/cocoa/tab_strip_view.h" 13 #import "chrome/browser/cocoa/tab_strip_view.h"
14 #import "chrome/browser/cocoa/tab_cell.h" 14 #import "chrome/browser/cocoa/tab_cell.h"
15 #import "chrome/browser/cocoa/tab_contents_controller.h" 15 #import "chrome/browser/cocoa/tab_contents_controller.h"
16 #import "chrome/browser/cocoa/tab_controller.h" 16 #import "chrome/browser/cocoa/tab_controller.h"
17 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 17 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
18 #import "chrome/browser/cocoa/tab_view.h" 18 #import "chrome/browser/cocoa/tab_view.h"
19 #import "chrome/browser/cocoa/throbber_view.h" 19 #import "chrome/browser/cocoa/throbber_view.h"
20 #include "chrome/browser/tab_contents/tab_contents.h" 20 #include "chrome/browser/tab_contents/tab_contents.h"
21 #include "chrome/browser/tab_contents/tab_contents_view.h" 21 #include "chrome/browser/tab_contents/tab_contents_view.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 22 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "grit/generated_resources.h" 23 #include "grit/generated_resources.h"
24 24
25 NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
26
25 // A simple view class that prevents the windowserver from dragging the 27 // A simple view class that prevents the windowserver from dragging the
26 // area behind tabs. Sometimes core animation confuses it. 28 // area behind tabs. Sometimes core animation confuses it.
27 @interface TabStripControllerDragBlockingView : NSView 29 @interface TabStripControllerDragBlockingView : NSView
28 @end 30 @end
29 @implementation TabStripControllerDragBlockingView 31 @implementation TabStripControllerDragBlockingView
30 - (BOOL)mouseDownCanMoveWindow {return NO;} 32 - (BOOL)mouseDownCanMoveWindow {return NO;}
31 - (void)drawRect:(NSRect)rect {} 33 - (void)drawRect:(NSRect)rect {}
32 @end 34 @end
33 35
34 @implementation TabStripController 36 @implementation TabStripController
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 positioned:inForeground ? NSWindowAbove : NSWindowBelow 332 positioned:inForeground ? NSWindowAbove : NSWindowBelow
331 relativeTo:nil]; 333 relativeTo:nil];
332 334
333 [self setTabTitle:newController withContents:contents]; 335 [self setTabTitle:newController withContents:contents];
334 336
335 // We don't need to call |-layoutTabs| if the tab will be in the foreground 337 // We don't need to call |-layoutTabs| if the tab will be in the foreground
336 // because it will get called when the new tab is selected by the tab model. 338 // because it will get called when the new tab is selected by the tab model.
337 if (!inForeground) { 339 if (!inForeground) {
338 [self layoutTabs]; 340 [self layoutTabs];
339 } 341 }
342
343 // Send a broadcast that the number of tabs have changed.
344 [[NSNotificationCenter defaultCenter]
345 postNotificationName:kTabStripNumberOfTabsChanged
346 object:self];
340 } 347 }
341 348
342 // Called when a notification is received from the model to select a particular 349 // Called when a notification is received from the model to select a particular
343 // tab. Swaps in the toolbar and content area associated with |newContents|. 350 // tab. Swaps in the toolbar and content area associated with |newContents|.
344 - (void)selectTabWithContents:(TabContents*)newContents 351 - (void)selectTabWithContents:(TabContents*)newContents
345 previousContents:(TabContents*)oldContents 352 previousContents:(TabContents*)oldContents
346 atIndex:(NSInteger)index 353 atIndex:(NSInteger)index
347 userGesture:(bool)wasUserGesture { 354 userGesture:(bool)wasUserGesture {
348 // De-select all other tabs and select the new tab. 355 // De-select all other tabs and select the new tab.
349 int i = 0; 356 int i = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Remove the |index|th view from the tab strip 397 // Remove the |index|th view from the tab strip
391 NSView* tab = [self viewAtIndex:index]; 398 NSView* tab = [self viewAtIndex:index];
392 [tab removeFromSuperview]; 399 [tab removeFromSuperview];
393 400
394 NSValue *identifier = [NSValue valueWithPointer:tab]; 401 NSValue *identifier = [NSValue valueWithPointer:tab];
395 [targetFrames_ removeObjectForKey:identifier]; 402 [targetFrames_ removeObjectForKey:identifier];
396 403
397 // Once we're totally done with the tab, delete its controller 404 // Once we're totally done with the tab, delete its controller
398 [tabArray_ removeObjectAtIndex:index]; 405 [tabArray_ removeObjectAtIndex:index];
399 406
407 // Send a broadcast that the number of tabs have changed.
408 [[NSNotificationCenter defaultCenter]
409 postNotificationName:kTabStripNumberOfTabsChanged
410 object:self];
411
400 [self layoutTabs]; 412 [self layoutTabs];
401 } 413 }
402 414
403 // A helper routine for creating an NSImageView to hold the fav icon for 415 // A helper routine for creating an NSImageView to hold the fav icon for
404 // |contents|. 416 // |contents|.
405 // TODO(pinkerton): fill in with code to use the real favicon, not the default 417 // TODO(pinkerton): fill in with code to use the real favicon, not the default
406 // for all cases. 418 // for all cases.
407 - (NSImageView*)favIconImageViewForContents:(TabContents*)contents { 419 - (NSImageView*)favIconImageViewForContents:(TabContents*)contents {
408 NSRect iconFrame = NSMakeRect(0, 0, 16, 16); 420 NSRect iconFrame = NSMakeRect(0, 0, 16, 16);
409 NSImageView* view = [[[NSImageView alloc] initWithFrame:iconFrame] 421 NSImageView* view = [[[NSImageView alloc] initWithFrame:iconFrame]
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 selectedIndex = 0; 554 selectedIndex = 0;
543 } 555 }
544 TabContentsController* selectedController = 556 TabContentsController* selectedController =
545 [tabContentsArray_ objectAtIndex:selectedIndex]; 557 [tabContentsArray_ objectAtIndex:selectedIndex];
546 if (!selectedController) 558 if (!selectedController)
547 return NSZeroRect; 559 return NSZeroRect;
548 return [selectedController growBoxRect]; 560 return [selectedController growBoxRect];
549 } 561 }
550 562
551 @end 563 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/tab_strip_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698