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; |
38 | |
39 // Used by the notification bridge to propagate back events (click, close...) | |
40 void ProcessNotificationOperation(NotificationCommon::Operation operation, | |
41 NotificationCommon::Type notification_type, | |
42 const std::string& origin, | |
43 const std::string& notification_id, | |
44 int action_index); | |
45 | |
46 void AddNotificationHandler(NotificationCommon::Type notification_type, | |
Peter Beverloo
2016/07/05 14:25:34
Please document public APIs.
Miguel Garcia
2016/07/05 17:12:52
Done.
| |
47 std::unique_ptr<NotificationHandler> handler); | |
48 void RemoveNotificationHandler(NotificationCommon::Type notification_type); | |
49 | |
31 bool SupportsNotificationCenter() const override; | 50 bool SupportsNotificationCenter() const override; |
Peter Beverloo
2016/07/05 14:25:34
Move this to line 38.
Miguel Garcia
2016/07/05 17:12:52
Done.
| |
32 | 51 |
33 private: | 52 private: |
53 NotificationHandler* GetNotificationHandler( | |
54 NotificationCommon::Type notification_type); | |
Peter Beverloo
2016/07/05 14:25:34
nit: const?
Miguel Garcia
2016/07/05 17:12:52
I know if I add it will compile but it feels like
| |
55 | |
34 Profile* profile_; | 56 Profile* profile_; |
35 NotificationPlatformBridge* notification_bridge_; | 57 NotificationPlatformBridge* notification_bridge_; |
58 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>> | |
Peter Beverloo
2016/07/05 14:25:34
nit: unordered_map
Miguel Garcia
2016/07/05 17:12:52
C++ 11 does not easily allow unordered maps keyed
| |
59 notification_handlers_; | |
36 | 60 |
37 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); | 61 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); |
38 }; | 62 }; |
39 | 63 |
40 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 64 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
OLD | NEW |