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

Unified Diff: content/renderer/presentation/presentation_dispatcher.cc

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: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index 34a1cfe1286da2772e792a59fc4924c14c7c162d..f88a82ee856dc6a27b9a2d1fd29d7f89145ed552 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -259,8 +259,16 @@ void PresentationDispatcher::closeSession(
void PresentationDispatcher::terminateSession(
const blink::WebURL& presentationUrl,
const blink::WebString& presentationId) {
- ConnectToPresentationServiceIfNeeded();
- presentation_service_->Terminate(presentationUrl, presentationId.utf8());
+ if (receiver_) {
+ receiver_->closeWindow();
imcheng 2016/11/28 22:12:01 If the receiver frame calls terminate, how do we e
zhaobin 2017/02/16 00:42:30 closeWindow() closes offscreen tab and MRP will si
+ return;
+ }
+
+ if (controller_) {
+ ConnectToPresentationServiceIfNeeded();
+ presentation_service_->Terminate(presentationUrl, presentationId.utf8());
+ return;
+ }
}
void PresentationDispatcher::getAvailability(
@@ -449,13 +457,22 @@ void PresentationDispatcher::OnReceiverConnectionAvailable(
void PresentationDispatcher::OnConnectionStateChanged(
blink::mojom::PresentationSessionInfoPtr connection,
blink::mojom::PresentationConnectionState state) {
- if (!controller_)
+ if (!controller_ && !receiver_)
return;
- DCHECK(!connection.is_null());
- controller_->didChangeSessionState(
- new PresentationConnectionClient(std::move(connection)),
- GetWebPresentationConnectionStateFromMojo(state));
+ if (receiver_) {
+ receiver_->didChangeSessionState(
+ GetWebPresentationConnectionStateFromMojo(state));
+ return;
+ }
+
+ if (controller_) {
+ DCHECK(!connection.is_null());
+ controller_->didChangeSessionState(
+ new PresentationConnectionClient(std::move(connection)),
+ GetWebPresentationConnectionStateFromMojo(state));
+ return;
+ }
}
void PresentationDispatcher::OnConnectionClosed(

Powered by Google App Engine
This is Rietveld 408576698