blob: d83d2b2f037d55755243dee8fe00500e78e2e60f [file] [log] [blame]
miguelg3cc06ec2016-06-30 09:14:091// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_
6#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_
7
miguelg30dfc2e2017-06-14 18:18:098#include "base/feature_list.h"
Peter Beverloo6dba2e102017-11-23 17:46:339#include "chrome/browser/notifications/notification_handler.h"
Evan Stade4ebefdf42017-09-21 23:50:1810#include "url/gurl.h"
miguelg30dfc2e2017-06-14 18:18:0911
miguelg30dfc2e2017-06-14 18:18:0912class GURL;
13class Profile;
14
miguelg3cc06ec2016-06-30 09:14:0915// Shared functionality for both in page and persistent notification
16class NotificationCommon {
17 public:
18 // Things as user can do to a notification.
peter28d8b732017-04-11 17:36:1719 // TODO(peter): Prefix these options with OPERATION_.
miguelg3cc06ec2016-06-30 09:14:0920 enum Operation {
21 CLICK = 0,
22 CLOSE = 1,
Peter Beverloo884488b2017-12-05 18:20:2823 DISABLE_PERMISSION = 2,
24 SETTINGS = 3,
miguelg4ca5df82016-07-04 16:08:3625 OPERATION_MAX = SETTINGS
miguelg3cc06ec2016-06-30 09:14:0926 };
27
Evan Stade4ebefdf42017-09-21 23:50:1828 // A struct that contains extra data about a notification specific to one of
29 // the above types.
30 struct Metadata {
31 virtual ~Metadata();
32
Peter Beverloo6dba2e102017-11-23 17:46:3333 NotificationHandler::Type type;
Evan Stade4ebefdf42017-09-21 23:50:1834 };
35
miguelg3cc06ec2016-06-30 09:14:0936 // Open the Notification settings screen when clicking the right button.
Peter Beverloo884488b2017-12-05 18:20:2837 static void OpenNotificationSettings(Profile* profile, const GURL& origin);
miguelg3cc06ec2016-06-30 09:14:0938};
39
Evan Stade4ebefdf42017-09-21 23:50:1840// Metadata for PERSISTENT notifications.
41struct PersistentNotificationMetadata : public NotificationCommon::Metadata {
42 PersistentNotificationMetadata();
43 ~PersistentNotificationMetadata() override;
44
45 static const PersistentNotificationMetadata* From(const Metadata* metadata);
46
47 GURL service_worker_scope;
48};
49
miguelg3cc06ec2016-06-30 09:14:0950#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_