| 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" |
| 11 #include "chrome/browser/notifications/notification_display_service.h" | 14 #include "chrome/browser/notifications/notification_display_service.h" |
| 15 #include "chrome/browser/notifications/notification_operation_common.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( |
| 28 const Notification& notification) override; | 33 notification_operation_common::NotificationHandlerType notification_type, |
| 29 void Close(const std::string& notification_id) override; | 34 const std::string& notification_id, |
| 35 const Notification& notification) override; |
| 36 void Close( |
| 37 notification_operation_common::NotificationHandlerType notification_type, |
| 38 const std::string& notification_id) override; |
| 30 bool GetDisplayed(std::set<std::string>* notifications) const override; | 39 bool GetDisplayed(std::set<std::string>* notifications) const override; |
| 40 |
| 41 void ProcessNotificationOperation( |
| 42 notification_operation_common::NotificationOperation operation, |
| 43 notification_operation_common::NotificationHandlerType notification_type, |
| 44 const std::string& origin, |
| 45 const std::string& notification_id, |
| 46 int action_index) override; |
| 47 |
| 48 void AddNotificationHandler( |
| 49 notification_operation_common::NotificationHandlerType notification_type, |
| 50 std::unique_ptr<NotificationHandler> handler); |
| 51 void RemoveNotificationHandler( |
| 52 notification_operation_common::NotificationHandlerType notification_type); |
| 53 |
| 31 bool SupportsNotificationCenter() const override; | 54 bool SupportsNotificationCenter() const override; |
| 32 | 55 |
| 33 private: | 56 private: |
| 57 NotificationHandler* GetNotificationHandler( |
| 58 notification_operation_common::NotificationHandlerType notification_type); |
| 59 |
| 34 Profile* profile_; | 60 Profile* profile_; |
| 35 NotificationPlatformBridge* notification_bridge_; | 61 NotificationPlatformBridge* notification_bridge_; |
| 62 std::map<notification_operation_common::NotificationHandlerType, |
| 63 std::unique_ptr<NotificationHandler>> |
| 64 notification_handlers_; |
| 36 | 65 |
| 37 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); | 66 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); |
| 38 }; | 67 }; |
| 39 | 68 |
| 40 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ | 69 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ |
| OLD | NEW |