Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 1380083005: Mac: Use [NSArray firstObject] for [NSScreen screens] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 - (void)saveWindowPositionIfNeeded { 115 - (void)saveWindowPositionIfNeeded {
116 if (!chrome::ShouldSaveWindowPlacement(browser_.get())) 116 if (!chrome::ShouldSaveWindowPlacement(browser_.get()))
117 return; 117 return;
118 118
119 // If we're in fullscreen mode, save the position of the regular window 119 // If we're in fullscreen mode, save the position of the regular window
120 // instead. 120 // instead.
121 NSWindow* window = 121 NSWindow* window =
122 [self isInAnyFullscreenMode] ? savedRegularWindow_ : [self window]; 122 [self isInAnyFullscreenMode] ? savedRegularWindow_ : [self window];
123 123
124 // Window positions are stored relative to the origin of the primary monitor. 124 // Window positions are stored relative to the origin of the primary monitor.
125 NSRect monitorFrame = [[[NSScreen screens] objectAtIndex:0] frame]; 125 NSRect monitorFrame = [[[NSScreen screens] firstObject] frame];
126 NSScreen* windowScreen = [window screen]; 126 NSScreen* windowScreen = [window screen];
127 127
128 // Start with the window's frame, which is in virtual coordinates. 128 // Start with the window's frame, which is in virtual coordinates.
129 // Do some y twiddling to flip the coordinate system. 129 // Do some y twiddling to flip the coordinate system.
130 gfx::Rect bounds(NSRectToCGRect([window frame])); 130 gfx::Rect bounds(NSRectToCGRect([window frame]));
131 bounds.set_y(monitorFrame.size.height - bounds.y() - bounds.height()); 131 bounds.set_y(monitorFrame.size.height - bounds.y() - bounds.height());
132 132
133 // Browser::SaveWindowPlacement saves information for session restore. 133 // Browser::SaveWindowPlacement saves information for session restore.
134 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; 134 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
135 if ([window isMiniaturized]) 135 if ([window isMiniaturized])
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 : CANONICAL_FULLSCREEN); 675 : CANONICAL_FULLSCREEN);
676 676
677 if (notification) // For System Fullscreen when non-nil. 677 if (notification) // For System Fullscreen when non-nil.
678 [self registerForContentViewResizeNotifications]; 678 [self registerForContentViewResizeNotifications];
679 679
680 NSWindow* window = [self window]; 680 NSWindow* window = [self window];
681 savedRegularWindowFrame_ = [window frame]; 681 savedRegularWindowFrame_ = [window frame];
682 682
683 enteringAppKitFullscreen_ = YES; 683 enteringAppKitFullscreen_ = YES;
684 enteringAppKitFullscreenOnPrimaryScreen_ = 684 enteringAppKitFullscreenOnPrimaryScreen_ =
685 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; 685 [[[self window] screen] isEqual:[[NSScreen screens] firstObject]];
686 686
687 fullscreen_mac::SlidingStyle style; 687 fullscreen_mac::SlidingStyle style;
688 if (browser_->exclusive_access_manager() 688 if (browser_->exclusive_access_manager()
689 ->fullscreen_controller() 689 ->fullscreen_controller()
690 ->IsWindowFullscreenForTabOrPending()) { 690 ->IsWindowFullscreenForTabOrPending()) {
691 style = fullscreen_mac::OMNIBOX_TABS_NONE; 691 style = fullscreen_mac::OMNIBOX_TABS_NONE;
692 } else if (enteringPresentationMode_) { 692 } else if (enteringPresentationMode_) {
693 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN; 693 style = fullscreen_mac::OMNIBOX_TABS_HIDDEN;
694 } else { 694 } else {
695 style = fullscreen_mac::OMNIBOX_TABS_PRESENT; 695 style = fullscreen_mac::OMNIBOX_TABS_PRESENT;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1091
1092 NSView* root = [[self.window contentView] superview]; 1092 NSView* root = [[self.window contentView] superview];
1093 if (!root.layer) 1093 if (!root.layer)
1094 return NO; 1094 return NO;
1095 1095
1096 // AppKit on OSX 10.9 has a bug for applications linked against OSX 10.8 SDK 1096 // AppKit on OSX 10.9 has a bug for applications linked against OSX 10.8 SDK
1097 // and earlier. Under specific circumstances, it prevents the custom AppKit 1097 // and earlier. Under specific circumstances, it prevents the custom AppKit
1098 // transition from working well. See http://crbug.com/396980 for more 1098 // transition from working well. See http://crbug.com/396980 for more
1099 // details. 1099 // details.
1100 if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] && 1100 if ([[self class] systemSettingsRequireMavericksAppKitFullscreenHack] &&
1101 ![[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) { 1101 ![[[self window] screen] isEqual:[[NSScreen screens] firstObject]]) {
1102 return NO; 1102 return NO;
1103 } 1103 }
1104 1104
1105 return YES; 1105 return YES;
1106 } 1106 }
1107 1107
1108 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window { 1108 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
1109 DCHECK([window isEqual:self.window]); 1109 DCHECK([window isEqual:self.window]);
1110 1110
1111 if (![self shouldUseCustomAppKitFullscreenTransition:YES]) 1111 if (![self shouldUseCustomAppKitFullscreenTransition:YES])
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 return browser_->tab_strip_model()->GetActiveWebContents(); 1157 return browser_->tab_strip_model()->GetActiveWebContents();
1158 } 1158 }
1159 1159
1160 - (PermissionBubbleManager*)permissionBubbleManager { 1160 - (PermissionBubbleManager*)permissionBubbleManager {
1161 if (WebContents* contents = [self webContents]) 1161 if (WebContents* contents = [self webContents])
1162 return PermissionBubbleManager::FromWebContents(contents); 1162 return PermissionBubbleManager::FromWebContents(contents);
1163 return nil; 1163 return nil;
1164 } 1164 }
1165 1165
1166 @end // @implementation BrowserWindowController(Private) 1166 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698