blob: d5823b1e53c7ff06982e9552a2a833e5da433cc9 [file] [log] [blame]
// Copyright 2015 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 <stdint.h>
#include <string>
#include "base/optional.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "third_party/blink/public/common/notifications/platform_notification_data.h"
#include "url/gurl.h"
namespace content {
// Stores information about a Web Notification as available in the notification
// database. Beyond the notification's own data, its id and attribution need
// to be available for users of the database as well.
// Note: There are extra properties being stored for UKM logging purposes.
// TODO( Add the UKM that will use these properties.
struct CONTENT_EXPORT NotificationDatabaseData {
NotificationDatabaseData(const NotificationDatabaseData& other);
NotificationDatabaseData& operator=(const NotificationDatabaseData& other);
// Corresponds to why a notification was closed.
enum class ClosedReason {
// The user explicitly closed the notification.
// The notification was closed by the developer.
// The notification was found to be closed in the notification database,
// but why it was closed was not found.
// Id of the notification as assigned by the NotificationIdGenerator.
std::string notification_id;
// Origin of the website this notification is associated with.
GURL origin;
// Id of the Service Worker registration this notification is associated with.
int64_t service_worker_registration_id = 0;
// Platform data of the notification that's being stored.
blink::PlatformNotificationData notification_data;
// Boolean for if this current notification is replacing an existing
// notification.
bool replaced_existing_notification = false;
// Number of clicks on the notification itself, i.e. clicks on the
// notification that take the user to the website. This excludes action
// button clicks.
int num_clicks = 0;
// Number of action button clicks.
int num_action_button_clicks = 0;
// Time the notification was first requested to be shown.
base::Time creation_time_millis;
// Amount of time, in ms, between when the notification is shown and the
// first click.
base::Optional<base::TimeDelta> time_until_first_click_millis;
// Amount of time, in ms, between when the notification is shown and the
// last click.
base::Optional<base::TimeDelta> time_until_last_click_millis;
// Amount of time, in ms, between when the notification is shown and closed.
base::Optional<base::TimeDelta> time_until_close_millis;
// Why the notification was closed.
ClosedReason closed_reason = ClosedReason::UNKNOWN;
} // namespace content