| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "chrome/browser/notifications/notification_delegate.h" | 11 #include "chrome/browser/notifications/notification_delegate.h" |
| 13 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 class BrowserContext; | 15 class BrowserContext; |
| 17 } | 16 } |
| 18 | 17 |
| 19 // Delegate responsible for listening to the click event on persistent | 18 // Delegate responsible for listening to the click event on persistent |
| 20 // notifications, to forward them to the PlatformNotificationService so that | 19 // notifications, to forward them to the PlatformNotificationService so that |
| 21 // JavaScript events can be fired on the associated Service Worker. | 20 // JavaScript events can be fired on the associated Service Worker. |
| 22 class PersistentNotificationDelegate : public NotificationDelegate { | 21 class PersistentNotificationDelegate : public NotificationDelegate { |
| 23 public: | 22 public: |
| 24 PersistentNotificationDelegate(content::BrowserContext* browser_context, | 23 PersistentNotificationDelegate(content::BrowserContext* browser_context, |
| 25 int64_t persistent_notification_id, | 24 const std::string& notification_id, |
| 26 const GURL& origin, | 25 const GURL& origin, |
| 27 int notification_settings_index); | 26 int notification_settings_index); |
| 28 | 27 |
| 29 // Persistent id of this notification in the notification database. To be | |
| 30 // used when retrieving all information associated with it. | |
| 31 int64_t persistent_notification_id() const { | |
| 32 return persistent_notification_id_; | |
| 33 } | |
| 34 | |
| 35 // NotificationDelegate implementation. | 28 // NotificationDelegate implementation. |
| 36 void Display() override; | 29 void Display() override; |
| 37 void Close(bool by_user) override; | 30 void Close(bool by_user) override; |
| 38 void Click() override; | 31 void Click() override; |
| 39 void ButtonClick(int button_index) override; | 32 void ButtonClick(int button_index) override; |
| 40 void SettingsClick() override; | 33 void SettingsClick() override; |
| 41 bool ShouldDisplaySettingsButton() override; | 34 bool ShouldDisplaySettingsButton() override; |
| 42 | 35 |
| 43 std::string id() const override; | 36 std::string id() const override; |
| 44 | 37 |
| 45 protected: | 38 protected: |
| 46 ~PersistentNotificationDelegate() override; | 39 ~PersistentNotificationDelegate() override; |
| 47 | 40 |
| 48 private: | 41 private: |
| 49 content::BrowserContext* browser_context_; | 42 content::BrowserContext* browser_context_; |
| 50 int64_t persistent_notification_id_; | 43 std::string notification_id_; |
| 51 GURL origin_; | 44 GURL origin_; |
| 52 std::string id_; | |
| 53 int notification_settings_index_; | 45 int notification_settings_index_; |
| 54 | 46 |
| 55 DISALLOW_COPY_AND_ASSIGN(PersistentNotificationDelegate); | 47 DISALLOW_COPY_AND_ASSIGN(PersistentNotificationDelegate); |
| 56 }; | 48 }; |
| 57 | 49 |
| 58 #endif // CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ | 50 #endif // CHROME_BROWSER_NOTIFICATIONS_PERSISTENT_NOTIFICATION_DELEGATE_H_ |
| OLD | NEW |