| 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 | 55 |
| 56 if (url.SchemeIsFileSystem() && url.inner_url() && | 56 if (url.SchemeIsFileSystem() && url.inner_url() && |
| 57 IsOriginSecure(*url.inner_url())) { | 57 IsOriginSecure(*url.inner_url())) { |
| 58 return true; | 58 return true; |
| 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 (ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), url.scheme())) | 65 if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_schemes(), |
| 66 url.scheme())) |
| 66 return true; | 67 return true; |
| 67 | 68 |
| 68 if (ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), | 69 if (base::ContainsKey(g_trustworthy_whitelist.Get().secure_origins(), |
| 69 url.GetOrigin())) { | 70 url.GetOrigin())) { |
| 70 return true; | 71 return true; |
| 71 } | 72 } |
| 72 | 73 |
| 73 return false; | 74 return false; |
| 74 } | 75 } |
| 75 | 76 |
| 76 bool OriginCanAccessServiceWorkers(const GURL& url) { | 77 bool OriginCanAccessServiceWorkers(const GURL& url) { |
| 77 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) | 78 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) |
| 78 return true; | 79 return true; |
| 79 | 80 |
| 80 if (ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), | 81 if (base::ContainsKey(g_trustworthy_whitelist.Get().service_worker_schemes(), |
| 81 url.scheme())) { | 82 url.scheme())) { |
| 82 return true; | 83 return true; |
| 83 } | 84 } |
| 84 | 85 |
| 85 return false; | 86 return false; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void ResetSchemesAndOriginsWhitelistForTesting() { | 89 void ResetSchemesAndOriginsWhitelistForTesting() { |
| 89 g_trustworthy_whitelist.Get().Reset(); | 90 g_trustworthy_whitelist.Get().Reset(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 } // namespace content | 93 } // namespace content |
| OLD | NEW |