Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / athena / input / accelerator_manager_impl.h
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.
4
5 #ifndef ATHENA_INPUT_ACCELERATOR_MANAGER_H_
6 #define ATHENA_INPUT_ACCELERATOR_MANAGER_H_
7
8 #include "athena/input/public/accelerator_manager.h"
9
10 #include <map>
11
12 #include "base/macros.h"
13 #include "ui/base/accelerators/accelerator.h"
14 #include "ui/events/event_target_iterator.h"
15
16 namespace aura {
17 class Window;
18 }
19
20 namespace wm {
21 class AcceleratorFilter;
22 class NestedAcceleratorController;
23 }
24
25 namespace athena {
26
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 {
33  public:
34   class AcceleratorWrapper;
35
36   // Creates an AcceleratorManager for global accelerators.
37   // This is the one returned by AcceleratorManager::Get()
38   static AcceleratorManagerImpl* CreateGlobalAcceleratorManager();
39
40   // Creates an AcceleratorManager for focus manager.
41   static scoped_ptr<AcceleratorManager> CreateForFocusManager(
42       views::FocusManager* focus_manager);
43
44   ~AcceleratorManagerImpl() override;
45
46   void Init();
47
48   void OnRootWindowCreated(aura::Window* root_window);
49
50   bool Process(const ui::Accelerator& accelerator);
51
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;
56
57  private:
58   class InternalData;
59
60   AcceleratorManagerImpl(AcceleratorWrapper* wrapper, bool global);
61
62   // AcceleratorManager:
63   virtual void RegisterAccelerators(const AcceleratorData accelerators[],
64                                     size_t num_accelerators,
65                                     AcceleratorHandler* handler) override;
66   virtual void RegisterAccelerator(const AcceleratorData& accelerator_data,
67                                    AcceleratorHandler* handler) override;
68   virtual void UnregisterAccelerator(const AcceleratorData& accelerator_data,
69                                      AcceleratorHandler* handler) override;
70   virtual void SetDebugAcceleratorsEnabled(bool enabled) override;
71
72   // ui::AcceleratorTarget:
73   virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
74   virtual bool CanHandleAccelerators() const override;
75
76   std::map<ui::Accelerator, InternalData> accelerators_;
77   scoped_ptr<AcceleratorWrapper> accelerator_wrapper_;
78   scoped_ptr<wm::AcceleratorFilter> accelerator_filter_;
79   scoped_ptr<wm::NestedAcceleratorController> nested_accelerator_controller_;
80   bool debug_accelerators_enabled_;
81   bool global_;
82
83   DISALLOW_COPY_AND_ASSIGN(AcceleratorManagerImpl);
84 };
85
86 }  // namespace athena
87
88 #endif  // ATHENA_INPUT_ACCELERATOR_MANAGER_H_