| 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/vector_icons/vector_icons.h" | 22 #include "ash/resources/vector_icons/vector_icons.h" |
| 23 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 24 #include "ash/strings/grit/ash_strings.h" | 24 #include "ash/strings/grit/ash_strings.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 28 #include "ui/gfx/color_palette.h" | |
| 29 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/paint_vector_icon.h" | 29 #include "ui/gfx/paint_vector_icon.h" |
| 31 #include "ui/resources/grit/ui_resources.h" | 30 #include "ui/resources/grit/ui_resources.h" |
| 32 #include "ui/views/background.h" | 31 #include "ui/views/background.h" |
| 33 #include "ui/views/controls/button/custom_button.h" | 32 #include "ui/views/controls/button/custom_button.h" |
| 34 #include "ui/views/controls/image_view.h" | 33 #include "ui/views/controls/image_view.h" |
| 35 #include "ui/views/controls/label.h" | 34 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/controls/separator.h" | 35 #include "ui/views/controls/separator.h" |
| 37 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
| 38 #include "ui/views/layout/grid_layout.h" | 37 #include "ui/views/layout/grid_layout.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 state |= A11Y_HIGHLIGHT_MOUSE_CURSOR; | 81 state |= A11Y_HIGHLIGHT_MOUSE_CURSOR; |
| 83 if (delegate->IsFocusHighlightEnabled()) | 82 if (delegate->IsFocusHighlightEnabled()) |
| 84 state |= A11Y_HIGHLIGHT_KEYBOARD_FOCUS; | 83 state |= A11Y_HIGHLIGHT_KEYBOARD_FOCUS; |
| 85 return state; | 84 return state; |
| 86 } | 85 } |
| 87 | 86 |
| 88 LoginStatus GetCurrentLoginStatus() { | 87 LoginStatus GetCurrentLoginStatus() { |
| 89 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 88 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void UpdateCheckMark(HoverHighlightView* container, bool checked) { | |
| 93 if (checked) { | |
| 94 gfx::ImageSkia check_mark = | |
| 95 CreateVectorIcon(kCheckCircleIcon, gfx::kGoogleGreen700); | |
| 96 container->AddRightIcon(check_mark, check_mark.width()); | |
| 97 container->SetRightViewVisible(true); | |
| 98 container->SetAccessiblityState( | |
| 99 HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX); | |
| 100 } else { | |
| 101 container->SetAccessiblityState( | |
| 102 HoverHighlightView::AccessibilityState::UNCHECKED_CHECKBOX); | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 } // namespace | 91 } // namespace |
| 107 | 92 |
| 108 namespace tray { | 93 namespace tray { |
| 109 | 94 |
| 110 class DefaultAccessibilityView : public TrayItemMore { | 95 class DefaultAccessibilityView : public TrayItemMore { |
| 111 public: | 96 public: |
| 112 explicit DefaultAccessibilityView(SystemTrayItem* owner) | 97 explicit DefaultAccessibilityView(SystemTrayItem* owner) |
| 113 : TrayItemMore(owner) { | 98 : TrayItemMore(owner) { |
| 114 base::string16 label = | 99 base::string16 label = |
| 115 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY); | 100 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 280 } |
| 296 } | 281 } |
| 297 | 282 |
| 298 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 283 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
| 299 const base::string16& text, | 284 const base::string16& text, |
| 300 bool checked, | 285 bool checked, |
| 301 const gfx::VectorIcon& icon) { | 286 const gfx::VectorIcon& icon) { |
| 302 HoverHighlightView* container = new HoverHighlightView(this); | 287 HoverHighlightView* container = new HoverHighlightView(this); |
| 303 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); | 288 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); |
| 304 container->AddIconAndLabel(image, text); | 289 container->AddIconAndLabel(image, text); |
| 305 UpdateCheckMark(container, checked); | 290 TrayPopupUtils::UpdateCheckMarkVisibility(container, checked); |
| 306 scroll_content()->AddChildView(container); | 291 scroll_content()->AddChildView(container); |
| 307 return container; | 292 return container; |
| 308 } | 293 } |
| 309 | 294 |
| 310 HoverHighlightView* AccessibilityDetailedView::AddScrollListItemWithoutIcon( | 295 HoverHighlightView* AccessibilityDetailedView::AddScrollListItemWithoutIcon( |
| 311 const base::string16& text, | 296 const base::string16& text, |
| 312 bool checked) { | 297 bool checked) { |
| 313 HoverHighlightView* container = new HoverHighlightView(this); | 298 HoverHighlightView* container = new HoverHighlightView(this); |
| 314 container->AddLabelRow(text); | 299 container->AddLabelRow(text); |
| 315 | 300 TrayPopupUtils::UpdateCheckMarkVisibility(container, checked); |
| 316 UpdateCheckMark(container, checked); | |
| 317 | |
| 318 scroll_content()->AddChildView(container); | 301 scroll_content()->AddChildView(container); |
| 319 return container; | 302 return container; |
| 320 } | 303 } |
| 321 | 304 |
| 322 void AccessibilityDetailedView::AddSubHeader( | 305 void AccessibilityDetailedView::AddSubHeader( |
| 323 const base::string16& header_text) { | 306 const base::string16& header_text) { |
| 324 TriView* header = TrayPopupUtils::CreateSubHeaderRowView(); | 307 TriView* header = TrayPopupUtils::CreateSubHeaderRowView(); |
| 325 TrayPopupUtils::ConfigureAsStickyHeader(header); | 308 TrayPopupUtils::ConfigureAsStickyHeader(header); |
| 326 | 309 |
| 327 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); | 310 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 if (detailed_popup_) | 537 if (detailed_popup_) |
| 555 detailed_popup_->GetWidget()->Close(); | 538 detailed_popup_->GetWidget()->Close(); |
| 556 if (detailed_menu_) | 539 if (detailed_menu_) |
| 557 detailed_menu_->GetWidget()->Close(); | 540 detailed_menu_->GetWidget()->Close(); |
| 558 } | 541 } |
| 559 | 542 |
| 560 previous_accessibility_state_ = accessibility_state; | 543 previous_accessibility_state_ = accessibility_state; |
| 561 } | 544 } |
| 562 | 545 |
| 563 } // namespace ash | 546 } // namespace ash |
| OLD | NEW |