| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/common/origin_util.h" | 5 #include "content/public/common/origin_util.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 std::string hostname = url.HostNoBrackets(); | 61 std::string hostname = url.HostNoBrackets(); |
| 62 if (net::IsLocalhost(hostname)) | 62 if (net::IsLocalhost(hostname)) |
| 63 return true; | 63 return true; |
| 64 | 64 |
| 65 if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), | 65 if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), |
| 66 url.scheme())) | 66 url.scheme())) |
| 67 return true; | 67 return true; |
| 68 | 68 |
| 69 if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), | 69 if (IsOriginWhiteListedTrustworthy(url)) |
| 70 url.GetOrigin())) { | |
| 71 return true; | 70 return true; |
| 72 } | |
| 73 | 71 |
| 74 return false; | 72 return false; |
| 75 } | 73 } |
| 76 | 74 |
| 77 bool OriginCanAccessServiceWorkers(const GURL& url) { | 75 bool OriginCanAccessServiceWorkers(const GURL& url) { |
| 78 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) | 76 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) |
| 79 return true; | 77 return true; |
| 80 | 78 |
| 81 if (base::ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), | 79 if (base::ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), |
| 82 url.scheme())) { | 80 url.scheme())) { |
| 83 return true; | 81 return true; |
| 84 } | 82 } |
| 85 | 83 |
| 86 return false; | 84 return false; |
| 87 } | 85 } |
| 88 | 86 |
| 87 bool IsOriginWhiteListedTrustworthy(const GURL& url) { |
| 88 return base::ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), |
| 89 url.GetOrigin()); |
| 90 } |
| 91 |
| 89 void ResetSchemesAndOriginsWhitelistForTesting() { | 92 void ResetSchemesAndOriginsWhitelistForTesting() { |
| 90 g_trustworthy_whitelist.Get().Reset(); | 93 g_trustworthy_whitelist.Get().Reset(); |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace content | 96 } // namespace content |
| OLD | NEW |