Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / accessibility / accessibility_manager.cc
index 1df977d..218f071 100644 (file)
@@ -32,7 +32,6 @@
 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
 #include "chrome/browser/chromeos/profiles/profile_helper.h"
 #include "chrome/browser/extensions/component_loader.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/common/extensions/extension_constants.h"
 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
 #include "chrome/common/pref_names.h"
+#include "chrome/grit/browser_resources.h"
 #include "chromeos/audio/chromeos_sounds.h"
 #include "chromeos/ime/input_method_manager.h"
 #include "chromeos/login/login_state.h"
+#include "components/user_manager/user_manager.h"
 #include "content/public/browser/browser_accessibility_state.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_details.h"
 #include "extensions/common/extension.h"
 #include "extensions/common/extension_messages.h"
 #include "extensions/common/extension_resource.h"
-#include "grit/browser_resources.h"
-#include "grit/generated_resources.h"
 #include "media/audio/sounds/sounds_manager.h"
-#include "ui/base/l10n/l10n_util.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/keyboard/keyboard_controller.h"
 #include "ui/keyboard/keyboard_util.h"
@@ -223,7 +221,7 @@ void InjectChromeVoxContentScript(
   for (size_t i = 0; i < content_scripts.size(); i++) {
     const extensions::UserScript& script = content_scripts[i];
     for (size_t j = 0; j < script.js_scripts().size(); ++j) {
-      const extensions::UserScript::File &file = script.js_scripts()[j];
+      const extensions::UserScript::Filefile = script.js_scripts()[j];
       extensions::ExtensionResource resource = extension->GetResource(
           file.relative_path());
       loader->AppendScript(resource);
@@ -343,12 +341,12 @@ AccessibilityManager::AccessibilityManager()
       autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
       virtual_keyboard_enabled_(false),
       spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
-      weak_ptr_factory_(this),
       should_speak_chrome_vox_announcements_on_user_screen_(true),
       system_sounds_enabled_(false),
       braille_display_connected_(false),
       scoped_braille_observer_(this),
-      braille_ime_current_(false) {
+      braille_ime_current_(false),
+      weak_ptr_factory_(this) {
   notification_registrar_.Add(this,
                               chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
                               content::NotificationService::AllSources());
@@ -374,6 +372,12 @@ AccessibilityManager::AccessibilityManager()
   manager->Initialize(
       SOUND_SPOKEN_FEEDBACK_DISABLED,
       bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_DISABLED_WAV));
+  manager->Initialize(SOUND_PASSTHROUGH,
+                      bundle.GetRawDataResource(IDR_SOUND_PASSTHROUGH_WAV));
+  manager->Initialize(SOUND_EXIT_SCREEN,
+                      bundle.GetRawDataResource(IDR_SOUND_EXIT_SCREEN_WAV));
+  manager->Initialize(SOUND_ENTER_SCREEN,
+                      bundle.GetRawDataResource(IDR_SOUND_ENTER_SCREEN_WAV));
 }
 
 AccessibilityManager::~AccessibilityManager() {
@@ -450,6 +454,8 @@ void AccessibilityManager::UpdateLargeCursorFromPref() {
       ash::A11Y_NOTIFICATION_NONE);
 
   NotifyAccessibilityStatusChanged(details);
+#if !defined(USE_ATHENA)
+  // crbug.com/408733 (and for all USE_ATHENA in this file)
 
 #if defined(USE_ASH)
   // Large cursor is implemented only in ash.
@@ -461,12 +467,13 @@ void AccessibilityManager::UpdateLargeCursorFromPref() {
   ash::Shell::GetInstance()->SetCursorCompositingEnabled(
       ShouldEnableCursorCompositing());
 #endif
+
+#endif // !USE_ATHENA
 }
 
 bool AccessibilityManager::IsIncognitoAllowed() {
-  UserManager* user_manager = UserManager::Get();
   // Supervised users can't create incognito-mode windows.
-  return !(user_manager->IsLoggedInAsLocallyManagedUser());
+  return !(user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser());
 }
 
 bool AccessibilityManager::IsLargeCursorEnabled() {
@@ -496,8 +503,7 @@ void AccessibilityManager::UpdateStickyKeysFromPref() {
     return;
 
   sticky_keys_enabled_ = enabled;
-#if defined(USE_ASH)
-  // Sticky keys is implemented only in ash.
+#if defined(USE_ASH) && !defined(USE_ATHENA)
   ash::Shell::GetInstance()->sticky_keys_controller()->Enable(enabled);
 #endif
 }
@@ -507,10 +513,11 @@ void AccessibilityManager::EnableSpokenFeedback(
     ash::AccessibilityNotificationVisibility notify) {
   if (!profile_)
     return;
-
+#if !defined(USE_ATHENA)
   ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
       enabled ? ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK
               : ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK);
+#endif
 
   spoken_feedback_notification_ = notify;
 
@@ -670,6 +677,8 @@ void AccessibilityManager::UpdateHighContrastFromPref() {
 
   NotifyAccessibilityStatusChanged(details);
 
+#if !defined(USE_ATHENA)
+
 #if defined(USE_ASH)
   ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled);
 #endif
@@ -678,6 +687,8 @@ void AccessibilityManager::UpdateHighContrastFromPref() {
   ash::Shell::GetInstance()->SetCursorCompositingEnabled(
       ShouldEnableCursorCompositing());
 #endif
+
+#endif
 }
 
 void AccessibilityManager::OnLocaleChanged() {
@@ -694,6 +705,11 @@ void AccessibilityManager::OnLocaleChanged() {
   EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_NONE);
 }
 
+void AccessibilityManager::PlayEarcon(int sound_key) {
+  DCHECK(sound_key < chromeos::SOUND_COUNT);
+  ash::PlaySystemSoundIfSpokenFeedback(sound_key);
+}
+
 bool AccessibilityManager::IsHighContrastEnabled() {
   return high_contrast_enabled_;
 }
@@ -719,7 +735,7 @@ void AccessibilityManager::UpdateAutoclickFromPref() {
     return;
   autoclick_enabled_ = enabled;
 
-#if defined(USE_ASH)
+#if defined(USE_ASH) && !defined(USE_ATHENA)
   ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled);
 #endif
 }
@@ -745,7 +761,7 @@ void AccessibilityManager::UpdateAutoclickDelayFromPref() {
     return;
   autoclick_delay_ms_ = autoclick_delay_ms;
 
-#if defined(USE_ASH)
+#if defined(USE_ASH) && !defined(USE_ATHENA)
   ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay(
       autoclick_delay_ms_);
 #endif
@@ -783,7 +799,7 @@ void AccessibilityManager::UpdateVirtualKeyboardFromPref() {
 
   NotifyAccessibilityStatusChanged(details);
 
-#if defined(USE_ASH)
+#if defined(USE_ASH) && !defined(USE_ATHENA)
   keyboard::SetAccessibilityKeyboardEnabled(enabled);
   // Note that there are two versions of the on-screen keyboard. A full layout
   // is provided for accessibility, which includes sticky modifier keys to
@@ -851,14 +867,15 @@ void AccessibilityManager::UpdateBrailleImeState() {
 void AccessibilityManager::InputMethodChanged(
     input_method::InputMethodManager* manager,
     bool show_message) {
-#if defined(USE_ASH)
+#if defined(USE_ASH) && !defined(USE_ATHENA)
   // Sticky keys is implemented only in ash.
+  // TODO(dpolukhin): support Athena, crbug.com/408733.
   ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled(
       manager->IsISOLevel5ShiftUsedByCurrentInputMethod(),
       manager->IsAltGrUsedByCurrentInputMethod());
 #endif
   const chromeos::input_method::InputMethodDescriptor descriptor =
-      manager->GetCurrentInputMethod();
+      manager->GetActiveIMEState()->GetCurrentInputMethod();
   braille_ime_current_ =
       (descriptor.id() == extension_misc::kBrailleImeEngineId);
 }
@@ -957,8 +974,10 @@ base::TimeDelta AccessibilityManager::PlayShutdownSound() {
   if (!system_sounds_enabled_)
     return base::TimeDelta();
   system_sounds_enabled_ = false;
+#if !defined(USE_ATHENA)
   if (!ash::PlaySystemSoundIfSpokenFeedback(SOUND_SHUTDOWN))
     return base::TimeDelta();
+#endif
   return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN);
 }
 
@@ -1086,8 +1105,10 @@ void AccessibilityManager::OnBrailleKeyEvent(const KeyEvent& event) {
   if ((event.command ==
        extensions::api::braille_display_private::KEY_COMMAND_DOTS) &&
       !braille_ime_current_) {
-    input_method::InputMethodManager::Get()->ChangeInputMethod(
-        extension_misc::kBrailleImeEngineId);
+    input_method::InputMethodManager::Get()
+        ->GetActiveIMEState()
+        ->ChangeInputMethod(extension_misc::kBrailleImeEngineId,
+                            false /* show_message */);
   }
 }