OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/html_dialog_view.h" | 5 #include "chrome/browser/views/html_dialog_view.h" |
6 | 6 |
| 7 #include "base/keyboard_codes.h" |
7 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
8 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
9 #include "views/widget/root_view.h" | 10 #include "views/widget/root_view.h" |
10 #include "views/widget/widget.h" | 11 #include "views/widget/widget.h" |
11 #include "views/window/window.h" | 12 #include "views/window/window.h" |
12 | 13 |
13 namespace browser { | 14 namespace browser { |
14 | 15 |
15 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 16 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
16 void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser, | 17 void ShowHtmlDialogView(gfx::NativeWindow parent, Browser* browser, |
(...skipping 24 matching lines...) Expand all Loading... |
41 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
42 // HtmlDialogView, views::View implementation: | 43 // HtmlDialogView, views::View implementation: |
43 | 44 |
44 gfx::Size HtmlDialogView::GetPreferredSize() { | 45 gfx::Size HtmlDialogView::GetPreferredSize() { |
45 gfx::Size out; | 46 gfx::Size out; |
46 if (delegate_) | 47 if (delegate_) |
47 delegate_->GetDialogSize(&out); | 48 delegate_->GetDialogSize(&out); |
48 return out; | 49 return out; |
49 } | 50 } |
50 | 51 |
| 52 bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) { |
| 53 // Pressing ESC closes the dialog. |
| 54 DCHECK_EQ(base::VKEY_ESCAPE, accelerator.GetKeyCode()); |
| 55 OnDialogClosed(std::string()); |
| 56 return true; |
| 57 } |
| 58 |
51 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
52 // HtmlDialogView, views::WindowDelegate implementation: | 60 // HtmlDialogView, views::WindowDelegate implementation: |
53 | 61 |
54 bool HtmlDialogView::CanResize() const { | 62 bool HtmlDialogView::CanResize() const { |
55 return true; | 63 return true; |
56 } | 64 } |
57 | 65 |
58 bool HtmlDialogView::IsModal() const { | 66 bool HtmlDialogView::IsModal() const { |
59 if (delegate_) | 67 if (delegate_) |
60 return delegate_->IsDialogModal(); | 68 return delegate_->IsDialogModal(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // Now Init the DOMView. This view runs in its own process to render the html. | 217 // Now Init the DOMView. This view runs in its own process to render the html. |
210 DOMView::Init(profile_, NULL); | 218 DOMView::Init(profile_, NULL); |
211 | 219 |
212 tab_contents_->set_delegate(this); | 220 tab_contents_->set_delegate(this); |
213 | 221 |
214 // Set the delegate. This must be done before loading the page. See | 222 // Set the delegate. This must be done before loading the page. See |
215 // the comment above HtmlDialogUI in its header file for why. | 223 // the comment above HtmlDialogUI in its header file for why. |
216 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), | 224 HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(), |
217 this); | 225 this); |
218 | 226 |
| 227 // Pressing the ESC key will close the dialog. |
| 228 AddAccelerator(views::Accelerator(base::VKEY_ESCAPE, false, false, false)); |
| 229 |
219 DOMView::LoadURL(delegate_->GetDialogContentURL()); | 230 DOMView::LoadURL(delegate_->GetDialogContentURL()); |
220 } | 231 } |
OLD | NEW |