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 "ios/web/public/origin_util.h" | 5 #import "ios/web/public/origin_util.h" |
6 | 6 |
| 7 #import <WebKit/WebKit.h> |
| 8 |
| 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/strings/sys_string_conversions.h" |
7 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
8 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 #include "url/scheme_host_port.h" |
9 | 14 |
10 namespace web { | 15 namespace web { |
11 | 16 |
12 bool IsOriginSecure(const GURL& url) { | 17 bool IsOriginSecure(const GURL& url) { |
13 if (url.SchemeIsCryptographic() || url.SchemeIsFile()) | 18 if (url.SchemeIsCryptographic() || url.SchemeIsFile()) |
14 return true; | 19 return true; |
15 | 20 |
16 if (url.SchemeIsFileSystem() && url.inner_url() && | 21 if (url.SchemeIsFileSystem() && url.inner_url() && |
17 IsOriginSecure(*url.inner_url())) { | 22 IsOriginSecure(*url.inner_url())) { |
18 return true; | 23 return true; |
19 } | 24 } |
20 | 25 |
21 std::string hostname = url.HostNoBrackets(); | 26 std::string hostname = url.HostNoBrackets(); |
22 if (net::IsLocalhost(hostname)) | 27 if (net::IsLocalhost(hostname)) |
23 return true; | 28 return true; |
24 | 29 |
25 return false; | 30 return false; |
26 } | 31 } |
27 | 32 |
| 33 GURL GURLOriginWithWKSecurityOrigin(WKSecurityOrigin* origin) { |
| 34 if (!origin) |
| 35 return GURL(); |
| 36 |
| 37 url::SchemeHostPort origin_tuple(base::SysNSStringToUTF8(origin.protocol), |
| 38 base::SysNSStringToUTF8(origin.host), |
| 39 base::checked_cast<uint16_t>(origin.port)); |
| 40 return GURL(origin_tuple.Serialize()); |
| 41 } |
| 42 |
28 } // namespace web | 43 } // namespace web |
OLD | NEW |