| OLD | NEW |
| 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_window_controller.h" | 5 #import "chrome/browser/cocoa/tab_window_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/cocoa/tab_strip_view.h" | 8 #import "chrome/browser/cocoa/tab_strip_view.h" |
| 9 | 9 |
| 10 @interface TabWindowController(PRIVATE) | 10 @interface TabWindowController(PRIVATE) |
| 11 - (void)setUseOverlay:(BOOL)useOverlay; | 11 - (void)setUseOverlay:(BOOL)useOverlay; |
| 12 @end | 12 @end |
| 13 | 13 |
| 14 @implementation TabWindowController | 14 @implementation TabWindowController |
| 15 @synthesize tabStripView = tabStripView_; | 15 @synthesize tabStripView = tabStripView_; |
| 16 @synthesize tabContentArea = tabContentArea_; | 16 @synthesize tabContentArea = tabContentArea_; |
| 17 | 17 |
| 18 - (id)initWithWindow:(NSWindow*)window { | 18 - (id)initWithWindow:(NSWindow*)window { |
| 19 if ((self = [super initWithWindow:window]) != nil) { | 19 if ((self = [super initWithWindow:window]) != nil) { |
| 20 lockedTabs_.reset([[NSMutableSet alloc] initWithCapacity:10]); | 20 lockedTabs_.reset([[NSMutableSet alloc] initWithCapacity:10]); |
| 21 } | 21 } |
| 22 return self; | 22 return self; |
| 23 } | 23 } |
| 24 | 24 |
| 25 - (void)windowDidLoad { | 25 - (void)windowDidLoad { |
| 26 if ([self isNormalWindow]) { | 26 if ([self hasTabStrip]) { |
| 27 // Place the tab bar above the content box and add it to the view hierarchy | 27 // Place the tab bar above the content box and add it to the view hierarchy |
| 28 // as a sibling of the content view so it can overlap with the window frame. | 28 // as a sibling of the content view so it can overlap with the window frame. |
| 29 NSRect tabFrame = [tabContentArea_ frame]; | 29 NSRect tabFrame = [tabContentArea_ frame]; |
| 30 tabFrame.origin = NSMakePoint(0, NSMaxY(tabFrame)); | 30 tabFrame.origin = NSMakePoint(0, NSMaxY(tabFrame)); |
| 31 tabFrame.size.height = NSHeight([tabStripView_ frame]); | 31 tabFrame.size.height = NSHeight([tabStripView_ frame]); |
| 32 [tabStripView_ setFrame:tabFrame]; | 32 [tabStripView_ setFrame:tabFrame]; |
| 33 [[[[self window] contentView] superview] addSubview:tabStripView_]; | 33 [[[[self window] contentView] superview] addSubview:tabStripView_]; |
| 34 } else { | 34 } else { |
| 35 // No tabstrip so remove the tabContentArea offset. | 35 // No tabstrip so remove the tabContentArea offset. |
| 36 NSRect tabFrame = [tabContentArea_ frame]; | 36 NSRect tabFrame = [tabContentArea_ frame]; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 NOTIMPLEMENTED(); | 192 NOTIMPLEMENTED(); |
| 193 return 0; | 193 return 0; |
| 194 } | 194 } |
| 195 | 195 |
| 196 - (NSString*)selectedTabTitle { | 196 - (NSString*)selectedTabTitle { |
| 197 // subclass must implement | 197 // subclass must implement |
| 198 NOTIMPLEMENTED(); | 198 NOTIMPLEMENTED(); |
| 199 return @""; | 199 return @""; |
| 200 } | 200 } |
| 201 | 201 |
| 202 - (BOOL)isNormalWindow { | 202 - (BOOL)hasTabStrip { |
| 203 // subclass must implement | 203 // Subclasses should implement this. |
| 204 NOTIMPLEMENTED(); | 204 NOTIMPLEMENTED(); |
| 205 return YES; | 205 return YES; |
| 206 } | 206 } |
| 207 | 207 |
| 208 - (BOOL)isTabDraggable:(NSView*)tabView { | 208 - (BOOL)isTabDraggable:(NSView*)tabView { |
| 209 return ![lockedTabs_ containsObject:tabView]; | 209 return ![lockedTabs_ containsObject:tabView]; |
| 210 } | 210 } |
| 211 | 211 |
| 212 - (void)setTab:(NSView*)tabView isDraggable:(BOOL)draggable { | 212 - (void)setTab:(NSView*)tabView isDraggable:(BOOL)draggable { |
| 213 if (draggable) | 213 if (draggable) |
| 214 [lockedTabs_ removeObject:tabView]; | 214 [lockedTabs_ removeObject:tabView]; |
| 215 else | 215 else |
| 216 [lockedTabs_ addObject:tabView]; | 216 [lockedTabs_ addObject:tabView]; |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Tell the window that it needs to call performClose: as soon as the current | 219 // Tell the window that it needs to call performClose: as soon as the current |
| 220 // drag is complete. This prevents a window (and its overlay) from going away | 220 // drag is complete. This prevents a window (and its overlay) from going away |
| 221 // during a drag. | 221 // during a drag. |
| 222 - (void)deferPerformClose { | 222 - (void)deferPerformClose { |
| 223 closeDeferred_ = YES; | 223 closeDeferred_ = YES; |
| 224 } | 224 } |
| 225 | 225 |
| 226 @end | 226 @end |
| OLD | NEW |