blob: 29d91600c62845e36538cd2a6dab2b4c267457c3 [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:
Peter Beverloo97658eb2018-01-31 21:15:5318 // Things as user can do to a notification. Keep in sync with the
19 // NotificationOperation enumeration in notification_response_builder_mac.h.
peter28d8b732017-04-11 17:36:1720 // TODO(peter): Prefix these options with OPERATION_.
miguelg3cc06ec2016-06-30 09:14:0921 enum Operation {
22 CLICK = 0,
23 CLOSE = 1,
Peter Beverloo884488b2017-12-05 18:20:2824 DISABLE_PERMISSION = 2,
25 SETTINGS = 3,
miguelg4ca5df82016-07-04 16:08:3626 OPERATION_MAX = SETTINGS
miguelg3cc06ec2016-06-30 09:14:0927 };
28
Evan Stade4ebefdf42017-09-21 23:50:1829 // A struct that contains extra data about a notification specific to one of
30 // the above types.
31 struct Metadata {
32 virtual ~Metadata();
33
Peter Beverloo6dba2e102017-11-23 17:46:3334 NotificationHandler::Type type;
Evan Stade4ebefdf42017-09-21 23:50:1835 };
36
miguelg3cc06ec2016-06-30 09:14:0937 // Open the Notification settings screen when clicking the right button.
Peter Beverloo884488b2017-12-05 18:20:2838 static void OpenNotificationSettings(Profile* profile, const GURL& origin);
miguelg3cc06ec2016-06-30 09:14:0939};
40
Evan Stade4ebefdf42017-09-21 23:50:1841// Metadata for PERSISTENT notifications.
42struct PersistentNotificationMetadata : public NotificationCommon::Metadata {
43 PersistentNotificationMetadata();
44 ~PersistentNotificationMetadata() override;
45
46 static const PersistentNotificationMetadata* From(const Metadata* metadata);
47
48 GURL service_worker_scope;
49};
50
miguelg3cc06ec2016-06-30 09:14:0951#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_