| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ | 6 #define UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "ui/message_center/message_center_export.h" |
| 11 | 12 |
| 12 namespace content { | 13 namespace content { |
| 13 class RenderViewHost; | 14 class RenderViewHost; |
| 14 } | 15 } |
| 15 | 16 |
| 17 namespace message_center { |
| 18 |
| 16 // Delegate for a notification. This class has two roles: to implement callback | 19 // Delegate for a notification. This class has two roles: to implement callback |
| 17 // methods for notification, and to provide an identity of the associated | 20 // methods for notification, and to provide an identity of the associated |
| 18 // notification. | 21 // notification. |
| 19 class NotificationDelegate | 22 class MESSAGE_CENTER_EXPORT NotificationDelegate |
| 20 : public base::RefCountedThreadSafe<NotificationDelegate> { | 23 : public base::RefCountedThreadSafe<NotificationDelegate> { |
| 21 public: | 24 public: |
| 22 // To be called when the desktop notification is actually shown. | 25 // To be called when the desktop notification is actually shown. |
| 23 virtual void Display() = 0; | 26 virtual void Display() = 0; |
| 24 | 27 |
| 25 // To be called when the desktop notification cannot be shown due to an | 28 // To be called when the desktop notification cannot be shown due to an |
| 26 // error. | 29 // error. |
| 27 virtual void Error() = 0; | 30 virtual void Error() = 0; |
| 28 | 31 |
| 29 // To be called when the desktop notification is closed. If closed by a | 32 // To be called when the desktop notification is closed. If closed by a |
| 30 // user explicitly (as opposed to timeout/script), |by_user| should be true. | 33 // user explicitly (as opposed to timeout/script), |by_user| should be true. |
| 31 virtual void Close(bool by_user) = 0; | 34 virtual void Close(bool by_user) = 0; |
| 32 | 35 |
| 36 // Returns true if the delegate can handle click event. |
| 37 virtual bool HasClickedListener(); |
| 38 |
| 33 // To be called when a desktop notification is clicked. | 39 // To be called when a desktop notification is clicked. |
| 34 virtual void Click() = 0; | 40 virtual void Click() = 0; |
| 35 | 41 |
| 36 // Returns true if the delegate can handle click event. | |
| 37 virtual bool HasClickedListener(); | |
| 38 | |
| 39 // To be called when the user clicks a button in a notification. TODO(miket): | 42 // To be called when the user clicks a button in a notification. TODO(miket): |
| 40 // consider providing default implementations of the pure virtuals of this | 43 // consider providing default implementations of the pure virtuals of this |
| 41 // interface, to avoid pinging so many OWNERs each time we enhance it. | 44 // interface, to avoid pinging so many OWNERs each time we enhance it. |
| 42 virtual void ButtonClick(int button_index); | 45 virtual void ButtonClick(int button_index); |
| 43 | 46 |
| 44 // Returns unique id of the notification. | |
| 45 virtual std::string id() const = 0; | |
| 46 | |
| 47 // Returns the id of renderer process which creates the notification, or -1. | |
| 48 virtual int process_id() const; | |
| 49 | |
| 50 // Returns the RenderViewHost that generated the notification, or NULL. | |
| 51 virtual content::RenderViewHost* GetRenderViewHost() const = 0; | |
| 52 | |
| 53 // Lets the delegate know that no more rendering will be necessary. | |
| 54 virtual void ReleaseRenderViewHost(); | |
| 55 | |
| 56 protected: | 47 protected: |
| 57 virtual ~NotificationDelegate() {} | 48 virtual ~NotificationDelegate() {} |
| 58 | 49 |
| 59 private: | 50 private: |
| 60 friend class base::RefCountedThreadSafe<NotificationDelegate>; | 51 friend class base::RefCountedThreadSafe<NotificationDelegate>; |
| 61 }; | 52 }; |
| 62 | 53 |
| 63 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_ | 54 } // namespace message_center |
| 55 |
| 56 #endif // UI_MESSAGE_CENTER_NOTIFICATION_DELEGATE_H_ |
| OLD | NEW |