Commit ad3e1064 authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Commit Bot

Do not enable experimental short notification timeouts for accessibility.

This cl ensures that short notification timeouts are not enabled if
at boot the user has enabled Chrome Vox, magnifier, autoclicks or
select to speak.

Bug: 1059017
Change-Id: I033ea01ee30330a3238bd13f5c94fd21c028734a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2105763
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750894}
parent 1f91bbfd
......@@ -21,6 +21,7 @@
#include "base/command_line.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/popup_timers_controller.h"
......@@ -45,6 +46,16 @@ void MessageCenterController::RegisterProfilePrefs(
namespace {
bool DisableShortNotificationsForAccessibility(PrefService* pref_service) {
DCHECK(pref_service);
return (
pref_service->GetBoolean(prefs::kAccessibilityAutoclickEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilityScreenMagnifierEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilitySelectToSpeakEnabled) ||
pref_service->GetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled) ||
pref_service->GetBoolean(prefs::kDockedMagnifierEnabled));
}
// A notification blocker that unconditionally blocks toasts. Implements
// --suppress-message-center-notifications.
class PopupNotificationBlocker : public message_center::NotificationBlocker {
......@@ -75,18 +86,14 @@ MessageCenterController::MessageCenterController() {
session_state_notification_blocker_ =
std::make_unique<SessionStateNotificationBlocker>(MessageCenter::Get());
Shell::Get()->session_controller()->AddObserver(this);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSuppressMessageCenterPopups)) {
all_popup_blocker_ =
std::make_unique<PopupNotificationBlocker>(MessageCenter::Get());
}
if (features::IsNotificationExperimentalShortTimeoutsEnabled()) {
message_center::PopupTimersController::SetNotificationTimeouts(
message_center::kAutocloseShortDelaySeconds,
message_center::kAutocloseShortDelaySeconds);
}
// Set the system notification source display name ("Chrome OS" or "Chromium
// OS").
message_center::MessageCenter::Get()->SetSystemNotificationAppName(
......@@ -102,6 +109,8 @@ MessageCenterController::~MessageCenterController() {
fullscreen_notification_blocker_.reset();
arc_notification_manager_.reset();
Shell::Get()->session_controller()->RemoveObserver(this);
message_center::MessageCenter::Shutdown();
}
......@@ -120,4 +129,16 @@ void MessageCenterController::SetArcNotificationsInstance(
arc_notification_manager_->SetInstance(std::move(arc_notification_instance));
}
void MessageCenterController::OnActiveUserPrefServiceChanged(
PrefService* prefs) {
if (!features::IsNotificationExperimentalShortTimeoutsEnabled() ||
DisableShortNotificationsForAccessibility(prefs)) {
return;
}
message_center::PopupTimersController::SetNotificationTimeouts(
message_center::kAutocloseShortDelaySeconds,
message_center::kAutocloseShortDelaySeconds);
}
} // namespace ash
......@@ -9,6 +9,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/arc_notifications_host_initializer.h"
#include "ash/session/session_observer.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
......@@ -28,7 +29,8 @@ class SessionStateNotificationBlocker;
// This class manages the ash message center and allows clients (like Chrome) to
// add and remove notifications.
class ASH_EXPORT MessageCenterController
: public ArcNotificationsHostInitializer {
: public ArcNotificationsHostInitializer,
public SessionObserver {
public:
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
......@@ -40,6 +42,9 @@ class ASH_EXPORT MessageCenterController
mojo::PendingRemote<arc::mojom::NotificationsInstance>
arc_notification_instance) override;
// SessionObserver:
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
InactiveUserNotificationBlocker*
inactive_user_notification_blocker_for_testing() {
return inactive_user_notification_blocker_.get();
......
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