| 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/browser_window_command_handler.h" | 7 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" |
| 8 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" | 8 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_frame.h" | 9 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_shutdown.h" | |
| 11 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 12 #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" |
| 13 #include "components/web_modal/web_contents_modal_dialog_host.h" | 12 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 14 #import "ui/base/cocoa/window_size_constants.h" | 13 #import "ui/base/cocoa/window_size_constants.h" |
| 15 | 14 |
| 16 BrowserFrameMac::BrowserFrameMac(BrowserFrame* browser_frame, | 15 BrowserFrameMac::BrowserFrameMac(BrowserFrame* browser_frame, |
| 17 BrowserView* browser_view) | 16 BrowserView* browser_view) |
| 18 : views::NativeWidgetMac(browser_frame), | 17 : views::NativeWidgetMac(browser_frame), |
| 19 browser_view_(browser_view), | 18 browser_view_(browser_view), |
| 20 command_dispatcher_delegate_( | 19 command_dispatcher_delegate_( |
| 21 [[ChromeCommandDispatcherDelegate alloc] init]) {} | 20 [[ChromeCommandDispatcherDelegate alloc] init]) {} |
| 22 | 21 |
| 23 BrowserFrameMac::~BrowserFrameMac() { | 22 BrowserFrameMac::~BrowserFrameMac() { |
| 24 } | 23 } |
| 25 | 24 |
| 26 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 27 // BrowserFrameMac, views::NativeWidgetMac implementation: | 26 // BrowserFrameMac, views::NativeWidgetMac implementation: |
| 28 | 27 |
| 29 void BrowserFrameMac::OnWindowWillClose() { | |
| 30 // Destroy any remaining WebContents early on. This is consistent with Aura. | |
| 31 // See comment in DesktopBrowserFrameAura::OnHostClosed(). | |
| 32 DestroyBrowserWebContents(browser_view_->browser()); | |
| 33 NativeWidgetMac::OnWindowWillClose(); | |
| 34 } | |
| 35 | |
| 36 int BrowserFrameMac::SheetPositionY() { | 28 int BrowserFrameMac::SheetPositionY() { |
| 37 web_modal::WebContentsModalDialogHost* dialog_host = | 29 web_modal::WebContentsModalDialogHost* dialog_host = |
| 38 browser_view_->GetWebContentsModalDialogHost(); | 30 browser_view_->GetWebContentsModalDialogHost(); |
| 39 NSView* view = dialog_host->GetHostView(); | 31 NSView* view = dialog_host->GetHostView(); |
| 40 // Get the position of the host view relative to the window since | 32 // Get the position of the host view relative to the window since |
| 41 // ModalDialogHost::GetDialogPosition() is relative to the host view. | 33 // ModalDialogHost::GetDialogPosition() is relative to the host view. |
| 42 int host_view_y = | 34 int host_view_y = |
| 43 [view convertPoint:NSMakePoint(0, NSHeight([view frame])) toView:nil].y; | 35 [view convertPoint:NSMakePoint(0, NSHeight([view frame])) toView:nil].y; |
| 44 return host_view_y - dialog_host->GetDialogPosition(gfx::Size()).y(); | 36 return host_view_y - dialog_host->GetDialogPosition(gfx::Size()).y(); |
| 45 } | 37 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 void BrowserFrameMac::GetWindowPlacement( | 92 void BrowserFrameMac::GetWindowPlacement( |
| 101 gfx::Rect* bounds, | 93 gfx::Rect* bounds, |
| 102 ui::WindowShowState* show_state) const { | 94 ui::WindowShowState* show_state) const { |
| 103 return NativeWidgetMac::GetWindowPlacement(bounds, show_state); | 95 return NativeWidgetMac::GetWindowPlacement(bounds, show_state); |
| 104 } | 96 } |
| 105 | 97 |
| 106 int BrowserFrameMac::GetMinimizeButtonOffset() const { | 98 int BrowserFrameMac::GetMinimizeButtonOffset() const { |
| 107 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
| 108 return 0; | 100 return 0; |
| 109 } | 101 } |
| OLD | NEW |