| 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 19 matching lines...) Expand all Loading... |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 31 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 33 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 34 #include "bindings/core/v8/ScriptPromise.h" | 34 #include "bindings/core/v8/ScriptPromise.h" |
| 35 #include "bindings/core/v8/ScriptPromiseResolver.h" | 35 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 36 #include "bindings/core/v8/ScriptState.h" | 36 #include "bindings/core/v8/ScriptState.h" |
| 37 #include "bindings/core/v8/SerializedScriptValue.h" | 37 #include "bindings/core/v8/SerializedScriptValue.h" |
| 38 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 38 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 39 #include "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
| 40 #include "core/dom/Document.h" |
| 40 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
| 41 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
| 42 #include "core/dom/MessagePort.h" | 43 #include "core/dom/MessagePort.h" |
| 43 #include "core/events/MessageEvent.h" | 44 #include "core/events/MessageEvent.h" |
| 44 #include "core/frame/LocalDOMWindow.h" | 45 #include "core/frame/LocalDOMWindow.h" |
| 45 #include "modules/EventTargetModules.h" | 46 #include "modules/EventTargetModules.h" |
| 46 #include "modules/serviceworkers/ServiceWorker.h" | 47 #include "modules/serviceworkers/ServiceWorker.h" |
| 47 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
| 48 #include "modules/serviceworkers/ServiceWorkerError.h" | 49 #include "modules/serviceworkers/ServiceWorkerError.h" |
| 49 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 50 #include "platform/RuntimeEnabledFeatures.h" | 51 #include "platform/RuntimeEnabledFeatures.h" |
| 51 #include "public/platform/WebServiceWorker.h" | 52 #include "public/platform/WebServiceWorker.h" |
| 53 #include "public/platform/WebServiceWorkerClientsInfo.h" |
| 52 #include "public/platform/WebServiceWorkerProvider.h" | 54 #include "public/platform/WebServiceWorkerProvider.h" |
| 53 #include "public/platform/WebServiceWorkerRegistration.h" | 55 #include "public/platform/WebServiceWorkerRegistration.h" |
| 54 #include "public/platform/WebString.h" | 56 #include "public/platform/WebString.h" |
| 55 #include "public/platform/WebURL.h" | 57 #include "public/platform/WebURL.h" |
| 56 | 58 |
| 57 namespace blink { | 59 namespace blink { |
| 58 | 60 |
| 59 // This wraps CallbackPromiseAdapter and resolves the promise with undefined | 61 // This wraps CallbackPromiseAdapter and resolves the promise with undefined |
| 60 // when nullptr is given to onSuccess. | 62 // when nullptr is given to onSuccess. |
| 61 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { | 63 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke
rGetRegistrationCallbacks { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); | 275 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray
(executionContext(), webChannels); |
| 274 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance
().createFromWire(message); | 276 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance
().createFromWire(message); |
| 275 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); | 277 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); |
| 276 } | 278 } |
| 277 | 279 |
| 278 const AtomicString& ServiceWorkerContainer::interfaceName() const | 280 const AtomicString& ServiceWorkerContainer::interfaceName() const |
| 279 { | 281 { |
| 280 return EventTargetNames::ServiceWorkerContainer; | 282 return EventTargetNames::ServiceWorkerContainer; |
| 281 } | 283 } |
| 282 | 284 |
| 285 bool ServiceWorkerContainer::getClientInfo(WebServiceWorkerClientInfo* info) |
| 286 { |
| 287 ExecutionContext* context = executionContext(); |
| 288 // FIXME: Make this work for non-document context (e.g. shared workers). |
| 289 if (!context || !context->isDocument()) |
| 290 return false; |
| 291 Document* document = toDocument(context); |
| 292 info->visibilityState = document->visibilityState(); |
| 293 info->focused = document->hasFocus(); |
| 294 info->url = document->url(); |
| 295 if (!document->frame()) |
| 296 info->frameType = WebURLRequest::FrameTypeNone; |
| 297 else if (document->frame()->isMainFrame()) |
| 298 info->frameType = WebURLRequest::FrameTypeTopLevel; |
| 299 else |
| 300 info->frameType = WebURLRequest::FrameTypeNested; |
| 301 return true; |
| 302 } |
| 303 |
| 283 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) | 304 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) |
| 284 : ContextLifecycleObserver(executionContext) | 305 : ContextLifecycleObserver(executionContext) |
| 285 , m_provider(0) | 306 , m_provider(0) |
| 286 { | 307 { |
| 287 | 308 |
| 288 if (!executionContext) | 309 if (!executionContext) |
| 289 return; | 310 return; |
| 290 | 311 |
| 291 m_ready = createReadyProperty(); | 312 m_ready = createReadyProperty(); |
| 292 | 313 |
| 293 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 314 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 294 m_provider = client->provider(); | 315 m_provider = client->provider(); |
| 295 if (m_provider) | 316 if (m_provider) |
| 296 m_provider->setClient(this); | 317 m_provider->setClient(this); |
| 297 } | 318 } |
| 298 } | 319 } |
| 299 | 320 |
| 300 } // namespace blink | 321 } // namespace blink |
| OLD | NEW |