Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2078)

Unified Diff: Source/modules/presentation/PresentationSession.cpp

Issue 1020303004: [PresentationAPI] Plumbing |onstatechange| event for the PresentationSession from Blink to platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/presentation/PresentationSession.cpp
diff --git a/Source/modules/presentation/PresentationSession.cpp b/Source/modules/presentation/PresentationSession.cpp
index 4727bebdb9c0397281ff4af261da66203d9597eb..d4c8d123ea13c2d03f521f2b1f68777551d8d3c8 100644
--- a/Source/modules/presentation/PresentationSession.cpp
+++ b/Source/modules/presentation/PresentationSession.cpp
@@ -6,21 +6,35 @@
#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/OwnPtr.h"
namespace blink {
+namespace {
+
+const AtomicString SessionStateToString(WebPresentationSessionClient::SessionState state)
Peter Beverloo 2015/03/20 19:07:40 Why do you return an AtomicString here and not jus
mlamouri (slow - plz ping) 2015/03/23 17:54:16 I think using an AtomicString is fine. However, co
whywhat 2015/03/23 21:12:16 Done.
whywhat 2015/03/23 21:12:16 To avoid extra conversion (from String to AtomicSt
+{
+ switch (state) {
+ case WebPresentationSessionClient::SessionStateConnected:
+ return "connected";
+ case WebPresentationSessionClient::SessionStateDisconnected:
+ default:
+ return "disconnected";
+ }
+}
+
+} // namespace
+
PresentationSession::PresentationSession(LocalFrame* frame, const WebString& id, const WebString& url)
: DOMWindowProperty(frame)
, m_id(id)
, m_url(url)
- , m_state("disconnected")
+ , m_state(WebPresentationSessionClient::SessionStateDisconnected)
{
}
@@ -63,19 +77,35 @@ DEFINE_TRACE(PresentationSession)
DOMWindowProperty::trace(visitor);
}
+const AtomicString PresentationSession::state() const
mark a. foltz 2015/03/20 20:40:22 Why is this returning a string instead of the enum
mlamouri (slow - plz ping) 2015/03/23 17:54:16 I would guess that ::state() is being used by the
whywhat 2015/03/23 21:12:16 As I understand it, that's how WebIDL enum values
whywhat 2015/03/23 21:12:16 Acknowledged.
+{
+ return SessionStateToString(m_state);
+}
+
void PresentationSession::postMessage(const String& message)
{
}
void PresentationSession::close()
{
- if (m_state != "connected")
+ if (m_state != WebPresentationSessionClient::SessionStateConnected)
return;
PresentationController* controller = presentationController();
if (controller)
controller->closeSession(m_url, m_id);
}
+bool PresentationSession::matches(WebPresentationSessionClient* client) const
+{
+ return client && client->getUrl() == m_url && client->getId() == m_id;
mark a. foltz 2015/03/20 20:40:22 The match between a PresentationSession and |clien
whywhat 2015/03/23 21:12:16 I expected the list to be fairy small. We could us
+}
+
+void PresentationSession::didChangeState(WebPresentationSessionClient::SessionState state)
+{
+ m_state = state;
mark a. foltz 2015/03/20 20:40:22 What if m_state == state? We don't need to dispat
whywhat 2015/03/23 21:12:16 Done.
+ dispatchEvent(Event::create(EventTypeNames::statechange));
+}
+
PresentationController* PresentationSession::presentationController()
{
if (!frame())

Powered by Google App Engine
This is Rietveld 408576698