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 "chrome/browser/accessibility/accessibility_extension_api.h" | 16 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 18 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
19 #include "chrome/browser/extensions/component_loader.h" | 19 #include "chrome/browser/extensions/component_loader.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/extensions/file_reader.h" | 21 #include "chrome/browser/extensions/file_reader.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
25 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" | 25 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
| 26 #include "chrome/browser/ui/singleton_tabs.h" |
26 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
28 #include "chrome/common/extensions/extension_resource.h" | 29 #include "chrome/common/extensions/extension_resource.h" |
29 #include "chrome/common/extensions/user_script.h" | 30 #include "chrome/common/extensions/user_script.h" |
30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/common/url_constants.h" |
31 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
34 #include "content/public/browser/web_ui.h" | 36 #include "content/public/browser/web_ui.h" |
| 37 #include "googleurl/src/gurl.h" |
35 #include "grit/browser_resources.h" | 38 #include "grit/browser_resources.h" |
36 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
37 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
39 | 42 |
40 using content::RenderViewHost; | 43 using content::RenderViewHost; |
41 | 44 |
42 namespace chromeos { | 45 namespace chromeos { |
43 namespace accessibility { | 46 namespace accessibility { |
44 | 47 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void EnableHighContrast(bool enabled) { | 186 void EnableHighContrast(bool enabled) { |
184 PrefService* pref_service = g_browser_process->local_state(); | 187 PrefService* pref_service = g_browser_process->local_state(); |
185 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); | 188 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); |
186 pref_service->CommitPendingWrite(); | 189 pref_service->CommitPendingWrite(); |
187 | 190 |
188 #if defined(USE_ASH) | 191 #if defined(USE_ASH) |
189 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 192 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
190 #endif | 193 #endif |
191 } | 194 } |
192 | 195 |
193 void SetScreenMagnifier(ScreenMagnifierType type) { | 196 void SetMagnifier(ash::MagnifierType type) { |
194 if (MagnificationManager::GetInstance()) | 197 if (MagnificationManager::GetInstance()) |
195 MagnificationManager::GetInstance()->SetScreenMagnifier(type); | 198 MagnificationManager::GetInstance()->SetMagnifier(type); |
196 } | 199 } |
197 | 200 |
198 void EnableVirtualKeyboard(bool enabled) { | 201 void EnableVirtualKeyboard(bool enabled) { |
199 PrefService* pref_service = g_browser_process->local_state(); | 202 PrefService* pref_service = g_browser_process->local_state(); |
200 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); | 203 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); |
201 pref_service->CommitPendingWrite(); | 204 pref_service->CommitPendingWrite(); |
202 } | 205 } |
203 | 206 |
204 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { | 207 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { |
205 bool spoken_feedback_enabled = g_browser_process && | 208 bool spoken_feedback_enabled = g_browser_process && |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 bool IsHighContrastEnabled() { | 240 bool IsHighContrastEnabled() { |
238 if (!g_browser_process) { | 241 if (!g_browser_process) { |
239 return false; | 242 return false; |
240 } | 243 } |
241 PrefService* prefs = g_browser_process->local_state(); | 244 PrefService* prefs = g_browser_process->local_state(); |
242 bool high_contrast_enabled = prefs && | 245 bool high_contrast_enabled = prefs && |
243 prefs->GetBoolean(prefs::kHighContrastEnabled); | 246 prefs->GetBoolean(prefs::kHighContrastEnabled); |
244 return high_contrast_enabled; | 247 return high_contrast_enabled; |
245 } | 248 } |
246 | 249 |
247 ScreenMagnifierType GetScreenMagnifierType() { | 250 ash::MagnifierType GetMagnifierType() { |
248 if (!MagnificationManager::GetInstance()) | 251 if (!MagnificationManager::GetInstance()) |
249 return MAGNIFIER_OFF; | 252 return ash::MAGNIFIER_OFF; |
250 return MagnificationManager::GetInstance()->GetScreenMagnifierType(); | 253 return MagnificationManager::GetInstance()->GetMagnifierType(); |
251 } | 254 } |
252 | 255 |
253 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { | 256 ash::MagnifierType MagnifierTypeFromName(const char type_name[]) { |
254 if (0 == strcmp(type_name, kScreenMagnifierFull)) | 257 if (0 == strcmp(type_name, kScreenMagnifierFull)) |
255 return MAGNIFIER_FULL; | 258 return ash::MAGNIFIER_FULL; |
256 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | 259 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) |
257 return MAGNIFIER_PARTIAL; | 260 return ash::MAGNIFIER_PARTIAL; |
258 else | 261 else |
259 return MAGNIFIER_OFF; | 262 return ash::MAGNIFIER_OFF; |
260 } | 263 } |
261 | 264 |
262 const char* ScreenMagnifierNameFromType(ScreenMagnifierType type) { | 265 const char* ScreenMagnifierNameFromType(ash::MagnifierType type) { |
263 switch (type) { | 266 switch (type) { |
264 case MAGNIFIER_OFF: | 267 case ash::MAGNIFIER_OFF: |
265 return kScreenMagnifierOff; | 268 return kScreenMagnifierOff; |
266 case MAGNIFIER_FULL: | 269 case ash::MAGNIFIER_FULL: |
267 return kScreenMagnifierFull; | 270 return kScreenMagnifierFull; |
268 case MAGNIFIER_PARTIAL: | 271 case ash::MAGNIFIER_PARTIAL: |
269 return kScreenMagnifierPartial; | 272 return kScreenMagnifierPartial; |
270 } | 273 } |
271 return kScreenMagnifierOff; | 274 return kScreenMagnifierOff; |
272 } | 275 } |
273 | 276 |
274 void MaybeSpeak(const std::string& utterance) { | 277 void MaybeSpeak(const std::string& utterance) { |
275 if (IsSpokenFeedbackEnabled()) | 278 if (IsSpokenFeedbackEnabled()) |
276 Speak(utterance); | 279 Speak(utterance); |
277 } | 280 } |
278 | 281 |
| 282 void ShowAccessibilityHelp(Browser* browser) { |
| 283 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 284 } |
| 285 |
279 } // namespace accessibility | 286 } // namespace accessibility |
280 } // namespace chromeos | 287 } // namespace chromeos |
OLD | NEW |