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

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

Issue 1262893005: Add NotificationEvent.action property in SW events (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@actions3_fix
Patch Set: Created 5 years, 4 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.h" 57 #include "modules/serviceworkers/ServiceWorkerGlobalScope.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/WebCrossOriginServiceWorkerClient.h" 60 #include "public/platform/WebCrossOriginServiceWorkerClient.h"
61 #include "public/platform/WebServiceWorkerEventResult.h" 61 #include "public/platform/WebServiceWorkerEventResult.h"
62 #include "public/platform/WebServiceWorkerRequest.h" 62 #include "public/platform/WebServiceWorkerRequest.h"
63 #include "public/platform/modules/notifications/WebNotificationData.h" 63 #include "public/platform/modules/notifications/WebNotificationData.h"
64 #include "public/web/WebSerializedScriptValue.h" 64 #include "public/web/WebSerializedScriptValue.h"
65 #include "public/web/WebServiceWorkerContextClient.h" 65 #include "public/web/WebServiceWorkerContextClient.h"
66 #include "web/WebEmbeddedWorkerImpl.h" 66 #include "web/WebEmbeddedWorkerImpl.h"
67 #include "wtf/Assertions.h"
67 #include "wtf/Functional.h" 68 #include "wtf/Functional.h"
68 #include "wtf/PassOwnPtr.h" 69 #include "wtf/PassOwnPtr.h"
69 70
70 namespace blink { 71 namespace blink {
71 72
72 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte xtClient& client) 73 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte xtClient& client)
73 { 74 {
74 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client)); 75 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client));
75 } 76 }
76 77
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 { 128 {
128 ASSERT(m_workerGlobalScope); 129 ASSERT(m_workerGlobalScope);
129 130
130 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); 131 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels);
131 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 132 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
132 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports, value)); 133 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports, value));
133 } 134 }
134 135
135 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data) 136 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data)
136 { 137 {
138 dispatchNotificationClickEvent(eventID, notificationID, data, -1 /* actionIn dex */);
139 }
140
141 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex)
142 {
137 ASSERT(m_workerGlobalScope); 143 ASSERT(m_workerGlobalScope);
138 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID); 144 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID);
139 NotificationEventInit eventInit; 145 NotificationEventInit eventInit;
140 eventInit.setNotification(Notification::create(m_workerGlobalScope, notifica tionID, data)); 146 eventInit.setNotification(Notification::create(m_workerGlobalScope, notifica tionID, data));
147 if (actionIndex >= 0)
Peter Beverloo 2015/08/04 21:01:23 Make sure that it's in bounds (upper-bound as well
johnme 2015/08/05 11:56:22 Done.
148 eventInit.setAction(data.actions[actionIndex].action);
141 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); 149 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer));
142 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 150 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
143 } 151 }
144 152
145 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 153 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
146 { 154 {
147 ASSERT(m_workerGlobalScope); 155 ASSERT(m_workerGlobalScope);
148 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID); 156 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID);
149 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 157 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer));
150 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); 158 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 234
227 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) 235 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client)
228 : m_embeddedWorker(embeddedWorker) 236 : m_embeddedWorker(embeddedWorker)
229 , m_document(document) 237 , m_document(document)
230 , m_client(client) 238 , m_client(client)
231 , m_workerGlobalScope(0) 239 , m_workerGlobalScope(0)
232 { 240 {
233 } 241 }
234 242
235 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698