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

Unified Diff: content/common/origin_util.cc

Issue 2622693002: Cleanup of static lists of schemes & origins that are created at startup. (Closed)
Patch Set: merge Created 3 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
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/savable_url_schemes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/origin_util.cc
diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc
index 11873d63cfd9de6f8b7b2c4592d785abef089e42..e8a348c0bedd4f630e3d395793f5c363a288260c 100644
--- a/content/common/origin_util.cc
+++ b/content/common/origin_util.cc
@@ -7,48 +7,12 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/stl_util.h"
-#include "content/public/common/content_client.h"
+#include "content/common/url_schemes.h"
#include "net/base/url_util.h"
#include "url/gurl.h"
namespace content {
-namespace {
-
-class SchemeAndOriginWhitelist {
- public:
- SchemeAndOriginWhitelist() { Reset(); }
- ~SchemeAndOriginWhitelist() {}
-
- void Reset() {
- secure_schemes_.clear();
- secure_origins_.clear();
- service_worker_schemes_.clear();
- GetContentClient()->AddSecureSchemesAndOrigins(&secure_schemes_,
- &secure_origins_);
- GetContentClient()->AddServiceWorkerSchemes(&service_worker_schemes_);
- }
-
- 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> secure_schemes_;
- std::set<GURL> secure_origins_;
- std::set<std::string> service_worker_schemes_;
- DISALLOW_COPY_AND_ASSIGN(SchemeAndOriginWhitelist);
-};
-
-base::LazyInstance<SchemeAndOriginWhitelist>::Leaky g_trustworthy_whitelist =
- LAZY_INSTANCE_INITIALIZER;
-
-} // namespace
-
bool IsOriginSecure(const GURL& url) {
if (url.SchemeIsCryptographic() || url.SchemeIsFile())
return true;
@@ -62,12 +26,10 @@ bool IsOriginSecure(const GURL& url) {
if (net::IsLocalhost(hostname))
return true;
- if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(),
- url.scheme()))
+ if (base::ContainsValue(GetSecureSchemes(), url.scheme()))
return true;
- if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_origins(),
- url.GetOrigin())) {
+ if (base::ContainsValue(GetSecureOrigins(), url.GetOrigin())) {
return true;
}
@@ -78,8 +40,7 @@ bool OriginCanAccessServiceWorkers(const GURL& url) {
if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url))
return true;
- if (base::ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(),
- url.scheme())) {
+ if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) {
return true;
}
@@ -87,7 +48,7 @@ bool OriginCanAccessServiceWorkers(const GURL& url) {
}
void ResetSchemesAndOriginsWhitelistForTesting() {
- g_trustworthy_whitelist.Get().Reset();
+ RefreshSecuritySchemesForTesting();
}
} // namespace content
« no previous file with comments | « content/common/BUILD.gn ('k') | content/common/savable_url_schemes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698