| Index: Source/modules/presentation/PresentationSession.cpp
|
| diff --git a/Source/modules/presentation/PresentationSession.cpp b/Source/modules/presentation/PresentationSession.cpp
|
| index 4727bebdb9c0397281ff4af261da66203d9597eb..47ba6253b3d33c471419808f6e6918b48f272bdd 100644
|
| --- a/Source/modules/presentation/PresentationSession.cpp
|
| +++ b/Source/modules/presentation/PresentationSession.cpp
|
| @@ -6,21 +6,43 @@
|
| #include "modules/presentation/PresentationSession.h"
|
|
|
| #include "core/dom/Document.h"
|
| +#include "core/events/Event.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "modules/EventTargetModules.h"
|
| #include "modules/presentation/Presentation.h"
|
| #include "modules/presentation/PresentationController.h"
|
| -#include "public/platform/WebString.h"
|
| #include "public/platform/modules/presentation/WebPresentationSessionClient.h"
|
| +#include "wtf/Assertions.h"
|
| #include "wtf/OwnPtr.h"
|
| +#include "wtf/text/AtomicString.h"
|
|
|
| namespace blink {
|
|
|
| -PresentationSession::PresentationSession(LocalFrame* frame, const WebString& id, const WebString& url)
|
| +namespace {
|
| +
|
| +const AtomicString& SessionStateToString(WebPresentationSessionState state)
|
| +{
|
| + DEFINE_STATIC_LOCAL(const AtomicString, connectedValue, ("connected", AtomicString::ConstructFromLiteral));
|
| + DEFINE_STATIC_LOCAL(const AtomicString, disconnectedValue, ("disconnected", AtomicString::ConstructFromLiteral));
|
| +
|
| + switch (state) {
|
| + case WebPresentationSessionState::Connected:
|
| + return connectedValue;
|
| + case WebPresentationSessionState::Disconnected:
|
| + return disconnectedValue;
|
| + }
|
| +
|
| + ASSERT_NOT_REACHED();
|
| + return disconnectedValue;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +PresentationSession::PresentationSession(LocalFrame* frame, const String& id, const String& url)
|
| : DOMWindowProperty(frame)
|
| , m_id(id)
|
| , m_url(url)
|
| - , m_state("disconnected")
|
| + , m_state(WebPresentationSessionState::Disconnected)
|
| {
|
| }
|
|
|
| @@ -63,19 +85,38 @@ DEFINE_TRACE(PresentationSession)
|
| DOMWindowProperty::trace(visitor);
|
| }
|
|
|
| +const AtomicString& PresentationSession::state() const
|
| +{
|
| + return SessionStateToString(m_state);
|
| +}
|
| +
|
| void PresentationSession::postMessage(const String& message)
|
| {
|
| }
|
|
|
| void PresentationSession::close()
|
| {
|
| - if (m_state != "connected")
|
| + if (m_state != WebPresentationSessionState::Connected)
|
| return;
|
| PresentationController* controller = presentationController();
|
| if (controller)
|
| controller->closeSession(m_url, m_id);
|
| }
|
|
|
| +bool PresentationSession::matches(WebPresentationSessionClient* client) const
|
| +{
|
| + return client && m_url == static_cast<String>(client->getUrl()) && m_id == static_cast<String>(client->getId());
|
| +}
|
| +
|
| +void PresentationSession::didChangeState(WebPresentationSessionState state)
|
| +{
|
| + if (m_state == state)
|
| + return;
|
| +
|
| + m_state = state;
|
| + dispatchEvent(Event::create(EventTypeNames::statechange));
|
| +}
|
| +
|
| PresentationController* PresentationSession::presentationController()
|
| {
|
| if (!frame())
|
|
|