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/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 Loading... |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 | 998 |
996 // Add in the subviews above the tabContentArea. | 999 // Add in the subviews above the tabContentArea. |
997 for (NSUInteger i = index + 1; i < [subviews count]; ++i) { | 1000 for (NSUInteger i = index + 1; i < [subviews count]; ++i) { |
998 NSView* view = [subviews objectAtIndex:i]; | 1001 NSView* view = [subviews objectAtIndex:i]; |
999 [self.chromeContentView addSubview:view | 1002 [self.chromeContentView addSubview:view |
1000 positioned:NSWindowAbove | 1003 positioned:NSWindowAbove |
1001 relativeTo:nil]; | 1004 relativeTo:nil]; |
1002 } | 1005 } |
1003 } | 1006 } |
1004 | 1007 |
1005 - (BOOL)shouldUseMavericksAppKitFullscreenHack { | 1008 + (BOOL)systemSettingsRequireMavericksAppKitFullscreenHack { |
1006 if (!base::mac::IsOSMavericks()) | 1009 if (!base::mac::IsOSMavericks()) |
1007 return NO; | 1010 return NO; |
1008 if (![NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] || | 1011 return [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && |
1009 ![NSScreen screensHaveSeparateSpaces]) { | 1012 [NSScreen screensHaveSeparateSpaces]; |
| 1013 } |
| 1014 |
| 1015 - (BOOL)shouldUseMavericksAppKitFullscreenHack { |
| 1016 if (![[self class] systemSettingsRequireMavericksAppKitFullscreenHack]) |
1010 return NO; | 1017 return NO; |
1011 } | |
1012 if (!enteringAppKitFullscreen_) | 1018 if (!enteringAppKitFullscreen_) |
1013 return NO; | 1019 return NO; |
1014 if (enteringAppKitFullscreenOnPrimaryScreen_) | 1020 if (enteringAppKitFullscreenOnPrimaryScreen_) |
1015 return NO; | 1021 return NO; |
1016 | 1022 |
1017 return YES; | 1023 return YES; |
1018 } | 1024 } |
1019 | 1025 |
| 1026 - (BOOL)shouldUseCustomAppKitFullscreenTransition { |
| 1027 if (base::mac::IsOSMountainLionOrEarlier()) |
| 1028 return NO; |
| 1029 |
| 1030 NSView* root = [[self.window contentView] superview]; |
| 1031 if (!root.layer) |
| 1032 return NO; |
| 1033 |
| 1034 // AppKit on OSX 10.9 has a bug for applications linked against OSX 10.8 SDK |
| 1035 // and earlier. Under specific circumstances, it prevents the custom AppKit |
| 1036 // transition from working well. See http://crbug.com/396980 for more |
| 1037 // details. |
| 1038 if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] && |
| 1039 ![[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) { |
| 1040 return NO; |
| 1041 } |
| 1042 |
| 1043 return YES; |
| 1044 } |
| 1045 |
| 1046 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window { |
| 1047 DCHECK([window isEqual:self.window]); |
| 1048 |
| 1049 if (![self shouldUseCustomAppKitFullscreenTransition]) |
| 1050 return nil; |
| 1051 |
| 1052 enterFullscreenTransition_.reset( |
| 1053 [[BrowserWindowEnterFullscreenTransition alloc] |
| 1054 initWithWindow:self.window]); |
| 1055 return [enterFullscreenTransition_ customWindowsToEnterFullScreen]; |
| 1056 } |
| 1057 |
| 1058 - (void)window:(NSWindow*)window |
| 1059 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration { |
| 1060 DCHECK([window isEqual:self.window]); |
| 1061 [enterFullscreenTransition_ |
| 1062 startCustomAnimationToEnterFullScreenWithDuration:duration]; |
| 1063 } |
| 1064 |
| 1065 - (BOOL)shouldConstrainFrameRect { |
| 1066 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained]) |
| 1067 return NO; |
| 1068 |
| 1069 return [super shouldConstrainFrameRect]; |
| 1070 } |
| 1071 |
1020 @end // @implementation BrowserWindowController(Private) | 1072 @end // @implementation BrowserWindowController(Private) |
OLD | NEW |