#include "chrome/browser/notifications/persistent_notification_handler.h"
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "chrome/browser/notifications/metrics/notification_metrics_logger.h"
#include "chrome/browser/notifications/metrics/notification_metrics_logger_factory.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_permission_context.h"
#include "chrome/browser/notifications/platform_notification_service_factory.h"
#include "chrome/browser/notifications/platform_notification_service_impl.h"
#include "chrome/browser/permissions/notifications_engagement_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_uma_util.h"
#include "components/permissions/permission_util.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_event_dispatcher.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/permission_result.h"
#include "content/public/common/persistent_notification_status.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "url/gurl.h"
#include "url/origin.h"
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
#include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#endif
BrowserThread;
PersistentNotificationHandler::PersistentNotificationHandler() = default;
PersistentNotificationHandler::~PersistentNotificationHandler() = default;
void PersistentNotificationHandler::OnClose(
Profile* profile,
const GURL& origin,
const std::string& notification_id,
bool by_user,
base::OnceClosure completed_closure) { … }
void PersistentNotificationHandler::OnCloseCompleted(
Profile* profile,
base::OnceClosure completed_closure,
content::PersistentNotificationStatus status) { … }
void PersistentNotificationHandler::OnClick(
Profile* profile,
const GURL& origin,
const std::string& notification_id,
const std::optional<int>& action_index,
const std::optional<std::u16string>& reply,
base::OnceClosure completed_closure) { … }
void PersistentNotificationHandler::OnClickCompleted(
Profile* profile,
const std::string& notification_id,
base::OnceClosure completed_closure,
content::PersistentNotificationStatus status) { … }
void PersistentNotificationHandler::DisableNotifications(Profile* profile,
const GURL& origin) { … }
void PersistentNotificationHandler::OpenSettings(Profile* profile,
const GURL& origin) { … }
#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
PersistentNotificationHandler::NotificationKeepAliveState::
NotificationKeepAliveState(KeepAliveOrigin keep_alive_origin,
ProfileKeepAliveOrigin profile_keep_alive_origin)
: … { … }
PersistentNotificationHandler::NotificationKeepAliveState::
~NotificationKeepAliveState() = default;
void PersistentNotificationHandler::NotificationKeepAliveState::AddKeepAlive(
Profile* profile) { … }
void PersistentNotificationHandler::NotificationKeepAliveState::RemoveKeepAlive(
Profile* profile) { … }
#endif