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

Unified Diff: third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp

Issue 2148643002: [Presentation API] Adds DOMString[] constructor to PresentationRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LayoutTests Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
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 7f79b25b0201050a6d7c4407e1e76bcf8d40ebed..608b09638fe3eeebddaa99ab355ad7c4dd8f6541 100644
--- a/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
+++ b/third_party/WebKit/Source/modules/presentation/PresentationRequest.cpp
@@ -20,6 +20,7 @@
#include "modules/presentation/PresentationController.h"
#include "modules/presentation/PresentationError.h"
#include "platform/UserGestureIndicator.h"
+#include "wtf/text/WTFString.h"
namespace blink {
@@ -50,13 +51,23 @@ Settings* settings(ExecutionContext* executionContext)
// static
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* request = new PresentationRequest(executionContext, parsedUrl);
+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.throwTypeError("'" + urls[i] + "' can't be resolved to a valid URL.");
+ return nullptr;
+ }
+ parsedUrls[i] = parsedUrl;
+ }
+ PresentationRequest* request = new PresentationRequest(executionContext, parsedUrls);
request->suspendIfNeeded();
return request;
}
@@ -111,7 +122,7 @@ ScriptPromise PresentationRequest::start(ScriptState* scriptState)
resolver->reject(DOMException::create(InvalidStateError, "The PresentationRequest is no longer associated to a frame."));
return promise;
}
- client->startSession(m_url.getString(), new PresentationConnectionCallbacks(resolver, this));
+ client->startSession(m_urls, new PresentationConnectionCallbacks(resolver, this));
return promise;
}
@@ -130,7 +141,7 @@ ScriptPromise PresentationRequest::reconnect(ScriptState* scriptState, const Str
resolver->reject(DOMException::create(InvalidStateError, "The PresentationRequest is no longer associated to a frame."));
return promise;
}
- client->joinSession(m_url.getString(), id, new PresentationConnectionCallbacks(resolver, this));
+ client->joinSession(m_urls, id, new PresentationConnectionCallbacks(resolver, this));
return promise;
}
@@ -149,13 +160,14 @@ ScriptPromise PresentationRequest::getAvailability(ScriptState* scriptState)
resolver->reject(DOMException::create(InvalidStateError, "The object is no longer associated to a frame."));
return promise;
}
- client->getAvailability(m_url.getString(), new PresentationAvailabilityCallbacks(resolver, m_url));
+
+ client->getAvailability(m_urls, new PresentationAvailabilityCallbacks(resolver, m_urls));
return promise;
}
-const KURL& PresentationRequest::url() const
+const WTF::Vector<KURL>& PresentationRequest::urls() const
{
- return m_url;
+ return m_urls;
}
DEFINE_TRACE(PresentationRequest)
@@ -164,10 +176,10 @@ DEFINE_TRACE(PresentationRequest)
ActiveDOMObject::trace(visitor);
}
-PresentationRequest::PresentationRequest(ExecutionContext* executionContext, const KURL& url)
+PresentationRequest::PresentationRequest(ExecutionContext* executionContext, const WTF::Vector<KURL>& urls)
: ActiveScriptWrappable(this)
, ActiveDOMObject(executionContext)
- , m_url(url)
+ , m_urls(urls)
{
}

Powered by Google App Engine
This is Rietveld 408576698