Permalink
Browse files

Added an accelerator to the HtmlDialogView class so that hitting the …

…ESC key closes the dialog.

BUG=19786
TEST=Open Sync Bookmaeks Login dialog. Enter credentials, TAB between fields, etc. to ensure nothing is broken. Hit the ESC key to dismiss the dialog.

Patch by Randy Posynick (http://codereview.chromium.org/199069)

Review URL: http://codereview.chromium.org/246020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27371 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information...
1 parent 41379aa commit c6ccd45a5d397f2daf7cba8c383f3cc6974eeca6 tim@chromium.org committed Sep 28, 2009
Showing with 14 additions and 0 deletions.
  1. +2 −0 AUTHORS
  2. +11 −0 chrome/browser/views/html_dialog_view.cc
  3. +1 −0 chrome/browser/views/html_dialog_view.h
View
@@ -49,3 +49,5 @@ Pierre-Antoine LaFayette <pierre.lafayette@gmail.com>
Song YeWen <ffmpeg@gmail.com>
Philippe Beauchamp <philippe.beauchamp@gmail.com>
Vedran Šajatović <vedran.sajatovic@gmail.com>
+Randy Posynick <randy.posynick@gmail.com>
+Bruno Calvignac <brunocalvignac@gmail.com>
@@ -4,6 +4,7 @@
#include "chrome/browser/views/html_dialog_view.h"
+#include "base/keyboard_codes.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "views/widget/root_view.h"
@@ -48,6 +49,13 @@ gfx::Size HtmlDialogView::GetPreferredSize() {
return out;
}
+bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) {
+ // Pressing ESC closes the dialog.
+ DCHECK_EQ(base::VKEY_ESCAPE, accelerator.GetKeyCode());
+ OnDialogClosed(std::string());
+ return true;
+}
+
////////////////////////////////////////////////////////////////////////////////
// HtmlDialogView, views::WindowDelegate implementation:
@@ -216,5 +224,8 @@ void HtmlDialogView::InitDialog() {
HtmlDialogUI::GetPropertyAccessor().SetProperty(tab_contents_->property_bag(),
this);
+ // Pressing the ESC key will close the dialog.
+ AddAccelerator(views::Accelerator(base::VKEY_ESCAPE, false, false, false));
+
DOMView::LoadURL(delegate_->GetDialogContentURL());
}
@@ -41,6 +41,7 @@ class HtmlDialogView
// Overridden from views::View:
virtual gfx::Size GetPreferredSize();
+ virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
// Overridden from views::WindowDelegate:
virtual bool CanResize() const;

0 comments on commit c6ccd45

Please sign in to comment.