Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1457)

Side by Side Diff: chrome/browser/chromeos/accessibility/magnification_manager.cc

Issue 11442036: Magnifier: Change the login-screen default scale from 1.0x to 2.0x (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray_accessibility.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "chrome/browser/api/prefs/pref_member.h" 13 #include "chrome/browser/api/prefs/pref_member.h"
14 #include "chrome/browser/chromeos/login/user_manager.h" 14 #include "chrome/browser/chromeos/login/user_manager.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 namespace { 27 namespace {
28 const double kInitialMagnifiedScale = 2.0;
28 static MagnificationManager* g_magnification_manager = NULL; 29 static MagnificationManager* g_magnification_manager = NULL;
29 } 30 }
30 31
31 class MagnificationManagerImpl : public MagnificationManager, 32 class MagnificationManagerImpl : public MagnificationManager,
32 public content::NotificationObserver { 33 public content::NotificationObserver {
33 public: 34 public:
34 MagnificationManagerImpl() : profile_(NULL), 35 MagnificationManagerImpl() : first_time_update_(true),
36 profile_(NULL),
35 type_(ash::MAGNIFIER_OFF) { 37 type_(ash::MAGNIFIER_OFF) {
36 registrar_.Add(this, 38 registrar_.Add(this,
37 chrome::NOTIFICATION_SESSION_STARTED, 39 chrome::NOTIFICATION_SESSION_STARTED,
38 content::NotificationService::AllSources()); 40 content::NotificationService::AllSources());
39 registrar_.Add(this, 41 registrar_.Add(this,
40 chrome::NOTIFICATION_PROFILE_DESTROYED, 42 chrome::NOTIFICATION_PROFILE_DESTROYED,
41 content::NotificationService::AllSources()); 43 content::NotificationService::AllSources());
42 registrar_.Add(this, 44 registrar_.Add(this,
43 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, 45 chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
44 content::NotificationService::AllSources()); 46 content::NotificationService::AllSources());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 prefs::kMagnifierType, 131 prefs::kMagnifierType,
130 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus, 132 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus,
131 base::Unretained(this))); 133 base::Unretained(this)));
132 } 134 }
133 135
134 profile_ = profile; 136 profile_ = profile;
135 UpdateMagnifierStatus(); 137 UpdateMagnifierStatus();
136 } 138 }
137 139
138 void UpdateMagnifierStatus() { 140 void UpdateMagnifierStatus() {
141 // Historycally, from r162080 to r170956, screen magnifier had been enabled
142 // with 1.0x scale on login screen by default, hence some users
143 // unintentionally have the pref to enable magnifier. Now, the default scale
144 // is 2.0x on login screen (same as other screens), so despite them, with
145 // the old pref, their screen might be magnified with 2.0x scale.
146 // The following code prevents it. If the user on login screen has full
147 // screen magnifier pref but no scale pref, doesn't make magnifier enabled.
Daniel Erat 2012/12/06 15:15:47 nit: can you add a TODO and/or bug to remove this
148 if (first_time_update_) {
149 first_time_update_ = false;
150 UserManager* manager = UserManager::Get();
151 if (profile_ &&
152 !profile_->GetPrefs()->HasPrefPath(prefs::kScreenMagnifierScale) &&
153 accessibility::MagnifierTypeFromName(profile_->GetPrefs()->GetString(
154 prefs::kMagnifierType).c_str()) == ash::MAGNIFIER_FULL &&
155 manager &&
156 !manager->IsSessionStarted()) {
157 SetMagnifier(ash::MAGNIFIER_OFF);
158 profile_->GetPrefs()->SetDouble(prefs::kScreenMagnifierScale,
159 kInitialMagnifiedScale);
160 return;
161 }
162 }
163
139 ash::MagnifierType type = GetMagnifierTypeFromPref(); 164 ash::MagnifierType type = GetMagnifierTypeFromPref();
140 SetMagnifier(type); 165 SetMagnifier(type);
141 } 166 }
142 167
143 // content::NotificationObserver implimentation: 168 // content::NotificationObserver implimentation:
144 virtual void Observe(int type, 169 virtual void Observe(int type,
145 const content::NotificationSource& source, 170 const content::NotificationSource& source,
146 const content::NotificationDetails& details) OVERRIDE { 171 const content::NotificationDetails& details) OVERRIDE {
147 switch (type) { 172 switch (type) {
148 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: 173 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE:
149 case chrome::NOTIFICATION_SESSION_STARTED: { 174 case chrome::NOTIFICATION_SESSION_STARTED: {
150 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord(); 175 Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
151 SetProfile(profile); 176 SetProfile(profile);
152 break; 177 break;
153 } 178 }
154 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 179 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
155 SetProfile(NULL); 180 SetProfile(NULL);
156 break; 181 break;
157 } 182 }
158 } 183 }
159 } 184 }
160 185
186 bool first_time_update_;
161 Profile* profile_; 187 Profile* profile_;
162 ash::MagnifierType type_; 188 ash::MagnifierType type_;
163 content::NotificationRegistrar registrar_; 189 content::NotificationRegistrar registrar_;
164 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; 190 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
165 191
166 ObserverList<MagnificationObserver> observers_; 192 ObserverList<MagnificationObserver> observers_;
167 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerImpl); 193 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerImpl);
168 }; 194 };
169 195
170 // static 196 // static
171 void MagnificationManager::Initialize() { 197 void MagnificationManager::Initialize() {
172 CHECK(g_magnification_manager == NULL); 198 CHECK(g_magnification_manager == NULL);
173 g_magnification_manager = new MagnificationManagerImpl(); 199 g_magnification_manager = new MagnificationManagerImpl();
174 } 200 }
175 201
176 // static 202 // static
177 void MagnificationManager::Shutdown() { 203 void MagnificationManager::Shutdown() {
178 CHECK(g_magnification_manager); 204 CHECK(g_magnification_manager);
179 delete g_magnification_manager; 205 delete g_magnification_manager;
180 g_magnification_manager = NULL; 206 g_magnification_manager = NULL;
181 } 207 }
182 208
183 // static 209 // static
184 MagnificationManager* MagnificationManager::Get() { 210 MagnificationManager* MagnificationManager::Get() {
185 return g_magnification_manager; 211 return g_magnification_manager;
186 } 212 }
187 213
188 } // namespace chromeos 214 } // namespace chromeos
OLDNEW
« no previous file with comments | « ash/system/tray_accessibility.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698