0

cros: Remove unused a11y partial screen magnifier code

The partial screen ("lens") magnifier accessibility feature was
deprioritized in 2013 and never shipped. Removing the code eliminates
ash-to-chrome delegate methods, which we need to do for go/mustash.

Bug: 170850, 594887
Test: ash_unittests, chrome browser_tests
Change-Id: I258761fbecedc5d6ebfe888e08a19756a2371566
Reviewed-on: https://chromium-review.googlesource.com/636347
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#498468}
This commit is contained in:
James Cook
2017-08-30 15:18:24 +00:00
committed by Commit Bot
parent 92cceac320
commit db81c76776
18 changed files with 25 additions and 261 deletions

@ -33,15 +33,9 @@ class ASH_EXPORT AccessibilityDelegate {
// Invoked to enable the screen magnifier.
virtual void SetMagnifierEnabled(bool enabled) = 0;
// Invoked to change the type of the screen magnifier.
virtual void SetMagnifierType(MagnifierType type) = 0;
// Returns true if the screen magnifier is enabled.
virtual bool IsMagnifierEnabled() const = 0;
// Returns the current screen magnifier mode.
virtual MagnifierType GetMagnifierType() const = 0;
// Invoked to enable Large Cursor.
virtual void SetLargeCursorEnabled(bool enabled) = 0;

@ -24,14 +24,12 @@ enum AccessibilityAlert {
// Note: Do not change these values; UMA and prefs depend on them.
enum MagnifierType {
MAGNIFIER_DISABLED = 0, // Used by enterprise policy.
MAGNIFIER_FULL = 1,
MAGNIFIER_PARTIAL = 2,
// Never shipped. Deprioritized in 2013. http://crbug.com/170850
// MAGNIFIER_PARTIAL = 2,
};
const int kMaxMagnifierType = 2;
const MagnifierType kDefaultMagnifierType = MAGNIFIER_FULL;
// Factor of magnification scale. For example, when this value is 1.189, scale
// value will be changed x1.000, x1.189, x1.414, x1.681, x2.000, ...
// Note: this value is 2.0 ^ (1 / 4).

@ -28,18 +28,10 @@ void DefaultAccessibilityDelegate::SetMagnifierEnabled(bool enabled) {
screen_magnifier_enabled_ = enabled;
}
void DefaultAccessibilityDelegate::SetMagnifierType(MagnifierType type) {
screen_magnifier_type_ = type;
}
bool DefaultAccessibilityDelegate::IsMagnifierEnabled() const {
return screen_magnifier_enabled_;
}
MagnifierType DefaultAccessibilityDelegate::GetMagnifierType() const {
return screen_magnifier_type_;
}
void DefaultAccessibilityDelegate::SetLargeCursorEnabled(bool enabled) {
large_cursor_enabled_ = enabled;
}

@ -21,9 +21,7 @@ class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate {
void ToggleHighContrast() override;
bool IsHighContrastEnabled() const override;
void SetMagnifierEnabled(bool enabled) override;
void SetMagnifierType(MagnifierType type) override;
bool IsMagnifierEnabled() const override;
MagnifierType GetMagnifierType() const override;
void SetLargeCursorEnabled(bool enabled) override;
bool IsLargeCursorEnabled() const override;
void SetAutoclickEnabled(bool enabled) override;
@ -66,7 +64,6 @@ class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate {
bool spoken_feedback_enabled_ = false;
bool high_contrast_enabled_ = false;
bool screen_magnifier_enabled_ = false;
MagnifierType screen_magnifier_type_ = kDefaultMagnifierType;
bool large_cursor_enabled_ = false;
bool autoclick_enabled_ = false;
bool virtual_keyboard_enabled_ = false;
@ -79,6 +76,7 @@ class ASH_EXPORT DefaultAccessibilityDelegate : public AccessibilityDelegate {
bool select_to_speak_enabled_ = false;
bool switch_access_enabled_ = false;
AccessibilityAlert accessibility_alert_ = A11Y_ALERT_NONE;
DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityDelegate);
};

@ -32,6 +32,7 @@ const char kAccessibilityScreenMagnifierCenterFocus[] =
// An integer pref which determines what type of screen magnifier is enabled.
// Note that: 'screen_magnifier_type' had been used as string pref. Hence,
// we are using another name pref here.
// NOTE: We only shipped one type (full). http://crbug.com/170850
const char kAccessibilityScreenMagnifierType[] =
"settings.a11y.screen_magnifier_type2";
// A double pref which determines a zooming scale of the screen magnifier.

@ -158,17 +158,6 @@ AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
ash::AccessibilityNotificationVisibility notify)
: notification_type(notification_type),
enabled(enabled),
magnifier_type(ash::kDefaultMagnifierType),
notify(notify) {}
AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
AccessibilityNotificationType notification_type,
bool enabled,
ash::MagnifierType magnifier_type,
ash::AccessibilityNotificationVisibility notify)
: notification_type(notification_type),
enabled(enabled),
magnifier_type(magnifier_type),
notify(notify) {}
///////////////////////////////////////////////////////////////////////////////
@ -1383,12 +1372,8 @@ void AccessibilityManager::UpdateChromeOSAccessibilityHistograms() {
IsVirtualKeyboardEnabled());
UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosStickyKeys", IsStickyKeysEnabled());
if (MagnificationManager::Get()) {
uint32_t type = MagnificationManager::Get()->IsMagnifierEnabled()
? MagnificationManager::Get()->GetMagnifierType()
: 0;
// '0' means magnifier is disabled.
UMA_HISTOGRAM_ENUMERATION("Accessibility.CrosScreenMagnifier", type,
ash::kMaxMagnifierType + 1);
UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosScreenMagnifier",
MagnificationManager::Get()->IsMagnifierEnabled());
}
if (profile_) {
const PrefService* const prefs = profile_->GetPrefs();

@ -62,15 +62,8 @@ struct AccessibilityStatusEventDetails {
bool enabled,
ash::AccessibilityNotificationVisibility notify);
AccessibilityStatusEventDetails(
AccessibilityNotificationType notification_type,
bool enabled,
ash::MagnifierType magnifier_type,
ash::AccessibilityNotificationVisibility notify);
AccessibilityNotificationType notification_type;
bool enabled;
ash::MagnifierType magnifier_type;
ash::AccessibilityNotificationVisibility notify;
};

