miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 1 | // 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 | |
miguelg | 30dfc2e | 2017-06-14 18:18:09 | [diff] [blame] | 8 | #include "base/feature_list.h" |
Peter Beverloo | 6dba2e10 | 2017-11-23 17:46:33 | [diff] [blame] | 9 | #include "chrome/browser/notifications/notification_handler.h" |
Evan Stade | 4ebefdf4 | 2017-09-21 23:50:18 | [diff] [blame] | 10 | #include "url/gurl.h" |
miguelg | 30dfc2e | 2017-06-14 18:18:09 | [diff] [blame] | 11 | |
miguelg | 30dfc2e | 2017-06-14 18:18:09 | [diff] [blame] | 12 | class GURL; |
| 13 | class Profile; |
| 14 | |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 15 | // Shared functionality for both in page and persistent notification |
| 16 | class NotificationCommon { |
| 17 | public: |
| 18 | // Things as user can do to a notification. |
peter | 28d8b73 | 2017-04-11 17:36:17 | [diff] [blame] | 19 | // TODO(peter): Prefix these options with OPERATION_. |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 20 | enum Operation { |
| 21 | CLICK = 0, |
| 22 | CLOSE = 1, |
Peter Beverloo | 884488b | 2017-12-05 18:20:28 | [diff] [blame^] | 23 | DISABLE_PERMISSION = 2, |
| 24 | SETTINGS = 3, |
miguelg | 4ca5df8 | 2016-07-04 16:08:36 | [diff] [blame] | 25 | OPERATION_MAX = SETTINGS |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 26 | }; |
| 27 | |
Evan Stade | 4ebefdf4 | 2017-09-21 23:50:18 | [diff] [blame] | 28 | // 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 Beverloo | 6dba2e10 | 2017-11-23 17:46:33 | [diff] [blame] | 33 | NotificationHandler::Type type; |
Evan Stade | 4ebefdf4 | 2017-09-21 23:50:18 | [diff] [blame] | 34 | }; |
| 35 | |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 36 | // Open the Notification settings screen when clicking the right button. |
Peter Beverloo | 884488b | 2017-12-05 18:20:28 | [diff] [blame^] | 37 | static void OpenNotificationSettings(Profile* profile, const GURL& origin); |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 38 | }; |
| 39 | |
Evan Stade | 4ebefdf4 | 2017-09-21 23:50:18 | [diff] [blame] | 40 | // Metadata for PERSISTENT notifications. |
| 41 | struct 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 | |
miguelg | 3cc06ec | 2016-06-30 09:14:09 | [diff] [blame] | 50 | #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_COMMON_H_ |