| 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 #import "base/auto_reset.h" | 9 #import "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 446 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 447 [center removeObserver:self | 447 [center removeObserver:self |
| 448 name:NSWindowWillCloseNotification | 448 name:NSWindowWillCloseNotification |
| 449 object:[notification object]]; | 449 object:[notification object]]; |
| 450 [self releaseBarVisibilityForOwner:[notification object] | 450 [self releaseBarVisibilityForOwner:[notification object] |
| 451 withAnimation:YES | 451 withAnimation:YES |
| 452 delay:YES]; | 452 delay:YES]; |
| 453 } | 453 } |
| 454 | 454 |
| 455 - (void)configurePresentationModeController { | 455 - (void)configurePresentationModeController { |
| 456 BOOL fullscreen_for_tab = browser_->exclusive_access_manager() | 456 BOOL fullscreenForTab = [self isFullscreenForTabContent]; |
| 457 ->fullscreen_controller() | 457 BOOL kioskMode = |
| 458 ->IsWindowFullscreenForTabOrPending(); | |
| 459 BOOL kiosk_mode = | |
| 460 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 458 base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 461 BOOL showDropdown = | 459 BOOL showDropdown = |
| 462 !fullscreen_for_tab && !kiosk_mode && ([self floatingBarHasFocus]); | 460 !fullscreenForTab && !kioskMode && ([self floatingBarHasFocus]); |
| 463 | 461 |
| 464 PermissionBubbleManager* manager = [self permissionBubbleManager]; | 462 PermissionBubbleManager* manager = [self permissionBubbleManager]; |
| 465 if (manager && manager->IsBubbleVisible()) { | 463 if (manager && manager->IsBubbleVisible()) { |
| 466 NSWindow* bubbleWindow = manager->GetBubbleWindow(); | 464 NSWindow* bubbleWindow = manager->GetBubbleWindow(); |
| 467 DCHECK(bubbleWindow); | 465 DCHECK(bubbleWindow); |
| 468 // A visible permission bubble will force the dropdown to remain | 466 // A visible permission bubble will force the dropdown to remain |
| 469 // visible. | 467 // visible. |
| 470 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO]; | 468 [self lockBarVisibilityForOwner:bubbleWindow withAnimation:NO delay:NO]; |
| 471 showDropdown = YES; | 469 showDropdown = YES; |
| 472 // Register to be notified when the permission bubble is closed, to | 470 // Register to be notified when the permission bubble is closed, to |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 if (isUsingCustomAnimation_) | 706 if (isUsingCustomAnimation_) |
| 709 blockLayoutSubviews_ = YES; | 707 blockLayoutSubviews_ = YES; |
| 710 else | 708 else |
| 711 [self adjustUIForEnteringFullscreen]; | 709 [self adjustUIForEnteringFullscreen]; |
| 712 } | 710 } |
| 713 | 711 |
| 714 - (void)windowDidEnterFullScreen:(NSNotification*)notification { | 712 - (void)windowDidEnterFullScreen:(NSNotification*)notification { |
| 715 blockLayoutSubviews_ = NO; | 713 blockLayoutSubviews_ = NO; |
| 716 fullscreenTransition_.reset(); | 714 fullscreenTransition_.reset(); |
| 717 | 715 |
| 716 if ([self isFullscreenForTabContent]) { |
| 717 NSRect windowFrame = [self window].frame; |
| 718 NSRect contentViewFrame = |
| 719 NSMakeRect(0, 0, windowFrame.size.width, windowFrame.size.height); |
| 720 [self.chromeContentView setFrame:contentViewFrame]; |
| 721 } |
| 722 |
| 718 // In Yosemite, some combination of the titlebar and toolbar always show in | 723 // In Yosemite, some combination of the titlebar and toolbar always show in |
| 719 // full-screen mode. We do not want either to show. Search for the window that | 724 // full-screen mode. We do not want either to show. Search for the window that |
| 720 // contains the views, and hide it. There is no need to ever unhide the view. | 725 // contains the views, and hide it. There is no need to ever unhide the view. |
| 721 // http://crbug.com/380235 | 726 // http://crbug.com/380235 |
| 722 if (base::mac::IsOSYosemiteOrLater()) { | 727 if (base::mac::IsOSYosemiteOrLater()) { |
| 723 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { | 728 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { |
| 724 if ([window | 729 if ([window |
| 725 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { | 730 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { |
| 726 // Hide the toolbar if it is for a FramedBrowserWindow. | 731 // Hide the toolbar if it is for a FramedBrowserWindow. |
| 727 if ([window respondsToSelector:@selector(_windowForToolbar)]) { | 732 if ([window respondsToSelector:@selector(_windowForToolbar)]) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 [sheetController unhideSheetForFullscreenTransition]; | 853 [sheetController unhideSheetForFullscreenTransition]; |
| 849 } | 854 } |
| 850 | 855 |
| 851 - (void)adjustUIForExitingFullscreen { | 856 - (void)adjustUIForExitingFullscreen { |
| 852 [self destroyFullscreenExitBubbleIfNecessary]; | 857 [self destroyFullscreenExitBubbleIfNecessary]; |
| 853 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; | 858 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; |
| 854 } | 859 } |
| 855 | 860 |
| 856 - (void)adjustUIForEnteringFullscreen { | 861 - (void)adjustUIForEnteringFullscreen { |
| 857 fullscreen_mac::SlidingStyle style; | 862 fullscreen_mac::SlidingStyle style; |
| 858 if (browser_->exclusive_access_manager() | 863 if ([self isFullscreenForTabContent]) { |
| 859 ->fullscreen_controller() | |
| 860 ->IsWindowFullscreenForTabOrPending()) { | |
| 861 style = fullscreen_mac::OMNIBOX_TABS_NONE; | 864 style = fullscreen_mac::OMNIBOX_TABS_NONE; |
| 862 } else if (enteringPresentationMode_) { | 865 } else if (enteringPresentationMode_) { |
| 863 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN; | 866 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN; |
| 864 } else { | 867 } else { |
| 865 style = fullscreen_mac::OMNIBOX_TABS_PRESENT; | 868 style = fullscreen_mac::OMNIBOX_TABS_PRESENT; |
| 866 } | 869 } |
| 867 | 870 |
| 868 [self adjustUIForSlidingFullscreenStyle:style]; | 871 [self adjustUIForSlidingFullscreenStyle:style]; |
| 869 } | 872 } |
| 870 | 873 |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 - (BOOL)shouldUseCustomAppKitFullscreenTransition:(BOOL)enterFullScreen { | 1163 - (BOOL)shouldUseCustomAppKitFullscreenTransition:(BOOL)enterFullScreen { |
| 1161 // Custom fullscreen transitions should only be available in OSX 10.10+. | 1164 // Custom fullscreen transitions should only be available in OSX 10.10+. |
| 1162 if (base::mac::IsOSMountainLionOrEarlier()) | 1165 if (base::mac::IsOSMountainLionOrEarlier()) |
| 1163 return NO; | 1166 return NO; |
| 1164 | 1167 |
| 1165 // Disable the custom exit animation in OSX 10.9: | 1168 // Disable the custom exit animation in OSX 10.9: |
| 1166 // https://code.google.com/p/chromium/issues/detail?id=526327#c3. | 1169 // https://code.google.com/p/chromium/issues/detail?id=526327#c3. |
| 1167 if (base::mac::IsOSMavericks() && !enterFullScreen) | 1170 if (base::mac::IsOSMavericks() && !enterFullScreen) |
| 1168 return NO; | 1171 return NO; |
| 1169 | 1172 |
| 1173 // Temporary disable custom enter animation since it currently breaks the |
| 1174 // fullscreen Flash content. |
| 1175 // TODO(spqchan): Fix the custom animation to enter fullscreen so that it |
| 1176 // will work with Flash content. |
| 1177 if (enterFullScreen && [self isFullscreenForTabContent]) |
| 1178 return NO; |
| 1179 |
| 1170 NSView* root = [[self.window contentView] superview]; | 1180 NSView* root = [[self.window contentView] superview]; |
| 1171 if (!root.layer) | 1181 if (!root.layer) |
| 1172 return NO; | 1182 return NO; |
| 1173 | 1183 |
| 1174 // AppKit on OSX 10.9 has a bug for applications linked against OSX 10.8 SDK | 1184 // AppKit on OSX 10.9 has a bug for applications linked against OSX 10.8 SDK |
| 1175 // and earlier. Under specific circumstances, it prevents the custom AppKit | 1185 // and earlier. Under specific circumstances, it prevents the custom AppKit |
| 1176 // transition from working well. See http://crbug.com/396980 for more | 1186 // transition from working well. See http://crbug.com/396980 for more |
| 1177 // details. | 1187 // details. |
| 1178 if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] && | 1188 if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] && |
| 1179 ![[[self window] screen] isEqual:[[NSScreen screens] firstObject]]) { | 1189 ![[[self window] screen] isEqual:[[NSScreen screens] firstObject]]) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 - (WebContents*)webContents { | 1258 - (WebContents*)webContents { |
| 1249 return browser_->tab_strip_model()->GetActiveWebContents(); | 1259 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 1250 } | 1260 } |
| 1251 | 1261 |
| 1252 - (PermissionBubbleManager*)permissionBubbleManager { | 1262 - (PermissionBubbleManager*)permissionBubbleManager { |
| 1253 if (WebContents* contents = [self webContents]) | 1263 if (WebContents* contents = [self webContents]) |
| 1254 return PermissionBubbleManager::FromWebContents(contents); | 1264 return PermissionBubbleManager::FromWebContents(contents); |
| 1255 return nil; | 1265 return nil; |
| 1256 } | 1266 } |
| 1257 | 1267 |
| 1268 - (BOOL)isFullscreenForTabContent { |
| 1269 return browser_->exclusive_access_manager() |
| 1270 ->fullscreen_controller() |
| 1271 ->IsWindowFullscreenForTabOrPending(); |
| 1272 } |
| 1273 |
| 1258 @end // @implementation BrowserWindowController(Private) | 1274 @end // @implementation BrowserWindowController(Private) |
| OLD | NEW |