OLD | NEW |
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 #ifndef ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ | 5 #ifndef ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ |
6 #define ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ | 6 #define ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/accelerators/key_hold_detector.h" | 10 #include "ash/accelerators/key_hold_detector.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // A KeyHoldDetector delegate to toggle spoken feedback. | 21 // A KeyHoldDetector delegate to toggle spoken feedback. |
22 class ASH_EXPORT SpokenFeedbackToggler : public KeyHoldDetector::Delegate { | 22 class ASH_EXPORT SpokenFeedbackToggler : public KeyHoldDetector::Delegate { |
23 public: | 23 public: |
24 static bool IsEnabled(); | 24 static bool IsEnabled(); |
25 static void SetEnabled(bool enabled); | 25 static void SetEnabled(bool enabled); |
26 static std::unique_ptr<ui::EventHandler> CreateHandler(); | 26 static std::unique_ptr<ui::EventHandler> CreateHandler(); |
27 | 27 |
28 // A scoped object to enable and disable the magnifier accelerator for test. | 28 // A scoped object to enable and disable the magnifier accelerator for test. |
29 class ScopedEnablerForTest { | 29 class ScopedEnablerForTest { |
30 public: | 30 public: |
31 ScopedEnablerForTest() { | 31 ScopedEnablerForTest() { SetEnabled(true); } |
32 SetEnabled(true); | 32 ~ScopedEnablerForTest() { SetEnabled(false); } |
33 } | |
34 ~ScopedEnablerForTest() { | |
35 SetEnabled(false); | |
36 } | |
37 | 33 |
38 private: | 34 private: |
39 DISALLOW_COPY_AND_ASSIGN(ScopedEnablerForTest); | 35 DISALLOW_COPY_AND_ASSIGN(ScopedEnablerForTest); |
40 }; | 36 }; |
41 | 37 |
42 private: | 38 private: |
43 // KeyHoldDetector overrides: | 39 // KeyHoldDetector overrides: |
44 bool ShouldProcessEvent(const ui::KeyEvent* event) const override; | 40 bool ShouldProcessEvent(const ui::KeyEvent* event) const override; |
45 bool IsStartEvent(const ui::KeyEvent* event) const override; | 41 bool IsStartEvent(const ui::KeyEvent* event) const override; |
46 bool ShouldStopEventPropagation() const override; | 42 bool ShouldStopEventPropagation() const override; |
47 void OnKeyHold(const ui::KeyEvent* event) override; | 43 void OnKeyHold(const ui::KeyEvent* event) override; |
48 void OnKeyUnhold(const ui::KeyEvent* event) override; | 44 void OnKeyUnhold(const ui::KeyEvent* event) override; |
49 | 45 |
50 SpokenFeedbackToggler(); | 46 SpokenFeedbackToggler(); |
51 ~SpokenFeedbackToggler() override; | 47 ~SpokenFeedbackToggler() override; |
52 | 48 |
53 bool toggled_; | 49 bool toggled_; |
54 | 50 |
55 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackToggler); | 51 DISALLOW_COPY_AND_ASSIGN(SpokenFeedbackToggler); |
56 }; | 52 }; |
57 | 53 |
58 } // namespace ash | 54 } // namespace ash |
59 | 55 |
60 #endif // ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ | 56 #endif // ASH_ACCELERATORS_SPOKEN_FEEDBACK_TOGGLER_H_ |
OLD | NEW |