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

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

Issue 469993003: Add AppWindow.setVisibleOnAllWorkspaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights rerved.
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"
11 #include "base/mac/sdk_forward_declarations.h" 11 #include "base/mac/sdk_forward_declarations.h"
(...skipping 41 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
63 void InitCollectionBehavior(NSWindow* window) { 72 void InitCollectionBehavior(NSWindow* window) {
64 // Since always-on-top windows have a higher window level 73 // Since always-on-top windows have a higher window level
65 // than NSNormalWindowLevel, they will default to 74 // than NSNormalWindowLevel, they will default to
66 // NSWindowCollectionBehaviorTransient. Set the value 75 // NSWindowCollectionBehaviorTransient. Set the value
67 // explicitly here to match normal windows. 76 // explicitly here to match normal windows.
68 NSWindowCollectionBehavior behavior = [window collectionBehavior]; 77 NSWindowCollectionBehavior behavior = [window collectionBehavior];
69 behavior |= NSWindowCollectionBehaviorManaged; 78 behavior |= NSWindowCollectionBehaviorManaged;
70 [window setCollectionBehavior:behavior]; 79 [window setCollectionBehavior:behavior];
71 } 80 }
72 81
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 382 }
374 383
375 if (base::mac::IsOSSnowLeopard() && 384 if (base::mac::IsOSSnowLeopard() &&
376 [window respondsToSelector:@selector(setBottomCornerRounded:)]) 385 [window respondsToSelector:@selector(setBottomCornerRounded:)])
377 [window setBottomCornerRounded:NO]; 386 [window setBottomCornerRounded:NO];
378 387
379 if (params.always_on_top) 388 if (params.always_on_top)
380 [window setLevel:AlwaysOnTopWindowLevel()]; 389 [window setLevel:AlwaysOnTopWindowLevel()];
381 InitCollectionBehavior(window); 390 InitCollectionBehavior(window);
382 391
392 SetWorkspacesCollectionBehavior(window, params.visible_on_all_workspaces);
393
383 window_controller_.reset( 394 window_controller_.reset(
384 [[NativeAppWindowController alloc] initWithWindow:window.release()]); 395 [[NativeAppWindowController alloc] initWithWindow:window.release()]);
385 396
386 NSView* view = WebContents()->GetNativeView(); 397 NSView* view = WebContents()->GetNativeView();
387 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; 398 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
388 399
389 InstallView(); 400 InstallView();
390 401
391 [[window_controller_ window] setDelegate:window_controller_]; 402 [[window_controller_ window] setDelegate:window_controller_];
392 [window_controller_ setAppWindow:this]; 403 [window_controller_ setAppWindow:this];
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 [[window() standardWindowButton:NSWindowZoomButton] 978 [[window() standardWindowButton:NSWindowZoomButton]
968 setEnabled:shows_fullscreen_controls_]; 979 setEnabled:shows_fullscreen_controls_];
969 } 980 }
970 } 981 }
971 982
972 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) { 983 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
973 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() : 984 [window() setLevel:(always_on_top ? AlwaysOnTopWindowLevel() :
974 NSNormalWindowLevel)]; 985 NSNormalWindowLevel)];
975 } 986 }
976 987
988 void NativeAppWindowCocoa::SetVisibleOnAllWorkspaces(bool always_visible) {
989 SetWorkspacesCollectionBehavior(window(), always_visible);
990 }
991
977 NativeAppWindowCocoa::~NativeAppWindowCocoa() { 992 NativeAppWindowCocoa::~NativeAppWindowCocoa() {
978 } 993 }
979 994
980 ShellNSWindow* NativeAppWindowCocoa::window() const { 995 ShellNSWindow* NativeAppWindowCocoa::window() const {
981 NSWindow* window = [window_controller_ window]; 996 NSWindow* window = [window_controller_ window];
982 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); 997 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]);
983 return static_cast<ShellNSWindow*>(window); 998 return static_cast<ShellNSWindow*>(window);
984 } 999 }
985 1000
986 content::WebContents* NativeAppWindowCocoa::WebContents() const { 1001 content::WebContents* NativeAppWindowCocoa::WebContents() const {
987 return app_window_->web_contents(); 1002 return app_window_->web_contents();
988 } 1003 }
989 1004
990 void NativeAppWindowCocoa::UpdateRestoredBounds() { 1005 void NativeAppWindowCocoa::UpdateRestoredBounds() {
991 if (IsRestored(*this)) 1006 if (IsRestored(*this))
992 restored_bounds_ = [window() frame]; 1007 restored_bounds_ = [window() frame];
993 } 1008 }
994 1009
995 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 1010 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
996 [window() orderOut:window_controller_]; 1011 [window() orderOut:window_controller_];
997 } 1012 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698