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

Side by Side Diff: ui/content_accelerators/accelerator_util.cc

Issue 2013293002: NOT FOR COMMIT: Make altgr+left and altgr+right navigate back/forward on views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 "ui/content_accelerators/accelerator_util.h" 5 #include "ui/content_accelerators/accelerator_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "third_party/WebKit/public/web/WebInputEvent.h" 8 #include "third_party/WebKit/public/web/WebInputEvent.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_constants.h" 10 #include "ui/events/event_constants.h"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 namespace { 14 namespace {
15 15
16 int GetModifiersFromNativeWebKeyboardEvent( 16 int GetModifiersFromNativeWebKeyboardEvent(
17 const content::NativeWebKeyboardEvent& event) { 17 const content::NativeWebKeyboardEvent& event) {
18 int modifiers = ui::EF_NONE; 18 int modifiers = ui::EF_NONE;
19 if (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey) 19 if (event.modifiers & content::NativeWebKeyboardEvent::ShiftKey)
20 modifiers |= ui::EF_SHIFT_DOWN; 20 modifiers |= ui::EF_SHIFT_DOWN;
21 if (event.modifiers & content::NativeWebKeyboardEvent::ControlKey) 21 if (event.modifiers & content::NativeWebKeyboardEvent::ControlKey)
22 modifiers |= ui::EF_CONTROL_DOWN; 22 modifiers |= ui::EF_CONTROL_DOWN;
23 if (event.modifiers & content::NativeWebKeyboardEvent::AltKey) 23 if (event.modifiers & content::NativeWebKeyboardEvent::AltKey)
24 modifiers |= ui::EF_ALT_DOWN; 24 modifiers |= ui::EF_ALT_DOWN;
25 if (event.modifiers & content::NativeWebKeyboardEvent::AltGrKey)
26 modifiers |= ui::EF_ALTGR_DOWN;
25 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 27 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
26 if (event.modifiers & content::NativeWebKeyboardEvent::MetaKey) 28 if (event.modifiers & content::NativeWebKeyboardEvent::MetaKey)
27 modifiers |= ui::EF_COMMAND_DOWN; 29 modifiers |= ui::EF_COMMAND_DOWN;
28 #endif 30 #endif
29 return modifiers; 31 return modifiers;
30 } 32 }
31 33
32 } // namespace 34 } // namespace
33 35
34 ui::Accelerator GetAcceleratorFromNativeWebKeyboardEvent( 36 ui::Accelerator GetAcceleratorFromNativeWebKeyboardEvent(
35 const content::NativeWebKeyboardEvent& event) { 37 const content::NativeWebKeyboardEvent& event) {
36 ui::Accelerator accelerator( 38 ui::Accelerator accelerator(
37 static_cast<ui::KeyboardCode>(event.windowsKeyCode), 39 static_cast<ui::KeyboardCode>(event.windowsKeyCode),
38 GetModifiersFromNativeWebKeyboardEvent(event)); 40 GetModifiersFromNativeWebKeyboardEvent(event));
39 if (event.type == blink::WebInputEvent::KeyUp) 41 if (event.type == blink::WebInputEvent::KeyUp)
40 accelerator.set_type(ui::ET_KEY_RELEASED); 42 accelerator.set_type(ui::ET_KEY_RELEASED);
41 #if defined(USE_AURA) 43 #if defined(USE_AURA)
42 if (event.os_event && static_cast<ui::KeyEvent*>(event.os_event)->is_repeat()) 44 if (event.os_event && static_cast<ui::KeyEvent*>(event.os_event)->is_repeat())
43 accelerator.set_is_repeat(true); 45 accelerator.set_is_repeat(true);
44 #endif 46 #endif
45 return accelerator; 47 return accelerator;
46 } 48 }
47 49
48 } // namespace ui 50 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698