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

Unified Diff: ash/keyboard_overlay/keyboard_overlay_view.cc

Issue 10825026: Make accelerators not to work when the keyboard overlay is shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 5 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 | « ash/keyboard_overlay/keyboard_overlay_view.h ('k') | ash/shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/keyboard_overlay/keyboard_overlay_view.cc
diff --git a/ash/keyboard_overlay/keyboard_overlay_view.cc b/ash/keyboard_overlay/keyboard_overlay_view.cc
index d9a7b6cf615a9b9b1118fe2fbe073b2bdb9e452d..1831dcbff30300a459d8fac536f51e642f60780d 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();
}
« no previous file with comments | « ash/keyboard_overlay/keyboard_overlay_view.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698