Chromium Code Reviews| 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 CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ | 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 10 #include "content/public/browser/notification_database_data.h" | 12 #include "content/public/browser/notification_database_data.h" |
| 11 #include "content/public/browser/notification_event_dispatcher.h" | 13 #include "content/public/browser/notification_event_dispatcher.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 class NotificationEventDispatcherImpl : public NotificationEventDispatcher { | 17 class NotificationEventDispatcherImpl : public NotificationEventDispatcher { |
| 16 public: | 18 public: |
| 17 // Returns the instance of the NotificationEventDispatcherImpl. Must be called | 19 // Returns the instance of the NotificationEventDispatcherImpl. Must be called |
| 18 // on the UI thread. | 20 // on the UI thread. |
| 19 static NotificationEventDispatcherImpl* GetInstance(); | 21 static NotificationEventDispatcherImpl* GetInstance(); |
| 20 | 22 |
| 21 // NotificationEventDispatcher implementation. | 23 // NotificationEventDispatcher implementation. |
| 24 | |
| 25 // TODO(miguelg) rename so it says Persistent. | |
|
Peter Beverloo
2017/05/31 17:52:43
Out of interest, why? Wouldn't it make the API sim
Miguel Garcia
2017/06/01 17:00:53
You mean having a single Dispatch method with comp
Peter Beverloo
2017/06/01 17:56:27
Ideally the embedder (i.e. //chrome) wouldn't have
Miguel Garcia
2017/06/02 12:37:12
Acknowledged.
| |
| 22 void DispatchNotificationClickEvent( | 26 void DispatchNotificationClickEvent( |
| 23 BrowserContext* browser_context, | 27 BrowserContext* browser_context, |
| 24 const std::string& notification_id, | 28 const std::string& notification_id, |
| 25 const GURL& origin, | 29 const GURL& origin, |
| 26 int action_index, | 30 int action_index, |
| 27 const base::NullableString16& reply, | 31 const base::NullableString16& reply, |
| 28 const NotificationDispatchCompleteCallback& dispatch_complete_callback) | 32 const NotificationDispatchCompleteCallback& dispatch_complete_callback) |
| 29 override; | 33 override; |
| 30 void DispatchNotificationCloseEvent( | 34 void DispatchNotificationCloseEvent( |
| 31 BrowserContext* browser_context, | 35 BrowserContext* browser_context, |
| 32 const std::string& notification_id, | 36 const std::string& notification_id, |
| 33 const GURL& origin, | 37 const GURL& origin, |
| 34 bool by_user, | 38 bool by_user, |
| 35 const NotificationDispatchCompleteCallback& dispatch_complete_callback) | 39 const NotificationDispatchCompleteCallback& dispatch_complete_callback) |
| 36 override; | 40 override; |
| 37 | 41 |
|
Peter Beverloo
2017/05/31 17:52:43
nit: no line breaks in override blocks like this.
Miguel Garcia
2017/06/01 17:00:53
Done.
| |
| 42 void RegisterNonPersistentNotification(const std::string& notification_id, | |
| 43 int renderer_id, | |
| 44 int non_persistent_id) override; | |
| 45 void DispatchNonPersistentShowEvent( | |
| 46 const std::string& notification_id) override; | |
| 47 void DispatchNonPersistentClickEvent( | |
| 48 const std::string& notification_id) override; | |
| 49 void DispatchNonPersistentCloseEvent( | |
| 50 const std::string& notification_id) override; | |
| 51 void RendererGone(int renderer_id) override; | |
| 52 | |
| 38 private: | 53 private: |
| 39 NotificationEventDispatcherImpl(); | 54 NotificationEventDispatcherImpl(); |
| 40 ~NotificationEventDispatcherImpl() override; | 55 ~NotificationEventDispatcherImpl() override; |
| 41 | 56 |
| 57 // Notification Id -> renderer id | |
| 58 std::map<std::string, int> notification_renderers_; | |
| 59 | |
| 60 // Notification real id -> non persistent id. | |
|
Peter Beverloo
2017/05/31 17:52:43
What is a "real" notification Id?
Since everythin
Miguel Garcia
2017/06/01 17:00:53
It just feels harder to read when both members of
Peter Beverloo
2017/06/01 17:56:27
But much simpler code since we'd only have to care
Peter Beverloo
2017/06/01 17:56:27
"Peter Beverlif you oo wrote:"
lol how did you do
Miguel Garcia
2017/06/02 12:37:13
I have no idea...
| |
| 61 std::map<std::string, int> notification_ids_; | |
| 62 | |
| 42 friend struct base::DefaultSingletonTraits<NotificationEventDispatcherImpl>; | 63 friend struct base::DefaultSingletonTraits<NotificationEventDispatcherImpl>; |
| 43 | 64 |
| 44 DISALLOW_COPY_AND_ASSIGN(NotificationEventDispatcherImpl); | 65 DISALLOW_COPY_AND_ASSIGN(NotificationEventDispatcherImpl); |
| 45 }; | 66 }; |
| 46 | 67 |
| 47 } // namespace content | 68 } // namespace content |
| 48 | 69 |
| 49 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ | 70 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_EVENT_DISPATCHER_IMPL_H_ |
| OLD | NEW |