| 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/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #include "ui/gfx/vector_icons_public.h" | 32 #include "ui/gfx/vector_icons_public.h" |
| 33 #include "ui/views/controls/button/custom_button.h" | 33 #include "ui/views/controls/button/custom_button.h" |
| 34 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
| 35 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
| 37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 38 | 38 |
| 39 namespace ash { | 39 namespace ash { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 bool UseMdMenu() { |
| 43 return MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 44 } |
| 45 |
| 42 enum AccessibilityState { | 46 enum AccessibilityState { |
| 43 A11Y_NONE = 0, | 47 A11Y_NONE = 0, |
| 44 A11Y_SPOKEN_FEEDBACK = 1 << 0, | 48 A11Y_SPOKEN_FEEDBACK = 1 << 0, |
| 45 A11Y_HIGH_CONTRAST = 1 << 1, | 49 A11Y_HIGH_CONTRAST = 1 << 1, |
| 46 A11Y_SCREEN_MAGNIFIER = 1 << 2, | 50 A11Y_SCREEN_MAGNIFIER = 1 << 2, |
| 47 A11Y_LARGE_CURSOR = 1 << 3, | 51 A11Y_LARGE_CURSOR = 1 << 3, |
| 48 A11Y_AUTOCLICK = 1 << 4, | 52 A11Y_AUTOCLICK = 1 << 4, |
| 49 A11Y_VIRTUAL_KEYBOARD = 1 << 5, | 53 A11Y_VIRTUAL_KEYBOARD = 1 << 5, |
| 50 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, | 54 A11Y_BRAILLE_DISPLAY_CONNECTED = 1 << 6, |
| 51 }; | 55 }; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 set_id(test::kAccessibilityTrayItemViewId); | 99 set_id(test::kAccessibilityTrayItemViewId); |
| 96 } | 100 } |
| 97 | 101 |
| 98 ~DefaultAccessibilityView() override {} | 102 ~DefaultAccessibilityView() override {} |
| 99 | 103 |
| 100 protected: | 104 protected: |
| 101 // TrayItemMore: | 105 // TrayItemMore: |
| 102 void UpdateStyle() override { | 106 void UpdateStyle() override { |
| 103 TrayItemMore::UpdateStyle(); | 107 TrayItemMore::UpdateStyle(); |
| 104 | 108 |
| 105 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 109 if (!UseMdMenu()) |
| 106 return; | 110 return; |
| 107 | 111 |
| 108 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); | 112 std::unique_ptr<TrayPopupItemStyle> style = CreateStyle(); |
| 109 SetImage(gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, | 113 SetImage(gfx::CreateVectorIcon(kSystemMenuAccessibilityIcon, |
| 110 style->GetForegroundColor())); | 114 style->GetForegroundColor())); |
| 111 } | 115 } |
| 112 | 116 |
| 113 private: | 117 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); | 118 DISALLOW_COPY_AND_ASSIGN(DefaultAccessibilityView); |
| 115 }; | 119 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 high_contrast_enabled_(false), | 166 high_contrast_enabled_(false), |
| 163 screen_magnifier_enabled_(false), | 167 screen_magnifier_enabled_(false), |
| 164 large_cursor_enabled_(false), | 168 large_cursor_enabled_(false), |
| 165 autoclick_enabled_(false), | 169 autoclick_enabled_(false), |
| 166 virtual_keyboard_enabled_(false), | 170 virtual_keyboard_enabled_(false), |
| 167 login_(login) { | 171 login_(login) { |
| 168 Reset(); | 172 Reset(); |
| 169 | 173 |
| 170 AppendAccessibilityList(); | 174 AppendAccessibilityList(); |
| 171 | 175 |
| 172 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 176 if (!UseMdMenu()) |
| 173 AppendHelpEntries(); | 177 AppendHelpEntries(); |
| 174 | 178 |
| 175 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); | 179 CreateTitleRow(IDS_ASH_STATUS_TRAY_ACCESSIBILITY_TITLE); |
| 176 | 180 |
| 177 Layout(); | 181 Layout(); |
| 178 } | 182 } |
| 179 | 183 |
| 180 void AccessibilityDetailedView::AppendAccessibilityList() { | 184 void AccessibilityDetailedView::AppendAccessibilityList() { |
| 181 CreateScrollableList(); | 185 CreateScrollableList(); |
| 182 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 186 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 227 |
| 224 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); | 228 virtual_keyboard_enabled_ = delegate->IsVirtualKeyboardEnabled(); |
| 225 virtual_keyboard_view_ = | 229 virtual_keyboard_view_ = |
| 226 AddScrollListItem(bundle.GetLocalizedString( | 230 AddScrollListItem(bundle.GetLocalizedString( |
| 227 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), | 231 IDS_ASH_STATUS_TRAY_ACCESSIBILITY_VIRTUAL_KEYBOARD), |
| 228 virtual_keyboard_enabled_, virtual_keyboard_enabled_, | 232 virtual_keyboard_enabled_, virtual_keyboard_enabled_, |
| 229 kSystemMenuKeyboardIcon); | 233 kSystemMenuKeyboardIcon); |
| 230 } | 234 } |
| 231 | 235 |
| 232 void AccessibilityDetailedView::AppendHelpEntries() { | 236 void AccessibilityDetailedView::AppendHelpEntries() { |
| 237 DCHECK(!UseMdMenu()); |
| 233 // Currently the help page requires a browser window. | 238 // Currently the help page requires a browser window. |
| 234 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 | 239 // TODO(yoshiki): show this even on login/lock screen. crbug.com/158286 |
| 235 if (!CanOpenWebUISettings(login_)) | 240 if (!CanOpenWebUISettings(login_)) |
| 236 return; | 241 return; |
| 237 | 242 |
| 238 views::View* bottom_row = new View(); | 243 views::View* bottom_row = new View(); |
| 239 views::BoxLayout* layout = new views::BoxLayout( | 244 views::BoxLayout* layout = new views::BoxLayout( |
| 240 views::BoxLayout::kHorizontal, kTrayMenuBottomRowPadding, | 245 views::BoxLayout::kHorizontal, kTrayMenuBottomRowPadding, |
| 241 kTrayMenuBottomRowPadding, kTrayMenuBottomRowPaddingBetweenItems); | 246 kTrayMenuBottomRowPadding, kTrayMenuBottomRowPaddingBetweenItems); |
| 242 layout->SetDefaultFlex(1); | 247 layout->SetDefaultFlex(1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 258 | 263 |
| 259 AddChildView(bottom_row); | 264 AddChildView(bottom_row); |
| 260 } | 265 } |
| 261 | 266 |
| 262 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( | 267 HoverHighlightView* AccessibilityDetailedView::AddScrollListItem( |
| 263 const base::string16& text, | 268 const base::string16& text, |
| 264 bool highlight, | 269 bool highlight, |
| 265 bool checked, | 270 bool checked, |
| 266 const gfx::VectorIcon& icon) { | 271 const gfx::VectorIcon& icon) { |
| 267 HoverHighlightView* container = new HoverHighlightView(this); | 272 HoverHighlightView* container = new HoverHighlightView(this); |
| 268 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 273 if (UseMdMenu()) { |
| 269 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); | 274 gfx::ImageSkia image = CreateVectorIcon(icon, kMenuIconColor); |
| 270 const int padding = (kMenuButtonSize - image.width()) / 2; | 275 const int padding = (kMenuButtonSize - image.width()) / 2; |
| 271 container->AddIconAndLabelCustomSize( | 276 container->AddIconAndLabelCustomSize( |
| 272 image, text, highlight, | 277 image, text, highlight, |
| 273 image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding); | 278 image.width() + kMenuSeparatorVerticalPadding * 2, padding, padding); |
| 274 gfx::ImageSkia check_mark = | 279 gfx::ImageSkia check_mark = |
| 275 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); | 280 CreateVectorIcon(gfx::VectorIconId::CHECK_CIRCLE, gfx::kGoogleGreen700); |
| 276 container->AddRightIcon(check_mark, check_mark.width()); | 281 container->AddRightIcon(check_mark, check_mark.width()); |
| 277 container->SetRightIconVisible(checked); | 282 container->SetRightIconVisible(checked); |
| 278 } else { | 283 } else { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 328 |
| 324 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, | 329 void AccessibilityDetailedView::HandleButtonPressed(views::Button* sender, |
| 325 const ui::Event& event) { | 330 const ui::Event& event) { |
| 326 if (sender == help_view_) | 331 if (sender == help_view_) |
| 327 ShowHelp(); | 332 ShowHelp(); |
| 328 else if (sender == settings_view_) | 333 else if (sender == settings_view_) |
| 329 ShowSettings(); | 334 ShowSettings(); |
| 330 } | 335 } |
| 331 | 336 |
| 332 void AccessibilityDetailedView::CreateExtraTitleRowButtons() { | 337 void AccessibilityDetailedView::CreateExtraTitleRowButtons() { |
| 333 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 338 if (UseMdMenu()) { |
| 334 help_view_ = title_row()->AddHelpButton(this, login_); | 339 help_view_ = title_row()->AddHelpButton(this, login_); |
| 335 settings_view_ = title_row()->AddSettingsButton(this, login_); | 340 settings_view_ = title_row()->AddSettingsButton(this, login_); |
| 336 } | 341 } |
| 337 } | 342 } |
| 338 | 343 |
| 339 void AccessibilityDetailedView::ShowSettings() { | 344 void AccessibilityDetailedView::ShowSettings() { |
| 340 if (CanOpenWebUISettings(login_)) { | 345 if (CanOpenWebUISettings(login_)) { |
| 341 WmShell::Get()->system_tray_controller()->ShowAccessibilitySettings(); | 346 WmShell::Get()->system_tray_controller()->ShowAccessibilitySettings(); |
| 342 owner()->system_tray()->CloseSystemBubble(); | 347 owner()->system_tray()->CloseSystemBubble(); |
| 343 } | 348 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 if (detailed_popup_) | 477 if (detailed_popup_) |
| 473 detailed_popup_->GetWidget()->Close(); | 478 detailed_popup_->GetWidget()->Close(); |
| 474 if (detailed_menu_) | 479 if (detailed_menu_) |
| 475 detailed_menu_->GetWidget()->Close(); | 480 detailed_menu_->GetWidget()->Close(); |
| 476 } | 481 } |
| 477 | 482 |
| 478 previous_accessibility_state_ = accessibility_state; | 483 previous_accessibility_state_ = accessibility_state; |
| 479 } | 484 } |
| 480 | 485 |
| 481 } // namespace ash | 486 } // namespace ash |
| OLD | NEW |