| 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/magnification_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ash/magnifier/magnification_controller.h" | 9 #include "ash/magnifier/magnification_controller.h" |
| 10 #include "ash/magnifier/partial_magnification_controller.h" | 10 #include "ash/magnifier/partial_magnification_controller.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 registrar_.Add(this, | 57 registrar_.Add(this, |
| 58 chrome::NOTIFICATION_PROFILE_DESTROYED, | 58 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 59 content::NotificationService::AllSources()); | 59 content::NotificationService::AllSources()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual ~MagnificationManagerImpl() { | 62 virtual ~MagnificationManagerImpl() { |
| 63 CHECK(this == g_magnification_manager); | 63 CHECK(this == g_magnification_manager); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // MagnificationManager implimentation: | 66 // MagnificationManager implimentation: |
| 67 virtual bool IsMagnifierEnabled() const OVERRIDE { | 67 virtual bool IsMagnifierEnabled() const override { |
| 68 return enabled_; | 68 return enabled_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual ash::MagnifierType GetMagnifierType() const OVERRIDE { | 71 virtual ash::MagnifierType GetMagnifierType() const override { |
| 72 return type_; | 72 return type_; |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual void SetMagnifierEnabled(bool enabled) OVERRIDE { | 75 virtual void SetMagnifierEnabled(bool enabled) override { |
| 76 if (!profile_) | 76 if (!profile_) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 PrefService* prefs = profile_->GetPrefs(); | 79 PrefService* prefs = profile_->GetPrefs(); |
| 80 prefs->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled); | 80 prefs->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled); |
| 81 prefs->CommitPendingWrite(); | 81 prefs->CommitPendingWrite(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual void SetMagnifierType(ash::MagnifierType type) OVERRIDE { | 84 virtual void SetMagnifierType(ash::MagnifierType type) override { |
| 85 if (!profile_) | 85 if (!profile_) |
| 86 return; | 86 return; |
| 87 | 87 |
| 88 PrefService* prefs = profile_->GetPrefs(); | 88 PrefService* prefs = profile_->GetPrefs(); |
| 89 prefs->SetInteger(prefs::kAccessibilityScreenMagnifierType, type); | 89 prefs->SetInteger(prefs::kAccessibilityScreenMagnifierType, type); |
| 90 prefs->CommitPendingWrite(); | 90 prefs->CommitPendingWrite(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void SaveScreenMagnifierScale(double scale) OVERRIDE { | 93 virtual void SaveScreenMagnifierScale(double scale) override { |
| 94 if (!profile_) | 94 if (!profile_) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 profile_->GetPrefs()->SetDouble(prefs::kAccessibilityScreenMagnifierScale, | 97 profile_->GetPrefs()->SetDouble(prefs::kAccessibilityScreenMagnifierScale, |
| 98 scale); | 98 scale); |
| 99 } | 99 } |
| 100 | 100 |
| 101 virtual double GetSavedScreenMagnifierScale() const OVERRIDE { | 101 virtual double GetSavedScreenMagnifierScale() const override { |
| 102 if (!profile_) | 102 if (!profile_) |
| 103 return std::numeric_limits<double>::min(); | 103 return std::numeric_limits<double>::min(); |
| 104 | 104 |
| 105 return profile_->GetPrefs()->GetDouble( | 105 return profile_->GetPrefs()->GetDouble( |
| 106 prefs::kAccessibilityScreenMagnifierScale); | 106 prefs::kAccessibilityScreenMagnifierScale); |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual void SetProfileForTest(Profile* profile) OVERRIDE { | 109 virtual void SetProfileForTest(Profile* profile) override { |
| 110 SetProfile(profile); | 110 SetProfile(profile); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // SessionStateObserver overrides: | 113 // SessionStateObserver overrides: |
| 114 virtual void ActiveUserChanged(const std::string& user_id) OVERRIDE { | 114 virtual void ActiveUserChanged(const std::string& user_id) override { |
| 115 SetProfile(ProfileManager::GetActiveUserProfile()); | 115 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 void SetProfile(Profile* profile) { | 119 void SetProfile(Profile* profile) { |
| 120 pref_change_registrar_.reset(); | 120 pref_change_registrar_.reset(); |
| 121 | 121 |
| 122 if (profile) { | 122 if (profile) { |
| 123 // TODO(yoshiki): Move following code to PrefHandler. | 123 // TODO(yoshiki): Move following code to PrefHandler. |
| 124 pref_change_registrar_.reset(new PrefChangeRegistrar); | 124 pref_change_registrar_.reset(new PrefChangeRegistrar); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 209 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
| 210 AccessibilityManager::Get()->ShouldEnableCursorCompositing()); | 210 AccessibilityManager::Get()->ShouldEnableCursorCompositing()); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 #endif | 213 #endif |
| 214 } | 214 } |
| 215 | 215 |
| 216 // content::NotificationObserver implementation: | 216 // content::NotificationObserver implementation: |
| 217 virtual void Observe(int type, | 217 virtual void Observe(int type, |
| 218 const content::NotificationSource& source, | 218 const content::NotificationSource& source, |
| 219 const content::NotificationDetails& details) OVERRIDE { | 219 const content::NotificationDetails& details) override { |
| 220 switch (type) { | 220 switch (type) { |
| 221 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { | 221 case chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE: { |
| 222 // Update |profile_| when entering the login screen. | 222 // Update |profile_| when entering the login screen. |
| 223 Profile* profile = ProfileManager::GetActiveUserProfile(); | 223 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 224 if (ProfileHelper::IsSigninProfile(profile)) | 224 if (ProfileHelper::IsSigninProfile(profile)) |
| 225 SetProfile(profile); | 225 SetProfile(profile); |
| 226 break; | 226 break; |
| 227 } | 227 } |
| 228 case chrome::NOTIFICATION_SESSION_STARTED: | 228 case chrome::NOTIFICATION_SESSION_STARTED: |
| 229 // Update |profile_| when entering a session. | 229 // Update |profile_| when entering a session. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 delete g_magnification_manager; | 273 delete g_magnification_manager; |
| 274 g_magnification_manager = NULL; | 274 g_magnification_manager = NULL; |
| 275 } | 275 } |
| 276 | 276 |
| 277 // static | 277 // static |
| 278 MagnificationManager* MagnificationManager::Get() { | 278 MagnificationManager* MagnificationManager::Get() { |
| 279 return g_magnification_manager; | 279 return g_magnification_manager; |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace chromeos | 282 } // namespace chromeos |
| OLD | NEW |