Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / accelerators / magnifier_key_scroller.h
blob41f5ce15e4987c17770b6aab04a5ccd600d8add9
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 ASH_ACCELERATORS_MAGNIFIER_KEY_SCROLLER_H_
6 #define ASH_ACCELERATORS_MAGNIFIER_KEY_SCROLLER_H_
8 #include "ash/accelerators/key_hold_detector.h"
9 #include "ash/ash_export.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/events/event_handler.h"
13 namespace ui {
14 class KeyEvent;
17 namespace ash {
19 // A KeyHoldDetector delegate to control control magnified screen.
20 class ASH_EXPORT MagnifierKeyScroller : public KeyHoldDetector::Delegate {
21 public:
22 static bool IsEnabled();
23 static void SetEnabled(bool enabled);
24 static scoped_ptr<ui::EventHandler> CreateHandler();
26 // A scoped object to enable and disable the magnifier accelerator for test.
27 class ScopedEnablerForTest {
28 public:
29 ScopedEnablerForTest() {
30 SetEnabled(true);
32 ~ScopedEnablerForTest() {
33 SetEnabled(false);
36 private:
37 DISALLOW_COPY_AND_ASSIGN(ScopedEnablerForTest);
40 private:
41 // KeyHoldDetector overrides:
42 bool ShouldProcessEvent(const ui::KeyEvent* event) const override;
43 bool IsStartEvent(const ui::KeyEvent* event) const override;
44 bool ShouldStopEventPropagation() const override;
45 void OnKeyHold(const ui::KeyEvent* event) override;
46 void OnKeyUnhold(const ui::KeyEvent* event) override;
48 MagnifierKeyScroller();
49 ~MagnifierKeyScroller() override;
51 DISALLOW_COPY_AND_ASSIGN(MagnifierKeyScroller);
54 } // namespace ash
56 #endif // ASH_ACCELERATORS_MAGNIFIER_KEY_SCROLLER_H_