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 |