Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1401 - (DownloadShelfController*)downloadShelf { | 1401 - (DownloadShelfController*)downloadShelf { |
| 1402 if (!downloadShelfController_.get()) { | 1402 if (!downloadShelfController_.get()) { |
| 1403 downloadShelfController_.reset([[DownloadShelfController alloc] | 1403 downloadShelfController_.reset([[DownloadShelfController alloc] |
| 1404 initWithBrowser:browser_.get() resizeDelegate:self]); | 1404 initWithBrowser:browser_.get() resizeDelegate:self]); |
| 1405 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; | 1405 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; |
| 1406 [downloadShelfController_ show:nil]; | 1406 [downloadShelfController_ show:nil]; |
| 1407 } | 1407 } |
| 1408 return downloadShelfController_; | 1408 return downloadShelfController_; |
| 1409 } | 1409 } |
| 1410 | 1410 |
| 1411 - (CGFloat)maxYForViewInsideContent { | |
| 1412 return [self placeBookmarkBarBelowInfoBar] ? | |
| 1413 NSMinY([[toolbarController_ view] frame]) : | |
| 1414 NSMinY([[bookmarkBarController_ view] frame]); | |
| 1415 } | |
| 1416 | |
| 1411 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1417 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 1412 // Shouldn't call addFindBar twice. | 1418 // Shouldn't call addFindBar twice. |
| 1413 DCHECK(!findBarCocoaController_.get()); | 1419 DCHECK(!findBarCocoaController_.get()); |
| 1414 | 1420 |
| 1415 // Create a controller for the findbar. | 1421 // Create a controller for the findbar. |
| 1416 findBarCocoaController_.reset([findBarCocoaController retain]); | 1422 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 1417 NSView* contentView = [[self window] contentView]; | 1423 NSView* contentView = [[self window] contentView]; |
| 1418 NSView* relativeView = | 1424 NSView* relativeView = |
| 1419 [self inPresentationMode] ? [toolbarController_ view] : | 1425 [self inPresentationMode] ? [toolbarController_ view] : |
| 1420 [infoBarContainerController_ view]; | 1426 [infoBarContainerController_ view]; |
| 1421 [contentView addSubview:[findBarCocoaController_ view] | 1427 [contentView addSubview:[findBarCocoaController_ view] |
| 1422 positioned:NSWindowAbove | 1428 positioned:NSWindowAbove |
| 1423 relativeTo:relativeView]; | 1429 relativeTo:relativeView]; |
| 1424 | 1430 |
| 1425 // Place the find bar immediately below the toolbar/attached bookmark bar. In | 1431 // Place the find bar immediately below the toolbar/attached bookmark bar. In |
| 1426 // presentation mode, it hangs off the top of the screen when the bar is | 1432 // presentation mode, it hangs off the top of the screen when the bar is |
| 1427 // hidden. | 1433 // hidden. |
| 1428 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? | 1434 CGFloat maxY = [self maxYForViewInsideContent]; |
| 1429 NSMinY([[toolbarController_ view] frame]) : | |
| 1430 NSMinY([[bookmarkBarController_ view] frame]); | |
| 1431 CGFloat maxWidth = NSWidth([contentView frame]); | 1435 CGFloat maxWidth = NSWidth([contentView frame]); |
| 1432 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; | 1436 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
| 1433 | 1437 |
| 1434 // This allows the FindBarCocoaController to call |layoutSubviews| and get | 1438 // This allows the FindBarCocoaController to call |layoutSubviews| and get |
| 1435 // its position adjusted. | 1439 // its position adjusted. |
| 1436 [findBarCocoaController_ setBrowserWindowController:self]; | 1440 [findBarCocoaController_ setBrowserWindowController:self]; |
| 1437 } | 1441 } |
| 1438 | 1442 |
| 1439 - (NSWindow*)createFullscreenWindow { | 1443 - (NSWindow*)createFullscreenWindow { |
| 1440 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1444 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1941 if (fullscreen == [self isFullscreen]) | 1945 if (fullscreen == [self isFullscreen]) |
| 1942 return; | 1946 return; |
| 1943 | 1947 |
| 1944 if (![self supportsFullscreen]) | 1948 if (![self supportsFullscreen]) |
| 1945 return; | 1949 return; |
| 1946 | 1950 |
| 1947 if (base::mac::IsOSLionOrLater()) { | 1951 if (base::mac::IsOSLionOrLater()) { |
| 1948 enteredPresentationModeFromFullscreen_ = YES; | 1952 enteredPresentationModeFromFullscreen_ = YES; |
| 1949 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) | 1953 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) |
| 1950 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; | 1954 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; |
| 1951 return; | 1955 } else { |
| 1956 if (fullscreen) | |
| 1957 [self enterFullscreenForSnowLeopardOrEarlier]; | |
| 1958 else | |
| 1959 [self exitFullscreenForSnowLeopardOrEarlier]; | |
| 1952 } | 1960 } |
| 1953 | 1961 |
| 1954 if (fullscreen) | 1962 // Disable the floating tab bar if this fullscreen request was from a page. |
| 1955 [self enterFullscreenForSnowLeopardOrEarlier]; | 1963 // It will be re-enabled by the FullscreenExitBubble after it disappears. |
|
Nico
2011/09/15 20:09:14
Have you tested this with the "always on" overlay
jeremya
2011/09/16 03:39:58
Good call. Testing on Lion reveals a bunch of bugs
| |
| 1956 else | 1964 BOOL show_exit_info_bubble = browser_->is_fullscreen_for_tab(); |
| 1957 [self exitFullscreenForSnowLeopardOrEarlier]; | 1965 [self setShowFloatingChrome:fullscreen && !show_exit_info_bubble]; |
| 1966 | |
| 1967 if (fullscreen && show_exit_info_bubble) { | |
| 1968 fullscreenExitBubbleController_.reset( | |
| 1969 [[FullscreenExitBubbleController alloc] initWithOwner:self | |
| 1970 browser:browser_.get()]); | |
| 1971 NSView* contentView = [[self window] contentView]; | |
| 1972 CGFloat maxWidth = NSWidth([contentView frame]); | |
| 1973 CGFloat maxY = [self maxYForViewInsideContent]; | |
| 1974 [fullscreenExitBubbleController_ | |
| 1975 positionInWindowAtTop:maxY width:maxWidth]; | |
| 1976 [contentView addSubview:[fullscreenExitBubbleController_ view]]; | |
| 1977 } else { | |
| 1978 [[fullscreenExitBubbleController_ view] removeFromSuperview]; | |
| 1979 fullscreenExitBubbleController_.reset(); | |
| 1980 } | |
| 1958 } | 1981 } |
| 1959 | 1982 |
| 1960 - (BOOL)isFullscreen { | 1983 - (BOOL)isFullscreen { |
| 1961 return (fullscreenWindow_.get() != nil) || | 1984 return (fullscreenWindow_.get() != nil) || |
| 1962 ([[self window] styleMask] & NSFullScreenWindowMask); | 1985 ([[self window] styleMask] & NSFullScreenWindowMask); |
| 1963 } | 1986 } |
| 1964 | 1987 |
| 1965 - (void)togglePresentationModeForLionOrLater:(id)sender { | 1988 - (void)togglePresentationModeForLionOrLater:(id)sender { |
| 1966 // Called only by the presentation mode toggle button. | 1989 // Called only by the presentation mode toggle button. |
| 1967 DCHECK(base::mac::IsOSLionOrLater()); | 1990 DCHECK(base::mac::IsOSLionOrLater()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2044 | 2067 |
| 2045 - (CGFloat)floatingBarShownFraction { | 2068 - (CGFloat)floatingBarShownFraction { |
| 2046 return floatingBarShownFraction_; | 2069 return floatingBarShownFraction_; |
| 2047 } | 2070 } |
| 2048 | 2071 |
| 2049 - (void)setFloatingBarShownFraction:(CGFloat)fraction { | 2072 - (void)setFloatingBarShownFraction:(CGFloat)fraction { |
| 2050 floatingBarShownFraction_ = fraction; | 2073 floatingBarShownFraction_ = fraction; |
| 2051 [self layoutSubviews]; | 2074 [self layoutSubviews]; |
| 2052 } | 2075 } |
| 2053 | 2076 |
| 2077 - (void)setShowFloatingChrome:(BOOL)showChrome { | |
| 2078 showFloatingChrome_ = showChrome; | |
| 2079 [self layoutSubviews]; | |
| 2080 } | |
| 2081 | |
| 2054 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { | 2082 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { |
| 2055 DCHECK(owner); | 2083 DCHECK(owner); |
| 2056 DCHECK(barVisibilityLocks_); | 2084 DCHECK(barVisibilityLocks_); |
| 2057 return [barVisibilityLocks_ containsObject:owner]; | 2085 return [barVisibilityLocks_ containsObject:owner]; |
| 2058 } | 2086 } |
| 2059 | 2087 |
| 2060 - (void)lockBarVisibilityForOwner:(id)owner | 2088 - (void)lockBarVisibilityForOwner:(id)owner |
| 2061 withAnimation:(BOOL)animate | 2089 withAnimation:(BOOL)animate |
| 2062 delay:(BOOL)delay { | 2090 delay:(BOOL)delay { |
| 2063 if (![self isBarVisibilityLockedForOwner:owner]) { | 2091 if (![self isBarVisibilityLockedForOwner:owner]) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2156 | 2184 |
| 2157 - (BOOL)supportsBookmarkBar { | 2185 - (BOOL)supportsBookmarkBar { |
| 2158 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2186 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2159 } | 2187 } |
| 2160 | 2188 |
| 2161 - (BOOL)isTabbedWindow { | 2189 - (BOOL)isTabbedWindow { |
| 2162 return browser_->is_type_tabbed(); | 2190 return browser_->is_type_tabbed(); |
| 2163 } | 2191 } |
| 2164 | 2192 |
| 2165 @end // @implementation BrowserWindowController(WindowType) | 2193 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |