| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/presentation/PresentationSession.h" | 6 #include "modules/presentation/PresentationSession.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/LocalFrame.h" |
| 8 #include "modules/EventTargetModules.h" | 10 #include "modules/EventTargetModules.h" |
| 11 #include "modules/presentation/Presentation.h" |
| 12 #include "public/platform/WebString.h" |
| 13 #include "public/platform/modules/presentation/WebPresentationSessionClient.h" |
| 14 #include "wtf/OwnPtr.h" |
| 9 | 15 |
| 10 namespace blink { | 16 namespace blink { |
| 11 | 17 |
| 12 PresentationSession::PresentationSession(ExecutionContext* executionContext) | 18 PresentationSession::PresentationSession(LocalFrame* frame, const WebString& id) |
| 13 : ContextLifecycleObserver(executionContext) | 19 : DOMWindowProperty(frame) |
| 20 , m_id(id) |
| 21 , m_state("disconnected") |
| 14 { | 22 { |
| 15 } | 23 } |
| 16 | 24 |
| 17 PresentationSession::~PresentationSession() | 25 PresentationSession::~PresentationSession() |
| 18 { | 26 { |
| 19 } | 27 } |
| 20 | 28 |
| 21 // static | 29 // static |
| 22 PresentationSession* PresentationSession::create(ExecutionContext* executionCont
ext) | 30 PresentationSession* PresentationSession::take(WebPresentationSessionClient* cli
entRaw, Presentation* presentation) |
| 23 { | 31 { |
| 24 return new PresentationSession(executionContext); | 32 ASSERT(clientRaw); |
| 33 ASSERT(presentation); |
| 34 OwnPtr<WebPresentationSessionClient> client = adoptPtr(clientRaw); |
| 35 |
| 36 PresentationSession* session = new PresentationSession(presentation->frame()
, client->getId()); |
| 37 presentation->registerSession(session); |
| 38 return session; |
| 39 } |
| 40 |
| 41 // static |
| 42 void PresentationSession::dispose(WebPresentationSessionClient* client) |
| 43 { |
| 44 delete client; |
| 25 } | 45 } |
| 26 | 46 |
| 27 const AtomicString& PresentationSession::interfaceName() const | 47 const AtomicString& PresentationSession::interfaceName() const |
| 28 { | 48 { |
| 29 return EventTargetNames::PresentationSession; | 49 return EventTargetNames::PresentationSession; |
| 30 } | 50 } |
| 31 | 51 |
| 32 ExecutionContext* PresentationSession::executionContext() const | 52 ExecutionContext* PresentationSession::executionContext() const |
| 33 { | 53 { |
| 34 return ContextLifecycleObserver::executionContext(); | 54 if (!frame()) |
| 35 } | 55 return nullptr; |
| 56 return frame()->document();} |
| 36 | 57 |
| 37 DEFINE_TRACE(PresentationSession) | 58 DEFINE_TRACE(PresentationSession) |
| 38 { | 59 { |
| 39 RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSession>::tr
ace(visitor); | 60 RefCountedGarbageCollectedEventTargetWithInlineData<PresentationSession>::tr
ace(visitor); |
| 40 ContextLifecycleObserver::trace(visitor); | 61 DOMWindowProperty::trace(visitor); |
| 41 } | 62 } |
| 42 | 63 |
| 43 void PresentationSession::postMessage(const String& message) | 64 void PresentationSession::postMessage(const String& message) |
| 44 { | 65 { |
| 45 } | 66 } |
| 46 | 67 |
| 47 void PresentationSession::close() | 68 void PresentationSession::close() |
| 48 { | 69 { |
| 49 } | 70 } |
| 50 | 71 |
| 51 } // namespace blink | 72 } // namespace blink |
| OLD | NEW |