Commit 3e907629 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Show all notifications as banners on macOS 10.15+

This is a temporary workaround as the XPC used to show alert style
notifications does not work on 10.15+. Showing those as banners is
not ideal as they auto dismiss into the notifications center but it
is better than not showing them at all.

Bug: 1007418
Change-Id: Ib50ed9f2125b7bdf5885b5ffd63e81137e50e2a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883648Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709887}
parent 4ce2a144
...@@ -123,6 +123,12 @@ base::string16 CreateNotificationTitle( ...@@ -123,6 +123,12 @@ base::string16 CreateNotificationTitle(
bool IsPersistentNotification( bool IsPersistentNotification(
const message_center::Notification& notification) { const message_center::Notification& notification) {
// TODO(crbug.com/1007418): Remove this and find a way to show alert style
// notifications in 10.15 and above. At least show them as banners until then
// as a temporary workaround.
if (base::mac::IsAtLeastOS10_15())
return false;
return notification.never_timeout() || return notification.never_timeout() ||
notification.type() == message_center::NOTIFICATION_TYPE_PROGRESS; notification.type() == message_center::NOTIFICATION_TYPE_PROGRESS;
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/i18n/number_formatting.h" #include "base/i18n/number_formatting.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -280,6 +281,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayOneButton) { ...@@ -280,6 +281,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayOneButton) {
} }
TEST_F(NotificationPlatformBridgeMacTest, TestDisplayProgress) { TEST_F(NotificationPlatformBridgeMacTest, TestDisplayProgress) {
// TODO(crbug.com/1007418): Enable this when we support alerts on 10.15 again.
if (base::mac::IsAtLeastOS10_15())
return;
std::unique_ptr<Notification> notification = std::unique_ptr<Notification> notification =
CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr); CreateBanner("Title", "Context", "https://gmail.com", nullptr, nullptr);
const int kSamplePercent = 10; const int kSamplePercent = 10;
...@@ -357,6 +362,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesNotifications) { ...@@ -357,6 +362,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesNotifications) {
} }
TEST_F(NotificationPlatformBridgeMacTest, TestDisplayAlert) { TEST_F(NotificationPlatformBridgeMacTest, TestDisplayAlert) {
// TODO(crbug.com/1007418): Enable this when we support alerts on 10.15 again.
if (base::mac::IsAtLeastOS10_15())
return;
std::unique_ptr<Notification> alert = std::unique_ptr<Notification> alert =
CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr); CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr);
std::unique_ptr<NotificationPlatformBridgeMac> bridge( std::unique_ptr<NotificationPlatformBridgeMac> bridge(
...@@ -369,6 +378,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayAlert) { ...@@ -369,6 +378,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayAlert) {
} }
TEST_F(NotificationPlatformBridgeMacTest, TestDisplayBannerAndAlert) { TEST_F(NotificationPlatformBridgeMacTest, TestDisplayBannerAndAlert) {
// TODO(crbug.com/1007418): Enable this when we support alerts on 10.15 again.
if (base::mac::IsAtLeastOS10_15())
return;
std::unique_ptr<Notification> alert = std::unique_ptr<Notification> alert =
CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr); CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr);
std::unique_ptr<Notification> banner = CreateBanner( std::unique_ptr<Notification> banner = CreateBanner(
...@@ -385,6 +398,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayBannerAndAlert) { ...@@ -385,6 +398,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayBannerAndAlert) {
} }
TEST_F(NotificationPlatformBridgeMacTest, TestCloseAlert) { TEST_F(NotificationPlatformBridgeMacTest, TestCloseAlert) {
// TODO(crbug.com/1007418): Enable this when we support alerts on 10.15 again.
if (base::mac::IsAtLeastOS10_15())
return;
std::unique_ptr<Notification> alert = std::unique_ptr<Notification> alert =
CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr); CreateAlert("Title", "Context", "https://gmail.com", "Button 1", nullptr);
std::unique_ptr<NotificationPlatformBridgeMac> bridge( std::unique_ptr<NotificationPlatformBridgeMac> bridge(
...@@ -400,6 +417,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestCloseAlert) { ...@@ -400,6 +417,10 @@ TEST_F(NotificationPlatformBridgeMacTest, TestCloseAlert) {
} }
TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesBannersAndAlerts) { TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesBannersAndAlerts) {
// TODO(crbug.com/1007418): Enable this when we support alerts on 10.15 again.
if (base::mac::IsAtLeastOS10_15())
return;
std::unique_ptr<Notification> notification = CreateBanner( std::unique_ptr<Notification> notification = CreateBanner(
"Title", "Context", "https://gmail.com", "Button 1", nullptr); "Title", "Context", "https://gmail.com", "Button 1", nullptr);
std::unique_ptr<Notification> alert = std::unique_ptr<Notification> alert =
......
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