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

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

Issue 11550010: Remove partial magnifier from settings page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a boolean pref instead of string pref. 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 | « no previous file | chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc » ('j') | 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"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 void SetMagnifier(ash::MagnifierType type) OVERRIDE { 58 void SetMagnifier(ash::MagnifierType type) OVERRIDE {
59 if (type == type_ && type == ash::MAGNIFIER_OFF) 59 if (type == type_ && type == ash::MAGNIFIER_OFF)
60 return; 60 return;
61 61
62 type_ = type; 62 type_ = type;
63 63
64 if (profile_) { 64 if (profile_) {
65 PrefService* prefs = profile_->GetPrefs(); 65 PrefService* prefs = profile_->GetPrefs();
66 if (prefs) { 66 if (prefs) {
67 std::string typeString = 67 bool enabled = (type != ash::MAGNIFIER_OFF);
68 accessibility::ScreenMagnifierNameFromType(type); 68 if (enabled != prefs->GetBoolean(prefs::kScreenMagnifierEnabled)) {
69 if (typeString != prefs->GetString(prefs::kMagnifierType)) { 69 prefs->SetBoolean(prefs::kScreenMagnifierEnabled, enabled);
70 prefs->SetString(prefs::kMagnifierType, typeString);
71 prefs->CommitPendingWrite(); 70 prefs->CommitPendingWrite();
72 } 71 }
73 } 72 }
74 } 73 }
75 74
76 content::NotificationService::current()->Notify( 75 content::NotificationService::current()->Notify(
77 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, 76 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER,
78 content::NotificationService::AllSources(), 77 content::NotificationService::AllSources(),
79 content::NotificationService::NoDetails()); 78 content::NotificationService::NoDetails());
80 79
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 112 }
114 113
115 ash::MagnifierType GetMagnifierTypeFromPref() { 114 ash::MagnifierType GetMagnifierTypeFromPref() {
116 if (!profile_) 115 if (!profile_)
117 return ash::MAGNIFIER_OFF; 116 return ash::MAGNIFIER_OFF;
118 117
119 PrefService* prefs = profile_->GetPrefs(); 118 PrefService* prefs = profile_->GetPrefs();
120 if (!prefs) 119 if (!prefs)
121 return ash::MAGNIFIER_OFF; 120 return ash::MAGNIFIER_OFF;
122 121
123 return accessibility::MagnifierTypeFromName( 122 return prefs->GetBoolean(prefs::kScreenMagnifierEnabled) ?
124 prefs->GetString(prefs::kMagnifierType).c_str()); 123 ash::MAGNIFIER_FULL : ash::MAGNIFIER_OFF;
125 } 124 }
126 125
127 void SetProfile(Profile* profile) { 126 void SetProfile(Profile* profile) {
128 if (pref_change_registrar_) { 127 if (pref_change_registrar_) {
129 pref_change_registrar_.reset(); 128 pref_change_registrar_.reset();
130 } 129 }
131 130
132 if (profile) { 131 if (profile) {
133 pref_change_registrar_.reset(new PrefChangeRegistrar); 132 pref_change_registrar_.reset(new PrefChangeRegistrar);
134 pref_change_registrar_->Init(profile->GetPrefs()); 133 pref_change_registrar_->Init(profile->GetPrefs());
135 pref_change_registrar_->Add( 134 pref_change_registrar_->Add(
136 prefs::kMagnifierType, 135 prefs::kScreenMagnifierEnabled,
137 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus, 136 base::Bind(&MagnificationManagerImpl::UpdateMagnifierStatus,
138 base::Unretained(this))); 137 base::Unretained(this)));
139 } 138 }
140 139
141 profile_ = profile; 140 profile_ = profile;
142 UpdateMagnifierStatus(); 141 UpdateMagnifierStatus();
143 } 142 }
144 143
145 void UpdateMagnifierStatus() { 144 void UpdateMagnifierStatus() {
146 // Historycally, from r162080 to r170956, screen magnifier had been enabled
147 // with 1.0x scale on login screen by default, hence some users
148 // unintentionally have the pref to enable magnifier. Now, the default scale
149 // is 2.0x on login screen (same as other screens), so despite them, with
150 // the old pref, their screen might be magnified with 2.0x scale.
151 // The following code prevents it. If the user on login screen has full
152 // screen magnifier pref but no scale pref, doesn't make magnifier enabled.
153 // TODO(yoshiki): remove this in the near future: crbug.com/164627
154 if (first_time_update_) {
155 first_time_update_ = false;
156 UserManager* manager = UserManager::Get();
157 if (profile_ &&
158 !profile_->GetPrefs()->HasPrefPath(prefs::kScreenMagnifierScale) &&
159 accessibility::MagnifierTypeFromName(profile_->GetPrefs()->GetString(
160 prefs::kMagnifierType).c_str()) == ash::MAGNIFIER_FULL &&
161 manager &&
162 !manager->IsSessionStarted()) {
163 SetMagnifier(ash::MAGNIFIER_OFF);
164 profile_->GetPrefs()->SetDouble(prefs::kScreenMagnifierScale,
165 kInitialMagnifiedScale);
166 return;
167 }
168 }
169
170 ash::MagnifierType type = GetMagnifierTypeFromPref(); 145 ash::MagnifierType type = GetMagnifierTypeFromPref();
171 SetMagnifier(type); 146 SetMagnifier(type);
172 } 147 }
173 148
174 // content::NotificationObserver implimentation: 149 // content::NotificationObserver implimentation:
175 virtual void Observe(int type, 150 virtual void Observe(int type,
176 const content::NotificationSource& source, 151 const content::NotificationSource& source,
177 const content::NotificationDetails& details) OVERRIDE { 152 const content::NotificationDetails& details) OVERRIDE {
178 switch (type) { 153 switch (type) {
179 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE: 154 case chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 delete g_magnification_manager; 186 delete g_magnification_manager;
212 g_magnification_manager = NULL; 187 g_magnification_manager = NULL;
213 } 188 }
214 189
215 // static 190 // static
216 MagnificationManager* MagnificationManager::Get() { 191 MagnificationManager* MagnificationManager::Get() {
217 return g_magnification_manager; 192 return g_magnification_manager;
218 } 193 }
219 194
220 } // namespace chromeos 195 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/accessibility/magnification_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698