Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 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_NON_PERSISTENT_NOTIFICATION_HANDLER_H_ |
| 6 | #define CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_ |
| 7 | |
Peter Beverloo | 71dba34 | 2018-05-26 11:10:29 | [diff] [blame] | 8 | #include "base/memory/weak_ptr.h" |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 9 | #include "chrome/browser/notifications/notification_handler.h" |
| 10 | |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 11 | // NotificationHandler implementation for non persistent notifications. |
| 12 | class NonPersistentNotificationHandler : public NotificationHandler { |
| 13 | public: |
| 14 | NonPersistentNotificationHandler(); |
Sundoo Kim | dd91d95 | 2020-08-26 17:11:20 | [diff] [blame] | 15 | NonPersistentNotificationHandler(const NonPersistentNotificationHandler&) = |
| 16 | delete; |
| 17 | NonPersistentNotificationHandler& operator=( |
| 18 | const NonPersistentNotificationHandler&) = delete; |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 19 | ~NonPersistentNotificationHandler() override; |
| 20 | |
| 21 | // NotificationHandler implementation |
miguelg | abf610a | 2017-06-02 17:31:43 | [diff] [blame] | 22 | void OnShow(Profile* profile, const std::string& notification_id) override; |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 23 | void OnClose(Profile* profile, |
Evan Stade | 7e48597c | 2017-11-03 22:04:48 | [diff] [blame] | 24 | const GURL& origin, |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 25 | const std::string& notification_id, |
Peter Beverloo | 64337af | 2017-11-21 18:04:02 | [diff] [blame] | 26 | bool by_user, |
| 27 | base::OnceClosure completed_closure) override; |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 28 | void OnClick(Profile* profile, |
Evan Stade | 7e48597c | 2017-11-03 22:04:48 | [diff] [blame] | 29 | const GURL& origin, |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 30 | const std::string& notification_id, |
Arthur Sonzogni | fe132ee | 2024-01-15 11:01:04 | [diff] [blame] | 31 | const std::optional<int>& action_index, |
| 32 | const std::optional<std::u16string>& reply, |
Peter Beverloo | 64337af | 2017-11-21 18:04:02 | [diff] [blame] | 33 | base::OnceClosure completed_closure) override; |
Peter Beverloo | 884488b | 2017-12-05 18:20:28 | [diff] [blame] | 34 | void DisableNotifications(Profile* profile, const GURL& origin) override; |
| 35 | void OpenSettings(Profile* profile, const GURL& origin) override; |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 36 | |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 37 | private: |
Peter Beverloo | 71dba34 | 2018-05-26 11:10:29 | [diff] [blame] | 38 | // Called when the "click" event for non-persistent notification has been |
| 39 | // dispatched. The |success| boolean indicates whether the click could be |
| 40 | // delivered to the originating document as a JavaScript event. |
| 41 | void DidDispatchClickEvent(Profile* profile, |
| 42 | const GURL& origin, |
| 43 | const std::string& notification_id, |
| 44 | base::OnceClosure completed_closure, |
| 45 | bool success); |
| 46 | |
| 47 | base::WeakPtrFactory<NonPersistentNotificationHandler> weak_ptr_factory_{ |
| 48 | this}; |
miguelg | 87e986d | 2016-07-08 18:04:44 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #endif // CHROME_BROWSER_NOTIFICATIONS_NON_PERSISTENT_NOTIFICATION_HANDLER_H_ |