| 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/extensions/component_loader.h" | 19 #include "chrome/browser/extensions/component_loader.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/file_reader.h" | 21 #include "chrome/browser/extensions/file_reader.h" |
| 21 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.h" | 25 #include "chrome/browser/speech/extension_api/tts_extension_api_controller.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" |
| 30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/browser/web_ui.h" | 34 #include "content/public/browser/web_ui.h" |
| 34 #include "grit/browser_resources.h" | 35 #include "grit/browser_resources.h" |
| 35 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 38 | 39 |
| 39 using content::RenderViewHost; | 40 using content::RenderViewHost; |
| 40 | 41 |
| 41 namespace { | |
| 42 const char kScreenMagnifierOff[] = ""; | |
| 43 const char kScreenMagnifierFull[] = "full"; | |
| 44 const char kScreenMagnifierPartial[] = "partial"; | |
| 45 } | |
| 46 | |
| 47 | |
| 48 namespace chromeos { | 42 namespace chromeos { |
| 49 namespace accessibility { | 43 namespace accessibility { |
| 50 | 44 |
| 45 const char kScreenMagnifierOff[] = ""; |
| 46 const char kScreenMagnifierFull[] = "full"; |
| 47 const char kScreenMagnifierPartial[] = "partial"; |
| 48 |
| 51 // Helper class that directly loads an extension's content scripts into | 49 // Helper class that directly loads an extension's content scripts into |
| 52 // all of the frames corresponding to a given RenderViewHost. | 50 // all of the frames corresponding to a given RenderViewHost. |
| 53 class ContentScriptLoader { | 51 class ContentScriptLoader { |
| 54 public: | 52 public: |
| 55 // Initialize the ContentScriptLoader with the ID of the extension | 53 // Initialize the ContentScriptLoader with the ID of the extension |
| 56 // and the RenderViewHost where the scripts should be loaded. | 54 // and the RenderViewHost where the scripts should be loaded. |
| 57 ContentScriptLoader(const std::string& extension_id, | 55 ContentScriptLoader(const std::string& extension_id, |
| 58 int render_process_id, | 56 int render_process_id, |
| 59 int render_view_id) | 57 int render_view_id) |
| 60 : extension_id_(extension_id), | 58 : extension_id_(extension_id), |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 PrefService* pref_service = g_browser_process->local_state(); | 185 PrefService* pref_service = g_browser_process->local_state(); |
| 188 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); | 186 pref_service->SetBoolean(prefs::kHighContrastEnabled, enabled); |
| 189 pref_service->CommitPendingWrite(); | 187 pref_service->CommitPendingWrite(); |
| 190 | 188 |
| 191 #if defined(USE_ASH) | 189 #if defined(USE_ASH) |
| 192 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 190 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
| 193 #endif | 191 #endif |
| 194 } | 192 } |
| 195 | 193 |
| 196 void SetScreenMagnifier(ScreenMagnifierType type) { | 194 void SetScreenMagnifier(ScreenMagnifierType type) { |
| 197 PrefService* pref_service = g_browser_process->local_state(); | 195 if (MagnificationManager::GetInstance()) |
| 198 pref_service->SetString(prefs::kScreenMagnifierType, | 196 MagnificationManager::GetInstance()->SetScreenMagnifier(type); |
| 199 ScreenMagnifierNameFromType(type)); | |
| 200 pref_service->CommitPendingWrite(); | |
| 201 | |
| 202 #if defined(USE_ASH) | |
| 203 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( | |
| 204 type == MAGNIFIER_FULL); | |
| 205 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( | |
| 206 type == MAGNIFIER_PARTIAL); | |
| 207 #endif | |
| 208 } | 197 } |
| 209 | 198 |
| 210 void EnableVirtualKeyboard(bool enabled) { | 199 void EnableVirtualKeyboard(bool enabled) { |
| 211 PrefService* pref_service = g_browser_process->local_state(); | 200 PrefService* pref_service = g_browser_process->local_state(); |
| 212 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); | 201 pref_service->SetBoolean(prefs::kVirtualKeyboardEnabled, enabled); |
| 213 pref_service->CommitPendingWrite(); | 202 pref_service->CommitPendingWrite(); |
| 214 } | 203 } |
| 215 | 204 |
| 216 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { | 205 void ToggleSpokenFeedback(content::WebUI* login_web_ui) { |
| 217 bool spoken_feedback_enabled = g_browser_process && | 206 bool spoken_feedback_enabled = g_browser_process && |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (!g_browser_process) { | 239 if (!g_browser_process) { |
| 251 return false; | 240 return false; |
| 252 } | 241 } |
| 253 PrefService* prefs = g_browser_process->local_state(); | 242 PrefService* prefs = g_browser_process->local_state(); |
| 254 bool high_contrast_enabled = prefs && | 243 bool high_contrast_enabled = prefs && |
| 255 prefs->GetBoolean(prefs::kHighContrastEnabled); | 244 prefs->GetBoolean(prefs::kHighContrastEnabled); |
| 256 return high_contrast_enabled; | 245 return high_contrast_enabled; |
| 257 } | 246 } |
| 258 | 247 |
| 259 ScreenMagnifierType GetScreenMagnifierType() { | 248 ScreenMagnifierType GetScreenMagnifierType() { |
| 260 if (!g_browser_process) | 249 if (!MagnificationManager::GetInstance()) |
| 261 return MAGNIFIER_OFF; | 250 return MAGNIFIER_OFF; |
| 262 | 251 return MagnificationManager::GetInstance()->GetScreenMagnifierType(); |
| 263 PrefService* prefs = g_browser_process->local_state(); | |
| 264 std::string screen_magnifier_type; | |
| 265 if (!prefs) | |
| 266 return MAGNIFIER_OFF; | |
| 267 | |
| 268 return ScreenMagnifierTypeFromName( | |
| 269 prefs->GetString(prefs::kScreenMagnifierType).c_str()); | |
| 270 } | 252 } |
| 271 | 253 |
| 272 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { | 254 ScreenMagnifierType ScreenMagnifierTypeFromName(const char type_name[]) { |
| 273 if (0 == strcmp(type_name, kScreenMagnifierFull)) | 255 if (0 == strcmp(type_name, kScreenMagnifierFull)) |
| 274 return MAGNIFIER_FULL; | 256 return MAGNIFIER_FULL; |
| 275 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) | 257 else if (0 == strcmp(type_name, kScreenMagnifierPartial)) |
| 276 return MAGNIFIER_PARTIAL; | 258 return MAGNIFIER_PARTIAL; |
| 277 else | 259 else |
| 278 return MAGNIFIER_OFF; | 260 return MAGNIFIER_OFF; |
| 279 } | 261 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 290 return kScreenMagnifierOff; | 272 return kScreenMagnifierOff; |
| 291 } | 273 } |
| 292 | 274 |
| 293 void MaybeSpeak(const std::string& utterance) { | 275 void MaybeSpeak(const std::string& utterance) { |
| 294 if (IsSpokenFeedbackEnabled()) | 276 if (IsSpokenFeedbackEnabled()) |
| 295 Speak(utterance); | 277 Speak(utterance); |
| 296 } | 278 } |
| 297 | 279 |
| 298 } // namespace accessibility | 280 } // namespace accessibility |
| 299 } // namespace chromeos | 281 } // namespace chromeos |
| OLD | NEW |