#include "content/browser/notifications/blink_notification_service_impl.h"
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "content/browser/notifications/notification_event_dispatcher_impl.h"
#include "content/browser/notifications/platform_notification_context_impl.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_database_data.h"
#include "content/public/browser/permission_controller.h"
#include "content/public/browser/platform_notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/weak_document_ptr.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
#include "third_party/blink/public/common/notifications/notification_constants.h"
#include "third_party/blink/public/common/notifications/notification_resources.h"
#include "third_party/blink/public/common/notifications/platform_notification_data.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
namespace content {
namespace {
const char kBadMessageImproperNotificationImage[] = …;
const char kBadMessageInvalidNotificationTriggerTimestamp[] = …;
const char kBadMessageInvalidNotificationActionButtons[] = …;
const char kBadMessageNonPersistentNotificationFromServiceWorker[] = …;
bool FilterByTag(const std::string& filter_tag,
const NotificationDatabaseData& database_data) { … }
bool FilterByTriggered(bool include_triggered,
const NotificationDatabaseData& database_data) { … }
bool CheckNotificationTriggerRange(
const blink::PlatformNotificationData& data) { … }
}
PersistentNotificationError;
BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
PlatformNotificationContextImpl* notification_context,
BrowserContext* browser_context,
scoped_refptr<ServiceWorkerContextWrapper> service_worker_context,
RenderProcessHost* render_process_host,
const blink::StorageKey& storage_key,
const GURL& document_url,
const WeakDocumentPtr& weak_document_ptr,
RenderProcessHost::NotificationServiceCreatorType creator_type,
mojo::PendingReceiver<blink::mojom::NotificationService> receiver)
: … { … }
BlinkNotificationServiceImpl::~BlinkNotificationServiceImpl() { … }
void BlinkNotificationServiceImpl::GetPermissionStatus(
GetPermissionStatusCallback callback) { … }
void BlinkNotificationServiceImpl::OnConnectionError() { … }
bool BlinkNotificationServiceImpl::IsValidForNonPersistentNotification() { … }
void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
const std::string& token,
const blink::PlatformNotificationData& platform_notification_data,
const blink::NotificationResources& notification_resources,
mojo::PendingRemote<blink::mojom::NonPersistentNotificationListener>
event_listener_remote) { … }
void BlinkNotificationServiceImpl::CloseNonPersistentNotification(
const std::string& token) { … }
blink::mojom::PermissionStatus
BlinkNotificationServiceImpl::CheckPermissionStatus() { … }
bool BlinkNotificationServiceImpl::ValidateNotificationDataAndResources(
const blink::PlatformNotificationData& platform_notification_data,
const blink::NotificationResources& notification_resources) { … }
void BlinkNotificationServiceImpl::DisplayPersistentNotification(
int64_t service_worker_registration_id,
const blink::PlatformNotificationData& platform_notification_data,
const blink::NotificationResources& notification_resources,
DisplayPersistentNotificationCallback callback) { … }
void BlinkNotificationServiceImpl::DidWriteNotificationData(
DisplayPersistentNotificationCallback callback,
bool success,
const std::string& notification_id) { … }
void BlinkNotificationServiceImpl::ClosePersistentNotification(
const std::string& notification_id) { … }
void BlinkNotificationServiceImpl::GetNotifications(
int64_t service_worker_registration_id,
const std::string& filter_tag,
bool include_triggered,
GetNotificationsCallback callback) { … }
void BlinkNotificationServiceImpl::DidGetNotifications(
const std::string& filter_tag,
bool include_triggered,
GetNotificationsCallback callback,
bool success,
const std::vector<NotificationDatabaseData>& notifications) { … }
}