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

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

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Make changes requested by danakj, fix a few more headers 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/PresentationRequest.h" 5 #include "modules/presentation/PresentationRequest.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return ScriptPromise::rejectWithDOMException( 135 return ScriptPromise::rejectWithDOMException(
136 scriptState, 136 scriptState,
137 DOMException::create( 137 DOMException::create(
138 InvalidStateError, 138 InvalidStateError,
139 "The PresentationRequest is no longer associated to a frame.")); 139 "The PresentationRequest is no longer associated to a frame."));
140 140
141 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 141 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
142 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. 142 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest.
143 WebVector<WebURL> presentationUrls(static_cast<size_t>(1U)); 143 WebVector<WebURL> presentationUrls(static_cast<size_t>(1U));
144 presentationUrls[0] = m_url; 144 presentationUrls[0] = m_url;
145 client->startSession(presentationUrls, 145 client->startSession(
146 new PresentationConnectionCallbacks(resolver, this)); 146 presentationUrls,
147 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
147 return resolver->promise(); 148 return resolver->promise();
148 } 149 }
149 150
150 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, 151 ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
151 const String& id) { 152 const String& id) {
152 if (MixedContentChecker::isMixedContent( 153 if (MixedContentChecker::isMixedContent(
153 getExecutionContext()->getSecurityOrigin(), m_url)) { 154 getExecutionContext()->getSecurityOrigin(), m_url)) {
154 return rejectWithMixedContentException(scriptState, m_url.getString()); 155 return rejectWithMixedContentException(scriptState, m_url.getString());
155 } 156 }
156 157
157 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) 158 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
158 return rejectWithSandBoxException(scriptState); 159 return rejectWithSandBoxException(scriptState);
159 160
160 WebPresentationClient* client = presentationClient(getExecutionContext()); 161 WebPresentationClient* client = presentationClient(getExecutionContext());
161 if (!client) 162 if (!client)
162 return ScriptPromise::rejectWithDOMException( 163 return ScriptPromise::rejectWithDOMException(
163 scriptState, 164 scriptState,
164 DOMException::create( 165 DOMException::create(
165 InvalidStateError, 166 InvalidStateError,
166 "The PresentationRequest is no longer associated to a frame.")); 167 "The PresentationRequest is no longer associated to a frame."));
167 168
168 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 169 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
169 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest. 170 // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest.
170 WebVector<WebURL> presentationUrls(static_cast<size_t>(1U)); 171 WebVector<WebURL> presentationUrls(static_cast<size_t>(1U));
171 presentationUrls[0] = m_url; 172 presentationUrls[0] = m_url;
172 client->joinSession(presentationUrls, id, 173 client->joinSession(
173 new PresentationConnectionCallbacks(resolver, this)); 174 presentationUrls, id,
175 WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
174 return resolver->promise(); 176 return resolver->promise();
175 } 177 }
176 178
177 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) { 179 ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) {
178 if (MixedContentChecker::isMixedContent( 180 if (MixedContentChecker::isMixedContent(
179 getExecutionContext()->getSecurityOrigin(), m_url)) { 181 getExecutionContext()->getSecurityOrigin(), m_url)) {
180 return rejectWithMixedContentException(scriptState, m_url.getString()); 182 return rejectWithMixedContentException(scriptState, m_url.getString());
181 } 183 }
182 184
183 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation)) 185 if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
184 return rejectWithSandBoxException(scriptState); 186 return rejectWithSandBoxException(scriptState);
185 187
186 WebPresentationClient* client = presentationClient(getExecutionContext()); 188 WebPresentationClient* client = presentationClient(getExecutionContext());
187 if (!client) 189 if (!client)
188 return ScriptPromise::rejectWithDOMException( 190 return ScriptPromise::rejectWithDOMException(
189 scriptState, 191 scriptState,
190 DOMException::create( 192 DOMException::create(
191 InvalidStateError, 193 InvalidStateError,
192 "The PresentationRequest is no longer associated to a frame.")); 194 "The PresentationRequest is no longer associated to a frame."));
193 195
194 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 196 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
195 client->getAvailability( 197 client->getAvailability(
196 m_url, new PresentationAvailabilityCallbacks(resolver, m_url)); 198 m_url,
199 WTF::makeUnique<PresentationAvailabilityCallbacks>(resolver, m_url));
197 return resolver->promise(); 200 return resolver->promise();
198 } 201 }
199 202
200 const KURL& PresentationRequest::url() const { 203 const KURL& PresentationRequest::url() const {
201 return m_url; 204 return m_url;
202 } 205 }
203 206
204 DEFINE_TRACE(PresentationRequest) { 207 DEFINE_TRACE(PresentationRequest) {
205 EventTargetWithInlineData::trace(visitor); 208 EventTargetWithInlineData::trace(visitor);
206 ActiveDOMObject::trace(visitor); 209 ActiveDOMObject::trace(visitor);
207 } 210 }
208 211
209 PresentationRequest::PresentationRequest(ExecutionContext* executionContext, 212 PresentationRequest::PresentationRequest(ExecutionContext* executionContext,
210 const KURL& url) 213 const KURL& url)
211 : ActiveScriptWrappable(this), 214 : ActiveScriptWrappable(this),
212 ActiveDOMObject(executionContext), 215 ActiveDOMObject(executionContext),
213 m_url(url) {} 216 m_url(url) {}
214 217
215 } // namespace blink 218 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698