| 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" | |
| 26 #import "chrome/browser/ui/cocoa/browser_window_layout.h" | 25 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 27 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 26 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
| 28 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 27 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 29 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 28 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 30 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" | 29 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" |
| 31 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 30 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 32 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 31 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
| 33 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 32 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
| 34 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 33 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
| 35 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 34 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; | 675 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; |
| 677 | 676 |
| 678 fullscreen_mac::SlidingStyle style = | 677 fullscreen_mac::SlidingStyle style = |
| 679 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN | 678 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN |
| 680 : fullscreen_mac::OMNIBOX_TABS_PRESENT; | 679 : fullscreen_mac::OMNIBOX_TABS_PRESENT; |
| 681 | 680 |
| 682 [self adjustUIForSlidingFullscreenStyle:style]; | 681 [self adjustUIForSlidingFullscreenStyle:style]; |
| 683 } | 682 } |
| 684 | 683 |
| 685 - (void)windowDidEnterFullScreen:(NSNotification*)notification { | 684 - (void)windowDidEnterFullScreen:(NSNotification*)notification { |
| 686 enterFullscreenTransition_.reset(); | |
| 687 | |
| 688 // In Yosemite, some combination of the titlebar and toolbar always show in | 685 // In Yosemite, some combination of the titlebar and toolbar always show in |
| 689 // full-screen mode. We do not want either to show. Search for the window that | 686 // full-screen mode. We do not want either to show. Search for the window that |
| 690 // contains the views, and hide it. There is no need to ever unhide the view. | 687 // contains the views, and hide it. There is no need to ever unhide the view. |
| 691 // http://crbug.com/380235 | 688 // http://crbug.com/380235 |
| 692 if (base::mac::IsOSYosemiteOrLater()) { | 689 if (base::mac::IsOSYosemiteOrLater()) { |
| 693 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { | 690 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { |
| 694 if ([window | 691 if ([window |
| 695 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { | 692 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { |
| 696 [[window contentView] setHidden:YES]; | 693 [[window contentView] setHidden:YES]; |
| 697 } | 694 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 | 995 |
| 999 // Add in the subviews above the tabContentArea. | 996 // Add in the subviews above the tabContentArea. |
| 1000 for (NSUInteger i = index + 1; i < [subviews count]; ++i) { | 997 for (NSUInteger i = index + 1; i < [subviews count]; ++i) { |
| 1001 NSView* view = [subviews objectAtIndex:i]; | 998 NSView* view = [subviews objectAtIndex:i]; |
| 1002 [self.chromeContentView addSubview:view | 999 [self.chromeContentView addSubview:view |
| 1003 positioned:NSWindowAbove | 1000 positioned:NSWindowAbove |
| 1004 relativeTo:nil]; | 1001 relativeTo:nil]; |
| 1005 } | 1002 } |
| 1006 } | 1003 } |
| 1007 | 1004 |
| 1008 + (BOOL)systemSettingsRequireMavericksAppKitFullscreenHack { | 1005 - (BOOL)shouldUseMavericksAppKitFullscreenHack { |
| 1009 if (!base::mac::IsOSMavericks()) | 1006 if (!base::mac::IsOSMavericks()) |
| 1010 return NO; | 1007 return NO; |
| 1011 return [NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] && | 1008 if (![NSScreen respondsToSelector:@selector(screensHaveSeparateSpaces)] || |
| 1012 [NSScreen screensHaveSeparateSpaces]; | 1009 ![NSScreen screensHaveSeparateSpaces]) { |
| 1013 } | |
| 1014 | |
| 1015 - (BOOL)shouldUseMavericksAppKitFullscreenHack { | |
| 1016 if (![[self class] systemSettingsRequireMavericksAppKitFullscreenHack]) | |
| 1017 return NO; | 1010 return NO; |
| 1011 } |
| 1018 if (!enteringAppKitFullscreen_) | 1012 if (!enteringAppKitFullscreen_) |
| 1019 return NO; | 1013 return NO; |
| 1020 if (enteringAppKitFullscreenOnPrimaryScreen_) | 1014 if (enteringAppKitFullscreenOnPrimaryScreen_) |
| 1021 return NO; | 1015 return NO; |
| 1022 | 1016 |
| 1023 return YES; | 1017 return YES; |
| 1024 } | 1018 } |
| 1025 | 1019 |
| 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 | |
| 1072 @end // @implementation BrowserWindowController(Private) | 1020 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |