| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "grit/browser_resources.h" | 43 #include "grit/browser_resources.h" |
| 44 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
| 45 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
| 46 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
| 47 | 47 |
| 48 using content::RenderViewHost; | 48 using content::RenderViewHost; |
| 49 | 49 |
| 50 namespace chromeos { | 50 namespace chromeos { |
| 51 namespace accessibility { | 51 namespace accessibility { |
| 52 | 52 |
| 53 const char kScreenMagnifierOff[] = ""; | |
| 54 const char kScreenMagnifierFull[] = "full"; | |
| 55 const char kScreenMagnifierPartial[] = "partial"; | |
| 56 | |
| 57 // Helper class that directly loads an extension's content scripts into | 53 // Helper class that directly loads an extension's content scripts into |
| 58 // all of the frames corresponding to a given RenderViewHost. | 54 // all of the frames corresponding to a given RenderViewHost. |
| 59 class ContentScriptLoader { | 55 class ContentScriptLoader { |
| 60 public: | 56 public: |
| 61 // Initialize the ContentScriptLoader with the ID of the extension | 57 // Initialize the ContentScriptLoader with the ID of the extension |
| 62 // and the RenderViewHost where the scripts should be loaded. | 58 // and the RenderViewHost where the scripts should be loaded. |
| 63 ContentScriptLoader(const std::string& extension_id, | 59 ContentScriptLoader(const std::string& extension_id, |
| 64 int render_process_id, | 60 int render_process_id, |
| 65 int render_view_id) | 61 int render_view_id) |
| 66 : extension_id_(extension_id), | 62 : extension_id_(extension_id), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 std::queue<ExtensionResource> resources_; | 112 std::queue<ExtensionResource> resources_; |
| 117 }; | 113 }; |
| 118 | 114 |
| 119 void UpdateChromeOSAccessibilityHistograms() { | 115 void UpdateChromeOSAccessibilityHistograms() { |
| 120 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", | 116 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", |
| 121 IsSpokenFeedbackEnabled()); | 117 IsSpokenFeedbackEnabled()); |
| 122 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", | 118 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", |
| 123 IsHighContrastEnabled()); | 119 IsHighContrastEnabled()); |
| 124 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", | 120 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", |
| 125 IsVirtualKeyboardEnabled()); | 121 IsVirtualKeyboardEnabled()); |
| 126 if (MagnificationManager::Get()) | 122 if (MagnificationManager::Get()) { |
| 127 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | 123 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? |
| 128 MagnificationManager::Get()->GetMagnifierType(), | 124 MagnificationManager::Get()->GetMagnifierType() : 0; |
| 129 3); | 125 // '0' means magnifier is disabled. |
| 126 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", type, 3); |
| 127 } |
| 130 } | 128 } |
| 131 | 129 |
| 132 void Initialize() { | 130 void Initialize() { |
| 133 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | 131 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( |
| 134 base::Bind(&UpdateChromeOSAccessibilityHistograms)); | 132 base::Bind(&UpdateChromeOSAccessibilityHistograms)); |
| 135 } | 133 } |
| 136 | 134 |
| 137 void EnableSpokenFeedback(bool enabled, | 135 void EnableSpokenFeedback(bool enabled, |
| 138 content::WebUI* login_web_ui, | 136 content::WebUI* login_web_ui, |
| 139 ash::AccessibilityNotificationVisibility notify) { | 137 ash::AccessibilityNotificationVisibility notify) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 bool IsVirtualKeyboardEnabled() { | 281 bool IsVirtualKeyboardEnabled() { |
| 284 if (!g_browser_process) { | 282 if (!g_browser_process) { |
| 285 return false; | 283 return false; |
| 286 } | 284 } |
| 287 PrefService* prefs = g_browser_process->local_state(); | 285 PrefService* prefs = g_browser_process->local_state(); |
| 288 bool virtual_keyboard_enabled = prefs && | 286 bool virtual_keyboard_enabled = prefs && |
| 289 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); | 287 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); |
| 290 return virtual_keyboard_enabled; | 288 return virtual_keyboard_enabled; |
| 291 } | 289 } |
| 292 | 290 |
| 293 ash::MagnifierType MagnifierTypeFromName(const char type_name[]) { | |
| 294 if (0 == strcmp(type_name, kScreenMagnifierFull)) | |
| 295 return ash::MAGNIFIER_FULL; | |
| 296 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | |
| 297 return ash::MAGNIFIER_PARTIAL; | |
| 298 else | |
| 299 return ash::MAGNIFIER_OFF; | |
| 300 } | |
| 301 | |
| 302 const char* ScreenMagnifierNameFromType(ash::MagnifierType type) { | |
| 303 switch (type) { | |
| 304 case ash::MAGNIFIER_OFF: | |
| 305 return kScreenMagnifierOff; | |
| 306 case ash::MAGNIFIER_FULL: | |
| 307 return kScreenMagnifierFull; | |
| 308 case ash::MAGNIFIER_PARTIAL: | |
| 309 return kScreenMagnifierPartial; | |
| 310 } | |
| 311 return kScreenMagnifierOff; | |
| 312 } | |
| 313 | |
| 314 void MaybeSpeak(const std::string& utterance) { | 291 void MaybeSpeak(const std::string& utterance) { |
| 315 if (IsSpokenFeedbackEnabled()) | 292 if (IsSpokenFeedbackEnabled()) |
| 316 Speak(utterance); | 293 Speak(utterance); |
| 317 } | 294 } |
| 318 | 295 |
| 319 void ShowAccessibilityHelp(Browser* browser) { | 296 void ShowAccessibilityHelp(Browser* browser) { |
| 320 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 297 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 321 } | 298 } |
| 322 | 299 |
| 323 } // namespace accessibility | 300 } // namespace accessibility |
| 324 } // namespace chromeos | 301 } // namespace chromeos |
| OLD | NEW |