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 |
53 // Helper class that directly loads an extension's content scripts into | 57 // Helper class that directly loads an extension's content scripts into |
54 // all of the frames corresponding to a given RenderViewHost. | 58 // all of the frames corresponding to a given RenderViewHost. |
55 class ContentScriptLoader { | 59 class ContentScriptLoader { |
56 public: | 60 public: |
57 // Initialize the ContentScriptLoader with the ID of the extension | 61 // Initialize the ContentScriptLoader with the ID of the extension |
58 // and the RenderViewHost where the scripts should be loaded. | 62 // and the RenderViewHost where the scripts should be loaded. |
59 ContentScriptLoader(const std::string& extension_id, | 63 ContentScriptLoader(const std::string& extension_id, |
60 int render_process_id, | 64 int render_process_id, |
61 int render_view_id) | 65 int render_view_id) |
62 : extension_id_(extension_id), | 66 : extension_id_(extension_id), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 std::queue<ExtensionResource> resources_; | 116 std::queue<ExtensionResource> resources_; |
113 }; | 117 }; |
114 | 118 |
115 void UpdateChromeOSAccessibilityHistograms() { | 119 void UpdateChromeOSAccessibilityHistograms() { |
116 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", | 120 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback", |
117 IsSpokenFeedbackEnabled()); | 121 IsSpokenFeedbackEnabled()); |
118 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", | 122 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast", |
119 IsHighContrastEnabled()); | 123 IsHighContrastEnabled()); |
120 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", | 124 UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard", |
121 IsVirtualKeyboardEnabled()); | 125 IsVirtualKeyboardEnabled()); |
122 if (MagnificationManager::Get()) { | 126 if (MagnificationManager::Get()) |
123 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? | |
124 MagnificationManager::Get()->GetMagnifierType() : 0; | |
125 // '0' means magnifier is disabled. | |
126 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | 127 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", |
127 type, | 128 MagnificationManager::Get()->GetMagnifierType(), |
128 ash::kMaxMagnifierType + 1); | 129 3); |
129 } | |
130 } | 130 } |
131 | 131 |
132 void Initialize() { | 132 void Initialize() { |
133 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( | 133 content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback( |
134 base::Bind(&UpdateChromeOSAccessibilityHistograms)); | 134 base::Bind(&UpdateChromeOSAccessibilityHistograms)); |
135 } | 135 } |
136 | 136 |
137 void EnableSpokenFeedback(bool enabled, | 137 void EnableSpokenFeedback(bool enabled, |
138 content::WebUI* login_web_ui, | 138 content::WebUI* login_web_ui, |
139 ash::AccessibilityNotificationVisibility notify) { | 139 ash::AccessibilityNotificationVisibility notify) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool IsVirtualKeyboardEnabled() { | 283 bool IsVirtualKeyboardEnabled() { |
284 if (!g_browser_process) { | 284 if (!g_browser_process) { |
285 return false; | 285 return false; |
286 } | 286 } |
287 PrefService* prefs = g_browser_process->local_state(); | 287 PrefService* prefs = g_browser_process->local_state(); |
288 bool virtual_keyboard_enabled = prefs && | 288 bool virtual_keyboard_enabled = prefs && |
289 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); | 289 prefs->GetBoolean(prefs::kVirtualKeyboardEnabled); |
290 return virtual_keyboard_enabled; | 290 return virtual_keyboard_enabled; |
291 } | 291 } |
292 | 292 |
| 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 |
293 void MaybeSpeak(const std::string& utterance) { | 314 void MaybeSpeak(const std::string& utterance) { |
294 if (IsSpokenFeedbackEnabled()) | 315 if (IsSpokenFeedbackEnabled()) |
295 Speak(utterance); | 316 Speak(utterance); |
296 } | 317 } |
297 | 318 |
298 void ShowAccessibilityHelp(Browser* browser) { | 319 void ShowAccessibilityHelp(Browser* browser) { |
299 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 320 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
300 } | 321 } |
301 | 322 |
302 } // namespace accessibility | 323 } // namespace accessibility |
303 } // namespace chromeos | 324 } // namespace chromeos |
OLD | NEW |