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 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "ash/high_contrast/high_contrast_controller.h" | 9 #include "ash/high_contrast/high_contrast_controller.h" |
10 #include "ash/magnifier/magnification_controller.h" | 10 #include "ash/magnifier/magnification_controller.h" |
11 #include "ash/magnifier/partial_magnification_controller.h" | 11 #include "ash/magnifier/partial_magnification_controller.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/metrics/histogram.h" | |
16 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 17 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
17 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 19 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
19 #include "chrome/browser/extensions/component_loader.h" | 20 #include "chrome/browser/extensions/component_loader.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/file_reader.h" | 22 #include "chrome/browser/extensions/file_reader.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" | 26 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
26 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
28 #include "chrome/common/extensions/extension_resource.h" | 29 #include "chrome/common/extensions/extension_resource.h" |
29 #include "chrome/common/extensions/user_script.h" | 30 #include "chrome/common/extensions/user_script.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "content/public/browser/browser_accessibility_state.h" | |
31 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
34 #include "content/public/browser/web_ui.h" | 36 #include "content/public/browser/web_ui.h" |
35 #include "grit/browser_resources.h" | 37 #include "grit/browser_resources.h" |
36 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
39 | 41 |
40 using content::RenderViewHost; | 42 using content::RenderViewHost; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 } | 103 } |
102 Run(); | 104 Run(); |
103 } | 105 } |
104 | 106 |
105 std::string extension_id_; | 107 std::string extension_id_; |
106 int render_process_id_; | 108 int render_process_id_; |
107 int render_view_id_; | 109 int render_view_id_; |
108 std::queue<ExtensionResource> resources_; | 110 std::queue<ExtensionResource> resources_; |
109 }; | 111 }; |
110 | 112 |
113 void UpdateChromeOSAccessibilityHistograms() { | |
114 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", | |
Nikita (slow)
2012/11/29 18:29:23
Should you also report histograms if users enable/
| |
115 IsSpokenFeedbackEnabled()); | |
116 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", | |
117 IsHighContrastEnabled()); | |
118 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", | |
119 IsVirtualKeyboardEnabled()); | |
120 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | |
121 GetScreenMagnifierType(), | |
122 3); | |
123 } | |
124 | |
125 void Initialize() { | |
126 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | |
127 base::Bind(&UpdateChromeOSAccessibilityHistograms)); | |
128 } | |
129 | |
111 void EnableSpokenFeedback(bool enabled, content::WebUI* login_web_ui) { | 130 void EnableSpokenFeedback(bool enabled, content::WebUI* login_web_ui) { |
112 bool spoken_feedback_enabled = g_browser_process && | 131 bool spoken_feedback_enabled = g_browser_process && |
113 g_browser_process->local_state()->GetBoolean( | 132 g_browser_process->local_state()->GetBoolean( |
114 prefs::kSpokenFeedbackEnabled); | 133 prefs::kSpokenFeedbackEnabled); |
115 if (spoken_feedback_enabled == enabled) { | 134 if (spoken_feedback_enabled == enabled) { |
116 DLOG(INFO) << "Spoken feedback is already " << | 135 DLOG(INFO) << "Spoken feedback is already " << |
117 (enabled ? "enabled" : "disabled") << ". Going to do nothing."; | 136 (enabled ? "enabled" : "disabled") << ". Going to do nothing."; |
118 return; | 137 return; |
119 } | 138 } |
120 | 139 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 bool IsHighContrastEnabled() { | 257 bool IsHighContrastEnabled() { |
239 if (!g_browser_process) { | 258 if (!g_browser_process) { |
240 return false; | 259 return false; |
241 } | 260 } |
242 PrefService* prefs = g_browser_process->local_state(); | 261 PrefService* prefs = g_browser_process->local_state(); |
243 bool high_contrast_enabled = prefs && | 262 bool high_contrast_enabled = prefs && |
244 prefs->GetBoolean(prefs::kHighContrastEnabled); | 263 prefs->GetBoolean(prefs::kHighContrastEnabled); |
245 return high_contrast_enabled; | 264 return high_contrast_enabled; |
246 } | 265 } |
247 | 266 |
267 bool IsVirtualKeyboardEnabled() { | |
268 if (!g_browser_process) { | |
269 return false; | |
270 } | |
271 PrefService* prefs = g_browser_process->local_state(); | |
272 bool virtual_keyboard_enabled = prefs && | |
273 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); | |
274 return virtual_keyboard_enabled; | |
275 } | |
276 | |
248 ScreenMagnifierType GetScreenMagnifierType() { | 277 ScreenMagnifierType GetScreenMagnifierType() { |
249 if (!MagnificationManager::GetInstance()) | 278 if (!MagnificationManager::GetInstance()) |
250 return MAGNIFIER_OFF; | 279 return MAGNIFIER_OFF; |
251 return MagnificationManager::GetInstance()->GetScreenMagnifierType(); | 280 return MagnificationManager::GetInstance()->GetScreenMagnifierType(); |
252 } | 281 } |
253 | 282 |
254 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { | 283 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { |
255 if (0 == strcmp(type_name, kScreenMagnifierFull)) | 284 if (0 == strcmp(type_name, kScreenMagnifierFull)) |
256 return MAGNIFIER_FULL; | 285 return MAGNIFIER_FULL; |
257 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | 286 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) |
(...skipping 14 matching lines...) Expand all Loading... | |
272 return kScreenMagnifierOff; | 301 return kScreenMagnifierOff; |
273 } | 302 } |
274 | 303 |
275 void MaybeSpeak(const std::string& utterance) { | 304 void MaybeSpeak(const std::string& utterance) { |
276 if (IsSpokenFeedbackEnabled()) | 305 if (IsSpokenFeedbackEnabled()) |
277 Speak(utterance); | 306 Speak(utterance); |
278 } | 307 } |
279 | 308 |
280 } // namespace accessibility | 309 } // namespace accessibility |
281 } // namespace chromeos | 310 } // namespace chromeos |
OLD | NEW |