Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_mac.mm

Issue 1315043003: [MacViews] Position modal sheets using ModalDialogHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bbobserver
Patch Set: Address comments. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/ui/views/frame/browser_frame.h" 7 #include "chrome/browser/ui/views/frame/browser_frame.h"
8 #include "chrome/browser/ui/views/frame/browser_shutdown.h" 8 #include "chrome/browser/ui/views/frame/browser_shutdown.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h" 10 #import "chrome/browser/ui/views/frame/native_widget_mac_frameless_nswindow.h"
11 #include "components/web_modal/web_contents_modal_dialog_host.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 }
18 19
19 BrowserFrameMac::~BrowserFrameMac() { 20 BrowserFrameMac::~BrowserFrameMac() {
20 } 21 }
21 22
22 //////////////////////////////////////////////////////////////////////////////// 23 ////////////////////////////////////////////////////////////////////////////////
23 // BrowserFrameMac, views::NativeWidgetMac implementation: 24 // BrowserFrameMac, views::NativeWidgetMac implementation:
24 25
25 void BrowserFrameMac::OnWindowWillClose() { 26 void BrowserFrameMac::OnWindowWillClose() {
26 // Destroy any remaining WebContents early on. This is consistent with Aura. 27 // Destroy any remaining WebContents early on. This is consistent with Aura.
27 // See comment in DesktopBrowserFrameAura::OnHostClosed(). 28 // See comment in DesktopBrowserFrameAura::OnHostClosed().
28 DestroyBrowserWebContents(browser_view_->browser()); 29 DestroyBrowserWebContents(browser_view_->browser());
29 NativeWidgetMac::OnWindowWillClose(); 30 NativeWidgetMac::OnWindowWillClose();
30 } 31 }
31 32
33 int BrowserFrameMac::SheetPositionY() {
34 web_modal::WebContentsModalDialogHost* dialog_host =
35 browser_view_->GetWebContentsModalDialogHost();
36 NSView* host_view = dialog_host->GetHostView();
37 // Get the position of the host view relative to the window since
38 // ModalDialogHost::GetDialogPosition is relative to the host view.
tapted 2015/08/26 07:27:48 nit: GetDialogPosition()
jackhou1 2015/08/27 05:38:09 Done.
39 int host_view_y =
40 NSHeight([[host_view window] frame]) - NSMaxY([host_view frame]);
tapted 2015/08/26 07:27:48 So I think this assumes host_view is the contentVi
jackhou1 2015/08/27 05:38:09 Changed to use -convertPoint to get the host_view'
41 return host_view_y + dialog_host->GetDialogPosition(gfx::Size()).y();
42 }
43
32 void BrowserFrameMac::InitNativeWidget( 44 void BrowserFrameMac::InitNativeWidget(
33 const views::Widget::InitParams& params) { 45 const views::Widget::InitParams& params) {
34 views::NativeWidgetMac::InitNativeWidget(params); 46 views::NativeWidgetMac::InitNativeWidget(params);
35 47
36 // Our content view draws on top of the titlebar area, but we want the window 48 // 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. 49 // 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 50 // 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. 51 // by giving the root view a layer so that the buttons get their own layers.
40 NSView* content_view = [GetNativeWindow() contentView]; 52 NSView* content_view = [GetNativeWindow() contentView];
41 NSView* root_view = [content_view superview]; 53 NSView* root_view = [content_view superview];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 void BrowserFrameMac::GetWindowPlacement( 92 void BrowserFrameMac::GetWindowPlacement(
81 gfx::Rect* bounds, 93 gfx::Rect* bounds,
82 ui::WindowShowState* show_state) const { 94 ui::WindowShowState* show_state) const {
83 return NativeWidgetMac::GetWindowPlacement(bounds, show_state); 95 return NativeWidgetMac::GetWindowPlacement(bounds, show_state);
84 } 96 }
85 97
86 int BrowserFrameMac::GetMinimizeButtonOffset() const { 98 int BrowserFrameMac::GetMinimizeButtonOffset() const {
87 NOTIMPLEMENTED(); 99 NOTIMPLEMENTED();
88 return 0; 100 return 0;
89 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698