OLD | NEW |
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/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 - (void)mouseDragged:(NSEvent*)event { | 258 - (void)mouseDragged:(NSEvent*)event { |
259 appWindow_->HandleMouseEvent(event); | 259 appWindow_->HandleMouseEvent(event); |
260 } | 260 } |
261 | 261 |
262 @end | 262 @end |
263 | 263 |
264 @interface NSView (WebContentsView) | 264 @interface NSView (WebContentsView) |
265 - (void)setMouseDownCanMoveWindow:(BOOL)can_move; | 265 - (void)setMouseDownCanMoveWindow:(BOOL)can_move; |
266 @end | 266 @end |
267 | 267 |
| 268 namespace { |
| 269 |
| 270 const NSInteger kAlwaysOnTopWindowLevel = NSFloatingWindowLevel; |
| 271 |
| 272 } // namespace |
| 273 |
268 NativeAppWindowCocoa::NativeAppWindowCocoa( | 274 NativeAppWindowCocoa::NativeAppWindowCocoa( |
269 ShellWindow* shell_window, | 275 ShellWindow* shell_window, |
270 const ShellWindow::CreateParams& params) | 276 const ShellWindow::CreateParams& params) |
271 : shell_window_(shell_window), | 277 : shell_window_(shell_window), |
272 has_frame_(params.frame == ShellWindow::FRAME_CHROME), | 278 has_frame_(params.frame == ShellWindow::FRAME_CHROME), |
273 is_hidden_(false), | 279 is_hidden_(false), |
274 is_hidden_with_app_(false), | 280 is_hidden_with_app_(false), |
275 is_maximized_(false), | 281 is_maximized_(false), |
276 is_fullscreen_(false), | 282 is_fullscreen_(false), |
277 attention_request_id_(0), | 283 attention_request_id_(0), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 if (IsBoundedSize(max_size_)) { | 333 if (IsBoundedSize(max_size_)) { |
328 CGFloat max_width = max_size_.width() ? max_size_.width() : CGFLOAT_MAX; | 334 CGFloat max_width = max_size_.width() ? max_size_.width() : CGFLOAT_MAX; |
329 CGFloat max_height = max_size_.height() ? max_size_.height() : CGFLOAT_MAX; | 335 CGFloat max_height = max_size_.height() ? max_size_.height() : CGFLOAT_MAX; |
330 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; | 336 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; |
331 } | 337 } |
332 | 338 |
333 if (base::mac::IsOSSnowLeopard() && | 339 if (base::mac::IsOSSnowLeopard() && |
334 [window respondsToSelector:@selector(setBottomCornerRounded:)]) | 340 [window respondsToSelector:@selector(setBottomCornerRounded:)]) |
335 [window setBottomCornerRounded:NO]; | 341 [window setBottomCornerRounded:NO]; |
336 | 342 |
| 343 if (params.always_on_top) |
| 344 [window setLevel:kAlwaysOnTopWindowLevel]; |
| 345 |
337 // Set the window to participate in Lion Fullscreen mode. Setting this flag | 346 // Set the window to participate in Lion Fullscreen mode. Setting this flag |
338 // has no effect on Snow Leopard or earlier. UI controls for fullscreen are | 347 // has no effect on Snow Leopard or earlier. UI controls for fullscreen are |
339 // only shown for apps that have unbounded size. | 348 // only shown for apps that have unbounded size. |
340 if (shows_fullscreen_controls_) | 349 if (shows_fullscreen_controls_) |
341 SetFullScreenCollectionBehavior(window, true); | 350 SetFullScreenCollectionBehavior(window, true); |
342 | 351 |
343 window_controller_.reset( | 352 window_controller_.reset( |
344 [[NativeAppWindowController alloc] initWithWindow:window.release()]); | 353 [[NativeAppWindowController alloc] initWithWindow:window.release()]); |
345 | 354 |
346 NSView* view = web_contents()->GetView()->GetNativeView(); | 355 NSView* view = web_contents()->GetView()->GetNativeView(); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 void NativeAppWindowCocoa::FlashFrame(bool flash) { | 812 void NativeAppWindowCocoa::FlashFrame(bool flash) { |
804 if (flash) { | 813 if (flash) { |
805 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; | 814 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; |
806 } else { | 815 } else { |
807 [NSApp cancelUserAttentionRequest:attention_request_id_]; | 816 [NSApp cancelUserAttentionRequest:attention_request_id_]; |
808 attention_request_id_ = 0; | 817 attention_request_id_ = 0; |
809 } | 818 } |
810 } | 819 } |
811 | 820 |
812 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { | 821 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { |
813 return false; | 822 return [window() level] == kAlwaysOnTopWindowLevel; |
814 } | 823 } |
815 | 824 |
816 void NativeAppWindowCocoa::RenderViewHostChanged( | 825 void NativeAppWindowCocoa::RenderViewHostChanged( |
817 content::RenderViewHost* old_host, | 826 content::RenderViewHost* old_host, |
818 content::RenderViewHost* new_host) { | 827 content::RenderViewHost* new_host) { |
819 web_contents()->GetView()->Focus(); | 828 web_contents()->GetView()->Focus(); |
820 } | 829 } |
821 | 830 |
822 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { | 831 gfx::Insets NativeAppWindowCocoa::GetFrameInsets() const { |
823 if (!has_frame_) | 832 if (!has_frame_) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 shell_window_->OnNativeWindowChanged(); | 988 shell_window_->OnNativeWindowChanged(); |
980 } | 989 } |
981 | 990 |
982 void NativeAppWindowCocoa::ShowWithApp() { | 991 void NativeAppWindowCocoa::ShowWithApp() { |
983 is_hidden_with_app_ = false; | 992 is_hidden_with_app_ = false; |
984 if (!is_hidden_) | 993 if (!is_hidden_) |
985 ShowInactive(); | 994 ShowInactive(); |
986 shell_window_->OnNativeWindowChanged(); | 995 shell_window_->OnNativeWindowChanged(); |
987 } | 996 } |
988 | 997 |
| 998 void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) { |
| 999 [window() setLevel:(always_on_top ? kAlwaysOnTopWindowLevel : |
| 1000 NSNormalWindowLevel)]; |
| 1001 shell_window_->OnNativeWindowChanged(); |
| 1002 } |
| 1003 |
989 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { | 1004 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { |
990 [window() orderOut:window_controller_]; | 1005 [window() orderOut:window_controller_]; |
991 } | 1006 } |
992 | 1007 |
993 NativeAppWindowCocoa::~NativeAppWindowCocoa() { | 1008 NativeAppWindowCocoa::~NativeAppWindowCocoa() { |
994 } | 1009 } |
995 | 1010 |
996 ShellNSWindow* NativeAppWindowCocoa::window() const { | 1011 ShellNSWindow* NativeAppWindowCocoa::window() const { |
997 NSWindow* window = [window_controller_ window]; | 1012 NSWindow* window = [window_controller_ window]; |
998 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 1013 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
999 return static_cast<ShellNSWindow*>(window); | 1014 return static_cast<ShellNSWindow*>(window); |
1000 } | 1015 } |
1001 | 1016 |
1002 void NativeAppWindowCocoa::UpdateRestoredBounds() { | 1017 void NativeAppWindowCocoa::UpdateRestoredBounds() { |
1003 if (IsRestored(*this)) | 1018 if (IsRestored(*this)) |
1004 restored_bounds_ = [window() frame]; | 1019 restored_bounds_ = [window() frame]; |
1005 } | 1020 } |
OLD | NEW |