Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / accessibility / magnification_manager.cc
index 592f62d..8f47444 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "ash/magnifier/magnification_controller.h"
 #include "ash/magnifier/partial_magnification_controller.h"
-#include "ash/session_state_delegate.h"
+#include "ash/session/session_state_delegate.h"
 #include "ash/shell.h"
 #include "ash/shell_delegate.h"
 #include "ash/system/tray/system_tray_notifier.h"
@@ -18,7 +18,6 @@
 #include "base/prefs/pref_service.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
 #include "chrome/browser/chromeos/profiles/profile_helper.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/profiles/profile_manager.h"
@@ -42,9 +41,11 @@ class MagnificationManagerImpl : public MagnificationManager,
   MagnificationManagerImpl()
       : first_time_update_(true),
         profile_(NULL),
-        magnifier_enabled_pref_handler_(prefs::kScreenMagnifierEnabled),
-        magnifier_type_pref_handler_(prefs::kScreenMagnifierType),
-        magnifier_scale_pref_handler_(prefs::kScreenMagnifierScale),
+        magnifier_enabled_pref_handler_(
+            prefs::kAccessibilityScreenMagnifierEnabled),
+        magnifier_type_pref_handler_(prefs::kAccessibilityScreenMagnifierType),
+        magnifier_scale_pref_handler_(
+            prefs::kAccessibilityScreenMagnifierScale),
         type_(ash::kDefaultMagnifierType),
         enabled_(false) {
     registrar_.Add(this,
@@ -76,7 +77,7 @@ class MagnificationManagerImpl : public MagnificationManager,
       return;
 
     PrefService* prefs = profile_->GetPrefs();
-    prefs->SetBoolean(prefs::kScreenMagnifierEnabled, enabled);
+    prefs->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled);
     prefs->CommitPendingWrite();
   }
 
@@ -85,7 +86,7 @@ class MagnificationManagerImpl : public MagnificationManager,
       return;
 
     PrefService* prefs = profile_->GetPrefs();
-    prefs->SetInteger(prefs::kScreenMagnifierType, type);
+    prefs->SetInteger(prefs::kAccessibilityScreenMagnifierType, type);
     prefs->CommitPendingWrite();
   }
 
@@ -93,14 +94,16 @@ class MagnificationManagerImpl : public MagnificationManager,
     if (!profile_)
       return;
 
-    profile_->GetPrefs()->SetDouble(prefs::kScreenMagnifierScale, scale);
+    profile_->GetPrefs()->SetDouble(prefs::kAccessibilityScreenMagnifierScale,
+                                    scale);
   }
 
   virtual double GetSavedScreenMagnifierScale() const OVERRIDE {
     if (!profile_)
       return std::numeric_limits<double>::min();
 
-    return profile_->GetPrefs()->GetDouble(prefs::kScreenMagnifierScale);
+    return profile_->GetPrefs()->GetDouble(
+        prefs::kAccessibilityScreenMagnifierScale);
   }
 
   virtual void SetProfileForTest(Profile* profile) OVERRIDE {
@@ -121,11 +124,11 @@ class MagnificationManagerImpl : public MagnificationManager,
       pref_change_registrar_.reset(new PrefChangeRegistrar);
       pref_change_registrar_->Init(profile->GetPrefs());
       pref_change_registrar_->Add(
-          prefs::kScreenMagnifierEnabled,
+          prefs::kAccessibilityScreenMagnifierEnabled,
           base::Bind(&MagnificationManagerImpl::UpdateMagnifierFromPrefs,
                      base::Unretained(this)));
       pref_change_registrar_->Add(
-          prefs::kScreenMagnifierType,
+          prefs::kAccessibilityScreenMagnifierType,
           base::Bind(&MagnificationManagerImpl::UpdateMagnifierFromPrefs,
                      base::Unretained(this)));
     }
@@ -169,10 +172,10 @@ class MagnificationManagerImpl : public MagnificationManager,
     if (!profile_)
       return;
 
-    const bool enabled =
-        profile_->GetPrefs()->GetBoolean(prefs::kScreenMagnifierEnabled);
-    const int type_integer =
-        profile_->GetPrefs()->GetInteger(prefs::kScreenMagnifierType);
+    const bool enabled = profile_->GetPrefs()->GetBoolean(
+        prefs::kAccessibilityScreenMagnifierEnabled);
+    const int type_integer = profile_->GetPrefs()->GetInteger(
+        prefs::kAccessibilityScreenMagnifierType);
 
     ash::MagnifierType type = ash::kDefaultMagnifierType;
     if (type_integer > 0 && type_integer <= ash::kMaxMagnifierType) {
@@ -194,11 +197,20 @@ class MagnificationManagerImpl : public MagnificationManager,
     }
 
     AccessibilityStatusEventDetails details(
-        enabled_, type_, ash::A11Y_NOTIFICATION_NONE);
-    content::NotificationService::current()->Notify(
-        chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
-        content::NotificationService::AllSources(),
-        content::Details<AccessibilityStatusEventDetails>(&details));
+        ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
+        enabled_,
+        type_,
+        ash::A11Y_NOTIFICATION_NONE);
+
+#if defined(OS_CHROMEOS)
+    if (AccessibilityManager::Get()) {
+      AccessibilityManager::Get()->NotifyAccessibilityStatusChanged(details);
+      if (ash::Shell::GetInstance()) {
+        ash::Shell::GetInstance()->SetCursorCompositingEnabled(
+            AccessibilityManager::Get()->ShouldEnableCursorCompositing());
+      }
+    }
+#endif
   }
 
   // content::NotificationObserver implementation: