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