summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 04:52:36 +0000
committeryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-13 04:52:36 +0000
commit467585bea136159cef8e6a5daa07410903e48f6f (patch)
tree96f104655e417920b36584254991a5251ef08df6 /ash
parentd0b03ce9d146df58a308818805f2f2d51837d52b (diff)
downloadchromium_src-467585bea136159cef8e6a5daa07410903e48f6f.zip
chromium_src-467585bea136159cef8e6a5daa07410903e48f6f.tar.gz
chromium_src-467585bea136159cef8e6a5daa07410903e48f6f.tar.bz2
Show an a11y notification only if the feature was enabled by its shortcut key
Currently, only spoken feedback has a shortcut key, so this CL supports only it. Major Changes: - Add a |notify| argument to ToggleSpokenFeedback() methods to pass the flag whether the tray should show a notification or not. - (in ash_system_tray_delegate.cc) Use chrome notifications instead of watching pref change to observe the accessibility feature status change. BUG=158288 TEST=manual R=zork@chromium.org,derat@chromium.org TBR=darin@chromium.org,dbeam@chromium.org #TBRing for small changes in chrome/browser/automation and chrome/browser/ui/webui/options Review URL: https://codereview.chromium.org/11510005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_controller.cc4
-rw-r--r--ash/accelerators/accelerator_controller_unittest.cc16
-rw-r--r--ash/shell/shell_delegate_impl.cc3
-rw-r--r--ash/shell/shell_delegate_impl.h3
-rw-r--r--ash/shell_delegate.h8
-rw-r--r--ash/system/tray/system_tray_notifier.cc5
-rw-r--r--ash/system/tray/system_tray_notifier.h3
-rw-r--r--ash/system/tray_accessibility.cc45
-rw-r--r--ash/system/tray_accessibility.h11
-rw-r--r--ash/test/test_shell_delegate.cc3
-rw-r--r--ash/test/test_shell_delegate.h3
11 files changed, 68 insertions, 36 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 22c0e2c..fbe39d1 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -113,9 +113,11 @@ bool HandleCrosh() {
}
bool HandleToggleSpokenFeedback() {
- Shell::GetInstance()->delegate()->ToggleSpokenFeedback();
+ Shell::GetInstance()->delegate()->
+ ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW);
return true;
}
+
void HandleCycleDisplayMode() {
Shell* shell = Shell::GetInstance();
if (!base::chromeos::IsRunningOnChromeOS()) {
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index d75d75d..1c5b9bb6 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -905,12 +905,12 @@ TEST_F(AcceleratorControllerTest,
EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
// When spoken feedback is on, the AppList should not toggle.
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ProcessWithContext(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE)));
EXPECT_FALSE(ProcessWithContext(
ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE)));
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
EXPECT_TRUE(ProcessWithContext(
@@ -920,12 +920,12 @@ TEST_F(AcceleratorControllerTest,
EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
// When spoken feedback is on, the AppList should not toggle.
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ProcessWithContext(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE)));
EXPECT_FALSE(ProcessWithContext(
ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE)));
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
}
@@ -948,12 +948,12 @@ TEST_F(AcceleratorControllerTest,
EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
// When spoken feedback is on, the AppList should not toggle.
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ProcessWithContext(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE)));
EXPECT_FALSE(ProcessWithContext(
ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE)));
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
EXPECT_FALSE(ProcessWithContext(
@@ -963,12 +963,12 @@ TEST_F(AcceleratorControllerTest,
EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
// When spoken feedback is on, the AppList should not toggle.
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ProcessWithContext(
ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE)));
EXPECT_FALSE(ProcessWithContext(
ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE)));
- delegate->ToggleSpokenFeedback();
+ delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility());
}
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 8cf97ba..d53fe07 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -116,7 +116,8 @@ content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() {
return Shell::GetInstance()->browser_context();
}
-void ShellDelegateImpl::ToggleSpokenFeedback() {
+void ShellDelegateImpl::ToggleSpokenFeedback(
+ AccessibilityNotificationVisibility notify) {
spoken_feedback_enabled_ = !spoken_feedback_enabled_;
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 6e0b7c0..ea26561 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -41,7 +41,8 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual void ShowKeyboardOverlay() OVERRIDE;
virtual void ShowTaskManager() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
- virtual void ToggleSpokenFeedback() OVERRIDE;
+ virtual void ToggleSpokenFeedback(
+ AccessibilityNotificationVisibility notify) OVERRIDE;
virtual bool IsSpokenFeedbackEnabled() const OVERRIDE;
virtual void ToggleHighContrast() OVERRIDE;
virtual bool IsHighContrastEnabled() const OVERRIDE;
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 26b54a1..96064e5 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -60,6 +60,11 @@ enum UserMetricsAction {
UMA_TOUCHSCREEN_TAP_DOWN,
};
+enum AccessibilityNotificationVisibility {
+ A11Y_NOTIFICATION_NONE,
+ A11Y_NOTIFICATION_SHOW,
+};
+
// Delegate of the Shell.
class ASH_EXPORT ShellDelegate {
public:
@@ -131,7 +136,8 @@ class ASH_EXPORT ShellDelegate {
virtual content::BrowserContext* GetCurrentBrowserContext() = 0;
// Invoked to toggle spoken feedback for accessibility
- virtual void ToggleSpokenFeedback() = 0;
+ virtual void ToggleSpokenFeedback(
+ AccessibilityNotificationVisibility notify) = 0;
// Returns true if spoken feedback is enabled.
virtual bool IsSpokenFeedbackEnabled() const = 0;
diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc
index 09704c8..e865550 100644
--- a/ash/system/tray/system_tray_notifier.cc
+++ b/ash/system/tray/system_tray_notifier.cc
@@ -149,11 +149,12 @@ void SystemTrayNotifier::RemoveSmsObserver(SmsObserver* observer) {
}
#endif
-void SystemTrayNotifier::NotifyAccessibilityModeChanged() {
+void SystemTrayNotifier::NotifyAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify) {
FOR_EACH_OBSERVER(
AccessibilityObserver,
accessibility_observers_,
- OnAccessibilityModeChanged());
+ OnAccessibilityModeChanged(notify));
}
void SystemTrayNotifier::NotifyVolumeChanged(float level) {
diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h
index 9cfddd2..895d929 100644
--- a/ash/system/tray/system_tray_notifier.h
+++ b/ash/system/tray/system_tray_notifier.h
@@ -88,7 +88,8 @@ public:
void RemoveSmsObserver(SmsObserver* observer);
#endif
- void NotifyAccessibilityModeChanged();
+ void NotifyAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify);
void NotifyVolumeChanged(float level);
void NotifyMuteToggled();
void NotifyRefreshBluetooth();
diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc
index 9f468ad..9b161f5 100644
--- a/ash/system/tray_accessibility.cc
+++ b/ash/system/tray_accessibility.cc
@@ -30,12 +30,23 @@ namespace internal {
namespace {
const int kPaddingAroundBottomRow = 5;
-bool IsAnyAccessibilityFeatureEnabled() {
+enum AccessibilityState {
+ A11Y_NONE = 0,
+ A11Y_SPOKEN_FEEDBACK = 1 << 0,
+ A11Y_HIGH_CONTRAST = 1 << 1,
+ A11Y_SCREEN_MAGNIFIER = 1 << 2,
+};
+
+uint32 GetAccessibilityState() {
ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
- return shell_delegate &&
- (shell_delegate->IsSpokenFeedbackEnabled() ||
- shell_delegate->IsHighContrastEnabled() ||
- shell_delegate->GetMagnifierType() != ash::MAGNIFIER_OFF);
+ uint32 state = A11Y_NONE;
+ if (shell_delegate->IsSpokenFeedbackEnabled())
+ state |= A11Y_SPOKEN_FEEDBACK;
+ if (shell_delegate->IsHighContrastEnabled())
+ state |= A11Y_HIGH_CONTRAST;
+ if (shell_delegate->GetMagnifierType() != ash::MAGNIFIER_OFF)
+ state |= A11Y_SCREEN_MAGNIFIER;
+ return state;
}
user::LoginStatus GetCurrentLoginStatus() {
@@ -168,7 +179,7 @@ class AccessibilityDetailedView : public TrayDetailsView,
if (sender == footer()->content()) {
owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
} else if (sender == spoken_feedback_view_) {
- shell_delegate->ToggleSpokenFeedback();
+ shell_delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
} else if (sender == high_contrast_view_) {
shell_delegate->ToggleHighContrast();
} else if (sender == screen_magnifier_view_) {
@@ -225,8 +236,8 @@ TrayAccessibility::TrayAccessibility(SystemTray* system_tray)
default_(NULL),
detailed_(NULL),
request_popup_view_(false),
- accessibility_previously_enabled_(IsAnyAccessibilityFeatureEnabled()),
- login_(GetCurrentLoginStatus()) {
+ login_(GetCurrentLoginStatus()),
+ previous_accessibility_state_(GetAccessibilityState()) {
DCHECK(Shell::GetInstance()->delegate());
DCHECK(system_tray);
Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(this);
@@ -240,7 +251,7 @@ TrayAccessibility::~TrayAccessibility() {
bool TrayAccessibility::GetInitialVisibility() {
// Shows accessibility icon if any accessibility feature is enabled.
// Otherwise, doen't show it.
- return IsAnyAccessibilityFeatureEnabled();
+ return GetAccessibilityState() != A11Y_NONE;
}
views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) {
@@ -256,7 +267,7 @@ views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) {
ShellDelegate* delegate = Shell::GetInstance()->delegate();
if (login_ != user::LOGGED_IN_NONE &&
!delegate->ShouldAlwaysShowAccessibilityMenu() &&
- !IsAnyAccessibilityFeatureEnabled())
+ GetAccessibilityState() == A11Y_NONE)
return NULL;
CHECK(default_ == NULL);
@@ -295,21 +306,23 @@ void TrayAccessibility::UpdateAfterLoginStatusChange(user::LoginStatus status) {
tray_view()->SetVisible(GetInitialVisibility());
}
-void TrayAccessibility::OnAccessibilityModeChanged() {
+void TrayAccessibility::OnAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify) {
if (tray_view())
tray_view()->SetVisible(GetInitialVisibility());
- bool accessibility_enabled = IsAnyAccessibilityFeatureEnabled();
- if (!accessibility_previously_enabled_ && accessibility_enabled) {
- // Shows popup if the accessibilty status is being changed to true from
- // false.
+ uint32 accessibility_state = GetAccessibilityState();
+ if ((notify == ash::A11Y_NOTIFICATION_SHOW)&&
+ !(previous_accessibility_state_ & A11Y_SPOKEN_FEEDBACK) &&
+ (accessibility_state & A11Y_SPOKEN_FEEDBACK)) {
+ // Shows popup if |notify| is true and the spoken feedback is being enabled.
request_popup_view_ = true;
PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false);
} else if (detailed_) {
detailed_->GetWidget()->Close();
}
- accessibility_previously_enabled_ = accessibility_enabled;
+ previous_accessibility_state_ = accessibility_state;
}
} // namespace internal
diff --git a/ash/system/tray_accessibility.h b/ash/system/tray_accessibility.h
index e0162f5..1000b65 100644
--- a/ash/system/tray_accessibility.h
+++ b/ash/system/tray_accessibility.h
@@ -5,6 +5,7 @@
#ifndef ASH_SYSTEM_TRAY_ACCESSIBILITY_H_
#define ASH_SYSTEM_TRAY_ACCESSIBILITY_H_
+#include "ash/shell_delegate.h"
#include "ash/shell_observer.h"
#include "ash/system/tray/tray_image_item.h"
@@ -20,7 +21,8 @@ class ASH_EXPORT AccessibilityObserver {
virtual ~AccessibilityObserver() {}
// Notifies when accessibilty mode changes.
- virtual void OnAccessibilityModeChanged() = 0;
+ virtual void OnAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify) = 0;
};
namespace internal {
@@ -41,15 +43,18 @@ class TrayAccessibility : public TrayImageItem,
virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
// Overridden from AccessibilityObserver.
- virtual void OnAccessibilityModeChanged() OVERRIDE;
+ virtual void OnAccessibilityModeChanged(
+ AccessibilityNotificationVisibility notify) OVERRIDE;
views::View* default_;
views::View* detailed_;
bool request_popup_view_;
- bool accessibility_previously_enabled_;
user::LoginStatus login_;
+ // Bitmap of values from AccessibilityState enum.
+ uint32 previous_accessibility_state_;
+
DISALLOW_COPY_AND_ASSIGN(TrayAccessibility);
};
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 066a14b..c57e41e 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -107,7 +107,8 @@ content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() {
return current_browser_context_.get();
}
-void TestShellDelegate::ToggleSpokenFeedback() {
+void TestShellDelegate::ToggleSpokenFeedback(
+ AccessibilityNotificationVisibility notify) {
spoken_feedback_enabled_ = !spoken_feedback_enabled_;
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index c35d116..398e0f4 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -40,7 +40,8 @@ class TestShellDelegate : public ShellDelegate {
virtual void ShowKeyboardOverlay() OVERRIDE;
virtual void ShowTaskManager() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
- virtual void ToggleSpokenFeedback() OVERRIDE;
+ virtual void ToggleSpokenFeedback(
+ AccessibilityNotificationVisibility notify) OVERRIDE;
virtual bool IsSpokenFeedbackEnabled() const OVERRIDE;
virtual void ToggleHighContrast() OVERRIDE;
virtual bool IsHighContrastEnabled() const OVERRIDE;