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 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/views/constrained_window_views.h" | |
9 #include "components/web_modal/web_contents_modal_dialog_host.h" | 8 #include "components/web_modal/web_contents_modal_dialog_host.h" |
10 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
11 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
12 #include "content/public/browser/native_web_keyboard_event.h" | 11 #include "content/public/browser/native_web_keyboard_event.h" |
13 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
14 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
15 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | 14 #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" |
16 #include "ui/views/controls/webview/webview.h" | 15 #include "ui/views/controls/webview/webview.h" |
17 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
18 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 virtual const views::Widget* GetWidget() const OVERRIDE { | 122 virtual const views::Widget* GetWidget() const OVERRIDE { |
124 return View::GetWidget(); | 123 return View::GetWidget(); |
125 } | 124 } |
126 virtual base::string16 GetWindowTitle() const OVERRIDE { | 125 virtual base::string16 GetWindowTitle() const OVERRIDE { |
127 return impl_->closed_via_webui() ? base::string16() : | 126 return impl_->closed_via_webui() ? base::string16() : |
128 GetWebDialogDelegate()->GetDialogTitle(); | 127 GetWebDialogDelegate()->GetDialogTitle(); |
129 } | 128 } |
130 virtual views::View* GetContentsView() OVERRIDE { | 129 virtual views::View* GetContentsView() OVERRIDE { |
131 return this; | 130 return this; |
132 } | 131 } |
133 // TODO(wittman): Remove this override once we move to the new style frame | |
134 // view on all dialogs. | |
135 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
136 views::Widget* widget) OVERRIDE { | |
137 return CreateConstrainedStyleNonClientFrameView( | |
138 widget, | |
139 GetWebContents()->GetBrowserContext()); | |
140 } | |
141 virtual bool ShouldShowCloseButton() const OVERRIDE { | 132 virtual bool ShouldShowCloseButton() const OVERRIDE { |
142 // No close button if the dialog doesn't want a title bar. | 133 // No close button if the dialog doesn't want a title bar. |
143 return impl_->GetWebDialogDelegate()->ShouldShowDialogTitle(); | 134 return impl_->GetWebDialogDelegate()->ShouldShowDialogTitle(); |
144 } | 135 } |
145 | 136 |
146 virtual ui::ModalType GetModalType() const OVERRIDE { | 137 virtual ui::ModalType GetModalType() const OVERRIDE { |
147 #if defined(USE_ASH) | 138 #if defined(USE_ASH) |
148 return ui::MODAL_TYPE_CHILD; | 139 return ui::MODAL_TYPE_CHILD; |
149 #else | 140 #else |
150 return views::WidgetDelegate::GetModalType(); | 141 return views::WidgetDelegate::GetModalType(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 impl_(new ConstrainedWebDialogDelegateViews(browser_context, | 183 impl_(new ConstrainedWebDialogDelegateViews(browser_context, |
193 delegate, | 184 delegate, |
194 tab_delegate, | 185 tab_delegate, |
195 this)) { | 186 this)) { |
196 SetWebContents(GetWebContents()); | 187 SetWebContents(GetWebContents()); |
197 | 188 |
198 // Pressing ESC closes the dialog. | 189 // Pressing ESC closes the dialog. |
199 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 190 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
200 } | 191 } |
201 | 192 |
202 ConstrainedWebDialogDelegateViewViews::~ConstrainedWebDialogDelegateViewViews()
{ | 193 ConstrainedWebDialogDelegateViewViews:: |
| 194 ~ConstrainedWebDialogDelegateViewViews() { |
203 } | 195 } |
204 | 196 |
205 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 197 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
206 content::BrowserContext* browser_context, | 198 content::BrowserContext* browser_context, |
207 WebDialogDelegate* delegate, | 199 WebDialogDelegate* delegate, |
208 WebDialogWebContentsDelegate* tab_delegate, | 200 WebDialogWebContentsDelegate* tab_delegate, |
209 content::WebContents* web_contents) { | 201 content::WebContents* web_contents) { |
210 ConstrainedWebDialogDelegateViewViews* constrained_delegate = | 202 ConstrainedWebDialogDelegateViewViews* constrained_delegate = |
211 new ConstrainedWebDialogDelegateViewViews( | 203 new ConstrainedWebDialogDelegateViewViews( |
212 browser_context, delegate, tab_delegate); | 204 browser_context, delegate, tab_delegate); |
213 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 205 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
214 WebContentsModalDialogManager::FromWebContents(web_contents); | 206 WebContentsModalDialogManager::FromWebContents(web_contents); |
215 WebContentsModalDialogManagerDelegate* modal_delegate = | 207 WebContentsModalDialogManagerDelegate* modal_delegate = |
216 web_contents_modal_dialog_manager->delegate(); | 208 web_contents_modal_dialog_manager->delegate(); |
217 DCHECK(modal_delegate); | 209 DCHECK(modal_delegate); |
218 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( | 210 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( |
219 constrained_delegate, | 211 constrained_delegate, |
220 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); | 212 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); |
221 web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); | 213 web_contents_modal_dialog_manager->ShowDialog(window->GetNativeView()); |
222 constrained_delegate->SetWindow(window); | 214 constrained_delegate->SetWindow(window); |
223 return constrained_delegate; | 215 return constrained_delegate; |
224 } | 216 } |
OLD | NEW |