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

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 1849343003: mac: Remove IsOSSnowLeopard(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/apps/native_app_window_cocoa.h" 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 backing:NSBackingStoreBuffered 269 backing:NSBackingStoreBuffered
270 defer:NO]; 270 defer:NO];
271 271
272 std::string name; 272 std::string name;
273 const extensions::Extension* extension = app_window_->GetExtension(); 273 const extensions::Extension* extension = app_window_->GetExtension();
274 if (extension) 274 if (extension)
275 name = extension->name(); 275 name = extension->name();
276 [window setTitle:base::SysUTF8ToNSString(name)]; 276 [window setTitle:base::SysUTF8ToNSString(name)];
277 [[window contentView] setWantsLayer:YES]; 277 [[window contentView] setWantsLayer:YES];
278 278
279 if (base::mac::IsOSSnowLeopard() &&
280 [window respondsToSelector:@selector(setBottomCornerRounded:)])
281 [window setBottomCornerRounded:NO];
282
283 if (params.always_on_top) 279 if (params.always_on_top)
284 gfx::SetNSWindowAlwaysOnTop(window, true); 280 gfx::SetNSWindowAlwaysOnTop(window, true);
285 281
286 gfx::SetNSWindowVisibleOnAllWorkspaces(window, 282 gfx::SetNSWindowVisibleOnAllWorkspaces(window,
287 params.visible_on_all_workspaces); 283 params.visible_on_all_workspaces);
288 284
289 window_controller_.reset( 285 window_controller_.reset(
290 [[NativeAppWindowController alloc] initWithWindow:window]); 286 [[NativeAppWindowController alloc] initWithWindow:window]);
291 287
292 if (has_frame_ && has_frame_color_) { 288 if (has_frame_ && has_frame_color_) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (fullscreen == is_fullscreen_) 385 if (fullscreen == is_fullscreen_)
390 return; 386 return;
391 387
392 // 10.11 posts an _endLiveResize event just before exiting fullscreen, so 388 // 10.11 posts an _endLiveResize event just before exiting fullscreen, so
393 // ensure the window reports as fullscreen while the window is transitioning 389 // ensure the window reports as fullscreen while the window is transitioning
394 // to ensure the window bounds are not incorrectly captured as the last known 390 // to ensure the window bounds are not incorrectly captured as the last known
395 // restored bounds. 391 // restored bounds.
396 if (fullscreen) 392 if (fullscreen)
397 is_fullscreen_ = true; 393 is_fullscreen_ = true;
398 394
399 if (base::mac::IsOSLionOrLater()) { 395 // If going fullscreen, but the window is constrained (fullscreen UI control
400 // If going fullscreen, but the window is constrained (fullscreen UI control 396 // is disabled), temporarily enable it. It will be disabled again on leaving
401 // is disabled), temporarily enable it. It will be disabled again on leaving 397 // fullscreen.
402 // fullscreen. 398 if (fullscreen && !shows_fullscreen_controls_)
403 if (fullscreen && !shows_fullscreen_controls_) 399 gfx::SetNSWindowCanFullscreen(window(), true);
404 gfx::SetNSWindowCanFullscreen(window(), true); 400 [window() toggleFullScreen:nil];
405 [window() toggleFullScreen:nil];
406 is_fullscreen_ = fullscreen;
407 return;
408 }
409
410 DCHECK(base::mac::IsOSSnowLeopard());
411
412 // Fade to black.
413 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
414 bool did_fade_out = false;
415 CGDisplayFadeReservationToken token;
416 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) ==
417 kCGErrorSuccess) {
418 did_fade_out = true;
419 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal,
420 kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true);
421 }
422
423 // Since frameless windows insert the WebContentsView into the NSThemeFrame
424 // ([[window contentView] superview]), and since that NSThemeFrame is
425 // destroyed and recreated when we change the styleMask of the window, we
426 // need to remove the view from the window when we change the style, and
427 // add it back afterwards.
428 UninstallView();
429 if (fullscreen) {
430 UpdateRestoredBounds();
431 [window() setStyleMask:NSBorderlessWindowMask];
432 [window() setFrame:[window()
433 frameRectForContentRect:[[window() screen] frame]]
434 display:YES];
435 base::mac::RequestFullScreen(base::mac::kFullScreenModeAutoHideAll);
436 } else {
437 base::mac::ReleaseFullScreen(base::mac::kFullScreenModeAutoHideAll);
438 [window() setStyleMask:GetWindowStyleMask()];
439 [window() setFrame:restored_bounds_ display:YES];
440 }
441 InstallView();
442
443 // Fade back in.
444 if (did_fade_out) {
445 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor,
446 kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false);
447 CGReleaseDisplayFadeReservation(token);
448 }
449 is_fullscreen_ = fullscreen; 401 is_fullscreen_ = fullscreen;
450 } 402 }
451 403
452 bool NativeAppWindowCocoa::IsFullscreenOrPending() const { 404 bool NativeAppWindowCocoa::IsFullscreenOrPending() const {
453 return is_fullscreen_; 405 return is_fullscreen_;
454 } 406 }
455 407
456 gfx::NativeWindow NativeAppWindowCocoa::GetNativeWindow() const { 408 gfx::NativeWindow NativeAppWindowCocoa::GetNativeWindow() const {
457 return window(); 409 return window();
458 } 410 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 832 }
881 833
882 void NativeAppWindowCocoa::UpdateRestoredBounds() { 834 void NativeAppWindowCocoa::UpdateRestoredBounds() {
883 if (IsRestored(*this)) 835 if (IsRestored(*this))
884 restored_bounds_ = [window() frame]; 836 restored_bounds_ = [window() frame];
885 } 837 }
886 838
887 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 839 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
888 [window() orderOut:window_controller_]; 840 [window() orderOut:window_controller_];
889 } 841 }
OLDNEW
« no previous file with comments | « chrome/browser/mac/bluetooth_utility.mm ('k') | chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698