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

Side by Side 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: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/keyboard_overlay/keyboard_overlay_view.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/keyboard_overlay/keyboard_overlay_view.h" 5 #include "ash/keyboard_overlay/keyboard_overlay_view.h"
6 6
7 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h" 7 #include "ash/keyboard_overlay/keyboard_overlay_delegate.h"
8 #include "ash/shell.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
10 #include "grit/ash_strings.h" 11 #include "grit/ash_strings.h"
11 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
14 #include "ui/web_dialogs/web_dialog_delegate.h" 15 #include "ui/web_dialogs/web_dialog_delegate.h"
15 16
16 using ui::WebDialogDelegate; 17 using ui::WebDialogDelegate;
17 18
18 namespace { 19 namespace {
19 // Store the pointer to the view currently shown. 20
20 KeyboardOverlayView* g_instance = NULL; 21 // Keys to invoke Cancel (Escape, Ctrl+Alt+/, or Shift+Ctrl+Alt+/).
22 const struct KeyEventData {
23 ui::KeyboardCode key_code;
24 int flags;
25 } kCancelKeys[] = {
26 { ui::VKEY_ESCAPE, 0},
27 { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN },
28 { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN },
29 };
30
21 } 31 }
22 32
23 KeyboardOverlayView::KeyboardOverlayView( 33 KeyboardOverlayView::KeyboardOverlayView(
24 content::BrowserContext* context, 34 content::BrowserContext* context,
25 WebDialogDelegate* delegate, 35 WebDialogDelegate* delegate,
26 WebContentsHandler* handler) 36 WebContentsHandler* handler)
27 : views::WebDialogView(context, delegate, handler) { 37 : views::WebDialogView(context, delegate, handler) {
28 } 38 }
29 39
30 KeyboardOverlayView::~KeyboardOverlayView() { 40 KeyboardOverlayView::~KeyboardOverlayView() {
31 } 41 }
32 42
43 void KeyboardOverlayView::Cancel() {
44 ash::Shell::GetInstance()->overlay_filter()->Deactivate();
45 views::Widget* widget = GetWidget();
46 if (widget)
47 widget->Close();
48 }
49
50 bool KeyboardOverlayView::IsCancelKeyEvent(aura::KeyEvent* event) {
Daniel Erat 2012/07/26 00:44:54 nit: KeyEventShouldCancel()? KeyEventCancels()?
mazda 2012/07/26 01:17:06 Changed it to IsCancelingKeyEvent.
51 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) {
52 if ((event->type() == ui::ET_KEY_PRESSED) &&
Daniel Erat 2012/07/26 00:44:54 just check this before the loop?
mazda 2012/07/26 01:17:06 Done.
53 (kCancelKeys[i].key_code == event->key_code()) &&
54 (kCancelKeys[i].flags == event->flags()))
55 return true;
56 }
57 return false;
58 }
59
60 aura::Window* KeyboardOverlayView::GetWindow() {
61 return GetWidget()->GetNativeWindow();
62 }
63
33 void KeyboardOverlayView::ShowDialog( 64 void KeyboardOverlayView::ShowDialog(
34 content::BrowserContext* context, 65 content::BrowserContext* context,
35 WebContentsHandler* handler, 66 WebContentsHandler* handler,
36 const GURL& url) { 67 const GURL& url) {
37 // Ignore the call if another view is already shown.
38 if (g_instance)
39 return;
40
41 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( 68 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate(
42 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); 69 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url);
43 KeyboardOverlayView* view = 70 KeyboardOverlayView* view =
44 new KeyboardOverlayView(context, delegate, handler); 71 new KeyboardOverlayView(context, delegate, handler);
45 delegate->Show(view); 72 delegate->Show(view);
46 73
47 g_instance = view; 74 ash::Shell::GetInstance()->overlay_filter()->Activate(view);
48 } 75 }
49 76
50 void KeyboardOverlayView::WindowClosing() { 77 void KeyboardOverlayView::WindowClosing() {
51 g_instance = NULL; 78 Cancel();
52 } 79 }
OLDNEW
« 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