| 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" | |
| 17 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 16 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| 18 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 18 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 20 #include "chrome/browser/extensions/component_loader.h" | 19 #include "chrome/browser/extensions/component_loader.h" |
| 21 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
| 23 #include "chrome/browser/extensions/file_reader.h" | 22 #include "chrome/browser/extensions/file_reader.h" |
| 24 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" | 26 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
| 28 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
| 29 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
| 30 #include "chrome/common/extensions/extension_messages.h" | 29 #include "chrome/common/extensions/extension_messages.h" |
| 31 #include "chrome/common/extensions/extension_resource.h" | 30 #include "chrome/common/extensions/extension_resource.h" |
| 32 #include "chrome/common/extensions/user_script.h" | 31 #include "chrome/common/extensions/user_script.h" |
| 33 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 34 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 35 #include "content/public/browser/browser_accessibility_state.h" | |
| 36 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 37 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 38 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 39 #include "content/public/browser/web_ui.h" | 37 #include "content/public/browser/web_ui.h" |
| 40 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
| 41 #include "grit/browser_resources.h" | 39 #include "grit/browser_resources.h" |
| 42 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
| 45 | 43 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 105 } |
| 108 Run(); | 106 Run(); |
| 109 } | 107 } |
| 110 | 108 |
| 111 std::string extension_id_; | 109 std::string extension_id_; |
| 112 int render_process_id_; | 110 int render_process_id_; |
| 113 int render_view_id_; | 111 int render_view_id_; |
| 114 std::queue<ExtensionResource> resources_; | 112 std::queue<ExtensionResource> resources_; |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 void UpdateChromeOSAccessibilityHistograms() { | |
| 118 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", | |
| 119 IsSpokenFeedbackEnabled()); | |
| 120 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", | |
| 121 IsHighContrastEnabled()); | |
| 122 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", | |
| 123 IsVirtualKeyboardEnabled()); | |
| 124 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | |
| 125 GetMagnifierType(), | |
| 126 3); | |
| 127 } | |
| 128 | |
| 129 void Initialize() { | |
| 130 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | |
| 131 base::Bind(&UpdateChromeOSAccessibilityHistograms)); | |
| 132 } | |
| 133 | |
| 134 void EnableSpokenFeedback(bool enabled, content::WebUI* login_web_ui) { | 115 void EnableSpokenFeedback(bool enabled, content::WebUI* login_web_ui) { |
| 135 bool spoken_feedback_enabled = g_browser_process && | 116 bool spoken_feedback_enabled = g_browser_process && |
| 136 g_browser_process->local_state()->GetBoolean( | 117 g_browser_process->local_state()->GetBoolean( |
| 137 prefs::kSpokenFeedbackEnabled); | 118 prefs::kSpokenFeedbackEnabled); |
| 138 if (spoken_feedback_enabled == enabled) { | 119 if (spoken_feedback_enabled == enabled) { |
| 139 DLOG(INFO) << "Spoken feedback is already " << | 120 DLOG(INFO) << "Spoken feedback is already " << |
| 140 (enabled ? "enabled" : "disabled") << ". Going to do nothing."; | 121 (enabled ? "enabled" : "disabled") << ". Going to do nothing."; |
| 141 return; | 122 return; |
| 142 } | 123 } |
| 143 | 124 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 bool IsHighContrastEnabled() { | 241 bool IsHighContrastEnabled() { |
| 261 if (!g_browser_process) { | 242 if (!g_browser_process) { |
| 262 return false; | 243 return false; |
| 263 } | 244 } |
| 264 PrefService* prefs = g_browser_process->local_state(); | 245 PrefService* prefs = g_browser_process->local_state(); |
| 265 bool high_contrast_enabled = prefs && | 246 bool high_contrast_enabled = prefs && |
| 266 prefs->GetBoolean(prefs::kHighContrastEnabled); | 247 prefs->GetBoolean(prefs::kHighContrastEnabled); |
| 267 return high_contrast_enabled; | 248 return high_contrast_enabled; |
| 268 } | 249 } |
| 269 | 250 |
| 270 bool IsVirtualKeyboardEnabled() { | |
| 271 if (!g_browser_process) { | |
| 272 return false; | |
| 273 } | |
| 274 PrefService* prefs = g_browser_process->local_state(); | |
| 275 bool virtual_keyboard_enabled = prefs && | |
| 276 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); | |
| 277 return virtual_keyboard_enabled; | |
| 278 } | |
| 279 | |
| 280 ash::MagnifierType GetMagnifierType() { | 251 ash::MagnifierType GetMagnifierType() { |
| 281 if (!MagnificationManager::GetInstance()) | 252 if (!MagnificationManager::GetInstance()) |
| 282 return ash::MAGNIFIER_OFF; | 253 return ash::MAGNIFIER_OFF; |
| 283 return MagnificationManager::GetInstance()->GetMagnifierType(); | 254 return MagnificationManager::GetInstance()->GetMagnifierType(); |
| 284 } | 255 } |
| 285 | 256 |
| 286 ash::MagnifierType MagnifierTypeFromName(const char type_name[]) { | 257 ash::MagnifierType MagnifierTypeFromName(const char type_name[]) { |
| 287 if (0 == strcmp(type_name, kScreenMagnifierFull)) | 258 if (0 == strcmp(type_name, kScreenMagnifierFull)) |
| 288 return ash::MAGNIFIER_FULL; | 259 return ash::MAGNIFIER_FULL; |
| 289 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | 260 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 308 if (IsSpokenFeedbackEnabled()) | 279 if (IsSpokenFeedbackEnabled()) |
| 309 Speak(utterance); | 280 Speak(utterance); |
| 310 } | 281 } |
| 311 | 282 |
| 312 void ShowAccessibilityHelp(Browser* browser) { | 283 void ShowAccessibilityHelp(Browser* browser) { |
| 313 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 284 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 314 } | 285 } |
| 315 | 286 |
| 316 } // namespace accessibility | 287 } // namespace accessibility |
| 317 } // namespace chromeos | 288 } // namespace chromeos |
| OLD | NEW |