| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | // Copyright (c) 2015 GitHub, Inc.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be
 | 
					
						
							|  |  |  | // found in the LICENSE file.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 20:01:11 +02:00
										 |  |  | #ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
 | 
					
						
							|  |  |  | #define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-18 15:06:57 -07:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2017-06-23 20:39:42 +10:00
										 |  |  | #include <vector>
 | 
					
						
							| 
									
										
										
										
											2017-05-18 15:06:57 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | #include "base/memory/weak_ptr.h"
 | 
					
						
							|  |  |  | #include "base/strings/string16.h"
 | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  | #include "third_party/skia/include/core/SkBitmap.h"
 | 
					
						
							|  |  |  | #include "url/gurl.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 20:01:11 +02:00
										 |  |  | namespace atom { | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  | class NotificationDelegate; | 
					
						
							|  |  |  | class NotificationPresenter; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-23 20:39:42 +10:00
										 |  |  | struct NotificationAction { | 
					
						
							|  |  |  |   base::string16 type; | 
					
						
							| 
									
										
										
										
											2017-06-23 21:04:39 +10:00
										 |  |  |   base::string16 text; | 
					
						
							| 
									
										
										
										
											2017-06-23 20:39:42 +10:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  | struct NotificationOptions { | 
					
						
							|  |  |  |   base::string16 title; | 
					
						
							| 
									
										
										
										
											2017-06-30 15:59:46 +02:00
										 |  |  |   base::string16 subtitle; | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  |   base::string16 msg; | 
					
						
							|  |  |  |   std::string tag; | 
					
						
							| 
									
										
										
										
											2018-01-22 10:48:12 -08:00
										 |  |  |   bool silent; | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  |   GURL icon_url; | 
					
						
							|  |  |  |   SkBitmap icon; | 
					
						
							|  |  |  |   bool has_reply; | 
					
						
							|  |  |  |   base::string16 reply_placeholder; | 
					
						
							| 
									
										
										
										
											2017-08-17 17:28:14 -07:00
										 |  |  |   base::string16 sound; | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  |   std::vector<NotificationAction> actions; | 
					
						
							| 
									
										
										
										
											2018-01-16 11:26:41 -08:00
										 |  |  |   base::string16 close_button_text; | 
					
						
							| 
									
										
										
										
											2018-04-17 16:37:22 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   NotificationOptions(); | 
					
						
							|  |  |  |   ~NotificationOptions(); | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | class Notification { | 
					
						
							|  |  |  |  public: | 
					
						
							| 
									
										
										
										
											2017-05-31 16:17:29 +09:00
										 |  |  |   virtual ~Notification(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  |   // Shows the notification.
 | 
					
						
							| 
									
										
										
										
											2017-06-24 21:03:27 +10:00
										 |  |  |   virtual void Show(const NotificationOptions& options) = 0; | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  |   // Closes the notification, this instance will be destroyed after the
 | 
					
						
							|  |  |  |   // notification gets closed.
 | 
					
						
							|  |  |  |   virtual void Dismiss() = 0; | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-15 16:14:13 +09:00
										 |  |  |   // Should be called by derived classes.
 | 
					
						
							|  |  |  |   void NotificationClicked(); | 
					
						
							|  |  |  |   void NotificationDismissed(); | 
					
						
							|  |  |  |   void NotificationFailed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-25 19:02:06 +05:30
										 |  |  |   // delete this.
 | 
					
						
							|  |  |  |   void Destroy(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  |   base::WeakPtr<Notification> GetWeakPtr() { | 
					
						
							|  |  |  |     return weak_factory_.GetWeakPtr(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-31 16:17:29 +09:00
										 |  |  |   void set_delegate(NotificationDelegate* delegate) { delegate_ = delegate; } | 
					
						
							| 
									
										
										
										
											2018-04-09 00:54:08 +05:30
										 |  |  |   void set_notification_id(const std::string& id) { notification_id_ = id; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  |   NotificationDelegate* delegate() const { return delegate_; } | 
					
						
							|  |  |  |   NotificationPresenter* presenter() const { return presenter_; } | 
					
						
							| 
									
										
										
										
											2018-04-09 00:54:08 +05:30
										 |  |  |   const std::string& notification_id() const { return notification_id_; } | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  |  protected: | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  |   Notification(NotificationDelegate* delegate, | 
					
						
							|  |  |  |                NotificationPresenter* presenter); | 
					
						
							| 
									
										
										
										
											2017-04-05 13:27:46 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  |  private: | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  |   NotificationDelegate* delegate_; | 
					
						
							|  |  |  |   NotificationPresenter* presenter_; | 
					
						
							| 
									
										
										
										
											2018-04-09 00:54:08 +05:30
										 |  |  |   std::string notification_id_; | 
					
						
							| 
									
										
										
										
											2015-12-25 10:16:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  |   base::WeakPtrFactory<Notification> weak_factory_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   DISALLOW_COPY_AND_ASSIGN(Notification); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 20:01:11 +02:00
										 |  |  | }  // namespace atom
 | 
					
						
							| 
									
										
										
										
											2015-12-24 22:06:41 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 20:01:11 +02:00
										 |  |  | #endif  // ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
 |