| Index: ash/system/tray_accessibility.cc
|
| diff --git a/ash/system/tray_accessibility.cc b/ash/system/tray_accessibility.cc
|
| index 9f468ad1db56350a7c3e5ed046cd8553f95502bb..f2f28d1cfbb444236d183915a00c83c8188ec9f5 100644
|
| --- a/ash/system/tray_accessibility.cc
|
| +++ b/ash/system/tray_accessibility.cc
|
| @@ -66,137 +66,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();
|
| - } 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)
|
| @@ -217,8 +86,126 @@ 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();
|
| + } 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),
|
| @@ -226,6 +213,7 @@ TrayAccessibility::TrayAccessibility(SystemTray* system_tray)
|
| detailed_(NULL),
|
| request_popup_view_(false),
|
| accessibility_previously_enabled_(IsAnyAccessibilityFeatureEnabled()),
|
| + tray_icon_visible_(false),
|
| login_(GetCurrentLoginStatus()) {
|
| DCHECK(Shell::GetInstance()->delegate());
|
| DCHECK(system_tray);
|
| @@ -237,6 +225,16 @@ TrayAccessibility::~TrayAccessibility() {
|
| RemoveAccessibilityObserver(this);
|
| }
|
|
|
| +void TrayAccessibility::SetTrayIconVisible(bool visible) {
|
| + if (tray_view())
|
| + tray_view()->SetVisible(GetInitialVisibility());
|
| + 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.
|
| @@ -274,7 +272,7 @@ views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) {
|
| detailed_ = new tray::AccessibilityPopupView(this);
|
| request_popup_view_ = false;
|
| } else {
|
| - detailed_ = new tray::AccessibilityDetailedView(this, status);
|
| + detailed_ = CreateDetailedMenu();
|
| }
|
|
|
| return detailed_;
|
| @@ -290,14 +288,11 @@ void TrayAccessibility::DestroyDetailedView() {
|
|
|
| void TrayAccessibility::UpdateAfterLoginStatusChange(user::LoginStatus status) {
|
| login_ = status;
|
| -
|
| - if (tray_view())
|
| - tray_view()->SetVisible(GetInitialVisibility());
|
| + SetTrayIconVisible(GetInitialVisibility());
|
| }
|
|
|
| void TrayAccessibility::OnAccessibilityModeChanged() {
|
| - if (tray_view())
|
| - tray_view()->SetVisible(GetInitialVisibility());
|
| + SetTrayIconVisible(GetInitialVisibility());
|
|
|
| bool accessibility_enabled = IsAnyAccessibilityFeatureEnabled();
|
| if (!accessibility_previously_enabled_ && accessibility_enabled) {
|
|
|