| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/tray_accessibility.h" | 5 #include "ash/system/tray_accessibility.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_views.h" | 10 #include "ash/system/tray/tray_views.h" |
| 11 #include "grit/ash_strings.h" | 11 #include "grit/ash_strings.h" |
| 12 #include "grit/ui_resources_standard.h" | 12 #include "grit/ui_resources_standard.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 15 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
| 17 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
| 18 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 39 IDS_ASH_STATUS_TRAY_DISABLE_SPOKEN_FEEDBACK); | 39 IDS_ASH_STATUS_TRAY_DISABLE_SPOKEN_FEEDBACK); |
| 40 AddChildView(new views::Label(label)); | 40 AddChildView(new views::Label(label)); |
| 41 SetAccessibleName(label); | 41 SetAccessibleName(label); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual ~DefaultAccessibilityView() {} | 44 virtual ~DefaultAccessibilityView() {} |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 // Overridden from ActionableView. | 47 // Overridden from ActionableView. |
| 48 virtual bool PerformAction(const views::Event& event) OVERRIDE { | 48 virtual bool PerformAction(const views::Event& event) OVERRIDE { |
| 49 ash::Shell::GetInstance()->tray_delegate()->SetEnableSpokenFeedback(false); | 49 if (Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) |
| 50 Shell::GetInstance()->delegate()->ToggleSpokenFeedback(); |
| 50 GetWidget()->Close(); | 51 GetWidget()->Close(); |
| 51 return true; | 52 return true; |
| 52 } | 53 } |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 | 56 |
| 56 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 57 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 TrayAccessibility::TrayAccessibility() | 60 TrayAccessibility::TrayAccessibility() |
| 60 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY), | 61 : TrayImageItem(IDR_AURA_UBER_TRAY_ACCESSIBILITY), |
| 61 default_(NULL), | 62 default_(NULL), |
| 62 detailed_(NULL), | 63 detailed_(NULL), |
| 63 string_id_(0) { | 64 string_id_(0) { |
| 64 } | 65 } |
| 65 | 66 |
| 66 TrayAccessibility::~TrayAccessibility() {} | 67 TrayAccessibility::~TrayAccessibility() {} |
| 67 | 68 |
| 68 bool TrayAccessibility::GetInitialVisibility() { | 69 bool TrayAccessibility::GetInitialVisibility() { |
| 69 return ash::Shell::GetInstance()->tray_delegate()->IsInAccessibilityMode(); | 70 return Shell::GetInstance()->delegate() && |
| 71 Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled(); |
| 70 } | 72 } |
| 71 | 73 |
| 72 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { | 74 views::View* TrayAccessibility::CreateDefaultView(user::LoginStatus status) { |
| 73 if (!ash::Shell::GetInstance()->tray_delegate()->IsInAccessibilityMode()) | 75 if (!Shell::GetInstance()->delegate()->IsSpokenFeedbackEnabled()) |
| 74 return NULL; | 76 return NULL; |
| 75 | 77 |
| 76 DCHECK(string_id_); | 78 DCHECK(string_id_); |
| 77 CHECK(default_ == NULL); | 79 CHECK(default_ == NULL); |
| 78 default_ = new DefaultAccessibilityView(); | 80 default_ = new DefaultAccessibilityView(); |
| 79 | 81 |
| 80 return default_; | 82 return default_; |
| 81 } | 83 } |
| 82 | 84 |
| 83 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { | 85 views::View* TrayAccessibility::CreateDetailedView(user::LoginStatus status) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 string_id_ = string_id; | 120 string_id_ = string_id; |
| 119 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); | 121 PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| 120 } else if (detailed_) { | 122 } else if (detailed_) { |
| 121 string_id_ = 0; | 123 string_id_ = 0; |
| 122 detailed_->GetWidget()->Close(); | 124 detailed_->GetWidget()->Close(); |
| 123 } | 125 } |
| 124 } | 126 } |
| 125 | 127 |
| 126 } // namespace internal | 128 } // namespace internal |
| 127 } // namespace ash | 129 } // namespace ash |
| OLD | NEW |