| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 std::string hostname = url.HostNoBrackets(); | 58 std::string hostname = url.HostNoBrackets(); |
| 59 if (net::IsLocalhost(hostname)) | 59 if (net::IsLocalhost(hostname)) |
| 60 return true; | 60 return true; |
| 61 | 61 |
| 62 if (ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), url.scheme())) | 62 if (ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), url.scheme())) |
| 63 return true; | 63 return true; |
| 64 | 64 |
| 65 if (ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), | 65 if (IsOriginWhiteListedTrustworthy(url)) |
| 66 url.GetOrigin())) { | |
| 67 return true; | 66 return true; |
| 68 } | |
| 69 | 67 |
| 70 return false; | 68 return false; |
| 71 } | 69 } |
| 72 | 70 |
| 73 bool OriginCanAccessServiceWorkers(const GURL& url) { | 71 bool OriginCanAccessServiceWorkers(const GURL& url) { |
| 74 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) | 72 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) |
| 75 return true; | 73 return true; |
| 76 | 74 |
| 77 if (ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), | 75 if (ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), |
| 78 url.scheme())) { | 76 url.scheme())) { |
| 79 return true; | 77 return true; |
| 80 } | 78 } |
| 81 | 79 |
| 82 return false; | 80 return false; |
| 83 } | 81 } |
| 84 | 82 |
| 83 bool IsOriginWhiteListedTrustworthy(const GURL& url) { |
| 84 return ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), |
| 85 url.GetOrigin()); |
| 86 } |
| 87 |
| 85 void ResetSchemesAndOriginsWhitelistForTesting() { | 88 void ResetSchemesAndOriginsWhitelistForTesting() { |
| 86 g_trustworthy_whitelist.Get().Reset(); | 89 g_trustworthy_whitelist.Get().Reset(); |
| 87 } | 90 } |
| 88 | 91 |
| 89 } // namespace content | 92 } // namespace content |
| OLD | NEW |