@ -44,11 +44,8 @@ class MagnificationManagerImpl
: profile_(NULL),
magnifier_enabled_pref_handler_(
ash::prefs::kAccessibilityScreenMagnifierEnabled),
magnifier_type_pref_handler_(
ash::prefs::kAccessibilityScreenMagnifierType),
magnifier_scale_pref_handler_(
ash::prefs::kAccessibilityScreenMagnifierScale),
type_(ash::kDefaultMagnifierType),
enabled_(false),
keep_focus_centered_(false),
observing_focus_change_in_page_(false) {
@ -70,8 +67,6 @@ class MagnificationManagerImpl
// MagnificationManager implimentation:
bool IsMagnifierEnabled() const override { return enabled_; }
ash::MagnifierType GetMagnifierType() const override { return type_; }
void SetMagnifierEnabled(bool enabled) override {
if (!profile_)
return;
@ -82,15 +77,6 @@ class MagnificationManagerImpl
prefs->CommitPendingWrite();
}
void SetMagnifierType(ash::MagnifierType type) override {
if (!profile_)
return;
PrefService* prefs = profile_->GetPrefs();
prefs->SetInteger(ash::prefs::kAccessibilityScreenMagnifierType, type);
prefs->CommitPendingWrite();
}
void SaveScreenMagnifierScale(double scale) override {
if (!profile_)
return;
@ -127,10 +113,6 @@ class MagnificationManagerImpl
ash::prefs::kAccessibilityScreenMagnifierEnabled,
base::Bind(&MagnificationManagerImpl::UpdateMagnifierFromPrefs,
base::Unretained(this)));
pref_change_registrar_->Add(
ash::prefs::kAccessibilityScreenMagnifierType,
base::Bind(&MagnificationManagerImpl::UpdateMagnifierFromPrefs,
base::Unretained(this)));
pref_change_registrar_->Add(
ash::prefs::kAccessibilityScreenMagnifierCenterFocus,
base::Bind(&MagnificationManagerImpl::UpdateMagnifierFromPrefs,
@ -138,7 +120,6 @@ class MagnificationManagerImpl
}
magnifier_enabled_pref_handler_.HandleProfileChanged(profile_, profile);
magnifier_type_pref_handler_.HandleProfileChanged(profile_, profile);
magnifier_scale_pref_handler_.HandleProfileChanged(profile_, profile);
profile_ = profile;
@ -156,20 +137,8 @@ class MagnificationManagerImpl
enabled_ = enabled;
if (type_ == ash::MAGNIFIER_FULL) {
ash::Shell::Get()->magnification_controller()->SetEnabled(enabled_);
MonitorFocusInPageChange();
} else {
ash::Shell::Get()->partial_magnification_controller()->SetEnabled(
enabled_);
}
}
virtual void SetMagnifierTypeInternal(ash::MagnifierType type) {
if (type_ == type)
return;
type_ = ash::MAGNIFIER_FULL; // (leave out for full magnifier)
ash::Shell::Get()->magnification_controller()->SetEnabled(enabled_);
MonitorFocusInPageChange();
}
virtual void SetMagniferKeepFocusCenteredInternal(bool keep_focus_centered) {
@ -178,10 +147,8 @@ class MagnificationManagerImpl
keep_focus_centered_ = keep_focus_centered;
if (type_ == ash::MAGNIFIER_FULL) {
ash::Shell::Get()->magnification_controller()->SetKeepFocusCentered(
keep_focus_centered_);
}
}
void UpdateMagnifierFromPrefs() {
@ -190,34 +157,19 @@ class MagnificationManagerImpl
const bool enabled = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilityScreenMagnifierEnabled);
const int type_integer = profile_->GetPrefs()->GetInteger(
ash::prefs::kAccessibilityScreenMagnifierType);
const bool keep_focus_centered = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilityScreenMagnifierCenterFocus);
ash::MagnifierType type = ash::kDefaultMagnifierType;
if (type_integer > 0 && type_integer <= ash::kMaxMagnifierType) {
type = static_cast<ash::MagnifierType>(type_integer);
} else if (type_integer == 0) {
// Type 0 is used to disable the screen magnifier through policy. As the
// magnifier type is irrelevant in this case, it is OK to just fall back
// to the default.
} else {
NOTREACHED();
}
if (!enabled) {
SetMagnifierEnabledInternal(enabled);
SetMagnifierTypeInternal(type);
SetMagniferKeepFocusCenteredInternal(keep_focus_centered);
} else {
SetMagniferKeepFocusCenteredInternal(keep_focus_centered);
SetMagnifierTypeInternal(type);
SetMagnifierEnabledInternal(enabled);
}
AccessibilityStatusEventDetails details(
ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, enabled_, type_,
ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, enabled_,
ash::A11Y_NOTIFICATION_NONE);
if (AccessibilityManager::Get()) {
@ -283,10 +235,8 @@ class MagnificationManagerImpl
Profile* profile_;
AccessibilityManager::PrefHandler magnifier_enabled_pref_handler_;
AccessibilityManager::PrefHandler magnifier_type_pref_handler_;
AccessibilityManager::PrefHandler magnifier_scale_pref_handler_;
ash::MagnifierType type_;
bool enabled_;
bool keep_focus_centered_;
bool observing_focus_change_in_page_;

@ -5,7 +5,6 @@
#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_MAGNIFICATION_MANAGER_H_
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_MAGNIFICATION_MANAGER_H_
#include "ash/accessibility_types.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
class Profile;
@ -20,12 +19,9 @@ namespace chromeos {
// desktop.
// - Watch change of the pref. When the pref changes, the setting of the
// magnifier will interlock with it.
class MagnificationManager {
public:
// Creates an instance of MagnificationManager. This should be called once,
// Returns the existing instance. If there is no instance, creates one.
// because only one instance should exist at the same time.
// Creates an instance of MagnificationManager. This should be called once.
static void Initialize();
// Deletes the existing instance of MagnificationManager.
@ -37,15 +33,9 @@ class MagnificationManager {
// Returns if the screen magnifier is enabled.
virtual bool IsMagnifierEnabled() const = 0;
// Returns the current type of the screen magnifier.
virtual ash::MagnifierType GetMagnifierType() const = 0;
// Enables the screen magnifier.
virtual void SetMagnifierEnabled(bool enabled) = 0;
// Changes the type of the screen magnifier.
virtual void SetMagnifierType(ash::MagnifierType type) = 0;
// Saves the magnifier scale to the pref.
virtual void SaveScreenMagnifierScale(double scale) = 0;

@ -39,10 +39,6 @@ void SetMagnifierEnabled(bool enabled) {
MagnificationManager::Get()->SetMagnifierEnabled(enabled);
}
void SetMagnifierType(ash::MagnifierType type) {
MagnificationManager::Get()->SetMagnifierType(type);
}
void SetFullScreenMagnifierScale(double scale) {
ash::Shell::Get()->magnification_controller()->SetScale(scale, false);
}
@ -59,10 +55,6 @@ double GetSavedFullScreenMagnifierScale() {
return MagnificationManager::Get()->GetSavedScreenMagnifierScale();
}
ash::MagnifierType GetMagnifierType() {
return MagnificationManager::Get()->GetMagnifierType();
}
bool IsMagnifierEnabled() {
return MagnificationManager::Get()->IsMagnifierEnabled();
}
@ -122,10 +114,7 @@ void StartUserSession(const AccountId& account_id) {
class MockMagnificationObserver {
public:
MockMagnificationObserver() : observed_(false),
observed_enabled_(false),
magnifier_type_(-1)
{
MockMagnificationObserver() {
AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
CHECK(accessibility_manager);
accessibility_subscription_ = accessibility_manager->RegisterCallback(
@ -137,7 +126,6 @@ class MockMagnificationObserver {
bool observed() const { return observed_; }
bool observed_enabled() const { return observed_enabled_; }
int magnifier_type() const { return magnifier_type_; }
void reset() { observed_ = false; }
@ -145,15 +133,13 @@ class MockMagnificationObserver {
void OnAccessibilityStatusChanged(
const AccessibilityStatusEventDetails& details) {
if (details.notification_type == ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER) {
magnifier_type_ = details.magnifier_type;
observed_enabled_ = details.enabled;
observed_ = true;
}
}
bool observed_;
bool observed_enabled_;
int magnifier_type_;
bool observed_ = false;
bool observed_enabled_ = false;
std::unique_ptr<AccessibilityStatusSubscription> accessibility_subscription_;
@ -215,7 +201,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToOff) {
SetMagnifierEnabled(true);
// Confirms that magnifier is enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
}
@ -233,10 +218,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) {
// Enables magnifier on login screen.
SetMagnifierEnabled(true);
SetMagnifierType(ash::MAGNIFIER_FULL);
SetFullScreenMagnifierScale(2.5);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
// Logs in (but the session is not started yet).
@ -245,7 +228,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToOff) {
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
StartUserSession(test_account_id_);
@ -281,7 +263,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginOffToFull) {
// Confirms that the magnifier is enabled and configured according to the
// explicitly set prefs just after session start.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
}
@ -298,11 +279,9 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToFull) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) {
// Enables magnifier on login screen.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
SetFullScreenMagnifierScale(3.0);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(3.0, GetFullScreenMagnifierScale());
// Logs in (but the session is not started yet).
@ -311,14 +290,12 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToFull) {
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
StartUserSession(test_account_id_);
// Confirms that the magnifier is enabled and configured according to the
// explicitly set prefs just after session start.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
}
@ -330,10 +307,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, PRE_LoginFullToUnset) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) {
// Enables full screen magnifier.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Logs in (but the session is not started yet).
session_manager::SessionManager::Get()->CreateSession(test_account_id_,
@ -341,7 +316,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginFullToUnset) {
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
StartUserSession(test_account_id_);
@ -373,11 +347,9 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserOff) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) {
// Enables magnifier on login screen.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
SetFullScreenMagnifierScale(2.5);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
// Logs in (but the session is not started yet).
@ -386,13 +358,11 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserFull) {
// Confirms that magnifier is keeping enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
StartUserSession(test_account_id_);
// Confirms that magnifier keeps enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
EXPECT_TRUE(GetScreenMagnifierEnabledFromPref());
}
@ -415,63 +385,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, LoginAsNewUserUnset) {
EXPECT_FALSE(GetScreenMagnifierEnabledFromPref());
}
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ChangeMagnifierType) {
// Enables/disables full screen magnifier.
SetMagnifierEnabled(false);
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierEnabled(false);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Enables/disables partial screen magnifier.
SetMagnifierType(ash::MAGNIFIER_PARTIAL);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierEnabled(false);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Changes the magnifier type when the magnifier is enabled.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierType(ash::MAGNIFIER_PARTIAL);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Changes the magnifier type when the magnifier is disabled.
SetMagnifierEnabled(false);
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierType(ash::MAGNIFIER_PARTIAL);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
}
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
// Logs in
session_manager::SessionManager::Get()->CreateSession(test_account_id_,
@ -486,7 +399,6 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, TypePref) {
SetScreenMagnifierEnabledPref(true);
// Confirms that magnifier is enabled.
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
}
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) {
@ -497,10 +409,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, ScalePref) {
SetSavedFullScreenMagnifierScale(2.5);
// Enables full screen magnifier.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Confirms that 2.5x is restored.
EXPECT_EQ(2.5, GetFullScreenMagnifierScale());
@ -519,10 +429,8 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) {
SetSavedFullScreenMagnifierScale(0.5);
// Enables full screen magnifier.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Confirms that the actual scale is set to the minimum scale.
EXPECT_EQ(1.0, GetFullScreenMagnifierScale());
@ -537,31 +445,25 @@ IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, InvalidScalePref) {
// Enables full screen magnifier.
SetMagnifierEnabled(true);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, GetMagnifierType());
// Confirms that the actual scale is set to the maximum scale.
EXPECT_EQ(4.0, GetFullScreenMagnifierScale());
}
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest,
ChangingTypeInvokesNotification) {
IN_PROC_BROWSER_TEST_F(MagnificationManagerTest, MagnificationObserver) {
MockMagnificationObserver observer;
EXPECT_FALSE(observer.observed());
// Set full screen magnifier, and confirm the observer is called.
SetMagnifierEnabled(true);
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_TRUE(observer.observed());
EXPECT_TRUE(observer.observed_enabled());
EXPECT_EQ(observer.magnifier_type(), ash::MAGNIFIER_FULL);
EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
observer.reset();
// Set full screen magnifier again, and confirm the observer is not called.
SetMagnifierType(ash::MAGNIFIER_FULL);
SetMagnifierEnabled(true);
EXPECT_FALSE(observer.observed());
EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
observer.reset();
}

@ -25,20 +25,12 @@ bool IsMagnifierEnabled() {
return MagnificationManager::Get()->IsMagnifierEnabled();
}
ash::MagnifierType GetMagnifierType() {
return MagnificationManager::Get()->GetMagnifierType();
}
void SetMagnifierType(ash::MagnifierType type) {
return MagnificationManager::Get()->SetMagnifierType(type);
}
} // namespace
class MagnificationManagerTest : public ash::AshTestBase {
public:
MagnificationManagerTest() {
}
MagnificationManagerTest() = default;
~MagnificationManagerTest() override = default;
void SetUp() override {
ash::AshTestBase::SetUp();
@ -55,22 +47,14 @@ class MagnificationManagerTest : public ash::AshTestBase {
TestingProfile profile_;
};
TEST_F(MagnificationManagerTest, ChangeType) {
TEST_F(MagnificationManagerTest, EnableDisable) {
// Set full screen magnifier, and confirm the status is set successfully.
EnableMagnifier();
SetMagnifierType(ash::MAGNIFIER_FULL);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
// Set partial screen magnifier, and confirm the change is ignored.
SetMagnifierType(ash::MAGNIFIER_PARTIAL);
EXPECT_TRUE(IsMagnifierEnabled());
EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
// Disables magnifier, and confirm the status is set successfully.
DisableMagnifier();
EXPECT_FALSE(IsMagnifierEnabled());
EXPECT_EQ(GetMagnifierType(), ash::MAGNIFIER_FULL);
}
} // namespace chromeos

@ -339,7 +339,7 @@ void PinnedLauncherAppsPolicyHandler::ApplyList(
ScreenMagnifierPolicyHandler::ScreenMagnifierPolicyHandler()
: IntRangePolicyHandlerBase(key::kScreenMagnifierType,
0,
ash::MAGNIFIER_DISABLED,
ash::MAGNIFIER_FULL,
false) {}
@ -353,7 +353,7 @@ void ScreenMagnifierPolicyHandler::ApplyPolicySettings(
int value_in_range;
if (value && EnsureInRange(value, &value_in_range, NULL)) {
prefs->SetBoolean(ash::prefs::kAccessibilityScreenMagnifierEnabled,
value_in_range != 0);
value_in_range != ash::MAGNIFIER_DISABLED);
prefs->SetInteger(ash::prefs::kAccessibilityScreenMagnifierType,
value_in_range);
}

@ -333,7 +333,6 @@ IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest,
chromeos::MagnificationManager::Get();
ASSERT_TRUE(magnification_manager);
EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
}
IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest,
@ -434,8 +433,6 @@ IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyInSessionBrowsertest,
chromeos::MagnificationManager::Get();
ASSERT_TRUE(magnification_manager);
EXPECT_FALSE(magnification_manager->IsMagnifierEnabled());
EXPECT_EQ(ash::kDefaultMagnifierType,
magnification_manager->GetMagnifierType());
}
IN_PROC_BROWSER_TEST_F(LoginScreenDefaultPolicyLoginScreenBrowsertest,

@ -200,7 +200,7 @@ void Preferences::RegisterProfilePrefs(
ash::prefs::kAccessibilityScreenMagnifierEnabled, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterIntegerPref(
ash::prefs::kAccessibilityScreenMagnifierType, ash::kDefaultMagnifierType,
ash::prefs::kAccessibilityScreenMagnifierType, ash::MAGNIFIER_FULL,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterDoublePref(ash::prefs::kAccessibilityScreenMagnifierScale,
std::numeric_limits<double>::min());

@ -1037,8 +1037,8 @@ std::unique_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
handlers->AddHandler(base::MakeUnique<IntRangePolicyHandler>(
key::kUptimeLimit, prefs::kUptimeLimit, 3600, INT_MAX, true));
handlers->AddHandler(base::WrapUnique(new IntRangePolicyHandler(
key::kDeviceLoginScreenDefaultScreenMagnifierType, NULL, 0,
ash::MAGNIFIER_FULL, false)));
key::kDeviceLoginScreenDefaultScreenMagnifierType, nullptr,
ash::MAGNIFIER_DISABLED, ash::MAGNIFIER_FULL, false)));
// TODO(binjin): Remove LegacyPoliciesDeprecatingPolicyHandler for these two
// policies once deprecation of legacy power management policies is done.
// http://crbug.com/346229

@ -2873,9 +2873,7 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeNone) {
chromeos::MagnificationManager::Get();
// Manually enable the full-screen magnifier.
magnification_manager->SetMagnifierType(ash::MAGNIFIER_FULL);
magnification_manager->SetMagnifierEnabled(true);
EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
// Verify that policy overrides the manual setting.
@ -2905,7 +2903,6 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ScreenMagnifierTypeFull) {
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
base::MakeUnique<base::Value>(ash::MAGNIFIER_FULL), nullptr);
UpdateProviderPolicy(policies);
EXPECT_EQ(ash::MAGNIFIER_FULL, magnification_manager->GetMagnifierType());
EXPECT_TRUE(magnification_manager->IsMagnifierEnabled());
// Verify that the screen magnifier cannot be disabled manually anymore.

