Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
|
sky
2011/02/07 17:07:11
Can this include be removed now?
dmazzoni
2011/02/08 04:00:09
Yes, both <map> and <vector> can be removed, thank
| |
| 11 | 11 |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/singleton.h" | 13 #include "base/singleton.h" |
| 14 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" | 14 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" |
| 15 #include "chrome/browser/ui/views/accessible_view_helper.h" | |
| 16 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
| 17 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
| 18 | 17 |
| 19 class Profile; | 18 class Profile; |
| 20 namespace views { | 19 namespace views { |
| 21 class Accelerator; | 20 class Accelerator; |
| 22 class View; | 21 class View; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace chromeos { | 24 namespace chromeos { |
| 26 | 25 |
| 27 // Class that provides convenience methods to enable accessibility for a | 26 // Class that provides convenience methods to enable accessibility for a |
| 28 // specified View. | 27 // specified View. |
| 29 class WizardAccessibilityHelper { | 28 class WizardAccessibilityHelper { |
| 30 public: | 29 public: |
| 31 // Get Singleton instance of WizardAccessibilityHelper. | 30 // Get Singleton instance of WizardAccessibilityHelper. |
| 32 static WizardAccessibilityHelper* GetInstance(); | 31 static WizardAccessibilityHelper* GetInstance(); |
| 33 | 32 |
| 34 // Get accelerator for enabling accessibility. | 33 // Get accelerator for enabling accessibility. |
| 35 static views::Accelerator GetAccelerator(); | 34 static views::Accelerator GetAccelerator(); |
| 36 | 35 |
| 37 // Enables Accessibility by setting the accessibility pref and registers | |
| 38 // all views in the view buffer to raise accessibility notifications, | |
| 39 // including the specified |view_tree|. | |
| 40 void EnableAccessibilityForView(views::View* view_tree); | |
| 41 | |
| 42 // Enables accessibility for the specified |view_tree| if the | |
| 43 // accessibility pref is already set. Otherwise the |view_tree| is | |
| 44 // added to a view buffer so that accessibility can be enabled for it | |
| 45 // later when requested. | |
| 46 void MaybeEnableAccessibility(views::View* view_tree); | |
| 47 | |
| 48 // Speak the given text if the accessibility pref is already set. |queue| | 36 // Speak the given text if the accessibility pref is already set. |queue| |
| 49 // specifies whether this utterance will be queued or spoken immediately. | 37 // specifies whether this utterance will be queued or spoken immediately. |
| 50 // |interruptible| specified whether this utterance can be flushed by a | 38 // |interruptible| specified whether this utterance can be flushed by a |
| 51 // subsequent utterance. | 39 // subsequent utterance. |
| 52 // TODO (chaitanyag): Change API to use string16 instead of char*. | 40 // TODO (chaitanyag): Change API to use string16 instead of char*. |
| 53 void MaybeSpeak(const char* str, bool queue, bool interruptible); | 41 void MaybeSpeak(const char* str, bool queue, bool interruptible); |
| 54 | 42 |
| 55 // Unregisters all accessibility notifications | 43 // Unregisters all accessibility notifications |
| 56 void UnregisterNotifications(); | 44 void UnregisterNotifications(); |
| 57 | 45 |
| 58 // Toggles accessibility support. If |view_tree| is null, only the | 46 // Toggles accessibility support. |
| 59 // access preference setting is toggled. |view_tree| has no effect while | 47 void ToggleAccessibility(); |
| 60 // disabling accessibility. | |
| 61 void ToggleAccessibility(views::View* view_tree); | |
| 62 | 48 |
| 63 private: | 49 private: |
| 64 friend struct DefaultSingletonTraits<WizardAccessibilityHelper>; | 50 friend struct DefaultSingletonTraits<WizardAccessibilityHelper>; |
| 65 | 51 |
| 66 WizardAccessibilityHelper(); | 52 WizardAccessibilityHelper(); |
| 67 | 53 |
| 68 virtual ~WizardAccessibilityHelper() {} | 54 virtual ~WizardAccessibilityHelper() {} |
| 69 | 55 |
| 70 void RegisterNotifications(); | 56 void RegisterNotifications(); |
| 71 | 57 |
| 72 bool IsAccessibilityEnabled(); | 58 bool IsAccessibilityEnabled(); |
| 73 | 59 |
| 74 void SetAccessibilityEnabled(bool); | 60 void SetAccessibilityEnabled(bool); |
| 75 | 61 |
| 76 static scoped_ptr<views::Accelerator> accelerator_; | 62 static scoped_ptr<views::Accelerator> accelerator_; |
| 77 | 63 |
| 78 void AddViewToBuffer(views::View* view_tree); | |
| 79 | |
| 80 std::map<views::View*, bool> views_buffer_; | |
| 81 | |
| 82 std::vector<AccessibleViewHelper*> accessible_view_helpers_; | |
| 83 | |
| 84 scoped_ptr<WizardAccessibilityHandler> accessibility_handler_; | 64 scoped_ptr<WizardAccessibilityHandler> accessibility_handler_; |
| 85 | 65 |
| 86 Profile* profile_; | 66 Profile* profile_; |
| 87 | 67 |
| 88 // Used for tracking registrations to accessibility notifications. | 68 // Used for tracking registrations to accessibility notifications. |
| 89 NotificationRegistrar registrar_; | 69 NotificationRegistrar registrar_; |
| 90 | 70 |
| 91 bool registered_notifications_; | 71 bool registered_notifications_; |
| 92 | 72 |
| 93 DISALLOW_COPY_AND_ASSIGN(WizardAccessibilityHelper); | 73 DISALLOW_COPY_AND_ASSIGN(WizardAccessibilityHelper); |
| 94 }; | 74 }; |
| 95 | 75 |
| 96 } // namespace chromeos | 76 } // namespace chromeos |
| 97 | 77 |
| 98 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ | 78 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_WIZARD_ACCESSIBILITY_HELPER_H_ |
| OLD | NEW |