blob: 9bb8620e7e727ce1af97b0850c4074262f1d9ff3 [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
miguelg3cc06ec2016-06-30 09:14:0912namespace content {
13class BrowserContext;
14} // namespace content
15
miguelg30dfc2e2017-06-14 18:18:0916class GURL;
17class Profile;
18
miguelg3cc06ec2016-06-30 09:14:0919// Shared functionality for both in page and persistent notification
20class NotificationCommon {
21 public:
22 // Things as user can do to a notification.
peter28d8b732017-04-11 17:36:1723 // TODO(peter): Prefix these options with OPERATION_.
miguelg3cc06ec2016-06-30 09:14:0924 enum Operation {
25 CLICK = 0,
26 CLOSE = 1,
miguelg4ca5df82016-07-04 16:08:3627 SETTINGS = 2,
28 OPERATION_MAX = SETTINGS
miguelg3cc06ec2016-06-30 09:14:0929 };
30
Evan Stade4ebefdf42017-09-21 23:50:1831 // A struct that contains extra data about a notification specific to one of
32 // the above types.
33 struct Metadata {
34 virtual ~Metadata();
35
Peter Beverloo6dba2e102017-11-23 17:46:3336 NotificationHandler::Type type;
Evan Stade4ebefdf42017-09-21 23:50:1837 };
38
miguelg3cc06ec2016-06-30 09:14:0939 // Open the Notification settings screen when clicking the right button.
40 // TODO(miguelg) have it take a Profile instead once NotificationObjectProxy
41 // is updated.
42 static void OpenNotificationSettings(
43 content::BrowserContext* browser_context);
miguelg3cc06ec2016-06-30 09:14:0944};
45
Evan Stade4ebefdf42017-09-21 23:50:1846// Metadata for PERSISTENT notifications.
47struct PersistentNotificationMetadata : public NotificationCommon::Metadata {
48 PersistentNotificationMetadata();
49 ~PersistentNotificationMetadata() override;
50
51 static const PersistentNotificationMetadata* From(const Metadata* metadata);
52
53 GURL service_worker_scope;
54};
55
miguelg3cc06ec2016-06-30 09:14:0956#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_