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

Unified Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1191793003: [Service Worker Registration] removed protocolIsInHTTPFamily and replaced with SchemeRegistry check (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added comments for scheme checks Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/platform/weborigin/SchemeRegistry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/ServiceWorkerContainer.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
index 7218343c7d6762070601ac46fb0ede71750f2fc7..8e808a0bd156b5aa449cfb1279a1b20a934a1b23 100644
--- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
+++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp
@@ -48,6 +48,7 @@
#include "modules/serviceworkers/ServiceWorkerError.h"
#include "modules/serviceworkers/ServiceWorkerRegistration.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/weborigin/SchemeRegistry.h"
#include "public/platform/WebServiceWorker.h"
#include "public/platform/WebServiceWorkerProvider.h"
#include "public/platform/WebServiceWorkerRegistration.h"
@@ -219,7 +220,10 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
}
KURL pageURL = KURL(KURL(), documentOrigin->toString());
- if (!pageURL.protocolIsInHTTPFamily()) {
+ // There is a check that a context is privileged before checking the scheme.
Devlin 2015/06/29 19:54:43 nit: It's better to comment exactly where the rele
+ // URL scheme occurs after to filter out things like blobs and files.
+ // HTTP is required because http://localhost is considered secure.
+ if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.protocol())) {
resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the current origin ('" + documentOrigin->toString() + "') is not supported."));
return promise;
}
@@ -231,7 +235,7 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The origin of the provided scriptURL ('" + scriptOrigin->toString() + "') does not match the current origin ('" + documentOrigin->toString() + "')."));
return promise;
}
- if (!scriptURL.protocolIsInHTTPFamily()) {
+ if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(scriptURL.protocol())) {
resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the script ('" + scriptURL.string() + "') is not supported."));
return promise;
}
@@ -248,7 +252,7 @@ ScriptPromise ServiceWorkerContainer::registerServiceWorker(ScriptState* scriptS
resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The origin of the provided scope ('" + patternOrigin->toString() + "') does not match the current origin ('" + documentOrigin->toString() + "')."));
return promise;
}
- if (!patternURL.protocolIsInHTTPFamily()) {
+ if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(patternURL.protocol())) {
resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the scope ('" + patternURL.string() + "') is not supported."));
return promise;
}
@@ -281,7 +285,7 @@ ScriptPromise ServiceWorkerContainer::getRegistration(ScriptState* scriptState,
}
KURL pageURL = KURL(KURL(), documentOrigin->toString());
- if (!pageURL.protocolIsInHTTPFamily()) {
+ if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.protocol())) {
resolver->reject(DOMException::create(SecurityError, "Failed to get a ServiceWorkerRegistration: The URL protocol of the current origin ('" + documentOrigin->toString() + "') is not supported."));
return promise;
}
@@ -317,7 +321,7 @@ ScriptPromise ServiceWorkerContainer::getRegistrations(ScriptState* scriptState)
}
KURL pageURL = KURL(KURL(), documentOrigin->toString());
- if (!pageURL.protocolIsInHTTPFamily()) {
+ if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.protocol())) {
resolver->reject(DOMException::create(SecurityError, "Failed to get ServiceWorkerRegistration objects: The URL protocol of the current origin ('" + documentOrigin->toString() + "') is not supported."));
return promise;
}
« no previous file with comments | « no previous file | Source/platform/weborigin/SchemeRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698