Skip to content

Commit

Permalink
Added an accelerator to the HtmlDialogView class so that hitting the …
Browse files Browse the repository at this point in the history
…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
tim@chromium.org committed Sep 28, 2009
1 parent 0d15805 commit 9b535cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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>
11 changes: 11 additions & 0 deletions chrome/browser/views/html_dialog_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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());
}
1 change: 1 addition & 0 deletions chrome/browser/views/html_dialog_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9b535cf

Please sign in to comment.