| 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/common/system/tray_accessibility.h" | 5 #include "ash/common/system/tray_accessibility.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/accessibility_types.h" | 8 #include "ash/common/accessibility_types.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/system/tray/hover_highlight_view.h" | 10 #include "ash/common/system/tray/hover_highlight_view.h" |
| 11 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
| 12 #include "ash/common/system/tray/system_tray_controller.h" | 12 #include "ash/common/system/tray/system_tray_controller.h" |
| 13 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 14 #include "ash/common/system/tray/system_tray_notifier.h" | 14 #include "ash/common/system/tray/system_tray_notifier.h" |
| 15 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 16 #include "ash/common/system/tray/tray_details_view.h" | 16 #include "ash/common/system/tray/tray_details_view.h" |
| 17 #include "ash/common/system/tray/tray_item_more.h" | 17 #include "ash/common/system/tray/tray_item_more.h" |
| 18 #include "ash/common/system/tray/tray_popup_item_style.h" | 18 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 19 #include "ash/common/system/tray/tray_popup_utils.h" | 19 #include "ash/common/system/tray/tray_popup_utils.h" |
| 20 #include "ash/common/system/tray/tri_view.h" | 20 #include "ash/common/system/tray/tri_view.h" |
| 21 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 22 #include "ash/resources/grit/ash_resources.h" | |
| 23 #include "ash/resources/vector_icons/vector_icons.h" | 22 #include "ash/resources/vector_icons/vector_icons.h" |
| 24 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 25 #include "ash/strings/grit/ash_strings.h" | 24 #include "ash/strings/grit/ash_strings.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/gfx/color_palette.h" | 28 #include "ui/gfx/color_palette.h" |
| 30 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 31 #include "ui/gfx/paint_vector_icon.h" | 30 #include "ui/gfx/paint_vector_icon.h" |
| 31 #include "ui/resources/grit/ui_resources.h" |
| 32 #include "ui/views/background.h" |
| 32 #include "ui/views/controls/button/custom_button.h" | 33 #include "ui/views/controls/button/custom_button.h" |
| 33 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
| 34 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 35 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
| 37 #include "ui/views/layout/grid_layout.h" |
| 36 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
| 37 | 39 |
| 38 namespace ash { | 40 namespace ash { |
| 39 namespace { | 41 namespace { |
| 40 | 42 |
| 41 enum AccessibilityState { | 43 enum AccessibilityState { |
| 42 A11Y_NONE = 0, | 44 A11Y_NONE = 0, |
| 43 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 45 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
| 44 A11Y_HIGH_CONTRAST = 1 << 1, | 46 A11Y_HIGH_CONTRAST = 1 << 1, |
| 45 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 47 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 103 } |
| 102 | 104 |
| 103 private: | 105 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 106 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 //////////////////////////////////////////////////////////////////////////////// | 109 //////////////////////////////////////////////////////////////////////////////// |
| 108 // ash::tray::AccessibilityPopupView | 110 // ash::tray::AccessibilityPopupView |
| 109 | 111 |
| 110 AccessibilityPopupView::AccessibilityPopupView(uint32_t enabled_state_bits) | 112 AccessibilityPopupView::AccessibilityPopupView(uint32_t enabled_state_bits) |
| 111 : TrayNotificationView(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK), | 113 : label_(CreateLabel(enabled_state_bits)) { |
| 112 label_(CreateLabel(enabled_state_bits)) { | 114 InitView(); |
| 113 InitView(label_); | |
| 114 } | 115 } |
| 115 | 116 |
| 116 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { | 117 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { |
| 117 DCHECK((enabled_state_bits & | 118 DCHECK((enabled_state_bits & |
| 118 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); | 119 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); |
| 119 base::string16 text; | 120 base::string16 text; |
| 120 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { | 121 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { |
| 121 text.append(l10n_util::GetStringUTF16( | 122 text.append(l10n_util::GetStringUTF16( |
| 122 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); | 123 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); |
| 123 } | 124 } |
| 124 if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) { | 125 if (enabled_state_bits & A11Y_SPOKEN_FEEDBACK) { |
| 125 if (!text.empty()) | 126 if (!text.empty()) |
| 126 text.append(base::ASCIIToUTF16(" ")); | 127 text.append(base::ASCIIToUTF16(" ")); |
| 127 text.append(l10n_util::GetStringUTF16( | 128 text.append(l10n_util::GetStringUTF16( |
| 128 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_BUBBLE)); | 129 IDS_ASH_STATUS_TRAY_SPOKEN_FEEDBACK_ENABLED_BUBBLE)); |
| 129 } | 130 } |
| 130 views::Label* label = new views::Label(text); | 131 views::Label* label = new views::Label(text); |
| 131 label->SetMultiLine(true); | 132 label->SetMultiLine(true); |
| 132 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 133 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 133 return label; | 134 return label; |
| 134 } | 135 } |
| 135 | 136 |
| 137 void AccessibilityPopupView::InitView() { |
| 138 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 139 |
| 140 views::GridLayout* layout = new views::GridLayout(this); |
| 141 SetLayoutManager(layout); |
| 142 |
| 143 views::ImageView* close_button = new views::ImageView(); |
| 144 close_button->SetImage( |
| 145 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); |
| 146 close_button->SetHorizontalAlignment(views::ImageView::CENTER); |
| 147 close_button->SetVerticalAlignment(views::ImageView::CENTER); |
| 148 |
| 149 views::ImageView* icon = new views::ImageView; |
| 150 icon->SetImage( |
| 151 gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, kMenuIconColor)); |
| 152 |
| 153 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 154 |
| 155 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 156 |
| 157 // Icon |
| 158 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, |
| 159 0, /* resize percent */ |
| 160 views::GridLayout::FIXED, kNotificationIconWidth, |
| 161 kNotificationIconWidth); |
| 162 |
| 163 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 164 |
| 165 // Contents |
| 166 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 167 100, /* resize percent */ |
| 168 views::GridLayout::FIXED, kTrayNotificationContentsWidth, |
| 169 kTrayNotificationContentsWidth); |
| 170 |
| 171 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 172 |
| 173 // Close button |
| 174 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, |
| 175 0, /* resize percent */ |
| 176 views::GridLayout::FIXED, kNotificationButtonWidth, |
| 177 kNotificationButtonWidth); |
| 178 |
| 179 // Layout rows |
| 180 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); |
| 181 layout->StartRow(0, 0); |
| 182 layout->AddView(icon); |
| 183 layout->AddView(label_); |
| 184 layout->AddView(close_button); |
| 185 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); |
| 186 } |
| 187 |
| 136 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
| 137 // ash::tray::AccessibilityDetailedView | 189 // ash::tray::AccessibilityDetailedView |
| 138 | 190 |
| 139 AccessibilityDetailedView::AccessibilityDetailedView(SystemTrayItem* owner, | 191 AccessibilityDetailedView::AccessibilityDetailedView(SystemTrayItem* owner, |
| 140 LoginStatus login) | 192 LoginStatus login) |
| 141 : TrayDetailsView(owner), | 193 : TrayDetailsView(owner), |
| 142 spoken_feedback_view_(nullptr), | 194 spoken_feedback_view_(nullptr), |
| 143 high_contrast_view_(nullptr), | 195 high_contrast_view_(nullptr), |
| 144 screen_magnifier_view_(nullptr), | 196 screen_magnifier_view_(nullptr), |
| 145 large_cursor_view_(nullptr), | 197 large_cursor_view_(nullptr), |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (detailed_popup_) | 491 if (detailed_popup_) |
| 440 detailed_popup_->GetWidget()->Close(); | 492 detailed_popup_->GetWidget()->Close(); |
| 441 if (detailed_menu_) | 493 if (detailed_menu_) |
| 442 detailed_menu_->GetWidget()->Close(); | 494 detailed_menu_->GetWidget()->Close(); |
| 443 } | 495 } |
| 444 | 496 |
| 445 previous_accessibility_state_ = accessibility_state; | 497 previous_accessibility_state_ = accessibility_state; |
| 446 } | 498 } |
| 447 | 499 |
| 448 } // namespace ash | 500 } // namespace ash |
| OLD | NEW |