| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/network/NetworkUtils.h" | 5 #include "platform/network/NetworkUtils.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" |
| 8 #include "net/base/filename_util.h" |
| 7 #include "net/base/ip_address.h" | 9 #include "net/base/ip_address.h" |
| 8 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 9 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
| 12 #include "public/platform/URLConversion.h" |
| 13 #include "public/platform/WebString.h" |
| 14 #include "url/gurl.h" |
| 10 #include "wtf/text/StringUTF8Adaptor.h" | 15 #include "wtf/text/StringUTF8Adaptor.h" |
| 11 #include "wtf/text/WTFString.h" | 16 #include "wtf/text/WTFString.h" |
| 12 | 17 |
| 13 namespace { | 18 namespace { |
| 14 | 19 |
| 15 net::registry_controlled_domains::PrivateRegistryFilter | 20 net::registry_controlled_domains::PrivateRegistryFilter |
| 16 getNetPrivateRegistryFilter(blink::NetworkUtils::PrivateRegistryFilter filter) { | 21 getNetPrivateRegistryFilter(blink::NetworkUtils::PrivateRegistryFilter filter) { |
| 17 switch (filter) { | 22 switch (filter) { |
| 18 case blink::NetworkUtils::IncludePrivateRegistries: | 23 case blink::NetworkUtils::IncludePrivateRegistries: |
| 19 return net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES; | 24 return net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 return net::IsLocalHostname(utf8.asStringPiece(), isLocal6); | 51 return net::IsLocalHostname(utf8.asStringPiece(), isLocal6); |
| 47 } | 52 } |
| 48 | 53 |
| 49 String getDomainAndRegistry(const String& host, PrivateRegistryFilter filter) { | 54 String getDomainAndRegistry(const String& host, PrivateRegistryFilter filter) { |
| 50 StringUTF8Adaptor hostUtf8(host); | 55 StringUTF8Adaptor hostUtf8(host); |
| 51 std::string domain = net::registry_controlled_domains::GetDomainAndRegistry( | 56 std::string domain = net::registry_controlled_domains::GetDomainAndRegistry( |
| 52 hostUtf8.asStringPiece(), getNetPrivateRegistryFilter(filter)); | 57 hostUtf8.asStringPiece(), getNetPrivateRegistryFilter(filter)); |
| 53 return String(domain.data(), domain.length()); | 58 return String(domain.data(), domain.length()); |
| 54 } | 59 } |
| 55 | 60 |
| 61 String getSuggestedFilename(const KURL& url, const String& contentDisposition) { |
| 62 // TODO(jungshik): Thread in the actual value of the referrer charset and pass |
| 63 // it to GetSuggestedFilename. |
| 64 CString disposition = contentDisposition.utf8(); |
| 65 base::string16 filename = net::GetSuggestedFilename( |
| 66 WebStringToGURL(WebString(url.getString())), |
| 67 std::string(disposition.data(), disposition.length()), |
| 68 std::string(), // referrer_charset |
| 69 std::string(), // suggested_name |
| 70 std::string(), // mime_type |
| 71 std::string()); // default_name |
| 72 return String(filename.data(), filename.length()); |
| 73 } |
| 74 |
| 56 } // NetworkUtils | 75 } // NetworkUtils |
| 57 | 76 |
| 58 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |