| Index: ash/system/tray_accessibility.cc
|
| diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc
|
| index 9b161f562f6c810438b785af0a45d5243a478fc6..9b1d2611bf3fac5d40bf291984adcf9d3b8792da 100644
|
| --- a/ash/system/tray_accessibility.cc
|
| +++ b/ash/system/tray_accessibility.cc
|
| @@ -77,137 +77,6 @@ class DefaultAccessibilityView : public TrayItemMore {
|
| DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView);
|
| };
|
|
|
| -class AccessibilityDetailedView : public TrayDetailsView,
|
| - public ViewClickListener,
|
| - public views::ButtonListener,
|
| - public ShellObserver {
|
| - public:
|
| - explicit AccessibilityDetailedView(SystemTrayItem* owner,
|
| - user::LoginStatus login) :
|
| - TrayDetailsView(owner),
|
| - spoken_feedback_view_(NULL),
|
| - high_contrast_view_(NULL),
|
| - screen_magnifier_view_(NULL),
|
| - help_view_(NULL),
|
| - login_(login) {
|
| -
|
| - Reset();
|
| -
|
| - AppendAccessibilityList();
|
| - AppendHelpEntries();
|
| - CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this);
|
| -
|
| - Layout();
|
| - }
|
| -
|
| - virtual ~AccessibilityDetailedView() {
|
| - }
|
| -
|
| - private:
|
| - // Add the accessibility feature list.
|
| - void AppendAccessibilityList() {
|
| - CreateScrollableList();
|
| - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| -
|
| - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
|
| - bool spoken_feedback_enabled = shell_delegate->IsSpokenFeedbackEnabled();
|
| - spoken_feedback_view_ = AddScrollListItem(
|
| - bundle.GetLocalizedString(
|
| - IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK),
|
| - spoken_feedback_enabled ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| - spoken_feedback_enabled);
|
| - bool high_contrast_mode_enabled = shell_delegate->IsHighContrastEnabled();
|
| - high_contrast_view_ = AddScrollListItem(
|
| - bundle.GetLocalizedString(
|
| - IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE),
|
| - high_contrast_mode_enabled ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| - high_contrast_mode_enabled);
|
| - bool screen_magnifier_enabled =
|
| - shell_delegate->GetMagnifierType() == ash::MAGNIFIER_FULL;
|
| - screen_magnifier_view_ = AddScrollListItem(
|
| - bundle.GetLocalizedString(
|
| - IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER),
|
| - screen_magnifier_enabled ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| - screen_magnifier_enabled);
|
| - }
|
| -
|
| - // Add help entries.
|
| - void AppendHelpEntries() {
|
| - // Currently the help page requires a browser window.
|
| - // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286
|
| - if (login_ == user::LOGGED_IN_NONE ||
|
| - login_ == user::LOGGED_IN_LOCKED)
|
| - return;
|
| -
|
| - views::View* bottom_row = new View();
|
| - views::BoxLayout* layout = new
|
| - views::BoxLayout(views::BoxLayout::kHorizontal,
|
| - kTrayMenuBottomRowPadding,
|
| - kTrayMenuBottomRowPadding,
|
| - kTrayMenuBottomRowPaddingBetweenItems);
|
| - layout->set_spread_blank_space(true);
|
| - bottom_row->SetLayoutManager(layout);
|
| -
|
| - ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| -
|
| - TrayPopupLabelButton* help = new TrayPopupLabelButton(
|
| - this,
|
| - bundle.GetLocalizedString(
|
| - IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LEARN_MORE));
|
| - bottom_row->AddChildView(help);
|
| - help_view_ = help;
|
| -
|
| - // TODO(yoshiki): Add "Customize accessibility" button when the customize is
|
| - // available. crbug.com/158281
|
| -
|
| - AddChildView(bottom_row);
|
| - }
|
| -
|
| - HoverHighlightView* AddScrollListItem(const string16& text,
|
| - gfx::Font::FontStyle style,
|
| - bool checked) {
|
| - HoverHighlightView* container = new HoverHighlightView(this);
|
| - container->set_fixed_height(kTrayPopupItemHeight);
|
| - container->AddCheckableLabel(text, style, checked);
|
| - scroll_content()->AddChildView(container);
|
| - return container;
|
| - }
|
| -
|
| - // Overridden from ViewClickListener.
|
| - virtual void ClickedOn(views::View* sender) OVERRIDE {
|
| - ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
|
| - if (sender == footer()->content()) {
|
| - owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
|
| - } else if (sender == spoken_feedback_view_) {
|
| - shell_delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE);
|
| - } else if (sender == high_contrast_view_) {
|
| - shell_delegate->ToggleHighContrast();
|
| - } else if (sender == screen_magnifier_view_) {
|
| - bool screen_magnifier_enabled =
|
| - shell_delegate->GetMagnifierType() == ash::MAGNIFIER_FULL;
|
| - shell_delegate->SetMagnifier(
|
| - screen_magnifier_enabled ? ash::MAGNIFIER_OFF : ash::MAGNIFIER_FULL);
|
| - }
|
| - }
|
| -
|
| - // Overridden from ButtonListener.
|
| - virtual void ButtonPressed(views::Button* sender,
|
| - const ui::Event& event) OVERRIDE {
|
| - SystemTrayDelegate* tray_delegate =
|
| - Shell::GetInstance()->system_tray_delegate();
|
| - if (sender == help_view_)
|
| - tray_delegate->ShowAccessibilityHelp();
|
| - }
|
| -
|
| - views::View* spoken_feedback_view_;
|
| - views::View* high_contrast_view_;
|
| - views::View* screen_magnifier_view_;;
|
| - views::View* help_view_;
|
| - user::LoginStatus login_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(AccessibilityDetailedView);
|
| -};
|
| -
|
| class AccessibilityPopupView : public TrayNotificationView {
|
| public:
|
| AccessibilityPopupView(SystemTrayItem* owner)
|
| @@ -228,14 +97,134 @@ class AccessibilityPopupView : public TrayNotificationView {
|
| DISALLOW_COPY_AND_ASSIGN(AccessibilityPopupView);
|
| };
|
|
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ash::internal::tray::AccessibilityDetailedView
|
| +
|
| +AccessibilityDetailedView::AccessibilityDetailedView(
|
| + SystemTrayItem* owner, user::LoginStatus login) :
|
| + TrayDetailsView(owner),
|
| + spoken_feedback_view_(NULL),
|
| + high_contrast_view_(NULL),
|
| + screen_magnifier_view_(NULL),
|
| + help_view_(NULL),
|
| + spoken_feedback_enabled_(false),
|
| + high_contrast_enabled_(false),
|
| + screen_magnifier_enabled_(false),
|
| + login_(login) {
|
| +
|
| + Reset();
|
| +
|
| + AppendAccessibilityList();
|
| + AppendHelpEntries();
|
| + CreateSpecialRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE, this);
|
| +
|
| + Layout();
|
| +}
|
| +
|
| +void AccessibilityDetailedView::AppendAccessibilityList() {
|
| + CreateScrollableList();
|
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| +
|
| + ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
|
| + spoken_feedback_enabled_ = shell_delegate->IsSpokenFeedbackEnabled();
|
| + spoken_feedback_view_ = AddScrollListItem(
|
| + bundle.GetLocalizedString(
|
| + IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SPOKEN_FEEDBACK),
|
| + spoken_feedback_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| + spoken_feedback_enabled_);
|
| + high_contrast_enabled_ = shell_delegate->IsHighContrastEnabled();
|
| + high_contrast_view_ = AddScrollListItem(
|
| + bundle.GetLocalizedString(
|
| + IDS_ASH_STATUS_TRAY_ACCESSIBILITY_HIGH_CONTRAST_MODE),
|
| + high_contrast_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| + high_contrast_enabled_);
|
| + screen_magnifier_enabled_ =
|
| + shell_delegate->GetMagnifierType() == ash::MAGNIFIER_FULL;
|
| + screen_magnifier_view_ = AddScrollListItem(
|
| + bundle.GetLocalizedString(
|
| + IDS_ASH_STATUS_TRAY_ACCESSIBILITY_SCREEN_MAGNIFIER),
|
| + screen_magnifier_enabled_ ? gfx::Font::BOLD : gfx::Font::NORMAL,
|
| + screen_magnifier_enabled_);
|
| +}
|
| +
|
| +void AccessibilityDetailedView::AppendHelpEntries() {
|
| + // Currently the help page requires a browser window.
|
| + // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286
|
| + if (login_ == user::LOGGED_IN_NONE ||
|
| + login_ == user::LOGGED_IN_LOCKED)
|
| + return;
|
| +
|
| + views::View* bottom_row = new View();
|
| + views::BoxLayout* layout = new
|
| + views::BoxLayout(views::BoxLayout::kHorizontal,
|
| + kTrayMenuBottomRowPadding,
|
| + kTrayMenuBottomRowPadding,
|
| + kTrayMenuBottomRowPaddingBetweenItems);
|
| + layout->set_spread_blank_space(true);
|
| + bottom_row->SetLayoutManager(layout);
|
| +
|
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| +
|
| + TrayPopupLabelButton* help = new TrayPopupLabelButton(
|
| + this,
|
| + bundle.GetLocalizedString(
|
| + IDS_ASH_STATUS_TRAY_ACCESSIBILITY_LEARN_MORE));
|
| + bottom_row->AddChildView(help);
|
| + help_view_ = help;
|
| +
|
| + // TODO(yoshiki): Add "Customize accessibility" button when the customize is
|
| + // available. crbug.com/158281
|
| +
|
| + AddChildView(bottom_row);
|
| +}
|
| +
|
| +HoverHighlightView* AccessibilityDetailedView::AddScrollListItem(
|
| + const string16& text,
|
| + gfx::Font::FontStyle style,
|
| + bool checked) {
|
| + HoverHighlightView* container = new HoverHighlightView(this);
|
| + container->set_fixed_height(kTrayPopupItemHeight);
|
| + container->AddCheckableLabel(text, style, checked);
|
| + scroll_content()->AddChildView(container);
|
| + return container;
|
| +}
|
| +
|
| +void AccessibilityDetailedView::ClickedOn(views::View* sender) {
|
| + ShellDelegate* shell_delegate = Shell::GetInstance()->delegate();
|
| + if (sender == footer()->content()) {
|
| + owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
|
| + } else if (sender == spoken_feedback_view_) {
|
| + shell_delegate->ToggleSpokenFeedback(ash::A11Y_NOTIFICATION_NONE);
|
| + } else if (sender == high_contrast_view_) {
|
| + shell_delegate->ToggleHighContrast();
|
| + } else if (sender == screen_magnifier_view_) {
|
| + bool screen_magnifier_enabled =
|
| + shell_delegate->GetMagnifierType() == ash::MAGNIFIER_FULL;
|
| + shell_delegate->SetMagnifier(
|
| + screen_magnifier_enabled ? ash::MAGNIFIER_OFF : ash::MAGNIFIER_FULL);
|
| + }
|
| +}
|
| +
|
| +void AccessibilityDetailedView::ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) {
|
| + SystemTrayDelegate* tray_delegate =
|
| + Shell::GetInstance()->system_tray_delegate();
|
| + if (sender == help_view_)
|
| + tray_delegate->ShowAccessibilityHelp();
|
| +}
|
| +
|
| } // namespace tray
|
|
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// ash::internal::TrayAccessibility
|
|
|
| TrayAccessibility::TrayAccessibility(SystemTray* system_tray)
|
| : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_ACCESSIBILITY),
|
| default_(NULL),
|
| - detailed_(NULL),
|
| + detailed_popup_(NULL),
|
| + detailed_menu_(NULL),
|
| request_popup_view_(false),
|
| + tray_icon_visible_(false),
|
| login_(GetCurrentLoginStatus()),
|
| previous_accessibility_state_(GetAccessibilityState()) {
|
| DCHECK(Shell::GetInstance()->delegate());
|
| @@ -248,6 +237,16 @@ TrayAccessibility::~TrayAccessibility() {
|
| RemoveAccessibilityObserver(this);
|
| }
|
|
|
| +void TrayAccessibility::SetTrayIconVisible(bool visible) {
|
| + if (tray_view())
|
| + tray_view()->SetVisible(visible);
|
| + tray_icon_visible_ = visible;
|
| +}
|
| +
|
| +tray::AccessibilityDetailedView* TrayAccessibility::CreateDetailedMenu() {
|
| + return new tray::AccessibilityDetailedView(this, login_);
|
| +}
|
| +
|
| bool TrayAccessibility::GetInitialVisibility() {
|
| // Shows accessibility icon if any accessibility feature is enabled.
|
| // Otherwise, doen't show it.
|
| @@ -277,18 +276,19 @@ views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) {
|
| }
|
|
|
| views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) {
|
| - CHECK(detailed_ == NULL);
|
| + CHECK(detailed_popup_ == NULL);
|
| + CHECK(detailed_menu_ == NULL);
|
|
|
| login_ = status;
|
|
|
| if (request_popup_view_) {
|
| - detailed_ = new tray::AccessibilityPopupView(this);
|
| + detailed_popup_ = new tray::AccessibilityPopupView(this);
|
| request_popup_view_ = false;
|
| + return detailed_popup_;
|
| } else {
|
| - detailed_ = new tray::AccessibilityDetailedView(this, status);
|
| + detailed_menu_ = CreateDetailedMenu();
|
| + return detailed_menu_;
|
| }
|
| -
|
| - return detailed_;
|
| }
|
|
|
| void TrayAccessibility::DestroyDefaultView() {
|
| @@ -296,20 +296,18 @@ void TrayAccessibility::DestroyDefaultView() {
|
| }
|
|
|
| void TrayAccessibility::DestroyDetailedView() {
|
| - detailed_ = NULL;
|
| + detailed_popup_ = NULL;
|
| + detailed_menu_ = NULL;
|
| }
|
|
|
| void TrayAccessibility::UpdateAfterLoginStatusChange(user::LoginStatus status) {
|
| login_ = status;
|
| -
|
| - if (tray_view())
|
| - tray_view()->SetVisible(GetInitialVisibility());
|
| + SetTrayIconVisible(GetInitialVisibility());
|
| }
|
|
|
| void TrayAccessibility::OnAccessibilityModeChanged(
|
| AccessibilityNotificationVisibility notify) {
|
| - if (tray_view())
|
| - tray_view()->SetVisible(GetInitialVisibility());
|
| + SetTrayIconVisible(GetInitialVisibility());
|
|
|
| uint32 accessibility_state = GetAccessibilityState();
|
| if ((notify == ash::A11Y_NOTIFICATION_SHOW)&&
|
| @@ -318,8 +316,11 @@ void TrayAccessibility::OnAccessibilityModeChanged(
|
| // 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();
|
| + } else {
|
| + if (detailed_popup_)
|
| + detailed_popup_->GetWidget()->Close();
|
| + if (detailed_menu_)
|
| + detailed_menu_->GetWidget()->Close();
|
| }
|
|
|
| previous_accessibility_state_ = accessibility_state;
|
|
|