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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp

Issue 2484273003: [Presentation API] (1-UA) fire PresentationConnection onterminate event if receiver page gets destr… (Closed)
Patch Set: rebase Created 3 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: third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp
diff --git a/third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp b/third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp
index 14aea2196ba1860d7528fa487ad86f398c4263c5..0419e13923f9475d05673d9457da00e657b60b90 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationReceiver.cpp
@@ -9,6 +9,7 @@
#include "core/dom/DOMException.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
+#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/UseCounter.h"
#include "modules/presentation/PresentationConnection.h"
@@ -62,6 +63,27 @@ WebPresentationConnection* PresentationReceiver::onReceiverConnectionAvailable(
return connection;
}
+void PresentationReceiver::didChangeSessionState(
+ WebPresentationConnectionState state) {
+ // TODO(zhaobin): remove or modify DCHECK when receiver supports more
+ // connection state change.
+ DCHECK(state == WebPresentationConnectionState::Terminated);
+
+ for (auto connection : m_connectionList->connections())
+ connection->didChangeState(state, false /* shouldDispatchEvent */);
+}
+
+void PresentationReceiver::terminateConnection() {
+ if (!frame())
+ return;
+
+ auto* window = frame()->domWindow();
+ if (!window || window->closed())
+ return;
+
+ window->close(frame()->document());
+}
+
void PresentationReceiver::registerConnection(
PresentationConnection* connection) {
DCHECK(m_connectionList);

Powered by Google App Engine
This is Rietveld 408576698