chromeos: bluetooth: add BluetoothNodeClient
[chromium-blink-merge.git] / ash / accelerators / accelerator_controller.h
blob03b3a1314d0a679f66caa46738d4b069d16dc3ee
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
3 // found in the LICENSE file.
5 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_
7 #pragma once
9 #include <map>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ash/ash_export.h"
15 #include "ui/base/accelerators/accelerator.h"
17 namespace ui {
18 class AcceleratorManager;
21 namespace ash {
23 class BrightnessControlDelegate;
24 class CapsLockDelegate;
25 class ImeControlDelegate;
26 class ScreenshotDelegate;
27 class VolumeControlDelegate;
29 // AcceleratorController provides functions for registering or unregistering
30 // global keyboard accelerators, which are handled earlier than any windows. It
31 // also implements several handlers as an accelerator target.
32 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget {
33 public:
34 AcceleratorController();
35 virtual ~AcceleratorController();
37 // Register a global keyboard accelerator for the specified target. If
38 // multiple targets are registered for an accelerator, a target registered
39 // later has higher priority.
40 void Register(const ui::Accelerator& accelerator,
41 ui::AcceleratorTarget* target);
43 // Unregister the specified keyboard accelerator for the specified target.
44 void Unregister(const ui::Accelerator& accelerator,
45 ui::AcceleratorTarget* target);
47 // Unregister all keyboard accelerators for the specified target.
48 void UnregisterAll(ui::AcceleratorTarget* target);
50 // Activate the target associated with the specified accelerator.
51 // First, AcceleratorPressed handler of the most recently registered target
52 // is called, and if that handler processes the event (i.e. returns true),
53 // this method immediately returns. If not, we do the same thing on the next
54 // target, and so on.
55 // Returns true if an accelerator was activated.
56 bool Process(const ui::Accelerator& accelerator);
58 // Overridden from ui::AcceleratorTarget:
59 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
60 virtual bool CanHandleAccelerators() const OVERRIDE;
62 void SetBrightnessControlDelegate(
63 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate);
64 void SetCapsLockDelegate(scoped_ptr<CapsLockDelegate> caps_lock_delegate);
65 void SetImeControlDelegate(
66 scoped_ptr<ImeControlDelegate> ime_control_delegate);
67 void SetScreenshotDelegate(
68 scoped_ptr<ScreenshotDelegate> screenshot_delegate);
69 void SetVolumeControlDelegate(
70 scoped_ptr<VolumeControlDelegate> volume_control_delegate);
72 private:
73 // Initialize the accelerators this class handles as a target.
74 void Init();
76 scoped_ptr<ui::AcceleratorManager> accelerator_manager_;
78 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate_;
79 scoped_ptr<CapsLockDelegate> caps_lock_delegate_;
80 scoped_ptr<ImeControlDelegate> ime_control_delegate_;
81 scoped_ptr<ScreenshotDelegate> screenshot_delegate_;
82 scoped_ptr<VolumeControlDelegate> volume_control_delegate_;
84 // A map from accelerators to the AcceleratorAction values, which are used in
85 // the implementation.
86 std::map<ui::Accelerator, int> accelerators_;
88 DISALLOW_COPY_AND_ASSIGN(AcceleratorController);
91 } // namespace ash
93 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_