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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp

Issue 1656933003: Add origins argument to registerForeignFetchScopes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/serviceworkers/InstallEvent.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
index 1cd134969c6b8998180c25147ea56a350991b341..61c9bcd70e64107b2c34397a929f9ea223df171a 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/InstallEvent.cpp
@@ -4,6 +4,7 @@
#include "modules/serviceworkers/InstallEvent.h"
+#include "bindings/modules/v8/UnionTypesModules.h"
#include "core/dom/ExceptionCode.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
@@ -28,13 +29,36 @@ InstallEvent::~InstallEvent()
{
}
-void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, ExceptionState& exceptionState)
+void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext, const Vector<String>& subScopes, const USVStringOrUSVStringSequence& origins, ExceptionState& exceptionState)
{
if (!isBeingDispatched()) {
exceptionState.throwDOMException(InvalidStateError, "The event handler is already finished.");
return;
}
+ Vector<String> originList;
+ if (origins.isUSVString()) {
+ originList.append(origins.getAsUSVString());
+ } else if (origins.isUSVStringSequence()) {
+ originList = origins.getAsUSVStringSequence();
+ }
+ if (originList.isEmpty()) {
+ exceptionState.throwTypeError("At least one origin is required");
+ return;
+ }
falken 2016/02/03 02:17:32 I'm not sure but would ['*'] and '*' arguments hav
Marijn Kruisselbrink 2016/02/03 17:53:31 Hmm, yeah. I think I would prefer to treat those t
+
+ Vector<KURL> originURLs;
+ if (originList.size() != 1 || originList[0] != "*") {
falken 2016/02/03 02:17:32 The '*' special case and how it translates to the
Marijn Kruisselbrink 2016/02/03 17:53:31 I added a comment to try to explain this.
+ originURLs.resize(originList.size());
+ for (size_t i = 0; i < originList.size(); ++i) {
+ originURLs[i] = KURL(KURL(), originList[i]);
+ if (!originURLs[i].isValid()) {
+ exceptionState.throwTypeError("Invalid Origin URL: " + originList[i]);
falken 2016/02/03 02:17:32 nit: should be consistent about origin vs Origin i
Marijn Kruisselbrink 2016/02/03 17:53:31 Done
+ return;
+ }
+ }
+ }
+
ServiceWorkerGlobalScopeClient* client = ServiceWorkerGlobalScopeClient::from(executionContext);
String scopePath = static_cast<KURL>(client->scope()).path();
@@ -58,7 +82,7 @@ void InstallEvent::registerForeignFetchScopes(ExecutionContext* executionContext
return;
}
}
- client->registerForeignFetchScopes(subScopeURLs);
+ client->registerForeignFetchScopes(subScopeURLs, originURLs);
}
const AtomicString& InstallEvent::interfaceName() const

Powered by Google App Engine
This is Rietveld 408576698