OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/native_app_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 cocoa_bounds.origin.y = | 219 cocoa_bounds.origin.y = |
220 floor((NSHeight(main_screen_rect) - NSHeight(cocoa_bounds)) / 2); | 220 floor((NSHeight(main_screen_rect) - NSHeight(cocoa_bounds)) / 2); |
221 } | 221 } |
222 | 222 |
223 resizable_ = params.resizable; | 223 resizable_ = params.resizable; |
224 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | | 224 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | |
225 NSMiniaturizableWindowMask | | 225 NSMiniaturizableWindowMask | |
226 NSTexturedBackgroundWindowMask; | 226 NSTexturedBackgroundWindowMask; |
227 if (resizable_) | 227 if (resizable_) |
228 style_mask |= NSResizableWindowMask; | 228 style_mask |= NSResizableWindowMask; |
229 scoped_nsobject<NSWindow> window; | 229 base::scoped_nsobject<NSWindow> window; |
230 if (has_frame_) { | 230 if (has_frame_) { |
231 window.reset([[ShellNSWindow alloc] | 231 window.reset([[ShellNSWindow alloc] |
232 initWithContentRect:cocoa_bounds | 232 initWithContentRect:cocoa_bounds |
233 styleMask:style_mask | 233 styleMask:style_mask |
234 backing:NSBackingStoreBuffered | 234 backing:NSBackingStoreBuffered |
235 defer:NO]); | 235 defer:NO]); |
236 } else { | 236 } else { |
237 window.reset([[ShellFramelessNSWindow alloc] | 237 window.reset([[ShellFramelessNSWindow alloc] |
238 initWithContentRect:cocoa_bounds | 238 initWithContentRect:cocoa_bounds |
239 styleMask:style_mask | 239 styleMask:style_mask |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 // All ControlRegionViews should be added as children of the WebContentsView, | 649 // All ControlRegionViews should be added as children of the WebContentsView, |
650 // because WebContentsView will be removed and re-added when entering and | 650 // because WebContentsView will be removed and re-added when entering and |
651 // leaving fullscreen mode. | 651 // leaving fullscreen mode. |
652 NSView* webView = web_contents()->GetView()->GetNativeView(); | 652 NSView* webView = web_contents()->GetView()->GetNativeView(); |
653 NSInteger webViewHeight = NSHeight([webView bounds]); | 653 NSInteger webViewHeight = NSHeight([webView bounds]); |
654 | 654 |
655 // Remove all ControlRegionViews that are added last time. | 655 // Remove all ControlRegionViews that are added last time. |
656 // Note that [webView subviews] returns the view's mutable internal array and | 656 // Note that [webView subviews] returns the view's mutable internal array and |
657 // it should be copied to avoid mutating the original array while enumerating | 657 // it should be copied to avoid mutating the original array while enumerating |
658 // it. | 658 // it. |
659 scoped_nsobject<NSArray> subviews([[webView subviews] copy]); | 659 base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]); |
660 for (NSView* subview in subviews.get()) | 660 for (NSView* subview in subviews.get()) |
661 if ([subview isKindOfClass:[ControlRegionView class]]) | 661 if ([subview isKindOfClass:[ControlRegionView class]]) |
662 [subview removeFromSuperview]; | 662 [subview removeFromSuperview]; |
663 | 663 |
664 // Create and add ControlRegionView for each region that needs to be excluded | 664 // Create and add ControlRegionView for each region that needs to be excluded |
665 // from the dragging. | 665 // from the dragging. |
666 for (std::vector<gfx::Rect>::const_iterator iter = | 666 for (std::vector<gfx::Rect>::const_iterator iter = |
667 system_drag_exclude_areas_.begin(); | 667 system_drag_exclude_areas_.begin(); |
668 iter != system_drag_exclude_areas_.end(); | 668 iter != system_drag_exclude_areas_.end(); |
669 ++iter) { | 669 ++iter) { |
670 scoped_nsobject<NSView> controlRegion( | 670 base::scoped_nsobject<NSView> controlRegion( |
671 [[ControlRegionView alloc] initWithAppWindow:this]); | 671 [[ControlRegionView alloc] initWithAppWindow:this]); |
672 [controlRegion setFrame:NSMakeRect(iter->x(), | 672 [controlRegion setFrame:NSMakeRect(iter->x(), |
673 webViewHeight - iter->bottom(), | 673 webViewHeight - iter->bottom(), |
674 iter->width(), | 674 iter->width(), |
675 iter->height())]; | 675 iter->height())]; |
676 [controlRegion setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; | 676 [controlRegion setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; |
677 [webView addSubview:controlRegion]; | 677 [webView addSubview:controlRegion]; |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 821 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
822 return static_cast<ShellNSWindow*>(window); | 822 return static_cast<ShellNSWindow*>(window); |
823 } | 823 } |
824 | 824 |
825 // static | 825 // static |
826 NativeAppWindow* NativeAppWindow::Create( | 826 NativeAppWindow* NativeAppWindow::Create( |
827 ShellWindow* shell_window, | 827 ShellWindow* shell_window, |
828 const ShellWindow::CreateParams& params) { | 828 const ShellWindow::CreateParams& params) { |
829 return new NativeAppWindowCocoa(shell_window, params); | 829 return new NativeAppWindowCocoa(shell_window, params); |
830 } | 830 } |
OLD | NEW |