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

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

Issue 2552343009: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed)
Patch Set: 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/frame/LocalFrame.h" 7 #include "core/frame/LocalFrame.h"
8 #include "modules/presentation/PresentationConnection.h" 8 #include "modules/presentation/PresentationConnection.h"
9 #include "public/platform/WebString.h"
10 #include "public/platform/WebVector.h"
9 #include "public/platform/modules/presentation/WebPresentationClient.h" 11 #include "public/platform/modules/presentation/WebPresentationClient.h"
10 #include "wtf/PtrUtil.h" 12 #include "wtf/PtrUtil.h"
11 #include <memory> 13 #include <memory>
12 14
13 namespace blink { 15 namespace blink {
14 16
15 PresentationController::PresentationController(LocalFrame& frame, 17 PresentationController::PresentationController(LocalFrame& frame,
16 WebPresentationClient* client) 18 WebPresentationClient* client)
17 : DOMWindowProperty(&frame), m_client(client) { 19 : DOMWindowProperty(&frame), m_client(client) {
18 if (m_client) 20 if (m_client)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 PresentationConnection* connection = findConnection(client.get()); 118 PresentationConnection* connection = findConnection(client.get());
117 if (!connection) 119 if (!connection)
118 return; 120 return;
119 connection->didReceiveBinaryMessage(data, length); 121 connection->didReceiveBinaryMessage(data, length);
120 } 122 }
121 123
122 void PresentationController::setPresentation(Presentation* presentation) { 124 void PresentationController::setPresentation(Presentation* presentation) {
123 m_presentation = presentation; 125 m_presentation = presentation;
124 } 126 }
125 127
126 void PresentationController::setDefaultRequestUrl(const KURL& url) { 128 void PresentationController::setDefaultRequestUrl(
129 const WTF::Vector<KURL>& urls) {
127 if (!m_client) 130 if (!m_client)
128 return; 131 return;
129 132
130 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. 133 WebVector<WebURL> presentationUrls(urls.size());
131 WebVector<WebURL> presentationUrls(static_cast<size_t>(1)); 134 for (size_t i = 0; i < urls.size(); ++i) {
132 if (url.isValid()) 135 if (urls[i].isValid())
mark a. foltz 2016/12/09 05:38:03 We should be throwing a SyntaxException in the cto
zhaobin 2016/12/09 23:01:59 We have checked urls in PresentationRequest ctor,
133 presentationUrls[0] = url; 136 presentationUrls[i] = urls[i];
137 }
134 138
135 m_client->setDefaultPresentationUrls(presentationUrls); 139 m_client->setDefaultPresentationUrls(presentationUrls);
136 } 140 }
137 141
138 void PresentationController::registerConnection( 142 void PresentationController::registerConnection(
139 PresentationConnection* connection) { 143 PresentationConnection* connection) {
140 m_connections.add(connection); 144 m_connections.add(connection);
141 } 145 }
142 146
143 void PresentationController::frameDestroyed() { 147 void PresentationController::frameDestroyed() {
144 if (m_client) { 148 if (m_client) {
145 m_client->setController(nullptr); 149 m_client->setController(nullptr);
146 m_client = nullptr; 150 m_client = nullptr;
147 } 151 }
148 DOMWindowProperty::frameDestroyed(); 152 DOMWindowProperty::frameDestroyed();
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