diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-26 03:25:18 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-26 03:25:18 +0000 |
commit | 9ae32df7e045a681bf2b65009997f5e93badbfe6 (patch) | |
tree | 309e4cde7eef398ee838ecf321fed64e66c5edfa /ash/keyboard_overlay/keyboard_overlay_view.cc | |
parent | 177bcf2f346f89e8e56b8e301fc3dc5ec9b060a0 (diff) | |
download | chromium_src-9ae32df7e045a681bf2b65009997f5e93badbfe6.zip chromium_src-9ae32df7e045a681bf2b65009997f5e93badbfe6.tar.gz chromium_src-9ae32df7e045a681bf2b65009997f5e93badbfe6.tar.bz2 |
Make accelerators not to work when the keyboard overlay is shown.
- Refactor PartialScreenshotEventFiler so that it can be reused, and renamed it to OverlayEventFilter
- Use OverlayEventFilter for the keyboard overlay
BUG=129834
TEST=Manually check accelerators do not work when the keyboard overlay.
Review URL: https://chromiumcodereview.appspot.com/10825026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/keyboard_overlay/keyboard_overlay_view.cc')
-rw-r--r-- | ash/keyboard_overlay/keyboard_overlay_view.cc | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/ash/keyboard_overlay/keyboard_overlay_view.cc b/ash/keyboard_overlay/keyboard_overlay_view.cc index d9a7b6c..1831dcb 100644 --- a/ash/keyboard_overlay/keyboard_overlay_view.cc +++ b/ash/keyboard_overlay/keyboard_overlay_view.cc @@ -5,6 +5,7 @@ #include "ash/keyboard_overlay/keyboard_overlay_view.h" #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" +#include "ash/shell.h" #include "base/utf_string_conversions.h" #include "content/public/browser/browser_context.h" #include "grit/ash_strings.h" @@ -16,8 +17,17 @@ using ui::WebDialogDelegate; namespace { -// Store the pointer to the view currently shown. -KeyboardOverlayView* g_instance = NULL; + +// Keys to invoke Cancel (Escape, Ctrl+Alt+/, or Shift+Ctrl+Alt+/). +const struct KeyEventData { + ui::KeyboardCode key_code; + int flags; +} kCancelKeys[] = { + { ui::VKEY_ESCAPE, 0}, + { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN }, + { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN }, +}; + } KeyboardOverlayView::KeyboardOverlayView( @@ -30,23 +40,41 @@ KeyboardOverlayView::KeyboardOverlayView( KeyboardOverlayView::~KeyboardOverlayView() { } +void KeyboardOverlayView::Cancel() { + ash::Shell::GetInstance()->overlay_filter()->Deactivate(); + views::Widget* widget = GetWidget(); + if (widget) + widget->Close(); +} + +bool KeyboardOverlayView::IsCancelingKeyEvent(aura::KeyEvent* event) { + if (event->type() != ui::ET_KEY_PRESSED) + return false; + for (size_t i = 0; i < arraysize(kCancelKeys); ++i) { + if ((kCancelKeys[i].key_code == event->key_code()) && + (kCancelKeys[i].flags == event->flags())) + return true; + } + return false; +} + +aura::Window* KeyboardOverlayView::GetWindow() { + return GetWidget()->GetNativeWindow(); +} + void KeyboardOverlayView::ShowDialog( content::BrowserContext* context, WebContentsHandler* handler, const GURL& url) { - // Ignore the call if another view is already shown. - if (g_instance) - return; - KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); KeyboardOverlayView* view = new KeyboardOverlayView(context, delegate, handler); delegate->Show(view); - g_instance = view; + ash::Shell::GetInstance()->overlay_filter()->Activate(view); } void KeyboardOverlayView::WindowClosing() { - g_instance = NULL; + Cancel(); } |