OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
7 | 7 |
| 8 #include <map> |
| 9 #include <memory> |
8 #include <set> | 10 #include <set> |
9 #include <string> | 11 #include <string> |
| 12 |
10 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/notifications/notification_common.h" |
11 #include "chrome/browser/notifications/notification_display_service.h" | 15 #include "chrome/browser/notifications/notification_display_service.h" |
12 | 16 |
13 class Notification; | 17 class Notification; |
| 18 class NotificationHandler; |
14 class NotificationPlatformBridge; | 19 class NotificationPlatformBridge; |
15 class Profile; | 20 class Profile; |
16 | 21 |
17 // A class to display and interact with notifications in native notification | 22 // A class to display and interact with notifications in native notification |
18 // centers on platforms that support it. | 23 // centers on platforms that support it. |
19 class NativeNotificationDisplayService : public NotificationDisplayService { | 24 class NativeNotificationDisplayService : public NotificationDisplayService { |
20 public: | 25 public: |
21 NativeNotificationDisplayService( | 26 NativeNotificationDisplayService( |
22 Profile* profile, | 27 Profile* profile, |
23 NotificationPlatformBridge* notification_bridge); | 28 NotificationPlatformBridge* notification_bridge); |
24 ~NativeNotificationDisplayService() override; | 29 ~NativeNotificationDisplayService() override; |
25 | 30 |
26 // NotificationDisplayService implementation. | 31 // NotificationDisplayService implementation. |
27 void Display(const std::string& notification_id, | 32 void Display(NotificationCommon::Type notification_type, |
| 33 const std::string& notification_id, |
28 const Notification& notification) override; | 34 const Notification& notification) override; |
29 void Close(const std::string& notification_id) override; | 35 void Close(NotificationCommon::Type notification_type, |
| 36 const std::string& notification_id) override; |
30 bool GetDisplayed(std::set<std::string>* notifications) const override; | 37 bool GetDisplayed(std::set<std::string>* notifications) const override; |
31 bool SupportsNotificationCenter() const override; | 38 bool SupportsNotificationCenter() const override; |
32 | 39 |
| 40 // Used by the notification bridge to propagate back events (click, close...). |
| 41 void ProcessNotificationOperation(NotificationCommon::Operation operation, |
| 42 NotificationCommon::Type notification_type, |
| 43 const std::string& origin, |
| 44 const std::string& notification_id, |
| 45 int action_index); |
| 46 |
| 47 // Registers an implementation object to handle notification operations |
| 48 // for |notification_type|. |
| 49 void AddNotificationHandler(NotificationCommon::Type notification_type, |
| 50 std::unique_ptr<NotificationHandler> handler); |
| 51 |
| 52 // Removes an implementation added via |AddNotificationHandler|. |
| 53 void RemoveNotificationHandler(NotificationCommon::Type notification_type); |
| 54 |
33 private: | 55 private: |
| 56 NotificationHandler* GetNotificationHandler( |
| 57 NotificationCommon::Type notification_type); |
| 58 |
34 Profile* profile_; | 59 Profile* profile_; |
35 NotificationPlatformBridge* notification_bridge_; | 60 NotificationPlatformBridge* notification_bridge_; |
| 61 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> |
| 62 notification_handlers_; |
36 | 63 |
37 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); | 64 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); |
38 }; | 65 }; |
39 | 66 |
40 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 67 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
OLD | NEW |