| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/tabs/tab_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 9 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 9 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 10 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 10 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 [tabStripBackgroundView_ | 94 [tabStripBackgroundView_ |
| 95 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; | 95 setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; |
| 96 [self insertTabStripBackgroundViewIntoWindow:window]; | 96 [self insertTabStripBackgroundViewIntoWindow:window]; |
| 97 | 97 |
| 98 tabStripView_.reset([[TabStripView alloc] | 98 tabStripView_.reset([[TabStripView alloc] |
| 99 initWithFrame:NSMakeRect( | 99 initWithFrame:NSMakeRect( |
| 100 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); | 100 0, 0, kDefaultWidth, chrome::kTabStripHeight)]); |
| 101 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | | 101 [tabStripView_ setAutoresizingMask:NSViewWidthSizable | |
| 102 NSViewMinYMargin]; | 102 NSViewMinYMargin]; |
| 103 if (hasTabStrip) | 103 if (hasTabStrip) |
| 104 [self insertTabStripView:tabStripView_ intoWindow:[self window]]; | 104 [windowView addSubview:tabStripView_]; |
| 105 } | 105 } |
| 106 return self; | 106 return self; |
| 107 } | 107 } |
| 108 | 108 |
| 109 - (NSView*)tabStripBackgroundView { | 109 - (NSView*)tabStripBackgroundView { |
| 110 return tabStripBackgroundView_; | 110 return tabStripBackgroundView_; |
| 111 } | 111 } |
| 112 | 112 |
| 113 - (TabStripView*)tabStripView { | 113 - (TabStripView*)tabStripView { |
| 114 return tabStripView_; | 114 return tabStripView_; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DCHECK(originalContentView_); | 182 DCHECK(originalContentView_); |
| 183 | 183 |
| 184 // Return the original window's tab strip view and content view to their | 184 // Return the original window's tab strip view and content view to their |
| 185 // places. The TabStripView always needs to be in front of the window's | 185 // places. The TabStripView always needs to be in front of the window's |
| 186 // content view and therefore it should always be added after the content | 186 // content view and therefore it should always be added after the content |
| 187 // view is set. | 187 // view is set. |
| 188 [[window contentView] addSubview:originalContentView_ | 188 [[window contentView] addSubview:originalContentView_ |
| 189 positioned:NSWindowBelow | 189 positioned:NSWindowBelow |
| 190 relativeTo:nil]; | 190 relativeTo:nil]; |
| 191 originalContentView_.frame = [[window contentView] bounds]; | 191 originalContentView_.frame = [[window contentView] bounds]; |
| 192 [self insertTabStripView:[self tabStripView] intoWindow:window]; | 192 [[window contentView] addSubview:[self tabStripView]]; |
| 193 [[window contentView] updateTrackingAreas]; | 193 [[window contentView] updateTrackingAreas]; |
| 194 | 194 |
| 195 [focusBeforeOverlay_ restoreFocusInWindow:window]; | 195 [focusBeforeOverlay_ restoreFocusInWindow:window]; |
| 196 focusBeforeOverlay_.reset(); | 196 focusBeforeOverlay_.reset(); |
| 197 | 197 |
| 198 [window display]; | 198 [window display]; |
| 199 [window removeChildWindow:overlayWindow_]; | 199 [window removeChildWindow:overlayWindow_]; |
| 200 | 200 |
| 201 [overlayWindow_ orderOut:nil]; | 201 [overlayWindow_ orderOut:nil]; |
| 202 [overlayWindow_ release]; | 202 [overlayWindow_ release]; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 return YES; | 320 return YES; |
| 321 } | 321 } |
| 322 | 322 |
| 323 // Tell the window that it needs to call performClose: as soon as the current | 323 // Tell the window that it needs to call performClose: as soon as the current |
| 324 // drag is complete. This prevents a window (and its overlay) from going away | 324 // drag is complete. This prevents a window (and its overlay) from going away |
| 325 // during a drag. | 325 // during a drag. |
| 326 - (void)deferPerformClose { | 326 - (void)deferPerformClose { |
| 327 closeDeferred_ = YES; | 327 closeDeferred_ = YES; |
| 328 } | 328 } |
| 329 | 329 |
| 330 - (void)insertTabStripView:(NSView*)tabStripView intoWindow:(NSWindow*)window { | |
| 331 NSView* contentParent = [window contentView]; | |
| 332 if (contentParent == [[window contentView] superview]) { | |
| 333 // Add the tab strip directly above the content view, if they are siblings. | |
| 334 [contentParent addSubview:tabStripView | |
| 335 positioned:NSWindowAbove | |
| 336 relativeTo:[window contentView]]; | |
| 337 } else { | |
| 338 [contentParent addSubview:tabStripView]; | |
| 339 } | |
| 340 } | |
| 341 | |
| 342 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window { | 330 - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window { |
| 343 DCHECK(tabStripBackgroundView_); | 331 DCHECK(tabStripBackgroundView_); |
| 344 NSView* rootView = [[window contentView] superview]; | 332 NSView* rootView = [[window contentView] superview]; |
| 345 [rootView addSubview:tabStripBackgroundView_ | 333 [rootView addSubview:tabStripBackgroundView_ |
| 346 positioned:NSWindowBelow | 334 positioned:NSWindowBelow |
| 347 relativeTo:nil]; | 335 relativeTo:nil]; |
| 348 } | 336 } |
| 349 | 337 |
| 350 // Called when the size of the window content area has changed. Override to | 338 // Called when the size of the window content area has changed. Override to |
| 351 // position specific views. Base class implementation does nothing. | 339 // position specific views. Base class implementation does nothing. |
| 352 - (void)layoutSubviews { | 340 - (void)layoutSubviews { |
| 353 NOTIMPLEMENTED(); | 341 NOTIMPLEMENTED(); |
| 354 } | 342 } |
| 355 | 343 |
| 356 @end | 344 @end |
| OLD | NEW |