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/extensions/component_loader.h" | 18 #include "chrome/browser/extensions/component_loader.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/file_reader.h" | 20 #include "chrome/browser/extensions/file_reader.h" |
21 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" | 24 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" |
| 25 #include "chrome/browser/ui/singleton_tabs.h" |
25 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_messages.h" | 27 #include "chrome/common/extensions/extension_messages.h" |
27 #include "chrome/common/extensions/extension_resource.h" | 28 #include "chrome/common/extensions/extension_resource.h" |
28 #include "chrome/common/extensions/user_script.h" | 29 #include "chrome/common/extensions/user_script.h" |
29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" |
30 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
32 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
33 #include "content/public/browser/web_ui.h" | 35 #include "content/public/browser/web_ui.h" |
| 36 #include "googleurl/src/gurl.h" |
34 #include "grit/browser_resources.h" | 37 #include "grit/browser_resources.h" |
35 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
36 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
38 | 41 |
39 using content::RenderViewHost; | 42 using content::RenderViewHost; |
40 | 43 |
41 namespace { | 44 namespace { |
42 const char kScreenMagnifierOff[] = ""; | 45 const char kScreenMagnifierOff[] = ""; |
43 const char kScreenMagnifierFull[] = "full"; | 46 const char kScreenMagnifierFull[] = "full"; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void EnableHighContrast(bool enabled) { | 189 void EnableHighContrast(bool enabled) { |
187 PrefService* pref_service = g_browser_process->local_state(); | 190 PrefService* pref_service = g_browser_process->local_state(); |
188 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); | 191 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); |
189 pref_service->CommitPendingWrite(); | 192 pref_service->CommitPendingWrite(); |
190 | 193 |
191 #if defined(USE_ASH) | 194 #if defined(USE_ASH) |
192 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 195 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
193 #endif | 196 #endif |
194 } | 197 } |
195 | 198 |
196 void SetScreenMagnifier(ScreenMagnifierType type) { | 199 void SetScreenMagnifier(ash::MagnifierType type) { |
197 PrefService* pref_service = g_browser_process->local_state(); | 200 PrefService* pref_service = g_browser_process->local_state(); |
198 pref_service->SetString(prefs::kScreenMagnifierType, | 201 pref_service->SetString(prefs::kMagnifierType, |
199 ScreenMagnifierNameFromType(type)); | 202 ScreenMagnifierNameFromType(type)); |
200 pref_service->CommitPendingWrite(); | 203 pref_service->CommitPendingWrite(); |
201 | 204 |
202 #if defined(USE_ASH) | 205 #if defined(USE_ASH) |
203 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( | 206 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( |
204 type == MAGNIFIER_FULL); | 207 type == ash::MAGNIFIER_FULL); |
205 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( | 208 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( |
206 type == MAGNIFIER_PARTIAL); | 209 type == ash::MAGNIFIER_PARTIAL); |
207 #endif | 210 #endif |
208 } | 211 } |
209 | 212 |
210 void EnableVirtualKeyboard(bool enabled) { | 213 void EnableVirtualKeyboard(bool enabled) { |
211 PrefService* pref_service = g_browser_process->local_state(); | 214 PrefService* pref_service = g_browser_process->local_state(); |
212 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); | 215 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); |
213 pref_service->CommitPendingWrite(); | 216 pref_service->CommitPendingWrite(); |
214 } | 217 } |
215 | 218 |
216 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { | 219 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool IsHighContrastEnabled() { | 252 bool IsHighContrastEnabled() { |
250 if (!g_browser_process) { | 253 if (!g_browser_process) { |
251 return false; | 254 return false; |
252 } | 255 } |
253 PrefService* prefs = g_browser_process->local_state(); | 256 PrefService* prefs = g_browser_process->local_state(); |
254 bool high_contrast_enabled = prefs && | 257 bool high_contrast_enabled = prefs && |
255 prefs->GetBoolean(prefs::kHighContrastEnabled); | 258 prefs->GetBoolean(prefs::kHighContrastEnabled); |
256 return high_contrast_enabled; | 259 return high_contrast_enabled; |
257 } | 260 } |
258 | 261 |
259 ScreenMagnifierType GetScreenMagnifierType() { | 262 ash::MagnifierType GetMagnifierType() { |
260 if (!g_browser_process) | 263 if (!g_browser_process) |
261 return MAGNIFIER_OFF; | 264 return ash::MAGNIFIER_OFF; |
262 | 265 |
263 PrefService* prefs = g_browser_process->local_state(); | 266 PrefService* prefs = g_browser_process->local_state(); |
264 std::string screen_magnifier_type; | 267 std::string screen_magnifier_type; |
265 if (!prefs) | 268 if (!prefs) |
266 return MAGNIFIER_OFF; | 269 return ash::MAGNIFIER_OFF; |
267 | 270 |
268 return ScreenMagnifierTypeFromName( | 271 return MagnifierTypeFromName( |
269 prefs->GetString(prefs::kScreenMagnifierType).c_str()); | 272 prefs->GetString(prefs::kMagnifierType).c_str()); |
270 } | 273 } |
271 | 274 |
272 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { | 275 ash::MagnifierType MagnifierTypeFromName(const char type_name[]) { |
273 if (0 == strcmp(type_name, kScreenMagnifierFull)) | 276 if (0 == strcmp(type_name, kScreenMagnifierFull)) |
274 return MAGNIFIER_FULL; | 277 return ash::MAGNIFIER_FULL; |
275 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | 278 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) |
276 return MAGNIFIER_PARTIAL; | 279 return ash::MAGNIFIER_PARTIAL; |
277 else | 280 else |
278 return MAGNIFIER_OFF; | 281 return ash::MAGNIFIER_OFF; |
279 } | 282 } |
280 | 283 |
281 const char* ScreenMagnifierNameFromType(ScreenMagnifierType type) { | 284 const char* ScreenMagnifierNameFromType(ash::MagnifierType type) { |
282 switch (type) { | 285 switch (type) { |
283 case MAGNIFIER_OFF: | 286 case ash::MAGNIFIER_OFF: |
284 return kScreenMagnifierOff; | 287 return kScreenMagnifierOff; |
285 case MAGNIFIER_FULL: | 288 case ash::MAGNIFIER_FULL: |
286 return kScreenMagnifierFull; | 289 return kScreenMagnifierFull; |
287 case MAGNIFIER_PARTIAL: | 290 case ash::MAGNIFIER_PARTIAL: |
288 return kScreenMagnifierPartial; | 291 return kScreenMagnifierPartial; |
289 } | 292 } |
290 return kScreenMagnifierOff; | 293 return kScreenMagnifierOff; |
291 } | 294 } |
292 | 295 |
293 void MaybeSpeak(const std::string& utterance) { | 296 void MaybeSpeak(const std::string& utterance) { |
294 if (IsSpokenFeedbackEnabled()) | 297 if (IsSpokenFeedbackEnabled()) |
295 Speak(utterance); | 298 Speak(utterance); |
296 } | 299 } |
297 | 300 |
| 301 void ShowAccessibilityHelp(Browser* browser) { |
| 302 chrome::ShowSingletonTab(browser, GURL(chrome::kChromeAccessibilityHelpURL)); |
| 303 } |
| 304 |
298 } // namespace accessibility | 305 } // namespace accessibility |
299 } // namespace chromeos | 306 } // namespace chromeos |
OLD | NEW |