| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_NOTIFICATION_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 | 12 |
| 13 namespace content { |
| 14 class RenderViewHost; |
| 15 } |
| 16 |
| 13 // Delegate for a notification. This class has two role, to implement | 17 // Delegate for a notification. This class has two role, to implement |
| 14 // callback methods for notification, and provides an identify of | 18 // callback methods for notification, and provides an identify of |
| 15 // the associated notification. | 19 // the associated notification. |
| 16 class NotificationDelegate | 20 class NotificationDelegate |
| 17 : public base::RefCountedThreadSafe<NotificationDelegate> { | 21 : public base::RefCountedThreadSafe<NotificationDelegate> { |
| 18 public: | 22 public: |
| 19 // To be called when the desktop notification is actually shown. | 23 // To be called when the desktop notification is actually shown. |
| 20 virtual void Display() = 0; | 24 virtual void Display() = 0; |
| 21 | 25 |
| 22 // To be called when the desktop notification cannot be shown due to an | 26 // To be called when the desktop notification cannot be shown due to an |
| 23 // error. | 27 // error. |
| 24 virtual void Error() = 0; | 28 virtual void Error() = 0; |
| 25 | 29 |
| 26 // To be called when the desktop notification is closed. If closed by a | 30 // To be called when the desktop notification is closed. If closed by a |
| 27 // user explicitly (as opposed to timeout/script), |by_user| should be true. | 31 // user explicitly (as opposed to timeout/script), |by_user| should be true. |
| 28 virtual void Close(bool by_user) = 0; | 32 virtual void Close(bool by_user) = 0; |
| 29 | 33 |
| 30 // To be called when a desktop notification is clicked. | 34 // To be called when a desktop notification is clicked. |
| 31 virtual void Click() = 0; | 35 virtual void Click() = 0; |
| 32 | 36 |
| 33 // Returns unique id of the notification. | 37 // Returns unique id of the notification. |
| 34 virtual std::string id() const = 0; | 38 virtual std::string id() const = 0; |
| 35 | 39 |
| 40 // Returns the RenderViewHost that generated the notification, or NULL. |
| 41 virtual content::RenderViewHost* GetRenderViewHost() const = 0; |
| 42 |
| 36 protected: | 43 protected: |
| 37 virtual ~NotificationDelegate() {} | 44 virtual ~NotificationDelegate() {} |
| 38 | 45 |
| 39 private: | 46 private: |
| 40 friend class base::RefCountedThreadSafe<NotificationDelegate>; | 47 friend class base::RefCountedThreadSafe<NotificationDelegate>; |
| 41 }; | 48 }; |
| 42 | 49 |
| 43 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ | 50 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ |
| OLD | NEW |