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 "ash/system/tray/system_tray_notifier.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 static MagnificationManager* g_magnification_manager = NULL; | 29 static MagnificationManager* g_magnification_manager = NULL; |
30 } | 30 } |
31 | 31 |
32 class MagnificationManagerImpl : public MagnificationManager, | 32 class MagnificationManagerImpl : public MagnificationManager, |
33 public content::NotificationObserver { | 33 public content::NotificationObserver { |
34 public: | 34 public: |
35 MagnificationManagerImpl() : first_time_update_(true), | 35 MagnificationManagerImpl() : first_time_update_(true), |
36 profile_(NULL), | 36 profile_(NULL), |
37 type_(ash::MAGNIFIER_OFF) { | 37 type_(ash::MAGNIFIER_OFF) { |
38 registrar_.Add(this, | 38 registrar_.Add(this, |
| 39 chrome::NOTIFICATION_PROFILE_CREATED, |
| 40 content::NotificationService::AllSources()); |
| 41 registrar_.Add(this, |
39 chrome::NOTIFICATION_SESSION_STARTED, | 42 chrome::NOTIFICATION_SESSION_STARTED, |
40 content::NotificationService::AllSources()); | 43 content::NotificationService::AllSources()); |
41 registrar_.Add(this, | 44 registrar_.Add(this, |
42 chrome::NOTIFICATION_PROFILE_DESTROYED, | 45 chrome::NOTIFICATION_PROFILE_DESTROYED, |
43 content::NotificationService::AllSources()); | 46 content::NotificationService::AllSources()); |
44 registrar_.Add(this, | 47 registrar_.Add(this, |
45 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, | 48 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, |
46 content::NotificationService::AllSources()); | 49 content::NotificationService::AllSources()); |
47 } | 50 } |
48 | 51 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 void UpdateMagnifierStatus() { | 135 void UpdateMagnifierStatus() { |
133 ash::MagnifierType type = GetMagnifierTypeFromPref(); | 136 ash::MagnifierType type = GetMagnifierTypeFromPref(); |
134 SetMagnifier(type); | 137 SetMagnifier(type); |
135 } | 138 } |
136 | 139 |
137 // content::NotificationObserver implimentation: | 140 // content::NotificationObserver implimentation: |
138 virtual void Observe(int type, | 141 virtual void Observe(int type, |
139 const content::NotificationSource& source, | 142 const content::NotificationSource& source, |
140 const content::NotificationDetails& details) OVERRIDE { | 143 const content::NotificationDetails& details) OVERRIDE { |
141 switch (type) { | 144 switch (type) { |
| 145 // When entering the login screen or non-guest desktop. |
142 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: | 146 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: |
143 case chrome::NOTIFICATION_SESSION_STARTED: { | 147 case chrome::NOTIFICATION_SESSION_STARTED: { |
144 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); | 148 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); |
145 SetProfile(profile); | 149 if (!profile->IsGuestSession()) |
| 150 SetProfile(profile); |
| 151 break; |
| 152 } |
| 153 // When entering guest desktop, no NOTIFICATION_SESSION_STARTED event is |
| 154 // fired, so we use NOTIFICATION_PROFILE_CREATED event instead. |
| 155 case chrome::NOTIFICATION_PROFILE_CREATED: { |
| 156 Profile* profile = content::Source<Profile>(source).ptr(); |
| 157 if (profile->IsGuestSession()) |
| 158 SetProfile(profile); |
146 break; | 159 break; |
147 } | 160 } |
148 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 161 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
149 SetProfile(NULL); | 162 SetProfile(NULL); |
150 break; | 163 break; |
151 } | 164 } |
152 } | 165 } |
153 } | 166 } |
154 | 167 |
155 bool first_time_update_; | 168 bool first_time_update_; |
(...skipping 17 matching lines...) Expand all Loading... |
173 delete g_magnification_manager; | 186 delete g_magnification_manager; |
174 g_magnification_manager = NULL; | 187 g_magnification_manager = NULL; |
175 } | 188 } |
176 | 189 |
177 // static | 190 // static |
178 MagnificationManager* MagnificationManager::Get() { | 191 MagnificationManager* MagnificationManager::Get() { |
179 return g_magnification_manager; | 192 return g_magnification_manager; |
180 } | 193 } |
181 | 194 |
182 } // namespace chromeos | 195 } // namespace chromeos |
OLD | NEW |