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