| 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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // content_settings::Observer implementation. | 84 // content_settings::Observer implementation. |
| 85 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 85 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 86 const ContentSettingsPattern& secondary_pattern, | 86 const ContentSettingsPattern& secondary_pattern, |
| 87 ContentSettingsType content_type, | 87 ContentSettingsType content_type, |
| 88 std::string resource_identifier) override; | 88 std::string resource_identifier) override; |
| 89 | 89 |
| 90 // KeyedService implementation. | 90 // KeyedService implementation. |
| 91 void Shutdown() override; | 91 void Shutdown() override; |
| 92 | 92 |
| 93 void SetMessageCallbackForTesting(const base::Closure& callback); |
| 93 void SetContentSettingChangedCallbackForTesting( | 94 void SetContentSettingChangedCallbackForTesting( |
| 94 const base::Closure& callback); | 95 const base::Closure& callback); |
| 95 | 96 |
| 96 private: | 97 private: |
| 97 // A registration is pending until it has succeeded or failed. | 98 // A registration is pending until it has succeeded or failed. |
| 98 void IncreasePushRegistrationCount(int add, bool is_pending); | 99 void IncreasePushRegistrationCount(int add, bool is_pending); |
| 99 void DecreasePushRegistrationCount(int subtract, bool was_pending); | 100 void DecreasePushRegistrationCount(int subtract, bool was_pending); |
| 100 | 101 |
| 101 // OnMessage methods --------------------------------------------------------- | 102 // OnMessage methods --------------------------------------------------------- |
| 102 | 103 |
| 103 void DeliverMessageCallback(const std::string& app_id_guid, | 104 void DeliverMessageCallback(const std::string& app_id_guid, |
| 104 const GURL& requesting_origin, | 105 const GURL& requesting_origin, |
| 105 int64 service_worker_registration_id, | 106 int64 service_worker_registration_id, |
| 106 const gcm::GCMClient::IncomingMessage& message, | 107 const gcm::GCMClient::IncomingMessage& message, |
| 108 const base::Closure& message_handled_closure, |
| 107 content::PushDeliveryStatus status); | 109 content::PushDeliveryStatus status); |
| 108 | 110 |
| 109 // Developers are required to display a Web Notification in response to an | 111 // Developers are required to display a Web Notification in response to an |
| 110 // incoming push message in order to clarify to the user that something has | 112 // incoming push message in order to clarify to the user that something has |
| 111 // happened in the background. When they forget to do so, display a default | 113 // happened in the background. When they forget to do so, display a default |
| 112 // notification on their behalf. | 114 // notification on their behalf. |
| 113 void RequireUserVisibleUX(const GURL& requesting_origin, | 115 void RequireUserVisibleUX(const GURL& requesting_origin, |
| 114 int64 service_worker_registration_id); | 116 int64 service_worker_registration_id, |
| 117 const base::Closure& message_handled_closure); |
| 115 void DidGetNotificationsShown( | 118 void DidGetNotificationsShown( |
| 116 const GURL& requesting_origin, | 119 const GURL& requesting_origin, |
| 117 int64 service_worker_registration_id, | 120 int64 service_worker_registration_id, |
| 118 bool notification_shown, | 121 bool notification_shown, |
| 119 bool notification_needed, | 122 bool notification_needed, |
| 123 const base::Closure& message_handled_closure, |
| 120 const std::string& data, | 124 const std::string& data, |
| 121 bool success, | 125 bool success, |
| 122 bool not_found); | 126 bool not_found); |
| 123 | 127 |
| 124 // Register methods ---------------------------------------------------------- | 128 // Register methods ---------------------------------------------------------- |
| 125 | 129 |
| 126 void RegisterEnd( | 130 void RegisterEnd( |
| 127 const content::PushMessagingService::RegisterCallback& callback, | 131 const content::PushMessagingService::RegisterCallback& callback, |
| 128 const std::string& registration_id, | 132 const std::string& registration_id, |
| 129 content::PushRegistrationStatus status); | 133 content::PushRegistrationStatus status); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Checks if a given origin is allowed to use Push. | 166 // Checks if a given origin is allowed to use Push. |
| 163 bool HasPermission(const GURL& origin); | 167 bool HasPermission(const GURL& origin); |
| 164 | 168 |
| 165 gcm::GCMDriver* GetGCMDriver() const; | 169 gcm::GCMDriver* GetGCMDriver() const; |
| 166 | 170 |
| 167 Profile* profile_; | 171 Profile* profile_; |
| 168 | 172 |
| 169 int push_registration_count_; | 173 int push_registration_count_; |
| 170 int pending_push_registration_count_; | 174 int pending_push_registration_count_; |
| 171 | 175 |
| 176 base::Closure message_callback_for_testing_; |
| 172 base::Closure content_setting_changed_callback_for_testing_; | 177 base::Closure content_setting_changed_callback_for_testing_; |
| 173 | 178 |
| 174 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; | 179 base::WeakPtrFactory<PushMessagingServiceImpl> weak_factory_; |
| 175 | 180 |
| 176 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); | 181 DISALLOW_COPY_AND_ASSIGN(PushMessagingServiceImpl); |
| 177 }; | 182 }; |
| 178 | 183 |
| 179 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ | 184 #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_IMPL_H_ |
| OLD | NEW |