Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager.h

Issue 166273014: Remove dependency on NotificationService for cros a11y settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge ToT. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "ash/accessibility_delegate.h" 10 #include "ash/accessibility_delegate.h"
11 #include "ash/session_state_observer.h" 11 #include "ash/session_state_observer.h"
12 #include "base/callback_list.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/prefs/pref_change_registrar.h" 14 #include "base/prefs/pref_change_registrar.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
16 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h" 17 #include "chrome/browser/extensions/api/braille_display_private/braille_controll er.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "extensions/browser/event_router.h" 20 #include "extensions/browser/event_router.h"
20 #include "extensions/browser/extension_system.h" 21 #include "extensions/browser/extension_system.h"
21 22
22 namespace content { 23 namespace content {
23 class RenderViewHost; 24 class RenderViewHost;
24 } 25 }
25 class Profile; 26 class Profile;
26 27
27 namespace chromeos { 28 namespace chromeos {
28 29
30 enum AccessibilityNotificationType {
31 ACCESSIBILITY_MANAGER_SHUTDOWN,
32 ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE,
33 ACCESSIBILITY_TOGGLE_LARGE_CURSOR,
34 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
35 ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK,
36 ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD
37 };
38
29 struct AccessibilityStatusEventDetails { 39 struct AccessibilityStatusEventDetails {
30 AccessibilityStatusEventDetails( 40 AccessibilityStatusEventDetails(
41 AccessibilityNotificationType notification_type,
31 bool enabled, 42 bool enabled,
32 ash::AccessibilityNotificationVisibility notify); 43 ash::AccessibilityNotificationVisibility notify);
33 44
34 AccessibilityStatusEventDetails( 45 AccessibilityStatusEventDetails(
46 AccessibilityNotificationType notification_type,
35 bool enabled, 47 bool enabled,
36 ash::MagnifierType magnifier_type, 48 ash::MagnifierType magnifier_type,
37 ash::AccessibilityNotificationVisibility notify); 49 ash::AccessibilityNotificationVisibility notify);
38 50
51 AccessibilityNotificationType notification_type;
39 bool enabled; 52 bool enabled;
40 ash::MagnifierType magnifier_type; 53 ash::MagnifierType magnifier_type;
41 ash::AccessibilityNotificationVisibility notify; 54 ash::AccessibilityNotificationVisibility notify;
42 }; 55 };
43 56
57 typedef base::Callback<void(const AccessibilityStatusEventDetails&)>
58 AccessibilityStatusCallback;
59
60 typedef base::CallbackList<void(const AccessibilityStatusEventDetails&)>
61 AccessibilityStatusCallbackList;
62
63 typedef AccessibilityStatusCallbackList::Subscription
64 AccessibilityStatusSubscription;
65
44 // AccessibilityManager changes the statuses of accessibility features 66 // AccessibilityManager changes the statuses of accessibility features
45 // watching profile notifications and pref-changes. 67 // watching profile notifications and pref-changes.
46 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. 68 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager.
47 class AccessibilityManager : public content::NotificationObserver, 69 class AccessibilityManager : public content::NotificationObserver,
48 extensions::api::braille_display_private::BrailleObserver, 70 extensions::api::braille_display_private::BrailleObserver,
49 public ash::SessionStateObserver { 71 public ash::SessionStateObserver {
50 public: 72 public:
51 // Creates an instance of AccessibilityManager, this should be called once, 73 // Creates an instance of AccessibilityManager, this should be called once,
52 // because only one instance should exist at the same time. 74 // because only one instance should exist at the same time.
53 static void Initialize(); 75 static void Initialize();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 159
138 // Enables/disables system sounds. 160 // Enables/disables system sounds.
139 void EnableSystemSounds(bool system_sounds_enabled); 161 void EnableSystemSounds(bool system_sounds_enabled);
140 162
141 // Initiates play of shutdown sound and returns it's duration. 163 // Initiates play of shutdown sound and returns it's duration.
142 base::TimeDelta PlayShutdownSound(); 164 base::TimeDelta PlayShutdownSound();
143 165
144 // Injects ChromeVox scripts into given |render_view_host|. 166 // Injects ChromeVox scripts into given |render_view_host|.
145 void InjectChromeVox(content::RenderViewHost* render_view_host); 167 void InjectChromeVox(content::RenderViewHost* render_view_host);
146 168
169 // Register a callback to be notified when the status of an accessibility
170 // option changes.
171 scoped_ptr<AccessibilityStatusSubscription> RegisterCallback(
172 const AccessibilityStatusCallback& cb);
173
174 // Notify registered callbacks of a status change in an accessibility setting.
175 void NotifyAccessibilityStatusChanged(
176 AccessibilityStatusEventDetails& details);
177
147 protected: 178 protected:
148 AccessibilityManager(); 179 AccessibilityManager();
149 virtual ~AccessibilityManager(); 180 virtual ~AccessibilityManager();
150 181
151 private: 182 private:
152 void LoadChromeVox(); 183 void LoadChromeVox();
153 void LoadChromeVoxToUserScreen(); 184 void LoadChromeVoxToUserScreen();
154 void LoadChromeVoxToLockScreen(); 185 void LoadChromeVoxToLockScreen();
155 void UnloadChromeVox(); 186 void UnloadChromeVox();
156 void UnloadChromeVoxFromLockScreen(); 187 void UnloadChromeVoxFromLockScreen();
157 void PostLoadChromeVox(Profile* profile); 188 void PostLoadChromeVox(Profile* profile);
158 void PostUnloadChromeVox(Profile* profile); 189 void PostUnloadChromeVox(Profile* profile);
159 190
160 void UpdateLargeCursorFromPref(); 191 void UpdateLargeCursorFromPref();
161 void UpdateStickyKeysFromPref(); 192 void UpdateStickyKeysFromPref();
162 void UpdateSpokenFeedbackFromPref(); 193 void UpdateSpokenFeedbackFromPref();
163 void UpdateHighContrastFromPref(); 194 void UpdateHighContrastFromPref();
164 void UpdateAutoclickFromPref(); 195 void UpdateAutoclickFromPref();
165 void UpdateAutoclickDelayFromPref(); 196 void UpdateAutoclickDelayFromPref();
166 void UpdateVirtualKeyboardFromPref(); 197 void UpdateVirtualKeyboardFromPref();
167 void LocalePrefChanged(); 198 void LocalePrefChanged();
168 199
169 void CheckBrailleState(); 200 void CheckBrailleState();
170 void ReceiveBrailleDisplayState( 201 void ReceiveBrailleDisplayState(
171 scoped_ptr<extensions::api::braille_display_private::DisplayState> state); 202 scoped_ptr<extensions::api::braille_display_private::DisplayState> state);
172 203
173
174 void SetProfile(Profile* profile); 204 void SetProfile(Profile* profile);
175 205
176 void UpdateChromeOSAccessibilityHistograms(); 206 void UpdateChromeOSAccessibilityHistograms();
177 207
178 // content::NotificationObserver implementation: 208 // content::NotificationObserver implementation:
179 virtual void Observe(int type, 209 virtual void Observe(int type,
180 const content::NotificationSource& source, 210 const content::NotificationSource& source,
181 const content::NotificationDetails& details) OVERRIDE; 211 const content::NotificationDetails& details) OVERRIDE;
182 212
183 // extensions::api::braille_display_private::BrailleObserver implementation. 213 // extensions::api::braille_display_private::BrailleObserver implementation.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool virtual_keyboard_enabled_; 245 bool virtual_keyboard_enabled_;
216 246
217 ash::AccessibilityNotificationVisibility spoken_feedback_notification_; 247 ash::AccessibilityNotificationVisibility spoken_feedback_notification_;
218 248
219 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_; 249 base::WeakPtrFactory<AccessibilityManager> weak_ptr_factory_;
220 250
221 bool should_speak_chrome_vox_announcements_on_user_screen_; 251 bool should_speak_chrome_vox_announcements_on_user_screen_;
222 252
223 bool system_sounds_enabled_; 253 bool system_sounds_enabled_;
224 254
255 AccessibilityStatusCallbackList callback_list_;
David Tseng 2014/02/21 17:42:59 I'm unclear as to the ownership of this list. It's
kevers 2014/02/21 17:52:31 External classes reset/cancel their subscriptions
David Tseng 2014/02/21 19:44:51 Ok; thanks for clarifying.
256
225 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); 257 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager);
226 }; 258 };
227 259
228 } // namespace chromeos 260 } // namespace chromeos
229 261
230 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ 262 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698