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.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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 ownsBrowser_ = ownIt; | 237 ownsBrowser_ = ownIt; |
238 NSWindow* window = [self window]; | 238 NSWindow* window = [self window]; |
239 windowShim_.reset(new BrowserWindowCocoa(browser, self)); | 239 windowShim_.reset(new BrowserWindowCocoa(browser, self)); |
240 | 240 |
241 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully | 241 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully |
242 // be big enough to hold all locks that'll ever be needed. | 242 // be big enough to hold all locks that'll ever be needed. |
243 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); | 243 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); |
244 | 244 |
245 // Set the window to not have rounded corners, which prevents the resize | 245 // Set the window to not have rounded corners, which prevents the resize |
246 // control from being inset slightly and looking ugly. Only bother to do | 246 // control from being inset slightly and looking ugly. Only bother to do |
247 // this on Snow Leopard and earlier; on Lion and later all windows have | 247 // this on Snow Leopard; on Lion and later all windows have rounded bottom |
248 // rounded bottom corners, and this won't work anyway. | 248 // corners, and this won't work anyway. |
249 if (base::mac::IsOSSnowLeopardOrEarlier() && | 249 if (base::mac::IsOSSnowLeopard() && |
250 [window respondsToSelector:@selector(setBottomCornerRounded:)]) | 250 [window respondsToSelector:@selector(setBottomCornerRounded:)]) |
251 [window setBottomCornerRounded:NO]; | 251 [window setBottomCornerRounded:NO]; |
252 | 252 |
253 // Lion will attempt to automagically save and restore the UI. This | 253 // Lion will attempt to automagically save and restore the UI. This |
254 // functionality appears to be leaky (or at least interacts badly with our | 254 // functionality appears to be leaky (or at least interacts badly with our |
255 // architecture) and thus BrowserWindowController never gets released. This | 255 // architecture) and thus BrowserWindowController never gets released. This |
256 // prevents the browser from being able to quit <http://crbug.com/79113>. | 256 // prevents the browser from being able to quit <http://crbug.com/79113>. |
257 if ([window respondsToSelector:@selector(setRestorable:)]) | 257 if ([window respondsToSelector:@selector(setRestorable:)]) |
258 [window setRestorable:NO]; | 258 [window setRestorable:NO]; |
259 | 259 |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 break; | 1038 break; |
1039 case IDC_FULLSCREEN: { | 1039 case IDC_FULLSCREEN: { |
1040 enable &= [self supportsFullscreen]; | 1040 enable &= [self supportsFullscreen]; |
1041 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { | 1041 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { |
1042 NSString* menuTitle = l10n_util::GetNSString( | 1042 NSString* menuTitle = l10n_util::GetNSString( |
1043 [self isFullscreen] && ![self inPresentationMode] ? | 1043 [self isFullscreen] && ![self inPresentationMode] ? |
1044 IDS_EXIT_FULLSCREEN_MAC : | 1044 IDS_EXIT_FULLSCREEN_MAC : |
1045 IDS_ENTER_FULLSCREEN_MAC); | 1045 IDS_ENTER_FULLSCREEN_MAC); |
1046 [static_cast<NSMenuItem*>(item) setTitle:menuTitle]; | 1046 [static_cast<NSMenuItem*>(item) setTitle:menuTitle]; |
1047 | 1047 |
1048 if (base::mac::IsOSSnowLeopardOrEarlier()) | 1048 if (base::mac::IsOSSnowLeopard()) |
1049 [static_cast<NSMenuItem*>(item) setHidden:YES]; | 1049 [static_cast<NSMenuItem*>(item) setHidden:YES]; |
1050 } | 1050 } |
1051 break; | 1051 break; |
1052 } | 1052 } |
1053 case IDC_PRESENTATION_MODE: { | 1053 case IDC_PRESENTATION_MODE: { |
1054 enable &= [self supportsFullscreen]; | 1054 enable &= [self supportsFullscreen]; |
1055 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { | 1055 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { |
1056 NSString* menuTitle = l10n_util::GetNSString( | 1056 NSString* menuTitle = l10n_util::GetNSString( |
1057 [self inPresentationMode] ? IDS_EXIT_PRESENTATION_MAC : | 1057 [self inPresentationMode] ? IDS_EXIT_PRESENTATION_MAC : |
1058 IDS_ENTER_PRESENTATION_MAC); | 1058 IDS_ENTER_PRESENTATION_MAC); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 | 1974 |
1975 if (![self supportsFullscreen]) | 1975 if (![self supportsFullscreen]) |
1976 return; | 1976 return; |
1977 | 1977 |
1978 if (base::mac::IsOSLionOrLater()) { | 1978 if (base::mac::IsOSLionOrLater()) { |
1979 enteredPresentationModeFromFullscreen_ = YES; | 1979 enteredPresentationModeFromFullscreen_ = YES; |
1980 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) | 1980 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) |
1981 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; | 1981 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; |
1982 } else { | 1982 } else { |
1983 if (fullscreen) | 1983 if (fullscreen) |
1984 [self enterFullscreenForSnowLeopardOrEarlier]; | 1984 [self enterFullscreenForSnowLeopard]; |
1985 else | 1985 else |
1986 [self exitFullscreenForSnowLeopardOrEarlier]; | 1986 [self exitFullscreenForSnowLeopard]; |
1987 } | 1987 } |
1988 } | 1988 } |
1989 | 1989 |
1990 - (void)enterFullscreenForURL:(const GURL&)url | 1990 - (void)enterFullscreenForURL:(const GURL&)url |
1991 bubbleType:(FullscreenExitBubbleType)bubbleType { | 1991 bubbleType:(FullscreenExitBubbleType)bubbleType { |
1992 [self setFullscreen:YES url:url bubbleType:bubbleType]; | 1992 [self setFullscreen:YES url:url bubbleType:bubbleType]; |
1993 } | 1993 } |
1994 | 1994 |
1995 - (void)exitFullscreen { | 1995 - (void)exitFullscreen { |
1996 // url: and bubbleType: are ignored when leaving fullscreen. | 1996 // url: and bubbleType: are ignored when leaving fullscreen. |
(...skipping 18 matching lines...) Expand all Loading... |
2015 // function also triggers the Lion machinery to enter fullscreen mode as well as | 2015 // function also triggers the Lion machinery to enter fullscreen mode as well as |
2016 // set presentation mode. On Snow Leopard, this function is called by the | 2016 // set presentation mode. On Snow Leopard, this function is called by the |
2017 // "Enter Presentation Mode" menu item, and triggering presentation mode always | 2017 // "Enter Presentation Mode" menu item, and triggering presentation mode always |
2018 // moves the user into fullscreen mode. | 2018 // moves the user into fullscreen mode. |
2019 - (void)setPresentationMode:(BOOL)presentationMode | 2019 - (void)setPresentationMode:(BOOL)presentationMode |
2020 url:(const GURL&)url | 2020 url:(const GURL&)url |
2021 bubbleType:(FullscreenExitBubbleType)bubbleType { | 2021 bubbleType:(FullscreenExitBubbleType)bubbleType { |
2022 fullscreenUrl_ = url; | 2022 fullscreenUrl_ = url; |
2023 fullscreenBubbleType_ = bubbleType; | 2023 fullscreenBubbleType_ = bubbleType; |
2024 | 2024 |
2025 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen | 2025 // Presentation mode on Snow Leopard maps directly to fullscreen mode. |
2026 // mode. | 2026 if (base::mac::IsOSSnowLeopard()) { |
2027 if (base::mac::IsOSSnowLeopardOrEarlier()) { | |
2028 [self setFullscreen:presentationMode url:url bubbleType:bubbleType]; | 2027 [self setFullscreen:presentationMode url:url bubbleType:bubbleType]; |
2029 return; | 2028 return; |
2030 } | 2029 } |
2031 | 2030 |
2032 if (presentationMode) { | 2031 if (presentationMode) { |
2033 BOOL fullscreen = [self isFullscreen]; | 2032 BOOL fullscreen = [self isFullscreen]; |
2034 enteredPresentationModeFromFullscreen_ = fullscreen; | 2033 enteredPresentationModeFromFullscreen_ = fullscreen; |
2035 enteringPresentationMode_ = YES; | 2034 enteringPresentationMode_ = YES; |
2036 | 2035 |
2037 if (fullscreen) { | 2036 if (fullscreen) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 | 2201 |
2203 - (BOOL)supportsBookmarkBar { | 2202 - (BOOL)supportsBookmarkBar { |
2204 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2203 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2205 } | 2204 } |
2206 | 2205 |
2207 - (BOOL)isTabbedWindow { | 2206 - (BOOL)isTabbedWindow { |
2208 return browser_->is_type_tabbed(); | 2207 return browser_->is_type_tabbed(); |
2209 } | 2208 } |
2210 | 2209 |
2211 @end // @implementation BrowserWindowController(WindowType) | 2210 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |