| 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 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" | 5 #include "modules/notifications/ServiceWorkerRegistrationNotifications.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 9 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 10 #include "bindings/core/v8/ExceptionState.h" | 10 #include "bindings/core/v8/ExceptionState.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 167 } |
| 168 return *supplement; | 168 return *supplement; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void ServiceWorkerRegistrationNotifications::PrepareShow( | 171 void ServiceWorkerRegistrationNotifications::PrepareShow( |
| 172 const WebNotificationData& data, | 172 const WebNotificationData& data, |
| 173 std::unique_ptr<WebNotificationShowCallbacks> callbacks) { | 173 std::unique_ptr<WebNotificationShowCallbacks> callbacks) { |
| 174 RefPtr<SecurityOrigin> origin = GetExecutionContext()->GetSecurityOrigin(); | 174 RefPtr<SecurityOrigin> origin = GetExecutionContext()->GetSecurityOrigin(); |
| 175 NotificationResourcesLoader* loader = new NotificationResourcesLoader( | 175 NotificationResourcesLoader* loader = new NotificationResourcesLoader( |
| 176 WTF::Bind(&ServiceWorkerRegistrationNotifications::DidLoadResources, | 176 WTF::Bind(&ServiceWorkerRegistrationNotifications::DidLoadResources, |
| 177 WrapWeakPersistent(this), origin.Release(), data, | 177 WrapWeakPersistent(this), std::move(origin), data, |
| 178 WTF::Passed(std::move(callbacks)))); | 178 WTF::Passed(std::move(callbacks)))); |
| 179 loaders_.insert(loader); | 179 loaders_.insert(loader); |
| 180 loader->Start(GetExecutionContext(), data); | 180 loader->Start(GetExecutionContext(), data); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void ServiceWorkerRegistrationNotifications::DidLoadResources( | 183 void ServiceWorkerRegistrationNotifications::DidLoadResources( |
| 184 PassRefPtr<SecurityOrigin> origin, | 184 PassRefPtr<SecurityOrigin> origin, |
| 185 const WebNotificationData& data, | 185 const WebNotificationData& data, |
| 186 std::unique_ptr<WebNotificationShowCallbacks> callbacks, | 186 std::unique_ptr<WebNotificationShowCallbacks> callbacks, |
| 187 NotificationResourcesLoader* loader) { | 187 NotificationResourcesLoader* loader) { |
| 188 DCHECK(loaders_.Contains(loader)); | 188 DCHECK(loaders_.Contains(loader)); |
| 189 | 189 |
| 190 WebNotificationManager* notification_manager = | 190 WebNotificationManager* notification_manager = |
| 191 Platform::Current()->GetNotificationManager(); | 191 Platform::Current()->GetNotificationManager(); |
| 192 DCHECK(notification_manager); | 192 DCHECK(notification_manager); |
| 193 | 193 |
| 194 notification_manager->ShowPersistent( | 194 notification_manager->ShowPersistent( |
| 195 WebSecurityOrigin(origin.Get()), data, loader->GetResources(), | 195 WebSecurityOrigin(origin.Get()), data, loader->GetResources(), |
| 196 registration_->WebRegistration(), std::move(callbacks)); | 196 registration_->WebRegistration(), std::move(callbacks)); |
| 197 loaders_.erase(loader); | 197 loaders_.erase(loader); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace blink | 200 } // namespace blink |
| OLD | NEW |