Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | |
| 7 | |
| 8 #include "ash/shell_delegate.h" | |
| 9 #include "base/prefs/pref_change_registrar.h" | |
| 10 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | |
| 11 #include "content/public/browser/notification_observer.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 13 | |
| 14 class Profile; | |
| 15 | |
| 16 namespace content { | |
| 17 class WebUI; | |
| 18 } | |
| 19 | |
| 20 namespace chromeos { | |
| 21 | |
| 22 struct AccessibilityStatusEventDetails { | |
| 23 AccessibilityStatusEventDetails( | |
| 24 bool enabled, ash::AccessibilityNotificationVisibility notify) | |
|
Zachary Kuznia
2013/04/24 04:21:03
line break after comma.
yoshiki
2013/04/24 06:00:52
Done.
| |
| 25 : enabled(enabled), | |
| 26 magnifier_type(ash::kDefaultMagnifierType), | |
| 27 notify(notify) {} | |
|
Zachary Kuznia
2013/04/24 04:21:03
Don't inline constructors in header files.
yoshiki
2013/04/24 06:00:52
Done.
| |
| 28 | |
| 29 AccessibilityStatusEventDetails( | |
| 30 bool enabled, | |
| 31 ash::MagnifierType magnifier_type, | |
| 32 ash::AccessibilityNotificationVisibility notify) | |
| 33 : enabled(enabled), | |
| 34 magnifier_type(magnifier_type), | |
| 35 notify(notify) {} | |
| 36 | |
| 37 bool enabled; | |
| 38 ash::MagnifierType magnifier_type; | |
| 39 ash::AccessibilityNotificationVisibility notify; | |
| 40 }; | |
| 41 | |
| 42 // AccessibilityManager changes the statuses of accessibility features | |
| 43 // watching profile notifications and pref-changes. | |
| 44 // TODO(yoshiki): merge MagnificationManager with AccessibilityManager. | |
| 45 class AccessibilityManager : public content::NotificationObserver { | |
| 46 public: | |
| 47 // Creates an instance of AccessibilityManager. This should be called once, | |
| 48 // Returns the existing instance. If there is no instance, creates one. | |
| 49 // because only one instance should exist at the same time. | |
| 50 static void Initialize(); | |
|
Zachary Kuznia
2013/04/24 04:21:03
What pattern are these statics based on? Why not
yoshiki
2013/04/24 06:00:52
Before, derat@ said that Singleton causes more tro
| |
| 51 // Deletes the existing instance of AccessibilityManager. | |
| 52 static void Shutdown(); | |
| 53 // Returns the existing instance. If there is no instance, returns NULL. | |
| 54 static AccessibilityManager* Get(); | |
| 55 | |
| 56 // Enables or disables spoken feedback. Enabling spoken feedback installs the | |
| 57 // ChromeVox component extension. If this is being called in a login/oobe | |
| 58 // login screen, pass the WebUI object in login_web_ui so that ChromeVox | |
| 59 // can be injected directly into that screen, otherwise it should be NULL. | |
| 60 void EnableSpokenFeedback(bool enabled, | |
| 61 content::WebUI* login_web_ui, | |
| 62 ash::AccessibilityNotificationVisibility notify); | |
| 63 | |
| 64 // Returns true if spoken feedback is enabled, or false if not. | |
| 65 bool IsSpokenFeedbackEnabled(); | |
| 66 | |
| 67 // Toggles whether Chrome OS spoken feedback is on or off. See docs for | |
| 68 // EnableSpokenFeedback, above. | |
| 69 void ToggleSpokenFeedback(content::WebUI* login_web_ui, | |
| 70 ash::AccessibilityNotificationVisibility notify); | |
| 71 | |
| 72 // Speaks the specified string. | |
| 73 void Speak(const std::string& text); | |
| 74 | |
| 75 // Speaks the given text if the accessibility pref is already set. | |
| 76 void MaybeSpeak(const std::string& utterance); | |
| 77 | |
| 78 // Enables or disables the high contrast mode for Chrome. | |
| 79 void EnableHighContrast(bool enabled); | |
| 80 | |
| 81 // Returns true if High Contrast is enabled, or false if not. | |
| 82 bool IsHighContrastEnabled(); | |
| 83 | |
| 84 // For test | |
| 85 void SetProfileForTest(Profile* profile); | |
| 86 | |
| 87 protected: | |
| 88 AccessibilityManager(); | |
| 89 virtual ~AccessibilityManager(); | |
| 90 | |
| 91 private: | |
| 92 void UpdateSpokenFeedbackStatus(); | |
| 93 void UpdateHighContrastStatus(); | |
| 94 | |
| 95 void SetProfile(Profile* profile); | |
| 96 | |
| 97 void UpdateChromeOSAccessibilityHistograms(); | |
| 98 | |
| 99 // content::NotificationObserver implimentation: | |
| 100 virtual void Observe(int type, | |
| 101 const content::NotificationSource& source, | |
| 102 const content::NotificationDetails& details) OVERRIDE; | |
| 103 | |
| 104 Profile* profile_; | |
| 105 content::NotificationRegistrar registrar_; | |
|
Zachary Kuznia
2013/04/24 04:21:03
you have two registrars, so you should give this a
yoshiki
2013/04/24 06:00:52
Done.
| |
| 106 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
| 107 | |
| 108 bool spoken_feedback_enabled_; | |
| 109 bool high_contrast_enabled_; | |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(AccessibilityManager); | |
| 112 }; | |
| 113 | |
| 114 } // namespace chromeos | |
| 115 | |
| 116 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_ACCESSIBILITY_MANAGER_H_ | |
| OLD | NEW |