| 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/controls/separator.h" | 36 #include "ui/views/controls/separator.h" |
| 36 #include "ui/views/layout/box_layout.h" | 37 #include "ui/views/layout/box_layout.h" |
| 38 #include "ui/views/layout/grid_layout.h" |
| 37 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
| 38 | 40 |
| 39 namespace ash { | 41 namespace ash { |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 42 enum AccessibilityState { | 44 enum AccessibilityState { |
| 43 A11Y_NONE = 0, | 45 A11Y_NONE = 0, |
| 44 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 46 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
| 45 A11Y_HIGH_CONTRAST = 1 << 1, | 47 A11Y_HIGH_CONTRAST = 1 << 1, |
| 46 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 48 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 130 } |
| 129 | 131 |
| 130 private: | 132 private: |
| 131 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 133 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
| 135 // ash::tray::AccessibilityPopupView | 137 // ash::tray::AccessibilityPopupView |
| 136 | 138 |
| 137 AccessibilityPopupView::AccessibilityPopupView(uint32_t enabled_state_bits) | 139 AccessibilityPopupView::AccessibilityPopupView(uint32_t enabled_state_bits) |
| 138 : TrayNotificationView(IDR_AURA_UBER_TRAY_ACCESSIBILITY_DARK), | 140 : label_(CreateLabel(enabled_state_bits)) {} |
| 139 label_(CreateLabel(enabled_state_bits)) { | 141 |
| 140 InitView(label_); | 142 void AccessibilityPopupView::Init() { |
| 143 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| 144 |
| 145 views::GridLayout* layout = new views::GridLayout(this); |
| 146 SetLayoutManager(layout); |
| 147 |
| 148 views::ImageView* close_button = new views::ImageView(); |
| 149 close_button->SetImage( |
| 150 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); |
| 151 close_button->SetHorizontalAlignment(views::ImageView::CENTER); |
| 152 close_button->SetVerticalAlignment(views::ImageView::CENTER); |
| 153 |
| 154 views::ImageView* icon = new views::ImageView; |
| 155 icon->SetImage( |
| 156 gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, kMenuIconColor)); |
| 157 |
| 158 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 159 |
| 160 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 161 |
| 162 // Icon |
| 163 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, |
| 164 0, /* resize percent */ |
| 165 views::GridLayout::FIXED, kNotificationIconWidth, |
| 166 kNotificationIconWidth); |
| 167 |
| 168 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 169 |
| 170 // Contents |
| 171 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 172 100, /* resize percent */ |
| 173 views::GridLayout::FIXED, kTrayNotificationContentsWidth, |
| 174 kTrayNotificationContentsWidth); |
| 175 |
| 176 columns->AddPaddingColumn(0, kTrayPopupPaddingHorizontal / 2); |
| 177 |
| 178 // Close button |
| 179 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, |
| 180 0, /* resize percent */ |
| 181 views::GridLayout::FIXED, kNotificationButtonWidth, |
| 182 kNotificationButtonWidth); |
| 183 |
| 184 // Layout rows |
| 185 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); |
| 186 layout->StartRow(0, 0); |
| 187 layout->AddView(icon); |
| 188 layout->AddView(label_); |
| 189 layout->AddView(close_button); |
| 190 layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); |
| 141 } | 191 } |
| 142 | 192 |
| 143 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { | 193 views::Label* AccessibilityPopupView::CreateLabel(uint32_t enabled_state_bits) { |
| 144 DCHECK((enabled_state_bits & | 194 DCHECK((enabled_state_bits & |
| 145 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); | 195 (A11Y_SPOKEN_FEEDBACK | A11Y_BRAILLE_DISPLAY_CONNECTED)) != 0); |
| 146 base::string16 text; | 196 base::string16 text; |
| 147 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { | 197 if (enabled_state_bits & A11Y_BRAILLE_DISPLAY_CONNECTED) { |
| 148 text.append(l10n_util::GetStringUTF16( | 198 text.append(l10n_util::GetStringUTF16( |
| 149 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); | 199 IDS_ASH_STATUS_TRAY_BRAILLE_DISPLAY_CONNECTED_BUBBLE)); |
| 150 } | 200 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 return default_; | 505 return default_; |
| 456 } | 506 } |
| 457 | 507 |
| 458 views::View* TrayAccessibility::CreateDetailedView(LoginStatus status) { | 508 views::View* TrayAccessibility::CreateDetailedView(LoginStatus status) { |
| 459 CHECK(detailed_popup_ == NULL); | 509 CHECK(detailed_popup_ == NULL); |
| 460 CHECK(detailed_menu_ == NULL); | 510 CHECK(detailed_menu_ == NULL); |
| 461 | 511 |
| 462 if (request_popup_view_state_) { | 512 if (request_popup_view_state_) { |
| 463 detailed_popup_ = | 513 detailed_popup_ = |
| 464 new tray::AccessibilityPopupView(request_popup_view_state_); | 514 new tray::AccessibilityPopupView(request_popup_view_state_); |
| 515 detailed_popup_->Init(); |
| 465 request_popup_view_state_ = A11Y_NONE; | 516 request_popup_view_state_ = A11Y_NONE; |
| 466 return detailed_popup_; | 517 return detailed_popup_; |
| 467 } else { | 518 } else { |
| 468 WmShell::Get()->RecordUserMetricsAction( | 519 WmShell::Get()->RecordUserMetricsAction( |
| 469 ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY); | 520 ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY); |
| 470 detailed_menu_ = CreateDetailedMenu(); | 521 detailed_menu_ = CreateDetailedMenu(); |
| 471 return detailed_menu_; | 522 return detailed_menu_; |
| 472 } | 523 } |
| 473 } | 524 } |
| 474 | 525 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 if (detailed_popup_) | 566 if (detailed_popup_) |
| 516 detailed_popup_->GetWidget()->Close(); | 567 detailed_popup_->GetWidget()->Close(); |
| 517 if (detailed_menu_) | 568 if (detailed_menu_) |
| 518 detailed_menu_->GetWidget()->Close(); | 569 detailed_menu_->GetWidget()->Close(); |
| 519 } | 570 } |
| 520 | 571 |
| 521 previous_accessibility_state_ = accessibility_state; | 572 previous_accessibility_state_ = accessibility_state; |
| 522 } | 573 } |
| 523 | 574 |
| 524 } // namespace ash | 575 } // namespace ash |
| OLD | NEW |