Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1904163002: Move Web Notifications to use Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@skbitmap-blink
Patch Set: it works \o/ Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "modules/serviceworkers/ExtendableEvent.h" 50 #include "modules/serviceworkers/ExtendableEvent.h"
51 #include "modules/serviceworkers/ExtendableMessageEvent.h" 51 #include "modules/serviceworkers/ExtendableMessageEvent.h"
52 #include "modules/serviceworkers/FetchEvent.h" 52 #include "modules/serviceworkers/FetchEvent.h"
53 #include "modules/serviceworkers/ForeignFetchEvent.h" 53 #include "modules/serviceworkers/ForeignFetchEvent.h"
54 #include "modules/serviceworkers/InstallEvent.h" 54 #include "modules/serviceworkers/InstallEvent.h"
55 #include "modules/serviceworkers/ServiceWorkerClient.h" 55 #include "modules/serviceworkers/ServiceWorkerClient.h"
56 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 56 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
57 #include "modules/serviceworkers/ServiceWorkerWindowClient.h" 57 #include "modules/serviceworkers/ServiceWorkerWindowClient.h"
58 #include "modules/serviceworkers/WaitUntilObserver.h" 58 #include "modules/serviceworkers/WaitUntilObserver.h"
59 #include "platform/RuntimeEnabledFeatures.h" 59 #include "platform/RuntimeEnabledFeatures.h"
60 #include "public/platform/modules/notifications/WebNotificationData.h" 60 #include "public/platform/modules/notifications/notification.mojom-blink.h"
61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h" 61 #include "public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" 62 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h"
63 #include "public/web/WebSerializedScriptValue.h" 63 #include "public/web/WebSerializedScriptValue.h"
64 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 64 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
65 #include "web/WebEmbeddedWorkerImpl.h" 65 #include "web/WebEmbeddedWorkerImpl.h"
66 #include "wtf/Assertions.h" 66 #include "wtf/Assertions.h"
67 #include "wtf/Functional.h" 67 #include "wtf/Functional.h"
68 #include "wtf/PassOwnPtr.h" 68 #include "wtf/PassOwnPtr.h"
69 69
70 #include <utility> 70 #include <utility>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 { 170 {
171 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID); 171 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID);
172 Event* event; 172 Event* event;
173 if (RuntimeEnabledFeatures::foreignFetchEnabled()) 173 if (RuntimeEnabledFeatures::foreignFetchEnabled())
174 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer); 174 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer);
175 else 175 else
176 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer); 176 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer);
177 workerGlobalScope()->dispatchExtendableEvent(event, observer); 177 workerGlobalScope()->dispatchExtendableEvent(event, observer);
178 } 178 }
179 179
180 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) 180 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, mojom::blink::NotificationPtr notification, int actionIndex)
181 { 181 {
182 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); 182 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID);
183 NotificationEventInit eventInit; 183 NotificationEventInit eventInit;
184 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */)); 184 if (actionIndex >= 0 && actionIndex < static_cast<int>(notification->actions .size()))
185 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) 185 eventInit.setAction(notification->actions[actionIndex]->action);
186 eventInit.setAction(data.actions[actionIndex].action); 186 eventInit.setNotification(Notification::create(workerGlobalScope(), std::mov e(notification), true /* showing */));
187 Event* event = NotificationEvent::create(EventTypeNames::notificationclick, eventInit, observer); 187 Event* event = NotificationEvent::create(EventTypeNames::notificationclick, eventInit, observer);
188 workerGlobalScope()->dispatchExtendableEvent(event, observer); 188 workerGlobalScope()->dispatchExtendableEvent(event, observer);
189 } 189 }
190 190
191 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, int64_t notificationID, const WebNotificationData& data) 191 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, mojom::blink::NotificationPtr notification)
192 { 192 {
193 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID); 193 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID);
194 NotificationEventInit eventInit; 194 NotificationEventInit eventInit;
195 eventInit.setAction(WTF::String()); // initialize as null. 195 eventInit.setAction(WTF::String()); // initialize as null.
196 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, false /* showing */)); 196 eventInit.setNotification(Notification::create(workerGlobalScope(), std::mov e(notification), false /* showing */));
197 Event* event = NotificationEvent::create(EventTypeNames::notificationclose, eventInit, observer); 197 Event* event = NotificationEvent::create(EventTypeNames::notificationclose, eventInit, observer);
198 workerGlobalScope()->dispatchExtendableEvent(event, observer); 198 workerGlobalScope()->dispatchExtendableEvent(event, observer);
199 } 199 }
200 200
201 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 201 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
202 { 202 {
203 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); 203 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID);
204 Event* event = PushEvent::create(EventTypeNames::push, PushMessageData::crea te(data), observer); 204 Event* event = PushEvent::create(EventTypeNames::push, PushMessageData::crea te(data), observer);
205 workerGlobalScope()->dispatchExtendableEvent(event, observer); 205 workerGlobalScope()->dispatchExtendableEvent(event, observer);
206 } 206 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return *m_document; 296 return *m_document;
297 } 297 }
298 298
299 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st 299 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st
300 { 300 {
301 DCHECK(m_workerGlobalScope); 301 DCHECK(m_workerGlobalScope);
302 return m_workerGlobalScope; 302 return m_workerGlobalScope;
303 } 303 }
304 304
305 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.h ('k') | third_party/WebKit/Source/web/web.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698