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 void DidGetNotificationsShowing( |
| 125 const GURL& requesting_origin, |
| 126 int64 service_worker_registration_id, |
| 127 const base::Closure& message_handled_closure, |
| 128 bool success, |
| 129 const std::vector<content::NotificationDatabaseData>& data); |
| 130 |
118 void DidGetNotificationsShown( | 131 void DidGetNotificationsShown( |
119 const GURL& requesting_origin, | 132 const GURL& requesting_origin, |
120 int64 service_worker_registration_id, | 133 int64 service_worker_registration_id, |
121 bool notification_shown, | 134 bool notification_shown, |
122 bool notification_needed, | 135 bool notification_needed, |
123 const base::Closure& message_handled_closure, | 136 const base::Closure& message_handled_closure, |
124 const std::string& data, | 137 const std::string& data, |
125 bool success, | 138 bool success, |
126 bool not_found); | 139 bool not_found); |
127 | 140 |
| 141 void DidWriteNotificationData( |
| 142 const GURL& requesting_origin, |
| 143 const content::PlatformNotificationData& notification_data, |
| 144 const base::Closure& message_handled_closure, |
| 145 bool success, |
| 146 int64_t persistent_notification_id); |
| 147 |
128 // Register methods ---------------------------------------------------------- | 148 // Register methods ---------------------------------------------------------- |
129 | 149 |
130 void RegisterEnd( | 150 void RegisterEnd( |
131 const content::PushMessagingService::RegisterCallback& callback, | 151 const content::PushMessagingService::RegisterCallback& callback, |
132 const std::string& registration_id, | 152 const std::string& registration_id, |
133 content::PushRegistrationStatus status); | 153 content::PushRegistrationStatus status); |
134 | 154 |
135 void DidRegister( | 155 void DidRegister( |
136 const PushMessagingApplicationId& application_id, | 156 const PushMessagingApplicationId& application_id, |
137 const content::PushMessagingService::RegisterCallback& callback, | 157 const content::PushMessagingService::RegisterCallback& callback, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 195 |
176 base::Closure message_callback_for_testing_; | 196 base::Closure message_callback_for_testing_; |
177 base::Closure content_setting_changed_callback_for_testing_; | 197 base::Closure content_setting_changed_callback_for_testing_; |
178 | 198 |
179 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 199 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; |
180 | 200 |
181 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 201 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
182 }; | 202 }; |
183 | 203 |
184 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 204 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
OLD | NEW |