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

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

Issue 1619703002: Implement notificationclose event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits Created 4 years, 10 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { 145 {
146 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); 146 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels);
147 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); 147 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e);
148 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value)); 148 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value));
149 } 149 }
150 150
151 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) 151 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex)
152 { 152 {
153 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); 153 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID);
154 NotificationEventInit eventInit; 154 NotificationEventInit eventInit;
155 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data)); 155 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */));
156 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) 156 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size()))
157 eventInit.setAction(data.actions[actionIndex].action); 157 eventInit.setAction(data.actions[actionIndex].action);
158 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); 158 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer));
159 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 159 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
160 } 160 }
161 161
162 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, int64_t notificationID, const WebNotificationData& data)
163 {
164 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID);
165 NotificationEventInit eventInit;
166 eventInit.setAction(WTF::String()); // initialize as null.
167 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, false /* showing */));
168 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclose, eventInit, observer));
169 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
170 }
171
162 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) 172 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data)
163 { 173 {
164 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); 174 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID);
165 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); 175 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer));
166 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); 176 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
167 } 177 }
168 178
169 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) 179 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID)
170 { 180 {
171 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); 181 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 eventInit.setCancelable(true); 301 eventInit.setCancelable(true);
292 eventInit.setRequest(request); 302 eventInit.setRequest(request);
293 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId()); 303 eventInit.setClientId(webRequest.isMainResourceLoad() ? WebString() : webReq uest.clientId());
294 eventInit.setIsReload(webRequest.isReload()); 304 eventInit.setIsReload(webRequest.isReload());
295 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer)); 305 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(eventTypeName, eventInit, observer));
296 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ; 306 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ;
297 observer->didDispatchEvent(defaultPrevented); 307 observer->didDispatchEvent(defaultPrevented);
298 } 308 }
299 309
300 } // namespace blink 310 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698