| 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/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 24 matching lines...) Expand all Loading... |
| 35 // | 35 // |
| 36 // Zooming is implemented manually in order to implement maximize functionality | 36 // Zooming is implemented manually in order to implement maximize functionality |
| 37 // and to support non resizable windows. The window will be resized explicitly | 37 // and to support non resizable windows. The window will be resized explicitly |
| 38 // in the |WindowWillZoom| call. | 38 // in the |WindowWillZoom| call. |
| 39 // | 39 // |
| 40 // Attempting maximize and restore functionality with non resizable windows | 40 // Attempting maximize and restore functionality with non resizable windows |
| 41 // using the native zoom method did not work, even with | 41 // using the native zoom method did not work, even with |
| 42 // windowWillUseStandardFrame, as the window would not restore back to the | 42 // windowWillUseStandardFrame, as the window would not restore back to the |
| 43 // desired size. | 43 // desired size. |
| 44 | 44 |
| 45 using apps::AppWindow; | 45 using extensions::AppWindow; |
| 46 | 46 |
| 47 @interface NSWindow (NSPrivateApis) | 47 @interface NSWindow (NSPrivateApis) |
| 48 - (void)setBottomCornerRounded:(BOOL)rounded; | 48 - (void)setBottomCornerRounded:(BOOL)rounded; |
| 49 - (BOOL)_isTitleHidden; | 49 - (BOOL)_isTitleHidden; |
| 50 @end | 50 @end |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 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]; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Returns the level for windows that are configured to be always on top. | 73 // Returns the level for windows that are configured to be always on top. |
| 74 // This is not a constant because NSFloatingWindowLevel is a macro defined | 74 // This is not a constant because NSFloatingWindowLevel is a macro defined |
| 75 // as a function call. | 75 // as a function call. |
| 76 NSInteger AlwaysOnTopWindowLevel() { | 76 NSInteger AlwaysOnTopWindowLevel() { |
| 77 return NSFloatingWindowLevel; | 77 return NSFloatingWindowLevel; |
| 78 } | 78 } |
| 79 | 79 |
| 80 NSRect GfxToCocoaBounds(gfx::Rect bounds) { | 80 NSRect GfxToCocoaBounds(gfx::Rect bounds) { |
| 81 typedef apps::AppWindow::BoundsSpecification BoundsSpecification; | 81 typedef AppWindow::BoundsSpecification BoundsSpecification; |
| 82 | 82 |
| 83 NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame]; | 83 NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame]; |
| 84 | 84 |
| 85 // If coordinates are unspecified, center window on primary screen. | 85 // If coordinates are unspecified, center window on primary screen. |
| 86 if (bounds.x() == BoundsSpecification::kUnspecifiedPosition) | 86 if (bounds.x() == BoundsSpecification::kUnspecifiedPosition) |
| 87 bounds.set_x(floor((NSWidth(main_screen_rect) - bounds.width()) / 2)); | 87 bounds.set_x(floor((NSWidth(main_screen_rect) - bounds.width()) / 2)); |
| 88 if (bounds.y() == BoundsSpecification::kUnspecifiedPosition) | 88 if (bounds.y() == BoundsSpecification::kUnspecifiedPosition) |
| 89 bounds.set_y(floor((NSHeight(main_screen_rect) - bounds.height()) / 2)); | 89 bounds.set_y(floor((NSHeight(main_screen_rect) - bounds.height()) / 2)); |
| 90 | 90 |
| 91 // Convert to Mac coordinates. | 91 // Convert to Mac coordinates. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 @end | 200 @end |
| 201 | 201 |
| 202 // This is really a method on NSGrayFrame, so it should only be called on the | 202 // This is really a method on NSGrayFrame, so it should only be called on the |
| 203 // view passed into -[NSWindow drawCustomFrameRect:forView:]. | 203 // view passed into -[NSWindow drawCustomFrameRect:forView:]. |
| 204 @interface NSView (PrivateMethods) | 204 @interface NSView (PrivateMethods) |
| 205 - (CGFloat)roundedCornerRadius; | 205 - (CGFloat)roundedCornerRadius; |
| 206 @end | 206 @end |
| 207 | 207 |
| 208 // TODO(jamescook): Should these be AppNSWindow to match apps::AppWindow? | 208 // TODO(jamescook): Should these be AppNSWindow to match AppWindow? |
| 209 // http://crbug.com/344082 | 209 // http://crbug.com/344082 |
| 210 @interface ShellNSWindow : ChromeEventProcessingWindow | 210 @interface ShellNSWindow : ChromeEventProcessingWindow |
| 211 @end | 211 @end |
| 212 @implementation ShellNSWindow | 212 @implementation ShellNSWindow |
| 213 | 213 |
| 214 // Similar to ChromeBrowserWindow, don't draw the title, but allow it to be seen | 214 // Similar to ChromeBrowserWindow, don't draw the title, but allow it to be seen |
| 215 // in menus, Expose, etc. | 215 // in menus, Expose, etc. |
| 216 - (BOOL)_isTitleHidden { | 216 - (BOOL)_isTitleHidden { |
| 217 return YES; | 217 return YES; |
| 218 } | 218 } |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 } | 981 } |
| 982 | 982 |
| 983 void NativeAppWindowCocoa::UpdateRestoredBounds() { | 983 void NativeAppWindowCocoa::UpdateRestoredBounds() { |
| 984 if (IsRestored(*this)) | 984 if (IsRestored(*this)) |
| 985 restored_bounds_ = [window() frame]; | 985 restored_bounds_ = [window() frame]; |
| 986 } | 986 } |
| 987 | 987 |
| 988 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { | 988 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { |
| 989 [window() orderOut:window_controller_]; | 989 [window() orderOut:window_controller_]; |
| 990 } | 990 } |
| OLD | NEW |