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

Unified Diff: content/common/origin_util.cc

Issue 1192013003: [Extension ServiceWorkers] Allow service worker registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Took out extra reload Created 5 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: content/common/origin_util.cc
diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc
index 1b16422ed11f209dbc38c3bd7bdb8e898812256d..808213d577be5898d4cce17a4c6c2c5bde7c921b 100644
--- a/content/common/origin_util.cc
+++ b/content/common/origin_util.cc
@@ -14,25 +14,33 @@ namespace content {
namespace {
-class SecureSchemeAndOriginSet {
+class CustomSchemeAndOriginSet {
public:
- SecureSchemeAndOriginSet() { Reset(); }
- ~SecureSchemeAndOriginSet() {}
+ CustomSchemeAndOriginSet() { Reset(); }
+ ~CustomSchemeAndOriginSet() {}
void Reset() {
- GetContentClient()->AddSecureSchemesAndOrigins(&schemes_, &origins_);
+ GetContentClient()->AddSecureSchemesAndOrigins(&secure_schemes_,
+ &secure_origins_);
+ GetContentClient()->AddServiceWorkerSchemes(&service_worker_schemes_);
}
- const std::set<std::string>& schemes() const { return schemes_; }
- const std::set<GURL>& origins() const { return origins_; }
+ const std::set<std::string>& secure_schemes() const {
+ return secure_schemes_;
+ }
+ const std::set<GURL>& secure_origins() const { return secure_origins_; }
+ const std::set<std::string>& service_worker_schemes() const {
+ return service_worker_schemes_;
+ }
private:
- std::set<std::string> schemes_;
- std::set<GURL> origins_;
- DISALLOW_COPY_AND_ASSIGN(SecureSchemeAndOriginSet);
+ std::set<std::string> secure_schemes_;
+ std::set<GURL> secure_origins_;
+ std::set<std::string> service_worker_schemes_;
+ DISALLOW_COPY_AND_ASSIGN(CustomSchemeAndOriginSet);
};
-base::LazyInstance<SecureSchemeAndOriginSet>::Leaky g_trustworthy_whitelist =
+base::LazyInstance<CustomSchemeAndOriginSet>::Leaky g_trustworthy_whitelist =
LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -50,16 +58,28 @@ bool IsOriginSecure(const GURL& url) {
if (net::IsLocalhost(hostname))
return true;
- if (ContainsKey(g_trustworthy_whitelist.Get().schemes(), url.scheme()))
+ if (ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), url.scheme()))
+ return true;
+
+ if (ContainsKey(g_trustworthy_whitelist.Get().secure_origins(),
+ url.GetOrigin()))
+ return true;
+
+ return false;
+}
+
+bool OriginCanAccessServiceWorkers(const GURL& url) {
+ if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url))
return true;
- if (ContainsKey(g_trustworthy_whitelist.Get().origins(), url.GetOrigin()))
+ if (ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(),
+ url.scheme()))
return true;
return false;
}
-void ResetSecureSchemesAndOriginsForTesting() {
+void ResetCustomSchemesAndOriginsForTesting() {
g_trustworthy_whitelist.Get().Reset();
}

Powered by Google App Engine
This is Rietveld 408576698