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

Unified Diff: chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc

Issue 10446076: Handle Escape key on constrained window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8c2db1932b8baa2e24fbff92a722a50fa5fdf875 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"
sky 2012/05/30 14:59:48 Only include aura if aura is defined.
yoshiki 2012/05/31 18:50:40 Done.
+#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 {
+ // Pressing ESC closes the dialog.
+ DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code());
+ if (GetWidget())
+ GetWidget()->Close();
sky 2012/05/30 14:59:48 Don't you need to route this to CloseConstrainedWi
yoshiki 2012/05/31 18:50:40 Done.
+ return true;
+ }
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 ESC closes the dialog.
+ set_allow_accelerators(true);
+ AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
}
ConstrainedWebDialogDelegateViewViews::~ConstrainedWebDialogDelegateViewViews() {
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698