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

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

Issue 550413002: Revert "Add AppWindow.setVisibleOnAllWorkspaces." (https://codereview.chromium.org/469993003) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) { 54 void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) {
55 NSWindowCollectionBehavior behavior = [window collectionBehavior]; 55 NSWindowCollectionBehavior behavior = [window collectionBehavior];
56 if (allow_fullscreen) 56 if (allow_fullscreen)
57 behavior |= NSWindowCollectionBehaviorFullScreenPrimary; 57 behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
58 else 58 else
59 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; 59 behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
60 [window setCollectionBehavior:behavior]; 60 [window setCollectionBehavior:behavior];
61 } 61 }
62 62
63 void SetWorkspacesCollectionBehavior(NSWindow* window, bool always_visible) {
64 NSWindowCollectionBehavior behavior = [window collectionBehavior];
65 if (always_visible)
66 behavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
67 else
68 behavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces;
69 [window setCollectionBehavior:behavior];
70 }
71
72 void InitCollectionBehavior(NSWindow* window) { 63 void InitCollectionBehavior(NSWindow* window) {
73 // Since always-on-top windows have a higher window level 64 // Since always-on-top windows have a higher window level
74 // than NSNormalWindowLevel, they will default to 65 // than NSNormalWindowLevel, they will default to
75 // NSWindowCollectionBehaviorTransient. Set the value 66 // NSWindowCollectionBehaviorTransient. Set the value
76 // explicitly here to match normal windows. 67 // explicitly here to match normal windows.
77 NSWindowCollectionBehavior behavior = [window collectionBehavior]; 68 NSWindowCollectionBehavior behavior = [window collectionBehavior];
78 behavior |= NSWindowCollectionBehaviorManaged; 69 behavior |= NSWindowCollectionBehaviorManaged;
79 [window setCollectionBehavior:behavior]; 70 [window setCollectionBehavior:behavior];
80 } 71 }
81 72
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 372 }
382 373
383 if (base::mac::IsOSSnowLeopard() && 374 if (base::mac::IsOSSnowLeopard() &&
384 [window respondsToSelector:@selector(setBottomCornerRounded:)]) 375 [window respondsToSelector:@selector(setBottomCornerRounded:)])
385 [window setBottomCornerRounded:NO]; 376 [window setBottomCornerRounded:NO];
386 377
387 if (params.always_on_top) 378 if (params.always_on_top)
388 [window setLevel:AlwaysOnTopWindowLevel()]; 379 [window setLevel:AlwaysOnTopWindowLevel()];
389 InitCollectionBehavior(window); 380 InitCollectionBehavior(window);
390 381
391 SetWorkspacesCollectionBehavior(window, params.visible_on_all_workspaces);
392
393 window_controller_.reset( 382 window_controller_.reset(
394 [[NativeAppWindowController alloc] initWithWindow:window.release()]); 383 [[NativeAppWindowController alloc] initWithWindow:window.release()]);
395 384
396 NSView* view = WebContents()->GetNativeView(); 385 NSView* view = WebContents()->GetNativeView();
397 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 386 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
398 387
399 InstallView(); 388 InstallView();
400 389
401 [[window_controller_ window] setDelegate:window_controller_]; 390 [[window_controller_ window] setDelegate:window_controller_];
402 [window_controller_ setAppWindow:this]; 391 [window_controller_ setAppWindow:this];
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 [[window() standardWindowButton:NSWindowZoomButton] 960 [[window() standardWindowButton:NSWindowZoomButton]
972 setEnabled:shows_fullscreen_controls_]; 961 setEnabled:shows_fullscreen_controls_];
973 } 962 }
974 } 963 }
975 964
976 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) { 965 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
977 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() : 966 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() :
978 NSNormalWindowLevel)]; 967 NSNormalWindowLevel)];
979 } 968 }
980 969
981 void NativeAppWindowCocoa::SetVisibleOnAllWorkspaces(bool always_visible) {
982 SetWorkspacesCollectionBehavior(window(), always_visible);
983 }
984
985 NativeAppWindowCocoa::~NativeAppWindowCocoa() { 970 NativeAppWindowCocoa::~NativeAppWindowCocoa() {
986 } 971 }
987 972
988 ShellNSWindow* NativeAppWindowCocoa::window() const { 973 ShellNSWindow* NativeAppWindowCocoa::window() const {
989 NSWindow* window = [window_controller_ window]; 974 NSWindow* window = [window_controller_ window];
990 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); 975 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]);
991 return static_cast<ShellNSWindow*>(window); 976 return static_cast<ShellNSWindow*>(window);
992 } 977 }
993 978
994 content::WebContents* NativeAppWindowCocoa::WebContents() const { 979 content::WebContents* NativeAppWindowCocoa::WebContents() const {
995 return app_window_->web_contents(); 980 return app_window_->web_contents();
996 } 981 }
997 982
998 void NativeAppWindowCocoa::UpdateRestoredBounds() { 983 void NativeAppWindowCocoa::UpdateRestoredBounds() {
999 if (IsRestored(*this)) 984 if (IsRestored(*this))
1000 restored_bounds_ = [window() frame]; 985 restored_bounds_ = [window() frame];
1001 } 986 }
1002 987
1003 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 988 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
1004 [window() orderOut:window_controller_]; 989 [window() orderOut:window_controller_];
1005 } 990 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h ('k') | chrome/browser/ui/views/apps/chrome_native_app_window_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698