@ -9,7 +9,6 @@
#include "ash/accessibility_types.h"
#include "ash/high_contrast/high_contrast_controller.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/magnifier/partial_magnification_controller.h"
#include "ash/mus/bridge/shell_port_mash.h"
#include "ash/mus/window_manager.h"
#include "ash/public/cpp/config.h"
@ -123,14 +122,8 @@ AshInit::AshInit() {
chromeos::AccessibilityManager::Get()->IsHighContrastEnabled());
DCHECK(chromeos::MagnificationManager::Get());
bool magnifier_enabled =
chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
ash::MagnifierType magnifier_type =
chromeos::MagnificationManager::Get()->GetMagnifierType();
shell->magnification_controller()->SetEnabled(
magnifier_enabled && magnifier_type == ash::MAGNIFIER_FULL);
shell->partial_magnification_controller()->SetEnabled(
magnifier_enabled && magnifier_type == ash::MAGNIFIER_PARTIAL);
chromeos::MagnificationManager::Get()->IsMagnifierEnabled());
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableZeroBrowsersOpenForTests)) {

@ -140,21 +140,11 @@ class AccessibilityDelegateImpl : public ash::AccessibilityDelegate {
return chromeos::MagnificationManager::Get()->SetMagnifierEnabled(enabled);
}
void SetMagnifierType(ash::MagnifierType type) override {
DCHECK(chromeos::MagnificationManager::Get());
return chromeos::MagnificationManager::Get()->SetMagnifierType(type);
}
bool IsMagnifierEnabled() const override {
DCHECK(chromeos::MagnificationManager::Get());
return chromeos::MagnificationManager::Get()->IsMagnifierEnabled();
}
ash::MagnifierType GetMagnifierType() const override {
DCHECK(chromeos::MagnificationManager::Get());
return chromeos::MagnificationManager::Get()->GetMagnifierType();
}
void SetLargeCursorEnabled(bool enabled) override {
DCHECK(AccessibilityManager::Get());
return AccessibilityManager::Get()->EnableLargeCursor(enabled);