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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationController.cpp

Issue 2552343009: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed)
Patch Set: rebase with master Created 4 years 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/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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 PresentationConnection* connection = findConnection(client.get()); 119 PresentationConnection* connection = findConnection(client.get());
118 if (!connection) 120 if (!connection)
119 return; 121 return;
120 connection->didReceiveBinaryMessage(data, length); 122 connection->didReceiveBinaryMessage(data, length);
121 } 123 }
122 124
123 void PresentationController::setPresentation(Presentation* presentation) { 125 void PresentationController::setPresentation(Presentation* presentation) {
124 m_presentation = presentation; 126 m_presentation = presentation;
125 } 127 }
126 128
127 void PresentationController::setDefaultRequestUrl(const KURL& url) { 129 void PresentationController::setDefaultRequestUrl(
130 const WTF::Vector<KURL>& urls) {
128 if (!m_client) 131 if (!m_client)
129 return; 132 return;
130 133
131 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. 134 WebVector<WebURL> presentationUrls(urls.size());
132 WebVector<WebURL> presentationUrls(static_cast<size_t>(1)); 135 for (size_t i = 0; i < urls.size(); ++i) {
133 if (url.isValid()) 136 if (urls[i].isValid())
134 presentationUrls[0] = url; 137 presentationUrls[i] = urls[i];
138 }
135 139
136 m_client->setDefaultPresentationUrls(presentationUrls); 140 m_client->setDefaultPresentationUrls(presentationUrls);
137 } 141 }
138 142
139 void PresentationController::registerConnection( 143 void PresentationController::registerConnection(
140 PresentationConnection* connection) { 144 PresentationConnection* connection) {
141 m_connections.add(connection); 145 m_connections.add(connection);
142 } 146 }
143 147
144 void PresentationController::contextDestroyed() { 148 void PresentationController::contextDestroyed() {
145 if (m_client) { 149 if (m_client) {
146 m_client->setController(nullptr); 150 m_client->setController(nullptr);
147 m_client = nullptr; 151 m_client = nullptr;
148 } 152 }
149 } 153 }
150 154
151 PresentationConnection* PresentationController::findConnection( 155 PresentationConnection* PresentationController::findConnection(
152 WebPresentationConnectionClient* connectionClient) { 156 WebPresentationConnectionClient* connectionClient) {
153 for (const auto& connection : m_connections) { 157 for (const auto& connection : m_connections) {
154 if (connection->matches(connectionClient)) 158 if (connection->matches(connectionClient))
155 return connection.get(); 159 return connection.get();
156 } 160 }
157 161
158 return nullptr; 162 return nullptr;
159 } 163 }
160 164
161 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698