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/webui/constrained_web_dialog_delegate_base.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" |
12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 12 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_view.h" |
14 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
15 #include "ui/web_dialogs/web_dialog_delegate.h" | 16 #include "ui/web_dialogs/web_dialog_delegate.h" |
16 #include "ui/web_dialogs/web_dialog_ui.h" | 17 #include "ui/web_dialogs/web_dialog_ui.h" |
17 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 18 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
18 | 19 |
19 using content::WebContents; | 20 using content::WebContents; |
20 using ui::WebDialogDelegate; | 21 using ui::WebDialogDelegate; |
21 using ui::WebDialogWebContentsDelegate; | 22 using ui::WebDialogWebContentsDelegate; |
22 | 23 |
23 namespace { | 24 namespace { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 : impl_(new ConstrainedWebDialogDelegateMac(browser_context, | 107 : impl_(new ConstrainedWebDialogDelegateMac(browser_context, |
107 delegate, | 108 delegate, |
108 tab_delegate)) { | 109 tab_delegate)) { |
109 // Create a window to hold web_contents in the constrained sheet: | 110 // Create a window to hold web_contents in the constrained sheet: |
110 gfx::Size size; | 111 gfx::Size size; |
111 delegate->GetDialogSize(&size); | 112 delegate->GetDialogSize(&size); |
112 NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); | 113 NSRect frame = NSMakeRect(0, 0, size.width(), size.height()); |
113 | 114 |
114 window_.reset( | 115 window_.reset( |
115 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]); | 116 [[ConstrainedWindowCustomWindow alloc] initWithContentRect:frame]); |
116 [GetWebContents()->GetNativeView() setFrame:frame]; | 117 [GetWebContents()->GetView()->GetNativeView() setFrame:frame]; |
117 [[window_ contentView] addSubview:GetWebContents()->GetNativeView()]; | 118 [[window_ contentView] |
| 119 addSubview:GetWebContents()->GetView()->GetNativeView()]; |
118 | 120 |
119 scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 121 scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
120 [[CustomConstrainedWindowSheet alloc] | 122 [[CustomConstrainedWindowSheet alloc] |
121 initWithCustomWindow:window_]); | 123 initWithCustomWindow:window_]); |
122 constrained_window_.reset(new ConstrainedWindowMac( | 124 constrained_window_.reset(new ConstrainedWindowMac( |
123 this, web_contents, sheet)); | 125 this, web_contents, sheet)); |
124 | 126 |
125 impl_->set_window(constrained_window_.get()); | 127 impl_->set_window(constrained_window_.get()); |
126 } | 128 } |
127 | 129 |
128 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 130 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
129 content::BrowserContext* browser_context, | 131 content::BrowserContext* browser_context, |
130 WebDialogDelegate* delegate, | 132 WebDialogDelegate* delegate, |
131 WebDialogWebContentsDelegate* tab_delegate, | 133 WebDialogWebContentsDelegate* tab_delegate, |
132 content::WebContents* web_contents) { | 134 content::WebContents* web_contents) { |
133 // Deleted when the dialog closes. | 135 // Deleted when the dialog closes. |
134 ConstrainedWebDialogDelegateViewMac* constrained_delegate = | 136 ConstrainedWebDialogDelegateViewMac* constrained_delegate = |
135 new ConstrainedWebDialogDelegateViewMac( | 137 new ConstrainedWebDialogDelegateViewMac( |
136 browser_context, delegate, tab_delegate, web_contents); | 138 browser_context, delegate, tab_delegate, web_contents); |
137 return constrained_delegate; | 139 return constrained_delegate; |
138 } | 140 } |
OLD | NEW |