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

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

Issue 2078393005: mash: Move accessibility_types.h from ui namespace to ash namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a11y
Patch Set: fix chromevox code generated from js Created 4 years, 6 months 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
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 <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/accessibility_types.h"
10 #include "ash/common/session/session_state_observer.h" 11 #include "ash/common/session/session_state_observer.h"
11 #include "ash/magnifier/magnification_controller.h" 12 #include "ash/magnifier/magnification_controller.h"
12 #include "ash/magnifier/partial_magnification_controller.h" 13 #include "ash/magnifier/partial_magnification_controller.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/shell_delegate.h" 15 #include "ash/shell_delegate.h"
15 #include "ash/system/tray/system_tray_notifier.h" 16 #include "ash/system/tray/system_tray_notifier.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
18 #include "chrome/browser/chrome_notification_types.h" 19 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 20 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
(...skipping 22 matching lines...) Expand all
42 public content::NotificationObserver, 43 public content::NotificationObserver,
43 public ash::SessionStateObserver { 44 public ash::SessionStateObserver {
44 public: 45 public:
45 MagnificationManagerImpl() 46 MagnificationManagerImpl()
46 : profile_(NULL), 47 : profile_(NULL),
47 magnifier_enabled_pref_handler_( 48 magnifier_enabled_pref_handler_(
48 prefs::kAccessibilityScreenMagnifierEnabled), 49 prefs::kAccessibilityScreenMagnifierEnabled),
49 magnifier_type_pref_handler_(prefs::kAccessibilityScreenMagnifierType), 50 magnifier_type_pref_handler_(prefs::kAccessibilityScreenMagnifierType),
50 magnifier_scale_pref_handler_( 51 magnifier_scale_pref_handler_(
51 prefs::kAccessibilityScreenMagnifierScale), 52 prefs::kAccessibilityScreenMagnifierScale),
52 type_(ui::kDefaultMagnifierType), 53 type_(ash::kDefaultMagnifierType),
53 enabled_(false), 54 enabled_(false),
54 keep_focus_centered_(false), 55 keep_focus_centered_(false),
55 observing_focus_change_in_page_(false) { 56 observing_focus_change_in_page_(false) {
56 registrar_.Add(this, 57 registrar_.Add(this,
57 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 58 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
58 content::NotificationService::AllSources()); 59 content::NotificationService::AllSources());
59 registrar_.Add(this, 60 registrar_.Add(this,
60 chrome::NOTIFICATION_SESSION_STARTED, 61 chrome::NOTIFICATION_SESSION_STARTED,
61 content::NotificationService::AllSources()); 62 content::NotificationService::AllSources());
62 registrar_.Add(this, 63 registrar_.Add(this,
63 chrome::NOTIFICATION_PROFILE_DESTROYED, 64 chrome::NOTIFICATION_PROFILE_DESTROYED,
64 content::NotificationService::AllSources()); 65 content::NotificationService::AllSources());
65 } 66 }
66 67
67 ~MagnificationManagerImpl() override { 68 ~MagnificationManagerImpl() override {
68 CHECK(this == g_magnification_manager); 69 CHECK(this == g_magnification_manager);
69 } 70 }
70 71
71 // MagnificationManager implimentation: 72 // MagnificationManager implimentation:
72 bool IsMagnifierEnabled() const override { return enabled_; } 73 bool IsMagnifierEnabled() const override { return enabled_; }
73 74
74 ui::MagnifierType GetMagnifierType() const override { return type_; } 75 ash::MagnifierType GetMagnifierType() const override { return type_; }
75 76
76 void SetMagnifierEnabled(bool enabled) override { 77 void SetMagnifierEnabled(bool enabled) override {
77 if (!profile_) 78 if (!profile_)
78 return; 79 return;
79 80
80 PrefService* prefs = profile_->GetPrefs(); 81 PrefService* prefs = profile_->GetPrefs();
81 prefs->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled); 82 prefs->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, enabled);
82 prefs->CommitPendingWrite(); 83 prefs->CommitPendingWrite();
83 } 84 }
84 85
85 void SetMagnifierType(ui::MagnifierType type) override { 86 void SetMagnifierType(ash::MagnifierType type) override {
86 if (!profile_) 87 if (!profile_)
87 return; 88 return;
88 89
89 PrefService* prefs = profile_->GetPrefs(); 90 PrefService* prefs = profile_->GetPrefs();
90 prefs->SetInteger(prefs::kAccessibilityScreenMagnifierType, type); 91 prefs->SetInteger(prefs::kAccessibilityScreenMagnifierType, type);
91 prefs->CommitPendingWrite(); 92 prefs->CommitPendingWrite();
92 } 93 }
93 94
94 void SaveScreenMagnifierScale(double scale) override { 95 void SaveScreenMagnifierScale(double scale) override {
95 if (!profile_) 96 if (!profile_)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // This method may be invoked even when the other magnifier settings (e.g. 149 // This method may be invoked even when the other magnifier settings (e.g.
149 // type or scale) are changed, so we need to call magnification controller 150 // type or scale) are changed, so we need to call magnification controller
150 // even if |enabled| is unchanged. Only if |enabled| is false and the 151 // even if |enabled| is unchanged. Only if |enabled| is false and the
151 // magnifier is already disabled, we are sure that we don't need to reflect 152 // magnifier is already disabled, we are sure that we don't need to reflect
152 // the new settings right now because the magnifier keeps disabled. 153 // the new settings right now because the magnifier keeps disabled.
153 if (!enabled && !enabled_) 154 if (!enabled && !enabled_)
154 return; 155 return;
155 156
156 enabled_ = enabled; 157 enabled_ = enabled;
157 158
158 if (type_ == ui::MAGNIFIER_FULL) { 159 if (type_ == ash::MAGNIFIER_FULL) {
159 ash::Shell::GetInstance()->magnification_controller()->SetEnabled( 160 ash::Shell::GetInstance()->magnification_controller()->SetEnabled(
160 enabled_); 161 enabled_);
161 MonitorFocusInPageChange(); 162 MonitorFocusInPageChange();
162 } else { 163 } else {
163 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled( 164 ash::Shell::GetInstance()->partial_magnification_controller()->SetEnabled(
164 enabled_); 165 enabled_);
165 } 166 }
166 } 167 }
167 168
168 virtual void SetMagnifierTypeInternal(ui::MagnifierType type) { 169 virtual void SetMagnifierTypeInternal(ash::MagnifierType type) {
169 if (type_ == type) 170 if (type_ == type)
170 return; 171 return;
171 172
172 type_ = ui::MAGNIFIER_FULL; // (leave out for full magnifier) 173 type_ = ash::MAGNIFIER_FULL; // (leave out for full magnifier)
173 } 174 }
174 175
175 virtual void SetMagniferKeepFocusCenteredInternal(bool keep_focus_centered) { 176 virtual void SetMagniferKeepFocusCenteredInternal(bool keep_focus_centered) {
176 if (keep_focus_centered_ == keep_focus_centered) 177 if (keep_focus_centered_ == keep_focus_centered)
177 return; 178 return;
178 179
179 keep_focus_centered_ = keep_focus_centered; 180 keep_focus_centered_ = keep_focus_centered;
180 181
181 if (type_ == ui::MAGNIFIER_FULL) { 182 if (type_ == ash::MAGNIFIER_FULL) {
182 ash::Shell::GetInstance() 183 ash::Shell::GetInstance()
183 ->magnification_controller() 184 ->magnification_controller()
184 ->SetKeepFocusCentered(keep_focus_centered_); 185 ->SetKeepFocusCentered(keep_focus_centered_);
185 } 186 }
186 } 187 }
187 188
188 void UpdateMagnifierFromPrefs() { 189 void UpdateMagnifierFromPrefs() {
189 if (!profile_) 190 if (!profile_)
190 return; 191 return;
191 192
192 const bool enabled = profile_->GetPrefs()->GetBoolean( 193 const bool enabled = profile_->GetPrefs()->GetBoolean(
193 prefs::kAccessibilityScreenMagnifierEnabled); 194 prefs::kAccessibilityScreenMagnifierEnabled);
194 const int type_integer = profile_->GetPrefs()->GetInteger( 195 const int type_integer = profile_->GetPrefs()->GetInteger(
195 prefs::kAccessibilityScreenMagnifierType); 196 prefs::kAccessibilityScreenMagnifierType);
196 const bool keep_focus_centered = profile_->GetPrefs()->GetBoolean( 197 const bool keep_focus_centered = profile_->GetPrefs()->GetBoolean(
197 prefs::kAccessibilityScreenMagnifierCenterFocus); 198 prefs::kAccessibilityScreenMagnifierCenterFocus);
198 199
199 ui::MagnifierType type = ui::kDefaultMagnifierType; 200 ash::MagnifierType type = ash::kDefaultMagnifierType;
200 if (type_integer > 0 && type_integer <= ui::kMaxMagnifierType) { 201 if (type_integer > 0 && type_integer <= ash::kMaxMagnifierType) {
201 type = static_cast<ui::MagnifierType>(type_integer); 202 type = static_cast<ash::MagnifierType>(type_integer);
202 } else if (type_integer == 0) { 203 } else if (type_integer == 0) {
203 // Type 0 is used to disable the screen magnifier through policy. As the 204 // Type 0 is used to disable the screen magnifier through policy. As the
204 // magnifier type is irrelevant in this case, it is OK to just fall back 205 // magnifier type is irrelevant in this case, it is OK to just fall back
205 // to the default. 206 // to the default.
206 } else { 207 } else {
207 NOTREACHED(); 208 NOTREACHED();
208 } 209 }
209 210
210 if (!enabled) { 211 if (!enabled) {
211 SetMagnifierEnabledInternal(enabled); 212 SetMagnifierEnabledInternal(enabled);
212 SetMagnifierTypeInternal(type); 213 SetMagnifierTypeInternal(type);
213 SetMagniferKeepFocusCenteredInternal(keep_focus_centered); 214 SetMagniferKeepFocusCenteredInternal(keep_focus_centered);
214 } else { 215 } else {
215 SetMagniferKeepFocusCenteredInternal(keep_focus_centered); 216 SetMagniferKeepFocusCenteredInternal(keep_focus_centered);
216 SetMagnifierTypeInternal(type); 217 SetMagnifierTypeInternal(type);
217 SetMagnifierEnabledInternal(enabled); 218 SetMagnifierEnabledInternal(enabled);
218 } 219 }
219 220
220 AccessibilityStatusEventDetails details( 221 AccessibilityStatusEventDetails details(
221 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, 222 ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, enabled_, type_,
222 enabled_, 223 ash::A11Y_NOTIFICATION_NONE);
223 type_,
224 ui::A11Y_NOTIFICATION_NONE);
225 224
226 if (AccessibilityManager::Get()) { 225 if (AccessibilityManager::Get()) {
227 AccessibilityManager::Get()->NotifyAccessibilityStatusChanged(details); 226 AccessibilityManager::Get()->NotifyAccessibilityStatusChanged(details);
228 if (ash::Shell::GetInstance()) { 227 if (ash::Shell::GetInstance()) {
229 ash::Shell::GetInstance()->SetCursorCompositingEnabled( 228 ash::Shell::GetInstance()->SetCursorCompositingEnabled(
230 AccessibilityManager::Get()->ShouldEnableCursorCompositing()); 229 AccessibilityManager::Get()->ShouldEnableCursorCompositing());
231 } 230 }
232 } 231 }
233 } 232 }
234 233
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 282 }
284 } 283 }
285 } 284 }
286 285
287 Profile* profile_; 286 Profile* profile_;
288 287
289 AccessibilityManager::PrefHandler magnifier_enabled_pref_handler_; 288 AccessibilityManager::PrefHandler magnifier_enabled_pref_handler_;
290 AccessibilityManager::PrefHandler magnifier_type_pref_handler_; 289 AccessibilityManager::PrefHandler magnifier_type_pref_handler_;
291 AccessibilityManager::PrefHandler magnifier_scale_pref_handler_; 290 AccessibilityManager::PrefHandler magnifier_scale_pref_handler_;
292 291
293 ui::MagnifierType type_; 292 ash::MagnifierType type_;
294 bool enabled_; 293 bool enabled_;
295 bool keep_focus_centered_; 294 bool keep_focus_centered_;
296 bool observing_focus_change_in_page_; 295 bool observing_focus_change_in_page_;
297 296
298 content::NotificationRegistrar registrar_; 297 content::NotificationRegistrar registrar_;
299 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; 298 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
300 std::unique_ptr<ash::ScopedSessionStateObserver> session_state_observer_; 299 std::unique_ptr<ash::ScopedSessionStateObserver> session_state_observer_;
301 300
302 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerImpl); 301 DISALLOW_COPY_AND_ASSIGN(MagnificationManagerImpl);
303 }; 302 };
(...skipping 10 matching lines...) Expand all
314 delete g_magnification_manager; 313 delete g_magnification_manager;
315 g_magnification_manager = NULL; 314 g_magnification_manager = NULL;
316 } 315 }
317 316
318 // static 317 // static
319 MagnificationManager* MagnificationManager::Get() { 318 MagnificationManager* MagnificationManager::Get() {
320 return g_magnification_manager; 319 return g_magnification_manager;
321 } 320 }
322 321
323 } // namespace chromeos 322 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698