Commit 6351ff51 authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add a11y feature pod button.

This CL adds a feature pod button for accessibility. By clicking on the
button, it will show accessibility detailed view of the existing
SystemTray. This behavior is described as Development Stage 1 in the
design doc: go/cros-qs-restyling

Screenshot: http://screen/scc32RkykN2

TEST=AccessibilityFeaturePodControllerTest
BUG=821671

Change-Id: I2c9f91b86c70e5bad3c1eb4261c14e4d167f0473
Reviewed-on: https://chromium-review.googlesource.com/961923
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543041}
parent d2c19e0c
...@@ -753,6 +753,8 @@ component("ash") { ...@@ -753,6 +753,8 @@ component("ash") {
"system/tray_drag_controller.h", "system/tray_drag_controller.h",
"system/tray_tracing.cc", "system/tray_tracing.cc",
"system/tray_tracing.h", "system/tray_tracing.h",
"system/unified/accessibility_feature_pod_controller.cc",
"system/unified/accessibility_feature_pod_controller.h",
"system/unified/collapse_button.cc", "system/unified/collapse_button.cc",
"system/unified/collapse_button.h", "system/unified/collapse_button.h",
"system/unified/feature_pod_button.cc", "system/unified/feature_pod_button.cc",
...@@ -1585,6 +1587,7 @@ test("ash_unittests") { ...@@ -1585,6 +1587,7 @@ test("ash_unittests") {
"system/tray_accessibility_unittest.cc", "system/tray_accessibility_unittest.cc",
"system/tray_caps_lock_unittest.cc", "system/tray_caps_lock_unittest.cc",
"system/tray_tracing_unittest.cc", "system/tray_tracing_unittest.cc",
"system/unified/accessibility_feature_pod_controller_unittest.cc",
"system/unified/top_shortcuts_view_unittest.cc", "system/unified/top_shortcuts_view_unittest.cc",
"system/unified/unified_system_info_view_unittest.cc", "system/unified/unified_system_info_view_unittest.cc",
"system/update/tray_update_unittest.cc", "system/update/tray_update_unittest.cc",
......
...@@ -410,6 +410,10 @@ TrayBluetooth* SystemTray::GetTrayBluetooth() const { ...@@ -410,6 +410,10 @@ TrayBluetooth* SystemTray::GetTrayBluetooth() const {
return tray_bluetooth_; return tray_bluetooth_;
} }
TrayAccessibility* SystemTray::GetTrayAccessibility() const {
return tray_accessibility_;
}
void SystemTray::CanSwitchAwayFromActiveUser( void SystemTray::CanSwitchAwayFromActiveUser(
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> callback) {
// If neither screen sharing nor capturing is going on we can immediately // If neither screen sharing nor capturing is going on we can immediately
......
...@@ -124,6 +124,8 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView { ...@@ -124,6 +124,8 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView {
TrayNetwork* GetTrayNetwork() const; TrayNetwork* GetTrayNetwork() const;
// Returns TrayBluetooth object if present or null otherwise. // Returns TrayBluetooth object if present or null otherwise.
TrayBluetooth* GetTrayBluetooth() const; TrayBluetooth* GetTrayBluetooth() const;
// Returns TrayAccessibility object if present or null otherwise.
TrayAccessibility* GetTrayAccessibility() const;
// Determines if it's ok to switch away from the currently active user. Screen // Determines if it's ok to switch away from the currently active user. Screen
// casting may block this (or at least throw up a confirmation dialog). Calls // casting may block this (or at least throw up a confirmation dialog). Calls
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/unified/accessibility_feature_pod_controller.h"
#include "ash/accessibility/accessibility_delegate.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ui/base/l10n/l10n_util.h"
namespace ash {
AccessibilityFeaturePodController::AccessibilityFeaturePodController(
UnifiedSystemTrayController* tray_controller)
: tray_controller_(tray_controller) {}
AccessibilityFeaturePodController::~AccessibilityFeaturePodController() =
default;
FeaturePodButton* AccessibilityFeaturePodController::CreateButton() {
auto* button = new FeaturePodButton(this);
button->SetLabel(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBILITY));
button->SetVectorIcon(kSystemMenuAccessibilityIcon);
AccessibilityDelegate* delegate = Shell::Get()->accessibility_delegate();
LoginStatus login_status = Shell::Get()->session_controller()->login_status();
button->SetVisible(login_status == LoginStatus::NOT_LOGGED_IN ||
delegate->ShouldShowAccessibilityMenu());
return button;
}
void AccessibilityFeaturePodController::OnPressed() {
tray_controller_->ShowAccessibilityDetailedView();
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_UNIFIED_ACCESSIBILITY_FEATURE_POD_CONTROLLER_H_
#define ASH_SYSTEM_UNIFIED_ACCESSIBILITY_FEATURE_POD_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/system/unified/feature_pod_controller_base.h"
#include "base/macros.h"
namespace ash {
class UnifiedSystemTrayController;
// Controller of accessibility feature pod button.
class ASH_EXPORT AccessibilityFeaturePodController
: public FeaturePodControllerBase {
public:
AccessibilityFeaturePodController(
UnifiedSystemTrayController* tray_controller);
~AccessibilityFeaturePodController() override;
// FeaturePodControllerBase:
FeaturePodButton* CreateButton() override;
void OnPressed() override;
private:
// Unowned.
UnifiedSystemTrayController* const tray_controller_;
DISALLOW_COPY_AND_ASSIGN(AccessibilityFeaturePodController);
};
} // namespace ash
#endif // ASH_SYSTEM_UNIFIED_ACCESSIBILITY_FEATURE_POD_CONTROLLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/unified/accessibility_feature_pod_controller.h"
#include "ash/system/unified/feature_pod_button.h"
#include "ash/system/unified/unified_system_tray_controller.h"
#include "ash/test/ash_test_base.h"
namespace ash {
// Tests manually control their session state.
class AccessibilityFeaturePodControllerTest : public NoSessionAshTestBase {
public:
AccessibilityFeaturePodControllerTest() = default;
~AccessibilityFeaturePodControllerTest() override = default;
void SetUp() override {
NoSessionAshTestBase::SetUp();
tray_controller_ =
std::make_unique<UnifiedSystemTrayController>(GetPrimarySystemTray());
}
void TearDown() override {
button_.reset();
controller_.reset();
tray_controller_.reset();
NoSessionAshTestBase::TearDown();
}
protected:
void SetUpButton() {
controller_ =
std::make_unique<AccessibilityFeaturePodController>(tray_controller());
button_.reset(controller_->CreateButton());
}
UnifiedSystemTrayController* tray_controller() {
return tray_controller_.get();
}
FeaturePodButton* button() { return button_.get(); }
private:
std::unique_ptr<UnifiedSystemTrayController> tray_controller_;
std::unique_ptr<AccessibilityFeaturePodController> controller_;
std::unique_ptr<FeaturePodButton> button_;
DISALLOW_COPY_AND_ASSIGN(AccessibilityFeaturePodControllerTest);
};
TEST_F(AccessibilityFeaturePodControllerTest, ButtonVisibilityNotLoggedIn) {
SetUpButton();
// If not logged in, it should be always visible.
EXPECT_TRUE(button()->visible());
}
TEST_F(AccessibilityFeaturePodControllerTest, ButtonVisibilityLoggedIn) {
CreateUserSessions(1);
SetUpButton();
// If logged in, it's not visible by default.
EXPECT_FALSE(button()->visible());
}
} // namespace ash
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include "ash/system/rotation/rotation_lock_feature_pod_controller.h" #include "ash/system/rotation/rotation_lock_feature_pod_controller.h"
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_controller.h" #include "ash/system/tray/system_tray_controller.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/unified/accessibility_feature_pod_controller.h"
#include "ash/system/unified/feature_pod_controller_base.h" #include "ash/system/unified/feature_pod_controller_base.h"
#include "ash/system/unified/quiet_mode_feature_pod_controller.h" #include "ash/system/unified/quiet_mode_feature_pod_controller.h"
#include "ash/system/unified/unified_system_tray_view.h" #include "ash/system/unified/unified_system_tray_view.h"
...@@ -91,12 +93,23 @@ void UnifiedSystemTrayController::ShowBluetoothDetailedView() { ...@@ -91,12 +93,23 @@ void UnifiedSystemTrayController::ShowBluetoothDetailedView() {
BubbleCreationType::BUBBLE_USE_EXISTING); BubbleCreationType::BUBBLE_USE_EXISTING);
} }
void UnifiedSystemTrayController::ShowAccessibilityDetailedView() {
// TODO(tetsui): Implement UnifiedSystemTray's Accessibility detailed view.
// Initially create default view to set |default_bubble_height_|.
system_tray_->ShowDefaultView(BubbleCreationType::BUBBLE_CREATE_NEW,
true /* show_by_click */);
system_tray_->ShowDetailedView(system_tray_->GetTrayAccessibility(), 0,
BubbleCreationType::BUBBLE_USE_EXISTING);
}
void UnifiedSystemTrayController::InitFeaturePods() { void UnifiedSystemTrayController::InitFeaturePods() {
AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<NetworkFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this)); AddFeaturePodItem(std::make_unique<BluetoothFeaturePodController>(this));
AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>()); AddFeaturePodItem(std::make_unique<QuietModeFeaturePodController>());
AddFeaturePodItem(std::make_unique<RotationLockFeaturePodController>()); AddFeaturePodItem(std::make_unique<RotationLockFeaturePodController>());
AddFeaturePodItem(std::make_unique<NightLightFeaturePodController>()); AddFeaturePodItem(std::make_unique<NightLightFeaturePodController>());
AddFeaturePodItem(std::make_unique<AccessibilityFeaturePodController>(this));
// If you want to add a new feature pod item, add here. // If you want to add a new feature pod item, add here.
// TODO(tetsui): Add more feature pod items in spec. // TODO(tetsui): Add more feature pod items in spec.
......
...@@ -44,6 +44,8 @@ class ASH_EXPORT UnifiedSystemTrayController { ...@@ -44,6 +44,8 @@ class ASH_EXPORT UnifiedSystemTrayController {
void ShowNetworkDetailedView(); void ShowNetworkDetailedView();
// Show the detailed view of bluetooth. Called from the view. // Show the detailed view of bluetooth. Called from the view.
void ShowBluetoothDetailedView(); void ShowBluetoothDetailedView();
// Show the detailed view of accessibility. Called from the view.
void ShowAccessibilityDetailedView();
private: private:
// Initialize feature pod controllers and their views. // Initialize feature pod controllers and their views.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment