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

Side by Side Diff: ash/accelerators/accelerator_delegate.cc

Issue 308023002: Add EF_IS_REPEAT flag to KeyEvent to handle repeated accelerators correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/accelerators/accelerator_delegate.h" 5 #include "ash/accelerators/accelerator_delegate.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/base/accelerators/accelerator.h" 10 #include "ui/base/accelerators/accelerator.h"
11 #include "ui/events/event.h" 11 #include "ui/events/event.h"
12 #include "ui/wm/core/window_util.h" 12 #include "ui/wm/core/window_util.h"
13 13
14 namespace ash { 14 namespace ash {
15 namespace {} // namespace 15 namespace {} // namespace
16 16
17 AcceleratorDelegate::AcceleratorDelegate() { 17 AcceleratorDelegate::AcceleratorDelegate() {
18 } 18 }
19 AcceleratorDelegate::~AcceleratorDelegate() { 19 AcceleratorDelegate::~AcceleratorDelegate() {
20 } 20 }
21 21
22 void AcceleratorDelegate::PreProcessAccelerator(
23 const ui::Accelerator& accelerator) {
24 // Fill out context object so AcceleratorController will know what
25 // was the previous accelerator or if the current accelerator is repeated.
26 Shell::GetInstance()->accelerator_controller()->context()->UpdateContext(
27 accelerator);
28 }
29
30 // Uses the top level window so if the target is a web contents window the 22 // Uses the top level window so if the target is a web contents window the
31 // containing parent window will be checked for the property. 23 // containing parent window will be checked for the property.
32 bool AcceleratorDelegate::CanConsumeSystemKeys(const ui::KeyEvent& event) { 24 bool AcceleratorDelegate::CanConsumeSystemKeys(const ui::KeyEvent& event) {
33 aura::Window* target = static_cast<aura::Window*>(event.target()); 25 aura::Window* target = static_cast<aura::Window*>(event.target());
34 if (!target) // Can be NULL in tests. 26 if (!target) // Can be NULL in tests.
35 return false; 27 return false;
36 aura::Window* top_level = ::wm::GetToplevelWindow(target); 28 aura::Window* top_level = ::wm::GetToplevelWindow(target);
37 return top_level && wm::GetWindowState(top_level)->can_consume_system_keys(); 29 return top_level && wm::GetWindowState(top_level)->can_consume_system_keys();
38 } 30 }
39 31
(...skipping 30 matching lines...) Expand all
70 return Shell::GetInstance()->accelerator_controller()->IsReservedAccelerator( 62 return Shell::GetInstance()->accelerator_controller()->IsReservedAccelerator(
71 accelerator); 63 accelerator);
72 } 64 }
73 65
74 bool AcceleratorDelegate::ProcessAccelerator( 66 bool AcceleratorDelegate::ProcessAccelerator(
75 const ui::Accelerator& accelerator) { 67 const ui::Accelerator& accelerator) {
76 return Shell::GetInstance()->accelerator_controller()->Process(accelerator); 68 return Shell::GetInstance()->accelerator_controller()->Process(accelerator);
77 } 69 }
78 70
79 } // namespace ash 71 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698