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_DISPLAY_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "chrome/browser/notifications/notification_operation_common.h" | |
11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
12 | 13 |
13 class Notification; | 14 class Notification; |
14 class NotificationPlatformBridge; | 15 class NotificationPlatformBridge; |
15 class Profile; | 16 class Profile; |
16 | 17 |
17 // Profile-bound service that enables notifications to be displayed and | 18 // Profile-bound service that enables notifications to be displayed and |
18 // interacted with on the user's screen, orthogonal of whether this | 19 // interacted with on the user's screen, orthogonal of whether this |
19 // functionality is provided by the browser or by the operating system. An | 20 // functionality is provided by the browser or by the operating system. An |
20 // instance can be retrieved through the NotificationDisplayServiceFactory. | 21 // instance can be retrieved through the NotificationDisplayServiceFactory. |
21 // | 22 // |
22 // TODO(peter): Add a NotificationHandler mechanism for registering listeners. | 23 // TODO(peter): Add a NotificationHandler mechanism for registering listeners. |
23 // TODO(miguelg): Remove the SupportsNotificationCenter method. | 24 // TODO(miguelg): Remove the SupportsNotificationCenter method. |
24 class NotificationDisplayService : public KeyedService { | 25 class NotificationDisplayService : public KeyedService { |
25 public: | 26 public: |
26 NotificationDisplayService() {} | 27 NotificationDisplayService() {} |
27 ~NotificationDisplayService() override {} | 28 ~NotificationDisplayService() override {} |
28 | 29 |
29 // Displays the |notification| identified by |notification_id|. | 30 // Displays the |notification| identified by |notification_id|. |
30 virtual void Display(const std::string& notification_id, | 31 virtual void Display( |
31 const Notification& notification) = 0; | 32 notification_operation_common::NotificationHandlerType notification_type, |
Peter Beverloo
2016/06/29 00:23:15
In the longer run, taking the services model, this
Peter Beverloo
2016/06/29 00:23:15
Needing to use the `notification_operation_common`
Miguel Garcia
2016/07/05 13:54:50
As discussed offline I am maintaining the type enu
Miguel Garcia
2016/07/05 13:54:50
I went with a class and enum classes.
| |
33 const std::string& notification_id, | |
34 const Notification& notification) = 0; | |
32 | 35 |
33 // Closes the notification identified by |notification_id|. | 36 // Closes the notification identified by |notification_id|. |
34 virtual void Close(const std::string& notification_id) = 0; | 37 // This only handles programatic close calls, notifications closed |
38 // by users get handled by |ProcessNotificationOperation|. | |
39 virtual void Close( | |
40 notification_operation_common::NotificationHandlerType notification_type, | |
41 const std::string& notification_id) = 0; | |
35 | 42 |
36 // Returns whether the implementation can retrieve a list of currently visible | 43 // Returns whether the implementation can retrieve a list of currently visible |
37 // notifications and stores them in |*notification_ids| when possible. | 44 // notifications and stores them in |*notification_ids| when possible. |
38 virtual bool GetDisplayed(std::set<std::string>* notifications) const = 0; | 45 virtual bool GetDisplayed(std::set<std::string>* notifications) const = 0; |
39 | 46 |
47 // Used by the notification bridge to propagate back events (click, close...) | |
48 virtual void ProcessNotificationOperation( | |
49 notification_operation_common::NotificationOperation operation, | |
50 notification_operation_common::NotificationHandlerType notification_type, | |
51 const std::string& origin, | |
52 const std::string& notification_id, | |
53 int action_index) = 0; | |
Peter Beverloo
2016/06/29 00:23:15
NotificationDisplayService defines the [feature] -
Miguel Garcia
2016/07/05 13:54:50
Indeed, made it a method of the native display ser
| |
54 | |
40 // Temporary method while we finish the refactor. Returns whether there is | 55 // Temporary method while we finish the refactor. Returns whether there is |
41 // a native notification center backing up notifications. | 56 // a native notification center backing up notifications. |
42 virtual bool SupportsNotificationCenter() const = 0; | 57 virtual bool SupportsNotificationCenter() const = 0; |
43 | 58 |
44 private: | 59 private: |
45 DISALLOW_COPY_AND_ASSIGN(NotificationDisplayService); | 60 DISALLOW_COPY_AND_ASSIGN(NotificationDisplayService); |
46 }; | 61 }; |
47 | 62 |
48 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ | 63 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_DISPLAY_SERVICE_H_ |
OLD | NEW |