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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 846443004: mac: Implement custom AppKit Enter Fullscreen transition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
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/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #import "base/mac/scoped_nsobject.h" 13 #import "base/mac/scoped_nsobject.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/prefs/scoped_user_pref_update.h" 17 #include "base/prefs/scoped_user_pref_update.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/fullscreen.h" 19 #include "chrome/browser/fullscreen.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 21 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_window_state.h" 24 #include "chrome/browser/ui/browser_window_state.h"
25 #import "chrome/browser/ui/cocoa/browser_window_enter_fullscreen_transition.h"
25 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 26 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
26 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 27 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
27 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 28 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
28 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 29 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
29 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 30 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
30 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 31 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
31 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 32 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
32 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 33 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
33 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 34 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
34 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" 35 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; 676 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]];
676 677
677 fullscreen_mac::SlidingStyle style = 678 fullscreen_mac::SlidingStyle style =
678 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN 679 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN
679 : fullscreen_mac::OMNIBOX_TABS_PRESENT; 680 : fullscreen_mac::OMNIBOX_TABS_PRESENT;
680 681
681 [self adjustUIForSlidingFullscreenStyle:style]; 682 [self adjustUIForSlidingFullscreenStyle:style];
682 } 683 }
683 684
684 - (void)windowDidEnterFullScreen:(NSNotification*)notification { 685 - (void)windowDidEnterFullScreen:(NSNotification*)notification {
686 enterFullscreenTransition_.reset();
687
685 // In Yosemite, some combination of the titlebar and toolbar always show in 688 // In Yosemite, some combination of the titlebar and toolbar always show in
686 // full-screen mode. We do not want either to show. Search for the window that 689 // full-screen mode. We do not want either to show. Search for the window that
687 // contains the views, and hide it. There is no need to ever unhide the view. 690 // contains the views, and hide it. There is no need to ever unhide the view.
688 // http://crbug.com/380235 691 // http://crbug.com/380235
689 if (base::mac::IsOSYosemiteOrLater()) { 692 if (base::mac::IsOSYosemiteOrLater()) {
690 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { 693 for (NSWindow* window in [[NSApplication sharedApplication] windows]) {
691 if ([window 694 if ([window
692 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { 695 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) {
693 [[window contentView] setHidden:YES]; 696 [[window contentView] setHidden:YES];
694 } 697 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return NO; 1013 return NO;
1011 } 1014 }
1012 if (!enteringAppKitFullscreen_) 1015 if (!enteringAppKitFullscreen_)
1013 return NO; 1016 return NO;
1014 if (enteringAppKitFullscreenOnPrimaryScreen_) 1017 if (enteringAppKitFullscreenOnPrimaryScreen_)
1015 return NO; 1018 return NO;
1016 1019
1017 return YES; 1020 return YES;
1018 } 1021 }
1019 1022
1023 - (BOOL)shouldUseCustomAppKitFullscreenTransition {
1024 if (base::mac::IsOSMountainLionOrEarlier())
1025 return NO;
1026 NSView* root = [[self.window contentView] superview];
1027 return root.layer != nil;
1028 }
1029
1030 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
1031 DCHECK([window isEqual:self.window]);
1032
1033 if (![self shouldUseCustomAppKitFullscreenTransition])
1034 return nil;
1035
1036 enterFullscreenTransition_.reset(
1037 [[BrowserWindowEnterFullscreenTransition alloc]
1038 initWithWindow:self.window]);
1039 return [enterFullscreenTransition_ customWindowsToEnterFullScreen];
1040 }
1041
1042 - (void)window:(NSWindow*)window
1043 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
1044 DCHECK([window isEqual:self.window]);
1045 [enterFullscreenTransition_
1046 startCustomAnimationToEnterFullScreenWithDuration:duration];
1047 }
1048
1049 - (BOOL)shouldConstrainFrameRect {
1050 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained])
1051 return NO;
1052
1053 return [super shouldConstrainFrameRect];
1054 }
1055
1020 @end // @implementation BrowserWindowController(Private) 1056 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698