Commit 89aef5a0 authored by Mohamed Adel's avatar Mohamed Adel Committed by Commit Bot

Added bridge that will support the new notification API

This CL introduces the addition of the bridge that will support
Apple's notification API UNUserNotification.

Fixed a typo in notification_platform_bridge_mac.h

Added a condition that determines which bridge to use in
notification_platform_bridge_mac.mm. As of now if the feature
flag:kNewMacNotificationAPI is set to Enabled, no notifications will
be delivered and the request to send notifications won't be triggered.

Bug: 1127330
Change-Id: Ia673c5e390a05f88da61862d78d57f6fa8510f7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404841Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Commit-Queue: Mohamed Adel <adelm@google.com>
Cr-Commit-Position: refs/heads/master@{#806212}
parent 4db85cee
......@@ -4454,6 +4454,8 @@ static_library("browser") {
"notifications/alert_dispatcher_mac.h",
"notifications/notification_platform_bridge_mac.h",
"notifications/notification_platform_bridge_mac.mm",
"notifications/notification_platform_bridge_mac_unnotification.h",
"notifications/notification_platform_bridge_mac_unnotification.mm",
"obsolete_system/obsolete_system_mac.cc",
"password_manager/password_manager_util_mac.h",
"password_manager/password_manager_util_mac.mm",
......
......@@ -19,9 +19,9 @@
@class NSUserNotificationCenter;
@class NSXPCConnection;
namespace message_cener {
namespace message_center {
class Notification;
}
} // namespace message_center
// This class is an implementation of NotificationPlatformBridge that will
// send platform notifications to the the MacOSX notification center.
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/notifications/notification_platform_bridge_mac.h"
#include "chrome/browser/notifications/notification_platform_bridge_mac_unnotification.h"
#include <memory>
#include <utility>
......@@ -11,6 +12,7 @@
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/feature_list.h"
#include "base/i18n/number_formatting.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
......@@ -24,6 +26,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_display_service_impl.h"
......@@ -222,6 +225,9 @@ NotificationPlatformBridgeMac::~NotificationPlatformBridgeMac() {
// static
std::unique_ptr<NotificationPlatformBridge>
NotificationPlatformBridge::Create() {
if (base::FeatureList::IsEnabled(features::kNewMacNotificationAPI)) {
return std::make_unique<NotificationPlatformBridgeMacUNNotification>();
}
base::scoped_nsobject<AlertDispatcherImpl> alert_dispatcher(
[[AlertDispatcherImpl alloc] init]);
return std::make_unique<NotificationPlatformBridgeMac>(
......
// Copyright 2020 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 CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_UNNOTIFICATION_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_UNNOTIFICATION_H_
#include <memory>
#include <string>
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
namespace message_center {
class Notification;
} // namespace message_center
// This class is an implementation of NotificationPlatformBridge that will
// send platform notifications to the the MacOSX notification center for devices
// running on macOS 10.14+.
class NotificationPlatformBridgeMacUNNotification
: public NotificationPlatformBridge {
public:
NotificationPlatformBridgeMacUNNotification();
NotificationPlatformBridgeMacUNNotification(
const NotificationPlatformBridgeMacUNNotification&) = delete;
NotificationPlatformBridgeMacUNNotification& operator=(
const NotificationPlatformBridgeMacUNNotification&) = delete;
~NotificationPlatformBridgeMacUNNotification() override;
// NotificationPlatformBridge implementation.
void Display(NotificationHandler::Type notification_type,
Profile* profile,
const message_center::Notification& notification,
std::unique_ptr<NotificationCommon::Metadata> metadata) override;
void Close(Profile* profile, const std::string& notification_id) override;
void GetDisplayed(Profile* profile,
GetDisplayedNotificationsCallback callback) const override;
void SetReadyCallback(NotificationBridgeReadyCallback callback) override;
void DisplayServiceShutDown(Profile* profile) override;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_MAC_UNNOTIFICATION_H_
// Copyright 2020 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 "chrome/browser/notifications/notification_platform_bridge_mac_unnotification.h"
#include "base/notreached.h"
NotificationPlatformBridgeMacUNNotification::
NotificationPlatformBridgeMacUNNotification() = default;
NotificationPlatformBridgeMacUNNotification::
~NotificationPlatformBridgeMacUNNotification() = default;
void NotificationPlatformBridgeMacUNNotification::Display(
NotificationHandler::Type notification_type,
Profile* profile,
const message_center::Notification& notification,
std::unique_ptr<NotificationCommon::Metadata> metadata) {
NOTIMPLEMENTED();
}
void NotificationPlatformBridgeMacUNNotification::Close(
Profile* profile,
const std::string& notification_id) {
NOTIMPLEMENTED();
}
void NotificationPlatformBridgeMacUNNotification::GetDisplayed(
Profile* profile,
GetDisplayedNotificationsCallback callback) const {
NOTIMPLEMENTED();
std::move(callback).Run(/*notification_ids=*/{}, /*supports_sync=*/false);
}
void NotificationPlatformBridgeMacUNNotification::SetReadyCallback(
NotificationBridgeReadyCallback callback) {
NOTIMPLEMENTED();
std::move(callback).Run(/*success=*/true);
}
void NotificationPlatformBridgeMacUNNotification::DisplayServiceShutDown(
Profile* profile) {
NOTIMPLEMENTED();
}
\ No newline at end of file
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