OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/net_util.h" | 5 #include "net/base/net_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 // don't attempt to divine a file name out of them. | 795 // don't attempt to divine a file name out of them. |
796 if (!url.is_valid() || url.SchemeIs("about") || url.SchemeIs("data")) | 796 if (!url.is_valid() || url.SchemeIs("about") || url.SchemeIs("data")) |
797 return std::string(); | 797 return std::string(); |
798 | 798 |
799 const std::string unescaped_url_filename = UnescapeURLComponent( | 799 const std::string unescaped_url_filename = UnescapeURLComponent( |
800 url.ExtractFileName(), | 800 url.ExtractFileName(), |
801 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); | 801 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); |
802 | 802 |
803 // The URL's path should be escaped UTF-8, but may not be. | 803 // The URL's path should be escaped UTF-8, but may not be. |
804 std::string decoded_filename = unescaped_url_filename; | 804 std::string decoded_filename = unescaped_url_filename; |
805 if (!IsStringUTF8(decoded_filename)) { | 805 if (!base::IsStringUTF8(decoded_filename)) { |
806 // TODO(jshin): this is probably not robust enough. To be sure, we need | 806 // TODO(jshin): this is probably not robust enough. To be sure, we need |
807 // encoding detection. | 807 // encoding detection. |
808 base::string16 utf16_output; | 808 base::string16 utf16_output; |
809 if (!referrer_charset.empty() && | 809 if (!referrer_charset.empty() && |
810 base::CodepageToUTF16(unescaped_url_filename, | 810 base::CodepageToUTF16(unescaped_url_filename, |
811 referrer_charset.c_str(), | 811 referrer_charset.c_str(), |
812 base::OnStringConversionError::FAIL, | 812 base::OnStringConversionError::FAIL, |
813 &utf16_output)) { | 813 &utf16_output)) { |
814 decoded_filename = base::UTF16ToUTF8(utf16_output); | 814 decoded_filename = base::UTF16ToUTF8(utf16_output); |
815 } else { | 815 } else { |
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 } | 2224 } |
2225 return a1.size() * CHAR_BIT; | 2225 return a1.size() * CHAR_BIT; |
2226 } | 2226 } |
2227 | 2227 |
2228 unsigned MaskPrefixLength(const IPAddressNumber& mask) { | 2228 unsigned MaskPrefixLength(const IPAddressNumber& mask) { |
2229 IPAddressNumber all_ones(mask.size(), 0xFF); | 2229 IPAddressNumber all_ones(mask.size(), 0xFF); |
2230 return CommonPrefixLength(mask, all_ones); | 2230 return CommonPrefixLength(mask, all_ones); |
2231 } | 2231 } |
2232 | 2232 |
2233 } // namespace net | 2233 } // namespace net |
OLD | NEW |