Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 { | 139 { |
| 140 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); | 140 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); |
| 141 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); | 141 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); |
| 142 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value)); | 142 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) | 145 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) |
| 146 { | 146 { |
| 147 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); | 147 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); |
| 148 NotificationEventInit eventInit; | 148 NotificationEventInit eventInit; |
| 149 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data)); | 149 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, true /* showing */)); |
| 150 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) | 150 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) |
| 151 eventInit.setAction(data.actions[actionIndex].action); | 151 eventInit.setAction(data.actions[actionIndex].action); |
| 152 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); | 152 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); |
| 153 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 153 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ServiceWorkerGlobalScopeProxy::dispatchNotificationCloseEvent(int eventID, int64_t notificationID, const WebNotificationData& data) | |
| 157 { | |
| 158 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClose, eventID); | |
| 159 NotificationEventInit eventInit; | |
| 160 eventInit.setAction(WTF::String()); | |
|
Peter Beverloo
2016/01/27 19:03:58
Why is this line necessary?
Nina
2016/01/28 11:59:01
We want the action to be null when closing, and it
| |
| 161 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data, false /* showing */)); | |
| 162 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclose, eventInit, observer)); | |
| 163 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | |
| 164 } | |
| 165 | |
| 156 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) | 166 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) |
| 157 { | 167 { |
| 158 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); | 168 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); |
| 159 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); | 169 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); |
| 160 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); | 170 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 161 } | 171 } |
| 162 | 172 |
| 163 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) | 173 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) |
| 164 { | 174 { |
| 165 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); | 175 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 return *m_document; | 279 return *m_document; |
| 270 } | 280 } |
| 271 | 281 |
| 272 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st | 282 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st |
| 273 { | 283 { |
| 274 ASSERT(m_workerGlobalScope); | 284 ASSERT(m_workerGlobalScope); |
| 275 return m_workerGlobalScope; | 285 return m_workerGlobalScope; |
| 276 } | 286 } |
| 277 | 287 |
| 278 } // namespace blink | 288 } // namespace blink |
| OLD | NEW |