OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // improvement over reading defaults preference values (which has no callback | 33 // improvement over reading defaults preference values (which has no callback |
34 // mechanism). | 34 // mechanism). |
35 class CONTENT_EXPORT BrowserAccessibilityStateImpl | 35 class CONTENT_EXPORT BrowserAccessibilityStateImpl |
36 : public base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>, | 36 : public base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>, |
37 public BrowserAccessibilityState { | 37 public BrowserAccessibilityState { |
38 public: | 38 public: |
39 BrowserAccessibilityStateImpl(); | 39 BrowserAccessibilityStateImpl(); |
40 | 40 |
41 static BrowserAccessibilityStateImpl* GetInstance(); | 41 static BrowserAccessibilityStateImpl* GetInstance(); |
42 | 42 |
43 virtual void EnableAccessibility() override; | 43 void EnableAccessibility() override; |
44 virtual void DisableAccessibility() override; | 44 void DisableAccessibility() override; |
45 virtual void ResetAccessibilityMode() override; | 45 void ResetAccessibilityMode() override; |
46 virtual void OnScreenReaderDetected() override; | 46 void OnScreenReaderDetected() override; |
47 virtual bool IsAccessibleBrowser() override; | 47 bool IsAccessibleBrowser() override; |
48 virtual void AddHistogramCallback(base::Closure callback) override; | 48 void AddHistogramCallback(base::Closure callback) override; |
49 | 49 |
50 virtual void UpdateHistogramsForTesting() override; | 50 void UpdateHistogramsForTesting() override; |
51 | 51 |
52 AccessibilityMode accessibility_mode() const { return accessibility_mode_; }; | 52 AccessibilityMode accessibility_mode() const { return accessibility_mode_; }; |
53 | 53 |
54 // Adds the given accessibility mode to the current accessibility mode bitmap. | 54 // Adds the given accessibility mode to the current accessibility mode bitmap. |
55 void AddAccessibilityMode(AccessibilityMode mode); | 55 void AddAccessibilityMode(AccessibilityMode mode); |
56 | 56 |
57 // Removes the given accessibility mode from the current accessibility mode | 57 // Removes the given accessibility mode from the current accessibility mode |
58 // bitmap, managing the bits that are shared with other modes such that a | 58 // bitmap, managing the bits that are shared with other modes such that a |
59 // bit will only be turned off when all modes that depend on it have been | 59 // bit will only be turned off when all modes that depend on it have been |
60 // removed. | 60 // removed. |
61 void RemoveAccessibilityMode(AccessibilityMode mode); | 61 void RemoveAccessibilityMode(AccessibilityMode mode); |
62 | 62 |
63 private: | 63 private: |
64 friend class base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>; | 64 friend class base::RefCountedThreadSafe<BrowserAccessibilityStateImpl>; |
65 friend struct DefaultSingletonTraits<BrowserAccessibilityStateImpl>; | 65 friend struct DefaultSingletonTraits<BrowserAccessibilityStateImpl>; |
66 | 66 |
67 // Resets accessibility_mode_ to the default value. | 67 // Resets accessibility_mode_ to the default value. |
68 void ResetAccessibilityModeValue(); | 68 void ResetAccessibilityModeValue(); |
69 | 69 |
70 // Called a short while after startup to allow time for the accessibility | 70 // Called a short while after startup to allow time for the accessibility |
71 // state to be determined. Updates histograms with the current state. | 71 // state to be determined. Updates histograms with the current state. |
72 void UpdateHistograms(); | 72 void UpdateHistograms(); |
73 | 73 |
74 // Leaky singleton, destructor generally won't be called. | 74 // Leaky singleton, destructor generally won't be called. |
75 virtual ~BrowserAccessibilityStateImpl(); | 75 ~BrowserAccessibilityStateImpl() override; |
76 | 76 |
77 void UpdatePlatformSpecificHistograms(); | 77 void UpdatePlatformSpecificHistograms(); |
78 | 78 |
79 // Updates the accessibility mode of all web contents, including swapped out | 79 // Updates the accessibility mode of all web contents, including swapped out |
80 // ones. |add| specifies whether the mode should be added or removed. | 80 // ones. |add| specifies whether the mode should be added or removed. |
81 void AddOrRemoveFromAllWebContents(AccessibilityMode mode, bool add); | 81 void AddOrRemoveFromAllWebContents(AccessibilityMode mode, bool add); |
82 | 82 |
83 AccessibilityMode accessibility_mode_; | 83 AccessibilityMode accessibility_mode_; |
84 | 84 |
85 std::vector<base::Closure> histogram_callbacks_; | 85 std::vector<base::Closure> histogram_callbacks_; |
86 | 86 |
87 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl); | 87 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl); |
88 }; | 88 }; |
89 | 89 |
90 } // namespace content | 90 } // namespace content |
91 | 91 |
92 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ | 92 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_ |
OLD | NEW |