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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/presentation/PresentationReceiver.h" 5 #include "modules/presentation/PresentationReceiver.h"
6 6
7 #include "bindings/core/v8/ScriptPromise.h" 7 #include "bindings/core/v8/ScriptPromise.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/frame/DOMWindow.h"
12 #include "core/frame/LocalFrame.h" 13 #include "core/frame/LocalFrame.h"
13 #include "modules/presentation/PresentationConnection.h" 14 #include "modules/presentation/PresentationConnection.h"
14 #include "modules/presentation/PresentationConnectionList.h" 15 #include "modules/presentation/PresentationConnectionList.h"
15 #include "public/platform/modules/presentation/WebPresentationClient.h" 16 #include "public/platform/modules/presentation/WebPresentationClient.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 PresentationReceiver::PresentationReceiver(LocalFrame* frame, 20 PresentationReceiver::PresentationReceiver(LocalFrame* frame,
20 WebPresentationClient* client) 21 WebPresentationClient* client)
21 : DOMWindowProperty(frame) { 22 : DOMWindowProperty(frame) {
(...skipping 30 matching lines...) Expand all
52 return; 53 return;
53 54
54 if (m_connectionListProperty->getState() == 55 if (m_connectionListProperty->getState() ==
55 ScriptPromisePropertyBase::Pending) 56 ScriptPromisePropertyBase::Pending)
56 m_connectionListProperty->resolve(m_connectionList); 57 m_connectionListProperty->resolve(m_connectionList);
57 else if (m_connectionListProperty->getState() == 58 else if (m_connectionListProperty->getState() ==
58 ScriptPromisePropertyBase::Resolved) 59 ScriptPromisePropertyBase::Resolved)
59 m_connectionList->dispatchConnectionAvailableEvent(connection); 60 m_connectionList->dispatchConnectionAvailableEvent(connection);
60 } 61 }
61 62
63 void PresentationReceiver::didChangeSessionState(
64 WebPresentationConnectionState state) {
65 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.
66
67 for (auto connection : m_connectionList->connections())
68 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
69 }
70
71 void PresentationReceiver::closeWindow() {
72 if (!frame())
73 return;
74
75 DOMWindow* window = frame()->domWindow();
76 if (!window || window->closed())
77 return;
78
79 Document* document = frame()->document();
80 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.
81 return;
82
83 window->close(document);
84 }
85
62 void PresentationReceiver::registerConnection( 86 void PresentationReceiver::registerConnection(
63 PresentationConnection* connection) { 87 PresentationConnection* connection) {
64 DCHECK(m_connectionList); 88 DCHECK(m_connectionList);
65 m_connectionList->addConnection(connection); 89 m_connectionList->addConnection(connection);
66 } 90 }
67 91
68 DEFINE_TRACE(PresentationReceiver) { 92 DEFINE_TRACE(PresentationReceiver) {
69 visitor->trace(m_connectionList); 93 visitor->trace(m_connectionList);
70 visitor->trace(m_connectionListProperty); 94 visitor->trace(m_connectionListProperty);
71 DOMWindowProperty::trace(visitor); 95 DOMWindowProperty::trace(visitor);
72 } 96 }
73 } // namespace blink 97 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698