OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 enum NotificationOperation { | 44 enum NotificationOperation { |
45 NOTIFICATION_CLICK, | 45 NOTIFICATION_CLICK, |
46 NOTIFICATION_CLOSE, | 46 NOTIFICATION_CLOSE, |
47 NOTIFICATION_SETTINGS | 47 NOTIFICATION_SETTINGS |
48 }; | 48 }; |
49 | 49 |
50 // Returns the active instance of the service in the browser process. Safe to | 50 // Returns the active instance of the service in the browser process. Safe to |
51 // be called from any thread. | 51 // be called from any thread. |
52 static PlatformNotificationServiceImpl* GetInstance(); | 52 static PlatformNotificationServiceImpl* GetInstance(); |
53 | 53 |
54 // Returns the notification display service to use. This is overriden in tests | |
55 // TODO(miguelg) make it private once the tests are updated | |
56 NotificationDisplayService* GetNotificationDisplayService(Profile* profile); | |
57 | |
58 // Load the profile corresponding to |profile_id| and perform the | 54 // Load the profile corresponding to |profile_id| and perform the |
59 // |operation| on the given notification once it has been loaded. | 55 // |operation| on the given notification once it has been loaded. |
60 void ProcessPersistentNotificationOperation( | 56 void ProcessPersistentNotificationOperation( |
61 NotificationOperation operation, | 57 NotificationOperation operation, |
62 const std::string& profile_id, | 58 const std::string& profile_id, |
63 bool incognito, | 59 bool incognito, |
64 const GURL& origin, | 60 const GURL& origin, |
65 int64_t persistent_notification_id, | 61 int64_t persistent_notification_id, |
66 int action_index); | 62 int action_index); |
67 | 63 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 Profile* profile, | 132 Profile* profile, |
137 const GURL& origin, | 133 const GURL& origin, |
138 const content::PlatformNotificationData& notification_data, | 134 const content::PlatformNotificationData& notification_data, |
139 const content::NotificationResources& notification_resources, | 135 const content::NotificationResources& notification_resources, |
140 NotificationDelegate* delegate) const; | 136 NotificationDelegate* delegate) const; |
141 | 137 |
142 // Returns a display name for an origin, to be used in the context message | 138 // Returns a display name for an origin, to be used in the context message |
143 base::string16 DisplayNameForContextMessage(Profile* profile, | 139 base::string16 DisplayNameForContextMessage(Profile* profile, |
144 const GURL& origin) const; | 140 const GURL& origin) const; |
145 | 141 |
| 142 // Returns the notification display service to use. |
| 143 // This can be overriden in tests |
| 144 NotificationDisplayService* GetNotificationDisplayService(Profile* profile); |
| 145 |
146 void SetNotificationDisplayServiceForTesting( | 146 void SetNotificationDisplayServiceForTesting( |
147 NotificationDisplayService* service); | 147 NotificationDisplayService* service); |
148 | 148 |
149 // Mapping between a persistent notification id and the id of the associated | 149 // Mapping between a persistent notification id and the id of the associated |
150 // message_center::Notification object. Must only be used on the UI thread. | 150 // message_center::Notification object. Must only be used on the UI thread. |
151 std::map<int64_t, std::string> persistent_notifications_; | 151 std::map<int64_t, std::string> persistent_notifications_; |
152 | 152 |
153 // Tracks the id of persistent notifications that have been closed | 153 // Tracks the id of persistent notifications that have been closed |
154 // programmatically to avoid dispatching close events for them. | 154 // programmatically to avoid dispatching close events for them. |
155 std::unordered_set<int64_t> closed_notifications_; | 155 std::unordered_set<int64_t> closed_notifications_; |
156 | 156 |
157 // Only set and used for tests, owned by the caller in that case. | 157 // Only set and used for tests, owned by the caller in that case. |
158 NotificationDisplayService* test_display_service_; | 158 NotificationDisplayService* test_display_service_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); | 160 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); |
161 }; | 161 }; |
162 | 162 |
163 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ | 163 #endif // CHROME_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ |
OLD | NEW |