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
3 // found in the LICENSE file.
5 #ifndef ATHENA_INPUT_ACCELERATOR_MANAGER_H_
6 #define ATHENA_INPUT_ACCELERATOR_MANAGER_H_
8 #include "athena/input/public/accelerator_manager.h"
12 #include "base/macros.h"
13 #include "ui/base/accelerators/accelerator.h"
14 #include "ui/events/event_target_iterator.h"
21 class AcceleratorFilter
;
22 class NestedAcceleratorController
;
27 // AcceleratorManagerImpl provides a API to register accelerators
28 // for athena modules. It hides various details on accelerator handling
29 // such as how to handle accelerator in a nested loop, reserved accelerators
30 // and repeated accelerators.
31 class AcceleratorManagerImpl
: public AcceleratorManager
,
32 public ui::AcceleratorTarget
{
34 class AcceleratorWrapper
;
36 // Creates an AcceleratorManager for global accelerators.
37 // This is the one returned by AcceleratorManager::Get()
38 static AcceleratorManagerImpl
* CreateGlobalAcceleratorManager();
40 // Creates an AcceleratorManager for focus manager.
41 static scoped_ptr
<AcceleratorManager
> CreateForFocusManager(
42 views::FocusManager
* focus_manager
);
44 virtual ~AcceleratorManagerImpl();
48 void OnRootWindowCreated(aura::Window
* root_window
);
50 bool Process(const ui::Accelerator
& accelerator
);
52 // AcceleratorManager:
53 // This is made public so that implementation classes can use this.
54 virtual bool IsRegistered(const ui::Accelerator
& accelerator
,
55 int flags
) const OVERRIDE
;
60 explicit AcceleratorManagerImpl(AcceleratorWrapper
* wrapper
);
62 // AcceleratorManager:
63 virtual void RegisterAccelerators(const AcceleratorData accelerators
[],
64 size_t num_accelerators
,
65 AcceleratorHandler
* handler
) OVERRIDE
;
66 virtual void SetDebugAcceleratorsEnabled(bool enabled
) OVERRIDE
;
68 // ui::AcceleratorTarget:
69 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
70 virtual bool CanHandleAccelerators() const OVERRIDE
;
72 void RegisterAccelerator(const AcceleratorData
& accelerator
,
73 AcceleratorHandler
* handler
);
75 std::map
<ui::Accelerator
, InternalData
> accelerators_
;
76 scoped_ptr
<AcceleratorWrapper
> accelerator_wrapper_
;
77 scoped_ptr
<wm::AcceleratorFilter
> accelerator_filter_
;
78 scoped_ptr
<wm::NestedAcceleratorController
> nested_accelerator_controller_
;
79 bool debug_accelerators_enabled_
;
81 DISALLOW_COPY_AND_ASSIGN(AcceleratorManagerImpl
);
86 #endif // ATHENA_INPUT_ACCELERATOR_MANAGER_H_