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/common/url_schemes.h" | 10 #include "content/common/url_schemes.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 return true; | 23 return true; |
24 } | 24 } |
25 | 25 |
26 std::string hostname = url.HostNoBrackets(); | 26 std::string hostname = url.HostNoBrackets(); |
27 if (net::IsLocalhost(hostname)) | 27 if (net::IsLocalhost(hostname)) |
28 return true; | 28 return true; |
29 | 29 |
30 if (base::ContainsValue(url::GetSecureSchemes(), url.scheme())) | 30 if (base::ContainsValue(url::GetSecureSchemes(), url.scheme())) |
31 return true; | 31 return true; |
32 | 32 |
33 if (base::ContainsValue(GetSecureOrigins(), url.GetOrigin())) { | 33 if (IsOriginWhiteListedTrustworthy(url)) |
34 return true; | 34 return true; |
35 } | |
36 | 35 |
37 return false; | 36 return false; |
38 } | 37 } |
39 | 38 |
40 bool OriginCanAccessServiceWorkers(const GURL& url) { | 39 bool OriginCanAccessServiceWorkers(const GURL& url) { |
41 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) | 40 if (url.SchemeIsHTTPOrHTTPS() && IsOriginSecure(url)) |
42 return true; | 41 return true; |
43 | 42 |
44 if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) { | 43 if (base::ContainsValue(GetServiceWorkerSchemes(), url.scheme())) { |
45 return true; | 44 return true; |
46 } | 45 } |
47 | 46 |
48 return false; | 47 return false; |
49 } | 48 } |
50 | 49 |
| 50 bool IsOriginWhiteListedTrustworthy(const GURL& url) { |
| 51 return base::ContainsValue(GetSecureOrigins(), url.GetOrigin()); |
| 52 } |
| 53 |
51 } // namespace content | 54 } // namespace content |
OLD | NEW |