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

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: resolve code review comments from haraken Created 4 years, 1 month 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 d7b86b576b1fde3121a28145f635e76542ed0e9a..1ad2467e0744c087555b254a686cb161aee3d1a0 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/DOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "modules/presentation/PresentationConnection.h"
#include "modules/presentation/PresentationConnectionList.h"
@@ -59,6 +60,29 @@ void PresentationReceiver::onReceiverConnectionAvailable(
m_connectionList->dispatchConnectionAvailableEvent(connection);
}
+void PresentationReceiver::didChangeSessionState(
+ WebPresentationConnectionState state) {
+ DCHECK(state == WebPresentationConnectionState::Terminated);
imcheng 2016/11/28 22:12:01 Is this temporary? Please add a TODO if so
zhaobin 2017/02/16 00:42:30 Done.
+
+ for (auto connection : m_connectionList->connections())
+ connection->didChangeState(state);
imcheng 2016/11/28 22:12:01 will you also need to close the window if the conn
zhaobin 2017/02/16 00:42:30 No. This is invoked when destroying receiver frame
+}
+
+void PresentationReceiver::closeWindow() {
+ if (!frame())
+ return;
+
+ DOMWindow* window = frame()->domWindow();
+ if (!window || window->closed())
+ return;
+
+ Document* document = frame()->document();
+ if (!document)
haraken 2016/11/29 02:15:50 This check won't be needed. You can pass in nullpt
zhaobin 2017/02/16 00:42:30 Done.
+ return;
+
+ window->close(document);
+}
+
void PresentationReceiver::registerConnection(
PresentationConnection* connection) {
DCHECK(m_connectionList);

Powered by Google App Engine
This is Rietveld 408576698