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

Side by Side Diff: ash/keyboard_overlay/keyboard_overlay_view.cc

Issue 10826211: Ignore the caps lock state for closing the keyboard overlay. (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 | « no previous file | no next file » | 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 "ash/shell.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "grit/ash_strings.h" 11 #include "grit/ash_strings.h"
12 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
14 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
15 #include "ui/web_dialogs/web_dialog_delegate.h" 15 #include "ui/web_dialogs/web_dialog_delegate.h"
16 16
17 using ui::WebDialogDelegate; 17 using ui::WebDialogDelegate;
18 18
19 namespace { 19 namespace {
20 20
21 // Keys to invoke Cancel (Escape, Ctrl+Alt+/, or Shift+Ctrl+Alt+/). 21 // Keys to invoke Cancel (Escape, Ctrl+Alt+/, or Shift+Ctrl+Alt+/).
22 const struct KeyEventData { 22 const struct KeyEventData {
23 ui::KeyboardCode key_code; 23 ui::KeyboardCode key_code;
24 int flags; 24 int flags;
25 } kCancelKeys[] = { 25 } kCancelKeys[] = {
26 { ui::VKEY_ESCAPE, 0}, 26 { ui::VKEY_ESCAPE, ui::EF_NONE},
27 { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN }, 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 }, 28 { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN },
29 }; 29 };
30 30
31 } 31 }
32 32
33 KeyboardOverlayView::KeyboardOverlayView( 33 KeyboardOverlayView::KeyboardOverlayView(
34 content::BrowserContext* context, 34 content::BrowserContext* context,
35 WebDialogDelegate* delegate, 35 WebDialogDelegate* delegate,
36 WebContentsHandler* handler) 36 WebContentsHandler* handler)
37 : views::WebDialogView(context, delegate, handler) { 37 : views::WebDialogView(context, delegate, handler) {
38 } 38 }
39 39
40 KeyboardOverlayView::~KeyboardOverlayView() { 40 KeyboardOverlayView::~KeyboardOverlayView() {
41 } 41 }
42 42
43 void KeyboardOverlayView::Cancel() { 43 void KeyboardOverlayView::Cancel() {
44 ash::Shell::GetInstance()->overlay_filter()->Deactivate(); 44 ash::Shell::GetInstance()->overlay_filter()->Deactivate();
45 views::Widget* widget = GetWidget(); 45 views::Widget* widget = GetWidget();
46 if (widget) 46 if (widget)
47 widget->Close(); 47 widget->Close();
48 } 48 }
49 49
50 bool KeyboardOverlayView::IsCancelingKeyEvent(aura::KeyEvent* event) { 50 bool KeyboardOverlayView::IsCancelingKeyEvent(aura::KeyEvent* event) {
51 if (event->type() != ui::ET_KEY_PRESSED) 51 if (event->type() != ui::ET_KEY_PRESSED)
52 return false; 52 return false;
53 // Ignore the caps lock state.
54 const int flags = (event->flags() & ~ui::EF_CAPS_LOCK_DOWN);
53 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) { 55 for (size_t i = 0; i < arraysize(kCancelKeys); ++i) {
54 if ((kCancelKeys[i].key_code == event->key_code()) && 56 if ((kCancelKeys[i].key_code == event->key_code()) &&
55 (kCancelKeys[i].flags == event->flags())) 57 (kCancelKeys[i].flags == flags))
56 return true; 58 return true;
57 } 59 }
58 return false; 60 return false;
59 } 61 }
60 62
61 aura::Window* KeyboardOverlayView::GetWindow() { 63 aura::Window* KeyboardOverlayView::GetWindow() {
62 return GetWidget()->GetNativeWindow(); 64 return GetWidget()->GetNativeWindow();
63 } 65 }
64 66
65 void KeyboardOverlayView::ShowDialog( 67 void KeyboardOverlayView::ShowDialog(
66 content::BrowserContext* context, 68 content::BrowserContext* context,
67 WebContentsHandler* handler, 69 WebContentsHandler* handler,
68 const GURL& url) { 70 const GURL& url) {
69 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate( 71 KeyboardOverlayDelegate* delegate = new KeyboardOverlayDelegate(
70 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url); 72 l10n_util::GetStringUTF16(IDS_ASH_KEYBOARD_OVERLAY_TITLE), url);
71 KeyboardOverlayView* view = 73 KeyboardOverlayView* view =
72 new KeyboardOverlayView(context, delegate, handler); 74 new KeyboardOverlayView(context, delegate, handler);
73 delegate->Show(view); 75 delegate->Show(view);
74 76
75 ash::Shell::GetInstance()->overlay_filter()->Activate(view); 77 ash::Shell::GetInstance()->overlay_filter()->Activate(view);
76 } 78 }
77 79
78 void KeyboardOverlayView::WindowClosing() { 80 void KeyboardOverlayView::WindowClosing() {
79 Cancel(); 81 Cancel();
80 } 82 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698