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()) { |
| 123 uint32 type = MagnificationManager::Get()->IsMagnifierEnabled() ? |
| 124 MagnificationManager::Get()->GetMagnifierType() : 0; |
| 125 // '0' means magnifier is disabled. |
127 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", | 126 UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", |
128 MagnificationManager::Get()->GetMagnifierType(), | 127 type, |
129 3); | 128 ash::kMaxMagnifierType + 1); |
| 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 | |
314 void MaybeSpeak(const std::string& utterance) { | 293 void MaybeSpeak(const std::string& utterance) { |
315 if (IsSpokenFeedbackEnabled()) | 294 if (IsSpokenFeedbackEnabled()) |
316 Speak(utterance); | 295 Speak(utterance); |
317 } | 296 } |
318 | 297 |
319 void ShowAccessibilityHelp(Browser* browser) { | 298 void ShowAccessibilityHelp(Browser* browser) { |
320 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); | 299 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
321 } | 300 } |
322 | 301 |
323 } // namespace accessibility | 302 } // namespace accessibility |
324 } // namespace chromeos | 303 } // namespace chromeos |
OLD | NEW |