| Index: Source/modules/presentation/Presentation.cpp
|
| diff --git a/Source/modules/presentation/Presentation.cpp b/Source/modules/presentation/Presentation.cpp
|
| index 93957fe0c91249fd3de4e7059667e4557ba7a0fc..660b59de0025521a53a28b209a547665c9c55b08 100644
|
| --- a/Source/modules/presentation/Presentation.cpp
|
| +++ b/Source/modules/presentation/Presentation.cpp
|
| @@ -9,8 +9,12 @@
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "bindings/core/v8/ScriptState.h"
|
| #include "core/dom/DOMException.h"
|
| +#include "core/dom/Document.h"
|
| #include "core/dom/ExceptionCode.h"
|
| +#include "core/frame/LocalFrame.h"
|
| #include "modules/EventTargetModules.h"
|
| +#include "modules/presentation/AvailableChangeEvent.h"
|
| +#include "modules/presentation/PresentationController.h"
|
|
|
| namespace blink {
|
|
|
| @@ -26,7 +30,11 @@ Presentation::~Presentation()
|
| // static
|
| Presentation* Presentation::create(ExecutionContext* executionContext)
|
| {
|
| - return new Presentation(executionContext);
|
| + Presentation* presentation = new Presentation(executionContext);
|
| + PresentationController* controller = presentation->presentationController();
|
| + if (controller)
|
| + controller->setPresentation(presentation);
|
| + return presentation;
|
| }
|
|
|
| const AtomicString& Presentation::interfaceName() const
|
| @@ -67,4 +75,40 @@ ScriptPromise Presentation::joinSession(ScriptState* state, const String& sender
|
| return promise;
|
| }
|
|
|
| +bool Presentation::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
|
| +{
|
| + if (eventType == EventTypeNames::availablechange) {
|
| + PresentationController* controller = presentationController();
|
| + if (controller)
|
| + controller->addDeviceAvailabilityListener();
|
| + }
|
| + return RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>::addEventListener(eventType, listener, useCapture);
|
| +}
|
| +
|
| +bool Presentation::removeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
|
| +{
|
| + if (eventType == EventTypeNames::availablechange) {
|
| + PresentationController* controller = presentationController();
|
| + if (controller)
|
| + controller->removeDeviceAvailabilityListener();
|
| + }
|
| + return RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>::removeEventListener(eventType, listener, useCapture);
|
| +}
|
| +
|
| +void Presentation::didChangeAvailability(bool available)
|
| +{
|
| + dispatchEvent(AvailableChangeEvent::create(EventTypeNames::availablechange, available));
|
| +}
|
| +
|
| +PresentationController* Presentation::presentationController()
|
| +{
|
| + Document* document = toDocument(executionContext());
|
| + if (!document)
|
| + return nullptr;
|
| + LocalFrame* frame = document->frame();
|
| + if (!frame)
|
| + return nullptr;
|
| + return PresentationController::from(*frame);
|
| +}
|
| +
|
| } // namespace blink
|
|
|