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

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/certificate_viewer.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 0727ea6de1580e135b70d088707fc5e2d7e366cc..bf59ef51e9b7d775ec1cffa0b0fbf8d3593f41ab 100644
--- a/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
+++ b/chrome/browser/ui/views/constrained_web_dialog_delegate_views.cc
@@ -8,14 +8,21 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/views/constrained_window_views.h"
+#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.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"
sky 2012/05/31 21:38:23 This should only be included for aura too.
yoshiki 2012/06/18 15:45:32 Done.
#include "ui/views/widget/widget_delegate.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
#include "ui/web_dialogs/web_dialog_ui.h"
+#if defined(USE_AURA)
+#include "ui/aura/event.h"
+#include "ui/aura/window.h"
+#endif // defined(USE_AURA)
sky 2012/05/31 21:38:23 remove the trailing //
yoshiki 2012/06/18 15:45:32 Done.
+
using content::WebContents;
using ui::ConstrainedWebDialogDelegate;
using ui::ConstrainedWebDialogUI;
@@ -47,6 +54,18 @@ class ConstrainedWebDialogDelegateViews
window()->CloseConstrainedWindow();
}
+ // contents::WebContentsDelegate
+ virtual void HandleKeyboardEvent(
+ const content::NativeWebKeyboardEvent& event) OVERRIDE {
+#if defined(USE_AURA)
sky 2012/05/31 21:38:23 Can you use unhandled_keyboard_event_handler for t
yoshiki 2012/06/18 15:45:32 Done.
+ 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);
};
@@ -113,6 +132,13 @@ 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());
+ window()->CloseConstrainedWindow();
+ return true;
+ }
virtual gfx::Size GetPreferredSize() OVERRIDE {
gfx::Size size;
if (!impl_->closed_via_webui())
@@ -135,6 +161,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/certificate_viewer.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698