Chromium Code Reviews| Index: chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| index 73d0f3e755b97af15cb87aef4bc07c9584dc3639..9c30ee80c6c529ef8dd771f732b959eb410a8861 100644 |
| --- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| +++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| @@ -5,7 +5,6 @@ |
| #import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h" |
| #include "base/logging.h" |
| -#import "base/mac/sdk_forward_declarations.h" |
| #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| @@ -16,24 +15,8 @@ |
| #include "ui/base/material_design/material_design_controller.h" |
| #include "ui/base/theme_provider.h" |
| -@interface TabWindowController () |
| -- (void)setUseOverlay:(BOOL)useOverlay; |
| - |
| -// The tab strip background view should always be inserted as the back-most |
| -// subview of the root view. It cannot be a subview of the contentView, as that |
| -// would cause it to become layer backed, which would cause it to draw on top |
| -// of non-layer backed content like the window controls. |
| -- (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window |
| - titleBar:(BOOL)hasTitleBar; |
| - |
| -// Called when NSWindowWillEnterFullScreenNotification notification received. |
| -// Makes visual effects view hidden as it should not be displayed in fullscreen. |
| -- (void)windowWillEnterFullScreenNotification:(NSNotification*)notification; |
| - |
| -// Called when NSWindowWillExitFullScreenNotification notification received. |
| -// Makes visual effects view visible since it was hidden in fullscreen. |
| -- (void)windowWillExitFullScreenNotification:(NSNotification*)notification; |
| - |
| +@interface NSWindow (TitlebarAppearsTransparent) |
|
Robert Sesek
2017/01/11 19:23:40
Is this a SPI or is this a forward declaration (in
Sidney San Martín
2017/01/13 00:10:07
It's a redeclaration of a partially-available prop
|
| +@property BOOL titlebarAppearsTransparent; |
| @end |
| @interface TabWindowOverlayWindow : NSWindow |
| @@ -104,7 +87,6 @@ |
| NSWidth([windowView bounds]), paintHeight)]); |
| [tabStripBackgroundView_ |
| setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; |
| - [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar]; |
| tabStripView_.reset([[TabStripView alloc] |
| initWithFrame:NSMakeRect( |
| @@ -114,23 +96,16 @@ |
| if (hasTabStrip) |
| [windowView addSubview:tabStripView_]; |
| + if ([window respondsToSelector:@selector(setTitlebarAppearsTransparent:)]) |
| + [window setTitlebarAppearsTransparent:YES]; |
| + |
| if (chrome::ShouldUseFullSizeContentView()) { |
| - // |windowWillEnterFullScreen:| and |windowWillExitFullScreen:| are |
| - // already called because self is a delegate for the window. However this |
| - // class is designed for subclassing and can not implement |
| - // NSWindowDelegate methods (because subclasses can do so as well and they |
| - // should be able to). TODO(crbug.com/654656): Move |visualEffectView_| to |
| - // subclass. |
| - [[NSNotificationCenter defaultCenter] |
| - addObserver:self |
| - selector:@selector(windowWillEnterFullScreenNotification:) |
| - name:NSWindowWillEnterFullScreenNotification |
| - object:window]; |
| - [[NSNotificationCenter defaultCenter] |
| - addObserver:self |
| - selector:@selector(windowWillExitFullScreenNotification:) |
| - name:NSWindowWillExitFullScreenNotification |
| - object:window]; |
| + [[window contentView] addSubview:tabStripBackgroundView_]; |
| + } else { |
| + NSView* rootView = [[self.window contentView] superview]; |
| + [rootView addSubview:tabStripBackgroundView_ |
| + positioned:NSWindowBelow |
| + relativeTo:nil]; |
| } |
| } |
| return self; |
| @@ -210,7 +185,7 @@ |
| // content view (rather than using setContentView:) because the overlay |
| // window has a different content size (due to it being borderless). |
| [[overlayWindow_ contentView] addSubview:[self tabStripView]]; |
| - [[self tabStripView] setInATabDraggingOverlayWindow:YES]; |
| + tabStripBackgroundView_.get().inATabDraggingOverlayWindow = YES; |
|
Robert Sesek
2017/01/11 19:23:40
Dot notation is not really used in this method. Be
Sidney San Martín
2017/01/13 00:10:07
Done.
|
| [[overlayWindow_ contentView] addSubview:originalContentView_]; |
| [overlayWindow_ orderFront:nil]; |
| @@ -229,7 +204,7 @@ |
| [[window contentView] addSubview:[self tabStripView] |
| positioned:NSWindowBelow |
| relativeTo:[self avatarView]]; |
| - [[self tabStripView] setInATabDraggingOverlayWindow:NO]; |
| + tabStripBackgroundView_.get().inATabDraggingOverlayWindow = NO; |
| [[window contentView] updateTrackingAreas]; |
| [focusBeforeOverlay_ restoreFocusInWindow:window]; |
| @@ -382,75 +357,10 @@ |
| closeDeferred_ = YES; |
| } |
| -- (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window |
| - titleBar:(BOOL)hasTitleBar { |
| - DCHECK(tabStripBackgroundView_); |
| - NSView* rootView = [[window contentView] superview]; |
| - |
| - // In Material Design on 10.10 and higher, the top portion of the window is |
| - // blurred using an NSVisualEffectView. |
| - Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); |
| - if (!nsVisualEffectViewClass) { |
| - DCHECK(!chrome::ShouldUseFullSizeContentView()); |
| - [rootView addSubview:tabStripBackgroundView_ |
| - positioned:NSWindowBelow |
| - relativeTo:nil]; |
| - return; |
| - } |
| - |
| - [window setTitlebarAppearsTransparent:YES]; |
| - |
| - // If the window has a normal titlebar, then do not add NSVisualEffectView. |
| - if (hasTitleBar) |
| - return; |
| - |
| - visualEffectView_.reset( |
| - [[nsVisualEffectViewClass alloc] |
| - initWithFrame:[tabStripBackgroundView_ frame]]); |
| - DCHECK(visualEffectView_); |
| - |
| - [visualEffectView_ setAutoresizingMask: |
| - [tabStripBackgroundView_ autoresizingMask]]; |
| - [tabStripBackgroundView_ |
| - setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| - |
| - // Set to a default appearance and material. If this is an Incognito window |
| - // the material and vibrancy should be dark but this method gets called at |
| - // the start of -[BrowserWindowController initWithBrowser:takeOwnership:], |
| - // before the |browser_| ivar has been set. Without a browser object we |
| - // can't check the window's theme. The final setup happens in |
| - // -[TabStripView setController:], at which point we have access to the theme. |
| - [visualEffectView_ setAppearance: |
| - [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]]; |
| - [visualEffectView_ setMaterial:NSVisualEffectMaterialLight]; |
| - [visualEffectView_ setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; |
| - [visualEffectView_ setState:NSVisualEffectStateFollowsWindowActiveState]; |
| - |
| - if (chrome::ShouldUseFullSizeContentView()) { |
| - [[window contentView] addSubview:visualEffectView_]; |
| - } else { |
| - [rootView addSubview:visualEffectView_ |
| - positioned:NSWindowBelow |
| - relativeTo:nil]; |
| - } |
| - |
| - // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView. |
| - [tabStripBackgroundView_ setFrame:[visualEffectView_ bounds]]; |
| - [visualEffectView_ addSubview:tabStripBackgroundView_]; |
| -} |
| - |
| // Called when the size of the window content area has changed. Override to |
| // position specific views. Base class implementation does nothing. |
| - (void)layoutSubviews { |
| NOTIMPLEMENTED(); |
| } |
| -- (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { |
| - [[visualEffectView_ animator] setAlphaValue:0.0]; |
| -} |
| - |
| -- (void)windowWillExitFullScreenNotification:(NSNotification*)notification { |
| - [[visualEffectView_ animator] setAlphaValue:1.0]; |
| -} |
| - |
| @end |