| Index: ash/system/tray_accessibility.cc
|
| diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc
|
| index 4e94408bb1d7fbf7204861c64205329ac7fa31d8..073b89896ed8b76a7a975ad00d75897bb7fdb230 100644
|
| --- a/ash/system/tray_accessibility.cc
|
| +++ b/ash/system/tray_accessibility.cc
|
| @@ -14,8 +14,8 @@
|
| #include "ash/system/tray/tray_constants.h"
|
| #include "ash/system/tray/tray_details_view.h"
|
| #include "ash/system/tray/tray_item_more.h"
|
| -#include "ash/system/tray/tray_notification_view.h"
|
| #include "ash/system/tray/tray_popup_label_button.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "grit/ash_resources.h"
|
| #include "grit/ash_strings.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -32,13 +32,14 @@ namespace internal {
|
| namespace {
|
|
|
| enum AccessibilityState {
|
| - A11Y_NONE = 0,
|
| - A11Y_SPOKEN_FEEDBACK = 1 << 0,
|
| - A11Y_HIGH_CONTRAST = 1 << 1,
|
| + A11Y_NONE = 0,
|
| + A11Y_SPOKEN_FEEDBACK = 1 << 0,
|
| + A11Y_HIGH_CONTRAST = 1 << 1,
|
| A11Y_SCREEN_MAGNIFIER = 1 << 2,
|
| - A11Y_LARGE_CURSOR = 1 << 3,
|
| - A11Y_AUTOCLICK = 1 << 4,
|
| + A11Y_LARGE_CURSOR = 1 << 3,
|
| + A11Y_AUTOCLICK = 1 << 4,
|
| A11Y_VIRTUAL_KEYBOARD = 1 << 5,
|
| + A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6,
|
| };
|
|
|
| uint32 GetAccessibilityState() {
|
| @@ -57,6 +58,8 @@ uint32 GetAccessibilityState() {
|
| state |= A11Y_AUTOCLICK;
|
| if (delegate->IsVirtualKeyboardEnabled())
|
| state |= A11Y_VIRTUAL_KEYBOARD;
|
| + if (delegate->IsBrailleDisplayConnected())
|
| + state |= A11Y_BRAILLE_DISPLAY_CONNECTED;
|
| return state;
|
| }
|
|
|
| @@ -88,25 +91,35 @@ class DefaultAccessibilityView : public TrayItemMore {
|
| DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView);
|
| };
|
|
|
| -class AccessibilityPopupView : public TrayNotificationView {
|
| - public:
|
| - AccessibilityPopupView(SystemTrayItem* owner)
|
| - : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK) {
|
| - InitView(GetLabel());
|
| - }
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ash::internal::tray::AccessibilityPopupView
|
|
|
| - private:
|
| - views::Label* GetLabel() {
|
| - views::Label* label = new views::Label(
|
| - l10n_util::GetStringUTF16(
|
| - IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_BUBBLE));
|
| - label->SetMultiLine(true);
|
| - label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| - return label;
|
| - }
|
| +AccessibilityPopupView::AccessibilityPopupView(SystemTrayItem* owner,
|
| + uint32 enabled_state_bits)
|
| + : TrayNotificationView(owner, IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK),
|
| + label_(CreateLabel(enabled_state_bits)) {
|
| + InitView(label_);
|
| +}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(AccessibilityPopupView);
|
| -};
|
| +views::Label* AccessibilityPopupView::CreateLabel(uint32 enabled_state_bits) {
|
| + DCHECK((enabled_state_bits &
|
| + (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0);
|
| + base::string16 text;
|
| + if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) {
|
| + text.append(l10n_util::GetStringUTF16(
|
| + IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE));
|
| + }
|
| + if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) {
|
| + if (!text.empty())
|
| + text.append(base::ASCIIToUTF16(" "));
|
| + text.append(l10n_util::GetStringUTF16(
|
| + IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_BUBBLE));
|
| + }
|
| + views::Label* label = new views::Label(text);
|
| + label->SetMultiLine(true);
|
| + label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| + return label;
|
| +}
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // ash::internal::tray::AccessibilityDetailedView
|
| @@ -302,7 +315,7 @@ TrayAccessibility::TrayAccessibility(SystemTray* system_tray)
|
| default_(NULL),
|
| detailed_popup_(NULL),
|
| detailed_menu_(NULL),
|
| - request_popup_view_(false),
|
| + request_popup_view_state_(A11Y_NONE),
|
| tray_icon_visible_(false),
|
| login_(GetCurrentLoginStatus()),
|
| previous_accessibility_state_(GetAccessibilityState()),
|
| @@ -359,9 +372,10 @@ views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) {
|
| CHECK(detailed_popup_ == NULL);
|
| CHECK(detailed_menu_ == NULL);
|
|
|
| - if (request_popup_view_) {
|
| - detailed_popup_ = new tray::AccessibilityPopupView(this);
|
| - request_popup_view_ = false;
|
| + if (request_popup_view_state_) {
|
| + detailed_popup_ =
|
| + new tray::AccessibilityPopupView(this, request_popup_view_state_);
|
| + request_popup_view_state_ = A11Y_NONE;
|
| return detailed_popup_;
|
| } else {
|
| Shell::GetInstance()->metrics()->RecordUserMetricsAction(
|
| @@ -394,11 +408,21 @@ void TrayAccessibility::OnAccessibilityModeChanged(
|
| SetTrayIconVisible(GetInitialVisibility());
|
|
|
| uint32 accessibility_state = GetAccessibilityState();
|
| - if ((notify == ash::A11Y_NOTIFICATION_SHOW) &&
|
| - !(previous_accessibility_state_ & A11Y_SPOKEN_FEEDBACK) &&
|
| - (accessibility_state & A11Y_SPOKEN_FEEDBACK)) {
|
| + // We'll get an extra notification if a braille display is connected when
|
| + // spoken feedback wasn't already enabled. This is because the braille
|
| + // connection state is already updated when spoken feedback is enabled so
|
| + // that the notifications can be consolidated into one. Therefore, we
|
| + // return early if there's no change in the state that we keep track of.
|
| + if (accessibility_state == previous_accessibility_state_)
|
| + return;
|
| + // Contains bits for spoken feedback and braille display connected currently
|
| + // being enabled.
|
| + uint32 being_enabled =
|
| + (accessibility_state & ~previous_accessibility_state_) &
|
| + (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED);
|
| + if ((notify == ash::A11Y_NOTIFICATION_SHOW) && being_enabled != A11Y_NONE) {
|
| // Shows popup if |notify| is true and the spoken feedback is being enabled.
|
| - request_popup_view_ = true;
|
| + request_popup_view_state_ = being_enabled;
|
| PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false);
|
| } else {
|
| if (detailed_popup_)
|
|
|