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 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (min_size.width() || min_size.height()) { | 122 if (min_size.width() || min_size.height()) { |
123 [window setContentMinSize:NSMakeSize(min_size.width(), min_size.height())]; | 123 [window setContentMinSize:NSMakeSize(min_size.width(), min_size.height())]; |
124 } | 124 } |
125 gfx::Size max_size = params.maximum_size; | 125 gfx::Size max_size = params.maximum_size; |
126 if (max_size.width() || max_size.height()) { | 126 if (max_size.width() || max_size.height()) { |
127 CGFloat max_width = max_size.width() ? max_size.width() : CGFLOAT_MAX; | 127 CGFloat max_width = max_size.width() ? max_size.width() : CGFLOAT_MAX; |
128 CGFloat max_height = max_size.height() ? max_size.height() : CGFLOAT_MAX; | 128 CGFloat max_height = max_size.height() ? max_size.height() : CGFLOAT_MAX; |
129 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; | 129 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; |
130 } | 130 } |
131 | 131 |
132 if (base::mac::IsOSSnowLeopardOrEarlier() && | 132 if (base::mac::IsOSSnowLeopard() && |
133 [window respondsToSelector:@selector(setBottomCornerRounded:)]) | 133 [window respondsToSelector:@selector(setBottomCornerRounded:)]) |
134 [window setBottomCornerRounded:NO]; | 134 [window setBottomCornerRounded:NO]; |
135 | 135 |
136 window_controller_.reset( | 136 window_controller_.reset( |
137 [[ShellWindowController alloc] initWithWindow:window.release()]); | 137 [[ShellWindowController alloc] initWithWindow:window.release()]); |
138 | 138 |
139 NSView* view = web_contents()->GetView()->GetNativeView(); | 139 NSView* view = web_contents()->GetView()->GetNativeView(); |
140 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 140 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
141 | 141 |
142 InstallView(); | 142 InstallView(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void ShellWindowCocoa::SetFullscreen(bool fullscreen) { | 193 void ShellWindowCocoa::SetFullscreen(bool fullscreen) { |
194 if (fullscreen == is_fullscreen_) | 194 if (fullscreen == is_fullscreen_) |
195 return; | 195 return; |
196 is_fullscreen_ = fullscreen; | 196 is_fullscreen_ = fullscreen; |
197 | 197 |
198 if (base::mac::IsOSLionOrLater()) { | 198 if (base::mac::IsOSLionOrLater()) { |
199 [window() toggleFullScreen:nil]; | 199 [window() toggleFullScreen:nil]; |
200 return; | 200 return; |
201 } | 201 } |
202 | 202 |
203 DCHECK(base::mac::IsOSSnowLeopardOrEarlier()); | 203 DCHECK(base::mac::IsOSSnowLeopard()); |
204 | 204 |
205 // Fade to black. | 205 // Fade to black. |
206 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; | 206 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; |
207 bool did_fade_out = false; | 207 bool did_fade_out = false; |
208 CGDisplayFadeReservationToken token; | 208 CGDisplayFadeReservationToken token; |
209 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) == | 209 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) == |
210 kCGErrorSuccess) { | 210 kCGErrorSuccess) { |
211 did_fade_out = true; | 211 did_fade_out = true; |
212 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal, | 212 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal, |
213 kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true); | 213 kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return [window_controller_ window]; | 419 return [window_controller_ window]; |
420 } | 420 } |
421 | 421 |
422 // static | 422 // static |
423 ShellWindow* ShellWindow::CreateImpl(Profile* profile, | 423 ShellWindow* ShellWindow::CreateImpl(Profile* profile, |
424 const extensions::Extension* extension, | 424 const extensions::Extension* extension, |
425 const GURL& url, | 425 const GURL& url, |
426 const ShellWindow::CreateParams& params) { | 426 const ShellWindow::CreateParams& params) { |
427 return new ShellWindowCocoa(profile, extension, url, params); | 427 return new ShellWindowCocoa(profile, extension, url, params); |
428 } | 428 } |
OLD | NEW |