| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // Called right after our window became the main window. | 607 // Called right after our window became the main window. |
| 608 - (void)windowDidBecomeMain:(NSNotification*)notification { | 608 - (void)windowDidBecomeMain:(NSNotification*)notification { |
| 609 BrowserList::SetLastActive(browser_.get()); | 609 BrowserList::SetLastActive(browser_.get()); |
| 610 [self saveWindowPositionIfNeeded]; | 610 [self saveWindowPositionIfNeeded]; |
| 611 | 611 |
| 612 // TODO(dmaclach): Instead of redrawing the whole window, views that care | 612 // TODO(dmaclach): Instead of redrawing the whole window, views that care |
| 613 // about the active window state should be registering for notifications. | 613 // about the active window state should be registering for notifications. |
| 614 [[self window] setViewsNeedDisplay:YES]; | 614 [[self window] setViewsNeedDisplay:YES]; |
| 615 | 615 |
| 616 // TODO(viettrungluu): For some reason, the above doesn't suffice. | 616 // TODO(viettrungluu): For some reason, the above doesn't suffice. |
| 617 if ([self isFullscreen]) | 617 if ([self isInAnyFullscreenMode]) |
| 618 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. | 618 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. |
| 619 } | 619 } |
| 620 | 620 |
| 621 - (void)windowDidResignMain:(NSNotification*)notification { | 621 - (void)windowDidResignMain:(NSNotification*)notification { |
| 622 // TODO(dmaclach): Instead of redrawing the whole window, views that care | 622 // TODO(dmaclach): Instead of redrawing the whole window, views that care |
| 623 // about the active window state should be registering for notifications. | 623 // about the active window state should be registering for notifications. |
| 624 [[self window] setViewsNeedDisplay:YES]; | 624 [[self window] setViewsNeedDisplay:YES]; |
| 625 | 625 |
| 626 // TODO(viettrungluu): For some reason, the above doesn't suffice. | 626 // TODO(viettrungluu): For some reason, the above doesn't suffice. |
| 627 if ([self isFullscreen]) | 627 if ([self isInAnyFullscreenMode]) |
| 628 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. | 628 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. |
| 629 } | 629 } |
| 630 | 630 |
| 631 // Called when we are activated (when we gain focus). | 631 // Called when we are activated (when we gain focus). |
| 632 - (void)windowDidBecomeKey:(NSNotification*)notification { | 632 - (void)windowDidBecomeKey:(NSNotification*)notification { |
| 633 // We need to activate the controls (in the "WebView"). To do this, get the | 633 // We need to activate the controls (in the "WebView"). To do this, get the |
| 634 // selected WebContents's RenderWidgetHostView and tell it to activate. | 634 // selected WebContents's RenderWidgetHostView and tell it to activate. |
| 635 if (WebContents* contents = | 635 if (WebContents* contents = |
| 636 browser_->tab_strip_model()->GetActiveWebContents()) { | 636 browser_->tab_strip_model()->GetActiveWebContents()) { |
| 637 | 637 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 838 } |
| 839 | 839 |
| 840 // If it wasn't reasonable, return NO. | 840 // If it wasn't reasonable, return NO. |
| 841 return NO; | 841 return NO; |
| 842 } | 842 } |
| 843 | 843 |
| 844 // Adjusts the window height by the given amount. | 844 // Adjusts the window height by the given amount. |
| 845 - (BOOL)adjustWindowHeightBy:(CGFloat)deltaH { | 845 - (BOOL)adjustWindowHeightBy:(CGFloat)deltaH { |
| 846 // By not adjusting the window height when initializing, we can ensure that | 846 // By not adjusting the window height when initializing, we can ensure that |
| 847 // the window opens with the same size that was saved on close. | 847 // the window opens with the same size that was saved on close. |
| 848 if (initializing_ || [self isFullscreen] || deltaH == 0) | 848 if (initializing_ || [self isInAnyFullscreenMode] || deltaH == 0) |
| 849 return NO; | 849 return NO; |
| 850 | 850 |
| 851 NSWindow* window = [self window]; | 851 NSWindow* window = [self window]; |
| 852 NSRect windowFrame = [window frame]; | 852 NSRect windowFrame = [window frame]; |
| 853 NSRect workarea = [[window screen] visibleFrame]; | 853 NSRect workarea = [[window screen] visibleFrame]; |
| 854 | 854 |
| 855 // If the window is not already fully in the workarea, do not adjust its frame | 855 // If the window is not already fully in the workarea, do not adjust its frame |
| 856 // at all. | 856 // at all. |
| 857 if (!NSContainsRect(workarea, windowFrame)) | 857 if (!NSContainsRect(workarea, windowFrame)) |
| 858 return NO; | 858 return NO; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 // Disable "close tab" if the receiving window is not tabbed. | 1080 // Disable "close tab" if the receiving window is not tabbed. |
| 1081 // We simply check whether the item has a keyboard shortcut set here; | 1081 // We simply check whether the item has a keyboard shortcut set here; |
| 1082 // app_controller_mac.mm actually determines whether the item should | 1082 // app_controller_mac.mm actually determines whether the item should |
| 1083 // be enabled. | 1083 // be enabled. |
| 1084 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) | 1084 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) |
| 1085 enable &= !![[menuItem keyEquivalent] length]; | 1085 enable &= !![[menuItem keyEquivalent] length]; |
| 1086 break; | 1086 break; |
| 1087 case IDC_FULLSCREEN: { | 1087 case IDC_FULLSCREEN: { |
| 1088 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { | 1088 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { |
| 1089 NSString* menuTitle = l10n_util::GetNSString( | 1089 NSString* menuTitle = l10n_util::GetNSString( |
| 1090 [self isFullscreen] && ![self inPresentationMode] ? | 1090 [self isInAppKitFullscreen] && ![self inPresentationMode] |
| 1091 IDS_EXIT_FULLSCREEN_MAC : | 1091 ? IDS_EXIT_FULLSCREEN_MAC |
| 1092 IDS_ENTER_FULLSCREEN_MAC); | 1092 : IDS_ENTER_FULLSCREEN_MAC); |
| 1093 [menuItem setTitle:menuTitle]; | 1093 [menuItem setTitle:menuTitle]; |
| 1094 | 1094 |
| 1095 if (!chrome::mac::SupportsSystemFullscreen()) | 1095 if (!chrome::mac::SupportsSystemFullscreen()) |
| 1096 [menuItem setHidden:YES]; | 1096 [menuItem setHidden:YES]; |
| 1097 } | 1097 } |
| 1098 break; | 1098 break; |
| 1099 } | 1099 } |
| 1100 case IDC_PRESENTATION_MODE: { | 1100 case IDC_PRESENTATION_MODE: { |
| 1101 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { | 1101 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { |
| 1102 NSString* menuTitle = l10n_util::GetNSString( | 1102 NSString* menuTitle = l10n_util::GetNSString( |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 // into its own window (then the overlay window will be present). | 1484 // into its own window (then the overlay window will be present). |
| 1485 return [[self tabStripController] isDragSessionActive] || | 1485 return [[self tabStripController] isDragSessionActive] || |
| 1486 [self overlayWindow] != nil; | 1486 [self overlayWindow] != nil; |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 - (BOOL)tabDraggingAllowed { | 1489 - (BOOL)tabDraggingAllowed { |
| 1490 return [tabStripController_ tabDraggingAllowed]; | 1490 return [tabStripController_ tabDraggingAllowed]; |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 - (BOOL)tabTearingAllowed { | 1493 - (BOOL)tabTearingAllowed { |
| 1494 return ![self isFullscreen]; | 1494 return ![self isInAnyFullscreenMode]; |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 - (BOOL)windowMovementAllowed { | 1497 - (BOOL)windowMovementAllowed { |
| 1498 return ![self isFullscreen]; | 1498 return ![self isInAnyFullscreenMode]; |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 - (BOOL)isTabFullyVisible:(TabView*)tab { | 1501 - (BOOL)isTabFullyVisible:(TabView*)tab { |
| 1502 return [tabStripController_ isTabFullyVisible:tab]; | 1502 return [tabStripController_ isTabFullyVisible:tab]; |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 - (void)showNewTabButton:(BOOL)show { | 1505 - (void)showNewTabButton:(BOOL)show { |
| 1506 [tabStripController_ showNewTabButton:show]; | 1506 [tabStripController_ showNewTabButton:show]; |
| 1507 } | 1507 } |
| 1508 | 1508 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 return downloadShelfController_; | 1557 return downloadShelfController_; |
| 1558 } | 1558 } |
| 1559 | 1559 |
| 1560 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1560 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 1561 // Shouldn't call addFindBar twice. | 1561 // Shouldn't call addFindBar twice. |
| 1562 DCHECK(!findBarCocoaController_.get()); | 1562 DCHECK(!findBarCocoaController_.get()); |
| 1563 | 1563 |
| 1564 // Create a controller for the findbar. | 1564 // Create a controller for the findbar. |
| 1565 findBarCocoaController_.reset([findBarCocoaController retain]); | 1565 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 1566 [self layoutSubviews]; | 1566 [self layoutSubviews]; |
| 1567 [self updateSubviewZOrder:[self inPresentationMode]]; | 1567 [self updateSubviewZOrder:[self isInFullscreenWithOmniboxSliding]]; |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 - (NSWindow*)createFullscreenWindow { | 1570 - (NSWindow*)createFullscreenWindow { |
| 1571 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1571 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
| 1572 autorelease]; | 1572 autorelease]; |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 - (NSInteger)numberOfTabs { | 1575 - (NSInteger)numberOfTabs { |
| 1576 // count() includes pinned tabs. | 1576 // count() includes pinned tabs. |
| 1577 return browser_->tab_strip_model()->count(); | 1577 return browser_->tab_strip_model()->count(); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 - (BOOL)hasLiveTabs { | 1580 - (BOOL)hasLiveTabs { |
| 1581 return !browser_->tab_strip_model()->empty(); | 1581 return !browser_->tab_strip_model()->empty(); |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 - (NSString*)activeTabTitle { | 1584 - (NSString*)activeTabTitle { |
| 1585 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 1585 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 1586 return base::SysUTF16ToNSString(contents->GetTitle()); | 1586 return base::SysUTF16ToNSString(contents->GetTitle()); |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 - (NSRect)regularWindowFrame { | 1589 - (NSRect)regularWindowFrame { |
| 1590 return [self isFullscreen] ? savedRegularWindowFrame_ : | 1590 return [self isInAnyFullscreenMode] ? savedRegularWindowFrame_ |
| 1591 [[self window] frame]; | 1591 : [[self window] frame]; |
| 1592 } | 1592 } |
| 1593 | 1593 |
| 1594 // (Override of |TabWindowController| method.) | 1594 // (Override of |TabWindowController| method.) |
| 1595 - (BOOL)hasTabStrip { | 1595 - (BOOL)hasTabStrip { |
| 1596 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; | 1596 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 - (BOOL)isTabDraggable:(NSView*)tabView { | 1599 - (BOOL)isTabDraggable:(NSView*)tabView { |
| 1600 // TODO(avi, thakis): ConstrainedWindowSheetController has no api to move | 1600 // TODO(avi, thakis): ConstrainedWindowSheetController has no api to move |
| 1601 // tabsheets between windows. Until then, we have to prevent having to move a | 1601 // tabsheets between windows. Until then, we have to prevent having to move a |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 command:(const extensions::Command&)command { | 2025 command:(const extensions::Command&)command { |
| 2026 // Global commands are handled by the ExtensionCommandsGlobalRegistry | 2026 // Global commands are handled by the ExtensionCommandsGlobalRegistry |
| 2027 // instance. | 2027 // instance. |
| 2028 DCHECK(!command.global()); | 2028 DCHECK(!command.global()); |
| 2029 extension_keybinding_registry_->ExecuteCommand(extension_id, | 2029 extension_keybinding_registry_->ExecuteCommand(extension_id, |
| 2030 command.accelerator()); | 2030 command.accelerator()); |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 @end // @implementation BrowserWindowController | 2033 @end // @implementation BrowserWindowController |
| 2034 | 2034 |
| 2035 | |
| 2036 @implementation BrowserWindowController(Fullscreen) | 2035 @implementation BrowserWindowController(Fullscreen) |
| 2037 | 2036 |
| 2038 - (void)handleLionToggleFullscreen { | 2037 - (void)handleLionToggleFullscreen { |
| 2039 DCHECK(base::mac::IsOSLionOrLater()); | 2038 DCHECK(base::mac::IsOSLionOrLater()); |
| 2040 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); | 2039 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); |
| 2041 } | 2040 } |
| 2042 | 2041 |
| 2043 // Called to transition into or out of fullscreen mode. Only use System | 2042 - (void)enterFullscreenWithChrome { |
| 2044 // Fullscreen mode if the system supports it and we aren't trying to go | 2043 if (![self isInAppKitFullscreen]) { |
| 2045 // fullscreen for the renderer-initiated use cases. | 2044 // Invoking the AppKitFullscreen API by default uses Canonical Fullscreen. |
| 2046 // Discussion: http://crbug.com/179181 and http:/crbug.com/351252 | 2045 [self enterAppKitFullscreen]; |
| 2047 - (void)setFullscreen:(BOOL)fullscreen { | |
| 2048 if (fullscreen == [self isFullscreen]) | |
| 2049 return; | 2046 return; |
| 2047 } |
| 2050 | 2048 |
| 2051 if (fullscreen) { | 2049 // If AppKitFullscreen is already enabled, then just switch to Canonical |
| 2052 const BOOL shouldUseSystemFullscreen = | 2050 // Fullscreen. |
| 2053 chrome::mac::SupportsSystemFullscreen() && !fullscreenWindow_ && | 2051 [self adjustUIForSlidingFullscreenStyle:fullscreen_mac::OMNIBOX_TABS_PRESENT]; |
| 2054 !browser_->fullscreen_controller()->IsWindowFullscreenForTabOrPending(); | |
| 2055 if (shouldUseSystemFullscreen) { | |
| 2056 if (FramedBrowserWindow* framedBrowserWindow = | |
| 2057 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { | |
| 2058 [framedBrowserWindow toggleSystemFullScreen]; | |
| 2059 } | |
| 2060 } else { | |
| 2061 [self enterImmersiveFullscreen]; | |
| 2062 } | |
| 2063 } else { | |
| 2064 if ([self isInSystemFullscreen]) { | |
| 2065 if (FramedBrowserWindow* framedBrowserWindow = | |
| 2066 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { | |
| 2067 [framedBrowserWindow toggleSystemFullScreen]; | |
| 2068 } | |
| 2069 } else { | |
| 2070 DCHECK(fullscreenWindow_.get()); | |
| 2071 [self exitImmersiveFullscreen]; | |
| 2072 } | |
| 2073 } | |
| 2074 } | |
| 2075 | |
| 2076 - (void)enterFullscreen { | |
| 2077 [self setFullscreen:YES]; | |
| 2078 } | |
| 2079 | |
| 2080 - (void)exitFullscreen { | |
| 2081 [self setFullscreen:NO]; | |
| 2082 } | 2052 } |
| 2083 | 2053 |
| 2084 - (void)updateFullscreenExitBubbleURL:(const GURL&)url | 2054 - (void)updateFullscreenExitBubbleURL:(const GURL&)url |
| 2085 bubbleType:(FullscreenExitBubbleType)bubbleType { | 2055 bubbleType:(FullscreenExitBubbleType)bubbleType { |
| 2086 fullscreenUrl_ = url; | 2056 fullscreenUrl_ = url; |
| 2087 fullscreenBubbleType_ = bubbleType; | 2057 fullscreenBubbleType_ = bubbleType; |
| 2088 [self layoutSubviews]; | 2058 [self layoutSubviews]; |
| 2089 [self showFullscreenExitBubbleIfNecessary]; | 2059 [self showFullscreenExitBubbleIfNecessary]; |
| 2090 } | 2060 } |
| 2091 | 2061 |
| 2092 - (BOOL)isFullscreen { | 2062 - (BOOL)isInAnyFullscreenMode { |
| 2093 return [self isInImmersiveFullscreen] || | 2063 return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen]; |
| 2094 [self isInSystemFullscreen] || | |
| 2095 enteringFullscreen_; | |
| 2096 } | 2064 } |
| 2097 | 2065 |
| 2098 - (BOOL)isInImmersiveFullscreen { | 2066 - (BOOL)isInImmersiveFullscreen { |
| 2099 return fullscreenWindow_.get() != nil; | 2067 return fullscreenWindow_.get() != nil || enteringImmersiveFullscreen_; |
| 2100 } | 2068 } |
| 2101 | 2069 |
| 2102 - (BOOL)isInSystemFullscreen { | 2070 - (BOOL)isInAppKitFullscreen { |
| 2103 return ([[self window] styleMask] & NSFullScreenWindowMask) == | 2071 return ([[self window] styleMask] & NSFullScreenWindowMask) == |
| 2104 NSFullScreenWindowMask; | 2072 NSFullScreenWindowMask || |
| 2073 enteringAppKitFullscreen_; |
| 2105 } | 2074 } |
| 2106 | 2075 |
| 2107 // On Lion, this function is called by either the presentation mode toggle | 2076 - (BOOL)isInFullscreenWithOmniboxSliding { |
| 2108 // button or the "Enter Presentation Mode" menu item. In the latter case, this | 2077 return presentationModeController_.get() != nil; |
| 2109 // function also triggers the Lion machinery to enter fullscreen mode as well as | |
| 2110 // set presentation mode. On Snow Leopard, this function is called by the | |
| 2111 // "Enter Presentation Mode" menu item, and triggering presentation mode always | |
| 2112 // moves the user into fullscreen mode. | |
| 2113 - (void)setPresentationMode:(BOOL)presentationMode | |
| 2114 url:(const GURL&)url | |
| 2115 bubbleType:(FullscreenExitBubbleType)bubbleType { | |
| 2116 fullscreenUrl_ = url; | |
| 2117 fullscreenBubbleType_ = bubbleType; | |
| 2118 | |
| 2119 // Presentation mode on systems without fullscreen support maps directly to | |
| 2120 // fullscreen mode. | |
| 2121 if (!chrome::mac::SupportsSystemFullscreen()) { | |
| 2122 [self setFullscreen:presentationMode]; | |
| 2123 return; | |
| 2124 } | |
| 2125 | |
| 2126 if (presentationMode) { | |
| 2127 BOOL fullscreen = [self isFullscreen]; | |
| 2128 enteringPresentationMode_ = YES; | |
| 2129 | |
| 2130 if (fullscreen) { | |
| 2131 // If already in fullscreen mode, just toggle the presentation mode | |
| 2132 // setting. Go through an elaborate dance to force the overlay to show, | |
| 2133 // then animate out once the mouse moves away. This helps draw attention | |
| 2134 // to the fact that the UI is in an overlay. Focus the tab contents | |
| 2135 // because the omnibox is the most likely source of bar visibility locks, | |
| 2136 // and taking focus away from the omnibox releases its lock. | |
| 2137 [self lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; | |
| 2138 [self focusTabContents]; | |
| 2139 [self setPresentationModeInternal:YES forceDropdown:YES]; | |
| 2140 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; | |
| 2141 // Since -windowDidEnterFullScreen: won't be called in the | |
| 2142 // fullscreen --> presentation mode case, manually show the exit bubble | |
| 2143 // and notify the change happened with WindowFullscreenStateChanged(). | |
| 2144 [self showFullscreenExitBubbleIfNecessary]; | |
| 2145 browser_->WindowFullscreenStateChanged(); | |
| 2146 } else { | |
| 2147 // Need to transition into fullscreen mode. Presentation mode will | |
| 2148 // automatically be enabled in |-windowWillEnterFullScreen:|. | |
| 2149 [self setFullscreen:YES]; | |
| 2150 } | |
| 2151 } else { | |
| 2152 // Exiting presentation mode does not exit system fullscreen; it merely | |
| 2153 // switches from presentation mode to normal fullscreen. | |
| 2154 [self setPresentationModeInternal:NO forceDropdown:NO]; | |
| 2155 | |
| 2156 // Since -windowDidExitFullScreen: won't be called in the | |
| 2157 // presentation mode --> normal fullscreen case, manually show the exit | |
| 2158 // bubble and notify the change happened with | |
| 2159 // WindowFullscreenStateChanged(). | |
| 2160 [self showFullscreenExitBubbleIfNecessary]; | |
| 2161 browser_->WindowFullscreenStateChanged(); | |
| 2162 } | |
| 2163 } | 2078 } |
| 2164 | 2079 |
| 2165 - (void)enterPresentationModeForURL:(const GURL&)url | 2080 - (void)enterPresentationModeForURL:(const GURL&)url |
| 2166 bubbleType:(FullscreenExitBubbleType)bubbleType { | 2081 bubbleType:(FullscreenExitBubbleType)bubbleType { |
| 2167 [self setPresentationMode:YES url:url bubbleType:bubbleType]; | 2082 DCHECK(chrome::mac::SupportsSystemFullscreen()); |
| 2083 fullscreenUrl_ = url; |
| 2084 fullscreenBubbleType_ = bubbleType; |
| 2085 |
| 2086 if ([self isInAppKitFullscreen]) { |
| 2087 // Already in AppKit Fullscreen. Adjust the UI to use Presentation Mode. |
| 2088 [self |
| 2089 adjustUIForSlidingFullscreenStyle:fullscreen_mac::OMNIBOX_TABS_HIDDEN]; |
| 2090 } else { |
| 2091 // Need to invoke AppKit Fullscreen API. Presentation mode will |
| 2092 // automatically be enabled in |-windowWillEnterFullScreen:|. |
| 2093 enteringPresentationMode_ = YES; |
| 2094 [self enterAppKitFullscreen]; |
| 2095 } |
| 2168 } | 2096 } |
| 2169 | 2097 |
| 2170 - (void)exitPresentationMode { | 2098 - (void)enterHTML5FullscreenForURL:(const GURL&)url |
| 2171 // url: and bubbleType: are ignored when leaving presentation mode. | 2099 bubbleType:(FullscreenExitBubbleType)bubbleType { |
| 2172 [self setPresentationMode:NO url:GURL() bubbleType:FEB_TYPE_NONE]; | 2100 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 2101 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen) || |
| 2102 !chrome::mac::SupportsSystemFullscreen()) { |
| 2103 [self enterImmersiveFullscreen]; |
| 2104 if (!url.is_empty()) |
| 2105 [self updateFullscreenExitBubbleURL:url bubbleType:bubbleType]; |
| 2106 } else { |
| 2107 [self enterPresentationModeForURL:url bubbleType:bubbleType]; |
| 2108 } |
| 2173 } | 2109 } |
| 2174 | 2110 |
| 2175 - (void)enterFullscreenForURL:(const GURL&)url | 2111 - (void)exitAnyFullscreen { |
| 2176 bubbleType:(FullscreenExitBubbleType)bubbleType { | 2112 // TODO(erikchen): Fullscreen modes should stack. Should be able to exit |
| 2177 // This method may only be called in simplified fullscreen mode. | 2113 // Immersive Fullscreen and still be in AppKit Fullscreen. |
| 2178 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 2114 if ([self isInAppKitFullscreen]) |
| 2179 DCHECK(command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)); | 2115 [self exitAppKitFullscreen]; |
| 2180 | 2116 if ([self isInImmersiveFullscreen]) |
| 2181 [self enterImmersiveFullscreen]; | 2117 [self exitImmersiveFullscreen]; |
| 2182 [self updateFullscreenExitBubbleURL:url bubbleType:bubbleType]; | |
| 2183 } | 2118 } |
| 2184 | 2119 |
| 2185 - (BOOL)inPresentationMode { | 2120 - (BOOL)inPresentationMode { |
| 2186 return presentationModeController_.get() && | 2121 return presentationModeController_.get() && |
| 2187 [presentationModeController_ inPresentationMode]; | 2122 [presentationModeController_ inPresentationMode] && |
| 2123 presentationModeController_.get().slidingStyle == |
| 2124 fullscreen_mac::OMNIBOX_TABS_HIDDEN; |
| 2188 } | 2125 } |
| 2189 | 2126 |
| 2190 - (void)resizeFullscreenWindow { | 2127 - (void)resizeFullscreenWindow { |
| 2191 DCHECK([self isFullscreen]); | 2128 DCHECK([self isInAnyFullscreenMode]); |
| 2192 if (![self isFullscreen]) | 2129 if (![self isInAnyFullscreenMode]) |
| 2193 return; | 2130 return; |
| 2194 | 2131 |
| 2195 NSWindow* window = [self window]; | 2132 NSWindow* window = [self window]; |
| 2196 [window setFrame:[[window screen] frame] display:YES]; | 2133 [window setFrame:[[window screen] frame] display:YES]; |
| 2197 [self layoutSubviews]; | 2134 [self layoutSubviews]; |
| 2198 } | 2135 } |
| 2199 | 2136 |
| 2200 - (CGFloat)floatingBarShownFraction { | |
| 2201 return floatingBarShownFraction_; | |
| 2202 } | |
| 2203 | |
| 2204 - (void)setFloatingBarShownFraction:(CGFloat)fraction { | |
| 2205 floatingBarShownFraction_ = fraction; | |
| 2206 [self layoutSubviews]; | |
| 2207 } | |
| 2208 | |
| 2209 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { | 2137 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { |
| 2210 DCHECK(owner); | 2138 DCHECK(owner); |
| 2211 DCHECK(barVisibilityLocks_); | 2139 DCHECK(barVisibilityLocks_); |
| 2212 return [barVisibilityLocks_ containsObject:owner]; | 2140 return [barVisibilityLocks_ containsObject:owner]; |
| 2213 } | 2141 } |
| 2214 | 2142 |
| 2215 - (void)lockBarVisibilityForOwner:(id)owner | 2143 - (void)lockBarVisibilityForOwner:(id)owner |
| 2216 withAnimation:(BOOL)animate | 2144 withAnimation:(BOOL)animate |
| 2217 delay:(BOOL)delay { | 2145 delay:(BOOL)delay { |
| 2218 if (![self isBarVisibilityLockedForOwner:owner]) { | 2146 if (![self isBarVisibilityLockedForOwner:owner]) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 | 2198 |
| 2271 - (BOOL)supportsBookmarkBar { | 2199 - (BOOL)supportsBookmarkBar { |
| 2272 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2200 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2273 } | 2201 } |
| 2274 | 2202 |
| 2275 - (BOOL)isTabbedWindow { | 2203 - (BOOL)isTabbedWindow { |
| 2276 return browser_->is_type_tabbed(); | 2204 return browser_->is_type_tabbed(); |
| 2277 } | 2205 } |
| 2278 | 2206 |
| 2279 @end // @implementation BrowserWindowController(WindowType) | 2207 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |