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_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "components/content_settings/core/browser/content_settings_observer.h" | 11 #include "components/content_settings/core/browser/content_settings_observer.h" |
12 #include "components/content_settings/core/common/content_settings.h" | 12 #include "components/content_settings/core/common/content_settings.h" |
13 #include "components/gcm_driver/gcm_app_handler.h" | 13 #include "components/gcm_driver/gcm_app_handler.h" |
14 #include "components/gcm_driver/gcm_client.h" | 14 #include "components/gcm_driver/gcm_client.h" |
15 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
16 #include "content/public/browser/push_messaging_service.h" | 16 #include "content/public/browser/push_messaging_service.h" |
17 #include "content/public/common/push_messaging_status.h" | 17 #include "content/public/common/push_messaging_status.h" |
18 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h" | 18 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermi ssionStatus.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 class PushMessagingApplicationId; | 21 class PushMessagingApplicationId; |
22 | 22 |
23 namespace user_prefs { | 23 namespace content { |
24 class PrefRegistrySyncable; | 24 struct NotificationDatabaseData; |
25 struct PlatformNotificationData; | |
25 } | 26 } |
26 | 27 |
27 namespace gcm { | 28 namespace gcm { |
28 class GCMDriver; | 29 class GCMDriver; |
29 class GCMProfileService; | 30 class GCMProfileService; |
30 } | 31 } |
31 | 32 |
33 namespace user_prefs { | |
34 class PrefRegistrySyncable; | |
35 } | |
36 | |
32 class PushMessagingServiceImpl : public content::PushMessagingService, | 37 class PushMessagingServiceImpl : public content::PushMessagingService, |
33 public gcm::GCMAppHandler, | 38 public gcm::GCMAppHandler, |
34 public content_settings::Observer, | 39 public content_settings::Observer, |
35 public KeyedService { | 40 public KeyedService { |
36 public: | 41 public: |
37 // Register profile-specific prefs for GCM. | 42 // Register profile-specific prefs for GCM. |
38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 43 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
39 | 44 |
40 // If any Service Workers are using push, starts GCM and adds an app handler. | 45 // If any Service Workers are using push, starts GCM and adds an app handler. |
41 static void InitializeForProfile(Profile* profile); | 46 static void InitializeForProfile(Profile* profile); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 const base::Closure& message_handled_closure, | 113 const base::Closure& message_handled_closure, |
109 content::PushDeliveryStatus status); | 114 content::PushDeliveryStatus status); |
110 | 115 |
111 // Developers are required to display a Web Notification in response to an | 116 // Developers are required to display a Web Notification in response to an |
112 // incoming push message in order to clarify to the user that something has | 117 // incoming push message in order to clarify to the user that something has |
113 // happened in the background. When they forget to do so, display a default | 118 // happened in the background. When they forget to do so, display a default |
114 // notification on their behalf. | 119 // notification on their behalf. |
115 void RequireUserVisibleUX(const GURL& requesting_origin, | 120 void RequireUserVisibleUX(const GURL& requesting_origin, |
116 int64 service_worker_registration_id, | 121 int64 service_worker_registration_id, |
117 const base::Closure& message_handled_closure); | 122 const base::Closure& message_handled_closure); |
123 | |
124 static void DidGetNotificationsShowingIOProxy( | |
Peter Beverloo
2015/04/30 11:11:42
Since they're not being explicitly tested by anyth
johnme
2015/04/30 13:30:12
Sadly not, as they post to private methods of PMSI
| |
125 const base::WeakPtr<PushMessagingServiceImpl>& ui_weak_ptr, | |
126 const GURL& requesting_origin, | |
127 int64 service_worker_registration_id, | |
Peter Beverloo
2015/04/30 11:11:42
int64 -> int64_t
johnme
2015/04/30 13:30:12
Done (ditto elsewhere that this patch touches).
| |
128 const base::Closure& message_handled_closure, | |
129 bool success, | |
130 const std::vector<content::NotificationDatabaseData>& data); | |
131 | |
132 void DidGetNotificationsShowing( | |
Peter Beverloo
2015/04/30 11:11:42
Perhaps "DidGetNotificationsFromDatabase" would be
johnme
2015/04/30 13:30:12
Done (I also renamed DidGetNotificationsShown to D
| |
133 const GURL& requesting_origin, | |
134 int64 service_worker_registration_id, | |
135 const base::Closure& message_handled_closure, | |
136 bool success, | |
137 const std::vector<content::NotificationDatabaseData>& data); | |
138 | |
118 void DidGetNotificationsShown( | 139 void DidGetNotificationsShown( |
119 const GURL& requesting_origin, | 140 const GURL& requesting_origin, |
120 int64 service_worker_registration_id, | 141 int64 service_worker_registration_id, |
121 bool notification_shown, | 142 bool notification_shown, |
122 bool notification_needed, | 143 bool notification_needed, |
123 const base::Closure& message_handled_closure, | 144 const base::Closure& message_handled_closure, |
124 const std::string& data, | 145 const std::string& data, |
125 bool success, | 146 bool success, |
126 bool not_found); | 147 bool not_found); |
127 | 148 |
149 static void DidWriteNotificationDataIOProxy( | |
150 const base::WeakPtr<PushMessagingServiceImpl>& ui_weak_ptr, | |
151 const GURL& requesting_origin, | |
152 const content::PlatformNotificationData& notification_data, | |
153 const base::Closure& message_handled_closure, | |
154 bool success, | |
155 int64_t persistent_notification_id); | |
156 | |
157 void DidWriteNotificationData( | |
158 const GURL& requesting_origin, | |
159 const content::PlatformNotificationData& notification_data, | |
160 const base::Closure& message_handled_closure, | |
161 bool success, | |
162 int64_t persistent_notification_id); | |
163 | |
128 // Register methods ---------------------------------------------------------- | 164 // Register methods ---------------------------------------------------------- |
129 | 165 |
130 void RegisterEnd( | 166 void RegisterEnd( |
131 const content::PushMessagingService::RegisterCallback& callback, | 167 const content::PushMessagingService::RegisterCallback& callback, |
132 const std::string& registration_id, | 168 const std::string& registration_id, |
133 content::PushRegistrationStatus status); | 169 content::PushRegistrationStatus status); |
134 | 170 |
135 void DidRegister( | 171 void DidRegister( |
136 const PushMessagingApplicationId& application_id, | 172 const PushMessagingApplicationId& application_id, |
137 const content::PushMessagingService::RegisterCallback& callback, | 173 const content::PushMessagingService::RegisterCallback& callback, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 | 211 |
176 base::Closure message_callback_for_testing_; | 212 base::Closure message_callback_for_testing_; |
177 base::Closure content_setting_changed_callback_for_testing_; | 213 base::Closure content_setting_changed_callback_for_testing_; |
178 | 214 |
179 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 215 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; |
180 | 216 |
181 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 217 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
182 }; | 218 }; |
183 | 219 |
184 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 220 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
OLD | NEW |