| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/views/frame/browser_frame_mac.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame_mac.h" |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
| 7 #include "chrome/browser/ui/views/frame/browser_frame.h" | 8 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 8 #include "chrome/browser/ui/views/frame/browser_shutdown.h" | 9 #include "chrome/browser/ui/views/frame/browser_shutdown.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" | 11 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" |
| 11 #import "ui/base/cocoa/window_size_constants.h" | 12 #import "ui/base/cocoa/window_size_constants.h" |
| 12 | 13 |
| 13 BrowserFrameMac::BrowserFrameMac(BrowserFrame* browser_frame, | 14 BrowserFrameMac::BrowserFrameMac(BrowserFrame* browser_frame, |
| 14 BrowserView* browser_view) | 15 BrowserView* browser_view) |
| 15 : views::NativeWidgetMac(browser_frame), | 16 : views::NativeWidgetMac(browser_frame), |
| 16 browser_view_(browser_view) { | 17 browser_view_(browser_view), |
| 17 } | 18 command_dispatcher_delegate_( |
| 19 [[ChromeCommandDispatcherDelegate alloc] init]) {} |
| 18 | 20 |
| 19 BrowserFrameMac::~BrowserFrameMac() { | 21 BrowserFrameMac::~BrowserFrameMac() { |
| 20 } | 22 } |
| 21 | 23 |
| 22 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
| 23 // BrowserFrameMac, views::NativeWidgetMac implementation: | 25 // BrowserFrameMac, views::NativeWidgetMac implementation: |
| 24 | 26 |
| 25 void BrowserFrameMac::OnWindowWillClose() { | 27 void BrowserFrameMac::OnWindowWillClose() { |
| 26 // Destroy any remaining WebContents early on. This is consistent with Aura. | 28 // Destroy any remaining WebContents early on. This is consistent with Aura. |
| 27 // See comment in DesktopBrowserFrameAura::OnHostClosed(). | 29 // See comment in DesktopBrowserFrameAura::OnHostClosed(). |
| 28 DestroyBrowserWebContents(browser_view_->browser()); | 30 DestroyBrowserWebContents(browser_view_->browser()); |
| 29 NativeWidgetMac::OnWindowWillClose(); | 31 NativeWidgetMac::OnWindowWillClose(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void BrowserFrameMac::InitNativeWidget( | 34 void BrowserFrameMac::InitNativeWidget( |
| 33 const views::Widget::InitParams& params) { | 35 const views::Widget::InitParams& params) { |
| 34 views::NativeWidgetMac::InitNativeWidget(params); | 36 views::NativeWidgetMac::InitNativeWidget(params); |
| 35 | 37 |
| 36 // Our content view draws on top of the titlebar area, but we want the window | 38 // Our content view draws on top of the titlebar area, but we want the window |
| 37 // control buttons to draw on top of the content view. | 39 // control buttons to draw on top of the content view. |
| 38 // We do this by setting the content view's z-order below the buttons, and | 40 // We do this by setting the content view's z-order below the buttons, and |
| 39 // by giving the root view a layer so that the buttons get their own layers. | 41 // by giving the root view a layer so that the buttons get their own layers. |
| 40 NSView* content_view = [GetNativeWindow() contentView]; | 42 NSView* content_view = [GetNativeWindow() contentView]; |
| 41 NSView* root_view = [content_view superview]; | 43 NSView* root_view = [content_view superview]; |
| 42 [content_view removeFromSuperview]; | 44 [content_view removeFromSuperview]; |
| 43 [root_view setWantsLayer:YES]; | 45 [root_view setWantsLayer:YES]; |
| 44 [root_view addSubview:content_view positioned:NSWindowBelow relativeTo:nil]; | 46 [root_view addSubview:content_view positioned:NSWindowBelow relativeTo:nil]; |
| 45 } | 47 } |
| 46 | 48 |
| 47 gfx::NativeWindow BrowserFrameMac::CreateNSWindow( | 49 NativeWidgetMacNSWindow* BrowserFrameMac::CreateNSWindow( |
| 48 const views::Widget::InitParams& params) { | 50 const views::Widget::InitParams& params) { |
| 49 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | | 51 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | |
| 50 NSMiniaturizableWindowMask | NSResizableWindowMask | | 52 NSMiniaturizableWindowMask | NSResizableWindowMask | |
| 51 NSTexturedBackgroundWindowMask; | 53 NSTexturedBackgroundWindowMask; |
| 52 return [[[NativeWidgetMacFramelessNSWindow alloc] | 54 base::scoped_nsobject<NativeWidgetMacFramelessNSWindow> ns_window( |
| 53 initWithContentRect:ui::kWindowSizeDeterminedLater | 55 [[NativeWidgetMacFramelessNSWindow alloc] |
| 54 styleMask:style_mask | 56 initWithContentRect:ui::kWindowSizeDeterminedLater |
| 55 backing:NSBackingStoreBuffered | 57 styleMask:style_mask |
| 56 defer:NO] autorelease]; | 58 backing:NSBackingStoreBuffered |
| 59 defer:NO]); |
| 60 [ns_window setCommandDispatcherDelegate:command_dispatcher_delegate_]; |
| 61 return ns_window.autorelease(); |
| 57 } | 62 } |
| 58 | 63 |
| 59 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 60 // BrowserFrameMac, NativeBrowserFrame implementation: | 65 // BrowserFrameMac, NativeBrowserFrame implementation: |
| 61 | 66 |
| 62 views::Widget::InitParams BrowserFrameMac::GetWidgetParams() { | 67 views::Widget::InitParams BrowserFrameMac::GetWidgetParams() { |
| 63 views::Widget::InitParams params; | 68 views::Widget::InitParams params; |
| 64 params.native_widget = this; | 69 params.native_widget = this; |
| 65 return params; | 70 return params; |
| 66 } | 71 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 80 void BrowserFrameMac::GetWindowPlacement( | 85 void BrowserFrameMac::GetWindowPlacement( |
| 81 gfx::Rect* bounds, | 86 gfx::Rect* bounds, |
| 82 ui::WindowShowState* show_state) const { | 87 ui::WindowShowState* show_state) const { |
| 83 return NativeWidgetMac::GetWindowPlacement(bounds, show_state); | 88 return NativeWidgetMac::GetWindowPlacement(bounds, show_state); |
| 84 } | 89 } |
| 85 | 90 |
| 86 int BrowserFrameMac::GetMinimizeButtonOffset() const { | 91 int BrowserFrameMac::GetMinimizeButtonOffset() const { |
| 87 NOTIMPLEMENTED(); | 92 NOTIMPLEMENTED(); |
| 88 return 0; | 93 return 0; |
| 89 } | 94 } |
| OLD | NEW |