#include "chrome/browser/notifications/notification_display_service_impl.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/notifications/non_persistent_notification_handler.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/notifications/persistent_notification_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/tailored_security/notification_handler_desktop.h"
#include "chrome/browser/updates/announcement_notification/announcement_notification_handler.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/message_center/public/cpp/notification.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/notifications/extension_notification_handler.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_MAC) || \
BUILDFLAG(IS_WIN)
#include "chrome/browser/send_tab_to_self/desktop_notification_handler.h"
#include "chrome/browser/sharing/sharing_notification_handler.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/nearby_sharing/nearby_notification_handler.h"
#include "chrome/browser/nearby_sharing/nearby_sharing_service_factory.h"
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/notifications/muted_notification_handler.h"
#include "chrome/browser/notifications/screen_capture_notification_blocker.h"
#endif
namespace {
void OperationCompleted() { … }
}
NotificationDisplayServiceImpl* NotificationDisplayServiceImpl::GetForProfile(
Profile* profile) { … }
void NotificationDisplayServiceImpl::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
NotificationDisplayServiceImpl::NotificationDisplayServiceImpl(Profile* profile)
: … { … }
NotificationDisplayServiceImpl::~NotificationDisplayServiceImpl() { … }
void NotificationDisplayServiceImpl::ProcessNotificationOperation(
NotificationOperation operation,
NotificationHandler::Type notification_type,
const GURL& origin,
const std::string& notification_id,
const std::optional<int>& action_index,
const std::optional<std::u16string>& reply,
const std::optional<bool>& by_user) { … }
void NotificationDisplayServiceImpl::AddNotificationHandler(
NotificationHandler::Type notification_type,
std::unique_ptr<NotificationHandler> handler) { … }
NotificationHandler* NotificationDisplayServiceImpl::GetNotificationHandler(
NotificationHandler::Type notification_type) { … }
void NotificationDisplayServiceImpl::Shutdown() { … }
void NotificationDisplayServiceImpl::Display(
NotificationHandler::Type notification_type,
const message_center::Notification& notification,
std::unique_ptr<NotificationCommon::Metadata> metadata) { … }
void NotificationDisplayServiceImpl::Close(
NotificationHandler::Type notification_type,
const std::string& notification_id) { … }
void NotificationDisplayServiceImpl::GetDisplayed(
DisplayedNotificationsCallback callback) { … }
void NotificationDisplayServiceImpl::GetDisplayedForOrigin(
const GURL& origin,
DisplayedNotificationsCallback callback) { … }
void NotificationDisplayServiceImpl::AddObserver(Observer* observer) { … }
void NotificationDisplayServiceImpl::RemoveObserver(Observer* observer) { … }
void NotificationDisplayServiceImpl::ProfileLoadedCallback(
NotificationOperation operation,
NotificationHandler::Type notification_type,
const GURL& origin,
const std::string& notification_id,
const std::optional<int>& action_index,
const std::optional<std::u16string>& reply,
const std::optional<bool>& by_user,
Profile* profile) { … }
void NotificationDisplayServiceImpl::SetBlockersForTesting(
NotificationDisplayQueue::NotificationBlockers blockers) { … }
void NotificationDisplayServiceImpl::
SetNotificationPlatformBridgeDelegatorForTesting(
std::unique_ptr<NotificationPlatformBridgeDelegator> bridge_delegator) { … }
void NotificationDisplayServiceImpl::OverrideNotificationHandlerForTesting(
NotificationHandler::Type notification_type,
std::unique_ptr<NotificationHandler> handler) { … }
void NotificationDisplayServiceImpl::OnNotificationPlatformBridgeReady() { … }
void NotificationDisplayServiceImpl::OnGetDisplayed(
std::optional<GURL> origin,
DisplayedNotificationsCallback callback,
std::set<std::string> notification_ids,
bool supports_synchronization) { … }