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 "ash/magnifier/magnification_controller.h" | 7 #include "ash/magnifier/magnification_controller.h" |
8 #include "ash/magnifier/partial_magnification_controller.h" | 8 #include "ash/magnifier/partial_magnification_controller.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
12 #include "chrome/browser/api/prefs/pref_member.h" | 13 #include "chrome/browser/api/prefs/pref_member.h" |
13 #include "chrome/browser/chromeos/login/user_manager.h" | 14 #include "chrome/browser/chromeos/login/user_manager.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
(...skipping 23 matching lines...) Expand all Loading... |
43 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 44 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
44 SetProfile(profile); | 45 SetProfile(profile); |
45 } | 46 } |
46 virtual ~MagnificationManagerImpl() {} | 47 virtual ~MagnificationManagerImpl() {} |
47 | 48 |
48 static MagnificationManagerImpl* GetInstance() { | 49 static MagnificationManagerImpl* GetInstance() { |
49 return instance_; | 50 return instance_; |
50 } | 51 } |
51 | 52 |
52 // MagnificationManager implimentation: | 53 // MagnificationManager implimentation: |
53 accessibility::ScreenMagnifierType GetScreenMagnifierType() OVERRIDE { | 54 ash::MagnifierType GetMagnifierType() OVERRIDE { |
54 if (!profile_) | 55 if (!profile_) |
55 return accessibility::MAGNIFIER_OFF; | 56 return ash::MAGNIFIER_OFF; |
56 | 57 |
57 PrefService* prefs = profile_->GetPrefs(); | 58 PrefService* prefs = profile_->GetPrefs(); |
58 if (!prefs) | 59 if (!prefs) |
59 return accessibility::MAGNIFIER_OFF; | 60 return ash::MAGNIFIER_OFF; |
60 | 61 |
61 return accessibility::ScreenMagnifierTypeFromName( | 62 return accessibility::MagnifierTypeFromName( |
62 prefs->GetString(prefs::kScreenMagnifierType).c_str()); | 63 prefs->GetString(prefs::kMagnifierType).c_str()); |
63 } | 64 } |
64 | 65 |
65 void SetScreenMagnifier(accessibility::ScreenMagnifierType type) OVERRIDE { | 66 void SetMagnifier(ash::MagnifierType type) OVERRIDE { |
66 PrefService* prefs = profile_->GetPrefs(); | 67 PrefService* prefs = profile_->GetPrefs(); |
67 if (prefs) { | 68 if (prefs) { |
68 std::string typeString = ScreenMagnifierNameFromType(type); | 69 std::string typeString = accessibility::ScreenMagnifierNameFromType(type); |
69 if (typeString != prefs->GetString(prefs::kScreenMagnifierType)) { | 70 if (typeString != prefs->GetString(prefs::kMagnifierType)) { |
70 prefs->SetString(prefs::kScreenMagnifierType, typeString); | 71 prefs->SetString(prefs::kMagnifierType, typeString); |
71 prefs->CommitPendingWrite(); | 72 prefs->CommitPendingWrite(); |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
| 76 ash::Shell::GetInstance()->system_tray_notifier()-> |
| 77 NotifyAccessibilityModeChanged(); |
| 78 |
75 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( | 79 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( |
76 type == accessibility::MAGNIFIER_FULL); | 80 type == ash::MAGNIFIER_FULL); |
77 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( | 81 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( |
78 type == accessibility::MAGNIFIER_PARTIAL); | 82 type == ash::MAGNIFIER_PARTIAL); |
79 } | 83 } |
80 | 84 |
81 private: | 85 private: |
82 void SetProfile(Profile* profile) { | 86 void SetProfile(Profile* profile) { |
83 if (pref_change_registrar_) { | 87 if (pref_change_registrar_) { |
84 pref_change_registrar_.reset(); | 88 pref_change_registrar_.reset(); |
85 } | 89 } |
86 | 90 |
87 if (profile) { | 91 if (profile) { |
88 pref_change_registrar_.reset(new PrefChangeRegistrar); | 92 pref_change_registrar_.reset(new PrefChangeRegistrar); |
89 pref_change_registrar_->Init(profile->GetPrefs()); | 93 pref_change_registrar_->Init(profile->GetPrefs()); |
90 pref_change_registrar_->Add( | 94 pref_change_registrar_->Add( |
91 prefs::kScreenMagnifierType, | 95 prefs::kMagnifierType, |
92 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus, | 96 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus, |
93 base::Unretained(this))); | 97 base::Unretained(this))); |
94 } | 98 } |
95 | 99 |
96 profile_ = profile; | 100 profile_ = profile; |
97 UpdateMagnifierStatus(); | 101 UpdateMagnifierStatus(); |
98 } | 102 } |
99 | 103 |
100 void UpdateMagnifierStatus() { | 104 void UpdateMagnifierStatus() { |
101 UserManager* manager = UserManager::Get(); | 105 UserManager* manager = UserManager::Get(); |
102 if (!profile_) { | 106 if (!profile_) { |
103 SetScreenMagnifier(accessibility::MAGNIFIER_OFF); | 107 SetMagnifier(ash::MAGNIFIER_OFF); |
104 } else if (manager && !manager->IsSessionStarted()) { | 108 } else if (manager && !manager->IsSessionStarted()) { |
105 SetScreenMagnifier(accessibility::MAGNIFIER_FULL); | 109 SetMagnifier(ash::MAGNIFIER_FULL); |
106 } else { | 110 } else { |
107 accessibility::ScreenMagnifierType type = GetScreenMagnifierType(); | 111 ash::MagnifierType type = GetMagnifierType(); |
108 SetScreenMagnifier(type); | 112 SetMagnifier(type); |
109 } | 113 } |
110 } | 114 } |
111 | 115 |
112 virtual void Observe(int type, | 116 virtual void Observe(int type, |
113 const content::NotificationSource& source, | 117 const content::NotificationSource& source, |
114 const content::NotificationDetails& details) OVERRIDE { | 118 const content::NotificationDetails& details) OVERRIDE { |
115 switch (type) { | 119 switch (type) { |
116 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: | 120 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: |
117 case chrome::NOTIFICATION_SESSION_STARTED: { | 121 case chrome::NOTIFICATION_SESSION_STARTED: { |
118 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 122 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
(...skipping 20 matching lines...) Expand all Loading... |
139 } | 143 } |
140 | 144 |
141 MagnificationManager* MagnificationManager::CreateInstance() { | 145 MagnificationManager* MagnificationManager::CreateInstance() { |
142 // Makes sure that this is not called more than once. | 146 // Makes sure that this is not called more than once. |
143 CHECK(!GetInstance()); | 147 CHECK(!GetInstance()); |
144 | 148 |
145 return new MagnificationManagerImpl(); | 149 return new MagnificationManagerImpl(); |
146 } | 150 } |
147 | 151 |
148 } // namespace chromeos | 152 } // namespace chromeos |
OLD | NEW |