| OLD | NEW |
| 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/PresentationController.h" | 5 #include "modules/presentation/PresentationController.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "modules/presentation/PresentationConnection.h" | 9 #include "modules/presentation/PresentationConnection.h" |
| 10 #include "public/platform/WebString.h" |
| 11 #include "public/platform/WebVector.h" |
| 10 #include "public/platform/modules/presentation/WebPresentationClient.h" | 12 #include "public/platform/modules/presentation/WebPresentationClient.h" |
| 11 #include "wtf/PtrUtil.h" | 13 #include "wtf/PtrUtil.h" |
| 12 #include <memory> | 14 #include <memory> |
| 13 | 15 |
| 14 namespace blink { | 16 namespace blink { |
| 15 | 17 |
| 16 PresentationController::PresentationController(LocalFrame& frame, | 18 PresentationController::PresentationController(LocalFrame& frame, |
| 17 WebPresentationClient* client) | 19 WebPresentationClient* client) |
| 18 : ContextLifecycleObserver(frame.document()), m_client(client) { | 20 : ContextLifecycleObserver(frame.document()), m_client(client) { |
| 19 if (m_client) | 21 if (m_client) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 PresentationConnection* connection = findConnection(sessionInfo); | 107 PresentationConnection* connection = findConnection(sessionInfo); |
| 106 if (!connection) | 108 if (!connection) |
| 107 return; | 109 return; |
| 108 connection->didReceiveBinaryMessage(data, length); | 110 connection->didReceiveBinaryMessage(data, length); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void PresentationController::setPresentation(Presentation* presentation) { | 113 void PresentationController::setPresentation(Presentation* presentation) { |
| 112 m_presentation = presentation; | 114 m_presentation = presentation; |
| 113 } | 115 } |
| 114 | 116 |
| 115 void PresentationController::setDefaultRequestUrl(const KURL& url) { | 117 void PresentationController::setDefaultRequestUrl( |
| 118 const WTF::Vector<KURL>& urls) { |
| 116 if (!m_client) | 119 if (!m_client) |
| 117 return; | 120 return; |
| 118 | 121 |
| 119 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. | 122 WebVector<WebURL> presentationUrls(urls.size()); |
| 120 WebVector<WebURL> presentationUrls(static_cast<size_t>(1)); | 123 for (size_t i = 0; i < urls.size(); ++i) { |
| 121 if (url.isValid()) | 124 if (urls[i].isValid()) |
| 122 presentationUrls[0] = url; | 125 presentationUrls[i] = urls[i]; |
| 126 } |
| 123 | 127 |
| 124 m_client->setDefaultPresentationUrls(presentationUrls); | 128 m_client->setDefaultPresentationUrls(presentationUrls); |
| 125 } | 129 } |
| 126 | 130 |
| 127 void PresentationController::registerConnection( | 131 void PresentationController::registerConnection( |
| 128 PresentationConnection* connection) { | 132 PresentationConnection* connection) { |
| 129 m_connections.add(connection); | 133 m_connections.add(connection); |
| 130 } | 134 } |
| 131 | 135 |
| 132 void PresentationController::contextDestroyed() { | 136 void PresentationController::contextDestroyed() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 155 const WebPresentationSessionInfo& sessionInfo) { | 159 const WebPresentationSessionInfo& sessionInfo) { |
| 156 for (const auto& connection : m_connections) { | 160 for (const auto& connection : m_connections) { |
| 157 if (connection->matches(sessionInfo)) | 161 if (connection->matches(sessionInfo)) |
| 158 return connection.get(); | 162 return connection.get(); |
| 159 } | 163 } |
| 160 | 164 |
| 161 return nullptr; | 165 return nullptr; |
| 162 } | 166 } |
| 163 | 167 |
| 164 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |