| 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 c5226b152dd05baaba5ee5986703f0d1dbfdcc0f..512991a555bc442dd394cf554021140e8813a929 100644
|
| --- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
|
| +++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
|
| @@ -46,15 +46,6 @@ Settings* settings(ExecutionContext* executionContext) {
|
| return document->settings();
|
| }
|
|
|
| -ScriptPromise rejectWithMixedContentException(ScriptState* scriptState,
|
| - const String& url) {
|
| - return ScriptPromise::rejectWithDOMException(
|
| - scriptState,
|
| - DOMException::create(SecurityError,
|
| - "Presentation of an insecure document [" + url +
|
| - "] is prohibited from a secure context."));
|
| -}
|
| -
|
| ScriptPromise rejectWithSandBoxException(ScriptState* scriptState) {
|
| return ScriptPromise::rejectWithDOMException(
|
| scriptState, DOMException::create(SecurityError,
|
| @@ -69,15 +60,37 @@ PresentationRequest* PresentationRequest::create(
|
| ExecutionContext* executionContext,
|
| const String& url,
|
| ExceptionState& exceptionState) {
|
| - KURL parsedUrl = KURL(executionContext->url(), url);
|
| - if (!parsedUrl.isValid() || parsedUrl.protocolIsAbout()) {
|
| - exceptionState.throwTypeError("'" + url +
|
| - "' can't be resolved to a valid URL.");
|
| - return nullptr;
|
| - }
|
| + WTF::Vector<String> urls(1);
|
| + urls[0] = url;
|
| + return create(executionContext, urls, exceptionState);
|
| +}
|
|
|
| +PresentationRequest* PresentationRequest::create(
|
| + ExecutionContext* executionContext,
|
| + const WTF::Vector<String>& urls,
|
| + ExceptionState& exceptionState) {
|
| + WTF::Vector<KURL> parsedUrls(urls.size());
|
| + for (size_t i = 0; i < urls.size(); ++i) {
|
| + const KURL& parsedUrl = KURL(executionContext->url(), urls[i]);
|
| +
|
| + if (!parsedUrl.isValid() || parsedUrl.protocolIsAbout()) {
|
| + exceptionState.throwDOMException(
|
| + SyntaxError, "'" + urls[i] + "' can't be resolved to a valid URL.");
|
| + return nullptr;
|
| + }
|
| +
|
| + if (MixedContentChecker::isMixedContent(
|
| + executionContext->getSecurityOrigin(), parsedUrl)) {
|
| + exceptionState.throwDOMException(
|
| + SecurityError, "Presentation of an insecure document [" + urls[i] +
|
| + "] is prohibited from a secure context.");
|
| + return nullptr;
|
| + }
|
| +
|
| + parsedUrls[i] = parsedUrl;
|
| + }
|
| PresentationRequest* request =
|
| - new PresentationRequest(executionContext, parsedUrl);
|
| + new PresentationRequest(executionContext, parsedUrls);
|
| request->suspendIfNeeded();
|
| return request;
|
| }
|
| @@ -121,11 +134,6 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState) {
|
| InvalidAccessError,
|
| "PresentationRequest::start() requires user gesture."));
|
|
|
| - if (MixedContentChecker::isMixedContent(
|
| - getExecutionContext()->getSecurityOrigin(), m_url)) {
|
| - return rejectWithMixedContentException(scriptState, m_url.getString());
|
| - }
|
| -
|
| if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
|
| return rejectWithSandBoxException(scriptState);
|
|
|
| @@ -138,22 +146,13 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState) {
|
| "The PresentationRequest is no longer associated to a frame."));
|
|
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| - // TODO(crbug.com/627655): Accept multiple URLs per PresentationRequest.
|
| - WebVector<WebURL> presentationUrls(static_cast<size_t>(1U));
|
| - presentationUrls[0] = m_url;
|
| client->startSession(
|
| - presentationUrls,
|
| - WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
|
| + m_urls, WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
|
| return resolver->promise();
|
| }
|
|
|
| ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
|
| const String& id) {
|
| - if (MixedContentChecker::isMixedContent(
|
| - getExecutionContext()->getSecurityOrigin(), m_url)) {
|
| - return rejectWithMixedContentException(scriptState, m_url.getString());
|
| - }
|
| -
|
| if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
|
| return rejectWithSandBoxException(scriptState);
|
|
|
| @@ -166,21 +165,13 @@ ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState,
|
| "The PresentationRequest is no longer associated to a frame."));
|
|
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(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,
|
| + m_urls, id,
|
| WTF::makeUnique<PresentationConnectionCallbacks>(resolver, this));
|
| return resolver->promise();
|
| }
|
|
|
| ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) {
|
| - if (MixedContentChecker::isMixedContent(
|
| - getExecutionContext()->getSecurityOrigin(), m_url)) {
|
| - return rejectWithMixedContentException(scriptState, m_url.getString());
|
| - }
|
| -
|
| if (toDocument(getExecutionContext())->isSandboxed(SandboxPresentation))
|
| return rejectWithSandBoxException(scriptState);
|
|
|
| @@ -194,13 +185,13 @@ ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState) {
|
|
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| client->getAvailability(
|
| - m_url,
|
| - WTF::makeUnique<PresentationAvailabilityCallbacks>(resolver, m_url));
|
| + m_urls,
|
| + WTF::makeUnique<PresentationAvailabilityCallbacks>(resolver, m_urls));
|
| return resolver->promise();
|
| }
|
|
|
| -const KURL& PresentationRequest::url() const {
|
| - return m_url;
|
| +const WTF::Vector<KURL>& PresentationRequest::urls() const {
|
| + return m_urls;
|
| }
|
|
|
| DEFINE_TRACE(PresentationRequest) {
|
| @@ -209,9 +200,9 @@ DEFINE_TRACE(PresentationRequest) {
|
| }
|
|
|
| PresentationRequest::PresentationRequest(ExecutionContext* executionContext,
|
| - const KURL& url)
|
| + const WTF::Vector<KURL>& urls)
|
| : ActiveScriptWrappable(this),
|
| ActiveDOMObject(executionContext),
|
| - m_url(url) {}
|
| + m_urls(urls) {}
|
|
|
| } // namespace blink
|
|
|