Commit 75970e03 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

[Ash] Add --suppress-message-center-popups.

This hides all notification popups. Its only purpose is for making sure
popups don't interfere with automated tests.

Bug: 807101
Change-Id: I7776af1b0fbd795ed1899a78fa5a7aef1c7b6f9a
Reviewed-on: https://chromium-review.googlesource.com/894152
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533736}
parent e7ad7238
......@@ -4,6 +4,8 @@
#include "ash/message_center/message_center_controller.h"
#include "ash/public/cpp/ash_switches.h"
#include "base/command_line.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
#include "ui/message_center/public/cpp/notifier_id.h"
......@@ -15,6 +17,23 @@ namespace ash {
namespace {
// A notification blocker that unconditionally blocks toasts. Implements
// --suppress-message-center-notifications.
class PopupNotificationBlocker : public message_center::NotificationBlocker {
public:
PopupNotificationBlocker(MessageCenter* message_center)
: NotificationBlocker(message_center) {}
~PopupNotificationBlocker() override = default;
bool ShouldShowNotificationAsPopup(
const message_center::Notification& notification) const override {
return false;
}
private:
DISALLOW_COPY_AND_ASSIGN(PopupNotificationBlocker);
};
// This notification delegate passes actions back to the client that asked for
// the notification (Chrome).
class AshClientNotificationDelegate
......@@ -51,7 +70,13 @@ MessageCenterController::MessageCenterController()
: fullscreen_notification_blocker_(MessageCenter::Get()),
inactive_user_notification_blocker_(MessageCenter::Get()),
session_state_notification_blocker_(MessageCenter::Get()),
binding_(this) {}
binding_(this) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSuppressMessageCenterPopups)) {
all_popup_blocker_ =
std::make_unique<PopupNotificationBlocker>(MessageCenter::Get());
}
}
MessageCenterController::~MessageCenterController() = default;
......
......@@ -74,6 +74,7 @@ class ASH_EXPORT MessageCenterController
FullscreenNotificationBlocker fullscreen_notification_blocker_;
InactiveUserNotificationBlocker inactive_user_notification_blocker_;
SessionStateNotificationBlocker session_state_notification_blocker_;
std::unique_ptr<message_center::NotificationBlocker> all_popup_blocker_;
NotifierSettingsListener* notifier_id_ = nullptr;
......
......@@ -184,6 +184,9 @@ const char kShowWebUiLock[] = "show-webui-lock";
const char kTouchscreenUsableWhileScreenOff[] =
"touchscreen-usable-while-screen-off";
// Hides all Message Center notification popups (toasts). Used for testing.
const char kSuppressMessageCenterPopups[] = "suppress-message-center-popups";
// By default we use classic IME (i.e. InputMethodChromeOS) in kMus. This flag
// enables the IME service (i.e. InputMethodMus) instead.
const char kUseIMEService[] = "use-ime-service";
......
......@@ -66,6 +66,7 @@ ASH_PUBLIC_EXPORT extern const char kShowPowerButtonMenu[];
ASH_PUBLIC_EXPORT extern const char kShowTaps[];
ASH_PUBLIC_EXPORT extern const char kShowViewsLogin[];
ASH_PUBLIC_EXPORT extern const char kShowWebUiLock[];
ASH_PUBLIC_EXPORT extern const char kSuppressMessageCenterPopups[];
ASH_PUBLIC_EXPORT extern const char kTouchscreenUsableWhileScreenOff[];
ASH_PUBLIC_EXPORT extern const char kUseIMEService[];
......
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