Chromium Code Reviews| Index: chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| diff --git a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| index b00603a1b16285aef9362e90e9249dc703fcb309..f64ec38bc84117cf7e8a4a47f964d6ba342abbca 100644 |
| --- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| +++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc |
| @@ -10,10 +10,14 @@ |
| #include "chrome/browser/ui/views/constrained_window_views.h" |
| #include "chrome/browser/ui/webui/web_dialog_delegate.h" |
| #include "chrome/browser/ui/webui/web_dialog_ui.h" |
| +#include "content/public/browser/native_web_keyboard_event.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "ui/aura/event.h" |
| +#include "ui/aura/window.h" |
| #include "ui/gfx/size.h" |
| #include "ui/views/controls/webview/webview.h" |
| #include "ui/views/view.h" |
| +#include "ui/views/widget/native_widget_aura.h" |
| #include "ui/views/widget/widget_delegate.h" |
| using content::WebContents; |
| @@ -44,6 +48,18 @@ class ConstrainedWebDialogDelegateViews |
| window()->CloseConstrainedWindow(); |
| } |
| + // contents::WebContentsDelegate |
| + virtual void HandleKeyboardEvent( |
| + const content::NativeWebKeyboardEvent& event) OVERRIDE { |
| +#if defined(USE_AURA) |
| + aura::KeyEvent aura_event(event.os_event->native_event(), false); |
| + window()->GetNativeWindow()->delegate()->OnKeyEvent(&aura_event); |
| +#elif defined(OS_WIN) |
| + // TODO(yoshiki): Fill this when this is necessary. |
| + NOTIMPLEMENTED(); |
| +#endif |
| + } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateViews); |
| }; |
| @@ -110,6 +126,14 @@ class ConstrainedWebDialogDelegateViewViews |
| } |
| // views::WebView overrides. |
| + virtual bool |
| + AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE { |
|
kochi
2012/05/30 07:17:31
style nit: newline after open paren.
virtual bool
yoshiki
2012/05/30 08:43:15
Done.
|
| + // Pressing ESC closes the dialog. |
| + DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); |
| + if (GetWidget()) |
| + GetWidget()->Close(); |
| + return true; |
| + }; |
|
kochi
2012/05/30 07:17:31
nit: a newline after this line.
yoshiki
2012/05/30 08:43:15
Other inherited methods are listed without blank l
|
| virtual gfx::Size GetPreferredSize() OVERRIDE { |
| gfx::Size size; |
| if (!impl_->closed_via_webui()) |
| @@ -132,6 +156,10 @@ ConstrainedWebDialogDelegateViewViews::ConstrainedWebDialogDelegateViewViews( |
| delegate, |
| tab_delegate)) { |
| SetWebContents(tab()->web_contents()); |
| + |
| + // Pressing the ESC key will close the dialog. |
|
kochi
2012/05/30 07:17:31
probably "the" is not necessary.
You can reuse the
yoshiki
2012/05/30 08:43:15
Done.
|
| + set_allow_accelerators(true); |
| + AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); |
|
kochi
2012/05/30 07:17:31
Don't we need to RemoveAccelerator()?
(I'm not sur
yoshiki
2012/05/30 08:43:15
I think it is not necessarily because WebDialogVie
|
| } |
| ConstrainedWebDialogDelegateViewViews::~ConstrainedWebDialogDelegateViewViews() { |