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

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

Issue 940503002: [PresentationAPI] Added plumbing for start/joinSession from JS to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comment Created 5 years, 10 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/Presentation.cpp
diff --git a/Source/modules/presentation/Presentation.cpp b/Source/modules/presentation/Presentation.cpp
index 1dd3bcc41dd3e792cab64a91641207d2469fa8f3..b68e35cd0e29c6322b015c3db46041f924bd4690 100644
--- a/Source/modules/presentation/Presentation.cpp
+++ b/Source/modules/presentation/Presentation.cpp
@@ -15,6 +15,7 @@
#include "modules/EventTargetModules.h"
#include "modules/presentation/AvailableChangeEvent.h"
#include "modules/presentation/PresentationController.h"
+#include "modules/presentation/PresentationSessionClientCallbacks.h"
namespace blink {
@@ -52,6 +53,7 @@ ExecutionContext* Presentation::executionContext() const
DEFINE_TRACE(Presentation)
{
visitor->trace(m_session);
+ visitor->trace(m_openSessions);
RefCountedGarbageCollectedEventTargetWithInlineData<Presentation>::trace(visitor);
DOMWindowProperty::trace(visitor);
}
@@ -65,7 +67,14 @@ ScriptPromise Presentation::startSession(ScriptState* state, const String& prese
{
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state);
ScriptPromise promise = resolver->promise();
- resolver->reject(DOMException::create(NotSupportedError, "The method is not supported yet."));
+
+ PresentationController* controller = presentationController();
+ if (!controller) {
+ resolver->reject(DOMException::create(InvalidStateError, "The object is no longer attached to the frame."));
+ return promise;
+ }
+ controller->startSession(presentationUrl, presentationId, new PresentationSessionClientCallbacks(resolver, this));
+
return promise;
}
@@ -73,7 +82,14 @@ ScriptPromise Presentation::joinSession(ScriptState* state, const String& presen
{
RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(state);
ScriptPromise promise = resolver->promise();
- resolver->reject(DOMException::create(NotSupportedError, "The method is not supported yet."));
+
+ PresentationController* controller = presentationController();
+ if (!controller) {
+ resolver->reject(DOMException::create(InvalidStateError, "The object is no longer attached to the frame."));
+ return promise;
+ }
+ controller->joinSession(presentationUrl, presentationId, new PresentationSessionClientCallbacks(resolver, this));
+
return promise;
}
@@ -129,6 +145,11 @@ bool Presentation::isAvailableChangeWatched() const
return hasEventListeners(EventTypeNames::availablechange);
}
+void Presentation::didCreateSession(PresentationSession* session)
+{
+ m_openSessions.add(session);
+}
+
PresentationController* Presentation::presentationController()
{
if (!frame())

Powered by Google App Engine
This is Rietveld 408576698