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_NOTIFICATION_PLATFORM_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/notifications/notification_operation_common.h" |
12 | 13 |
13 class Notification; | 14 class Notification; |
14 | 15 |
15 // Provides the low-level interface that enables notifications to be displayed | 16 // Provides the low-level interface that enables notifications to be displayed |
16 // and interacted with on the user's screen, orthogonal of whether this | 17 // and interacted with on the user's screen, orthogonal of whether this |
17 // functionality is provided by the browser or by the operating system. | 18 // functionality is provided by the browser or by the operating system. |
18 // TODO(miguelg): Add support for click and close events. | 19 // TODO(miguelg): Add support for click and close events. |
19 class NotificationPlatformBridge { | 20 class NotificationPlatformBridge { |
20 public: | 21 public: |
21 static NotificationPlatformBridge* Create(); | 22 static NotificationPlatformBridge* Create(); |
22 | 23 |
23 virtual ~NotificationPlatformBridge() {} | 24 virtual ~NotificationPlatformBridge() {} |
24 | 25 |
25 // Shows a toast on screen using the data passed in |notification|. | 26 // Shows a toast on screen using the data passed in |notification|. |
26 virtual void Display(const std::string& notification_id, | 27 virtual void Display( |
27 const std::string& profile_id, | 28 notification_operation_common::NotificationHandlerType notification_type, |
28 bool is_incognito, | 29 const std::string& notification_id, |
29 const Notification& notification) = 0; | 30 const std::string& profile_id, |
| 31 bool is_incognito, |
| 32 const Notification& notification) = 0; |
30 | 33 |
31 // Closes a nofication with |notification_id| and |profile_id| if being | 34 // Closes a nofication with |notification_id| and |profile_id| if being |
32 // displayed. | 35 // displayed. |
33 virtual void Close(const std::string& profile_id, | 36 virtual void Close(const std::string& profile_id, |
34 const std::string& notification_id) = 0; | 37 const std::string& notification_id) = 0; |
35 | 38 |
36 // Fills in |notifications| with a set of notification ids currently being | 39 // Fills in |notifications| with a set of notification ids currently being |
37 // displayed for a given profile. | 40 // displayed for a given profile. |
38 // The return value expresses whether the underlying platform has the | 41 // The return value expresses whether the underlying platform has the |
39 // capability to provide displayed notifications so the empty set | 42 // capability to provide displayed notifications so the empty set |
40 // can be disambiguated. | 43 // can be disambiguated. |
41 virtual bool GetDisplayed(const std::string& profile_id, | 44 virtual bool GetDisplayed(const std::string& profile_id, |
42 bool incognito, | 45 bool incognito, |
43 std::set<std::string>* notification_ids) const = 0; | 46 std::set<std::string>* notification_ids) const = 0; |
44 | 47 |
45 // Temporary method while the refactor is finished. It denotes whether | 48 // Temporary method while the refactor is finished. It denotes whether |
46 // the notifications will be shown by chrome itself or by the OS. | 49 // the notifications will be shown by chrome itself or by the OS. |
47 // It is needed while migrating MacOSX and Windows to their respective | 50 // It is needed while migrating MacOSX and Windows to their respective |
48 // notification centers since the decision is made at runtime via flags. | 51 // notification centers since the decision is made at runtime via flags. |
49 virtual bool SupportsNotificationCenter() const = 0; | 52 virtual bool SupportsNotificationCenter() const = 0; |
50 | 53 |
51 protected: | 54 protected: |
52 NotificationPlatformBridge() {} | 55 NotificationPlatformBridge() {} |
53 | 56 |
54 private: | 57 private: |
55 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge); | 58 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge); |
56 }; | 59 }; |
57 | 60 |
58 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ | 61 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ |
OLD | NEW |