Chromium Code Reviews| Index: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp |
| diff --git a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp |
| index d26008add8582a518c4962370abd62d3271ca54a..3c6f32d94701908ad733deada454d4d11d5f29c2 100644 |
| --- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp |
| +++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp |
| @@ -28,14 +28,18 @@ namespace blink { |
| namespace { |
| // TODO(mlamouri): refactor in one common place. |
| -WebPresentationClient* presentationClient(ExecutionContext* executionContext) { |
| +PresentationController* presentationController( |
| + ExecutionContext* executionContext) { |
| DCHECK(executionContext); |
| Document* document = toDocument(executionContext); |
| if (!document->frame()) |
| return nullptr; |
| - PresentationController* controller = |
| - PresentationController::from(*document->frame()); |
| + return PresentationController::from(*document->frame()); |
| +} |
| + |
| +WebPresentationClient* presentationClient(ExecutionContext* executionContext) { |
| + PresentationController* controller = presentationController(executionContext); |
| return controller ? controller->client() : nullptr; |
| } |
| @@ -166,9 +170,23 @@ ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, |
| // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. |
| WebVector<WebURL> presentationUrls(static_cast<size_t>(1U)); |
| presentationUrls[0] = m_url; |
| - client->joinSession( |
| - presentationUrls, id, |
| - WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); |
| + |
| + PresentationController* controller = |
| + presentationController(getExecutionContext()); |
|
haraken
2016/12/23 14:26:10
Not related to this CL, getExecutionContext() retu
zhaobin
2016/12/30 05:05:00
Done.
|
| + DCHECK(controller); |
| + |
| + PresentationConnection* existingConnection = |
| + controller->findExistingConnection(presentationUrls, id); |
| + if (existingConnection) { |
| + client->joinSession( |
| + presentationUrls, id, |
| + WTF::makeUnique<ExistingPresentationConnectionCallbacks>( |
| + resolver, existingConnection)); |
| + } else { |
| + client->joinSession( |
| + presentationUrls, id, |
| + WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this)); |
| + } |
| return resolver->promise(); |
| } |