| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <unicode/ucnv.h> | 6 #include <unicode/ucnv.h> |
| 7 #include <unicode/uidna.h> | 7 #include <unicode/uidna.h> |
| 8 #include <unicode/ulocdata.h> | 8 #include <unicode/ulocdata.h> |
| 9 #include <unicode/uniset.h> | 9 #include <unicode/uniset.h> |
| 10 #include <unicode/uscript.h> | 10 #include <unicode/uscript.h> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "net/base/net_module.h" | 42 #include "net/base/net_module.h" |
| 43 #include "net/base/net_resources.h" | 43 #include "net/base/net_resources.h" |
| 44 #include "net/base/base64.h" | 44 #include "net/base/base64.h" |
| 45 #include "unicode/datefmt.h" | 45 #include "unicode/datefmt.h" |
| 46 | 46 |
| 47 using base::Time; | 47 using base::Time; |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 // what we prepend to get a file URL | 51 // what we prepend to get a file URL |
| 52 static const wchar_t kFileURLPrefix[] = L"file:///"; | 52 static const FilePath::CharType kFileURLPrefix[] = |
| 53 FILE_PATH_LITERAL("file:///"); |
| 53 | 54 |
| 54 // The general list of blocked ports. Will be blocked unless a specific | 55 // The general list of blocked ports. Will be blocked unless a specific |
| 55 // protocol overrides it. (Ex: ftp can use ports 20 and 21) | 56 // protocol overrides it. (Ex: ftp can use ports 20 and 21) |
| 56 static const int kRestrictedPorts[] = { | 57 static const int kRestrictedPorts[] = { |
| 57 1, // tcpmux | 58 1, // tcpmux |
| 58 7, // echo | 59 7, // echo |
| 59 9, // discard | 60 9, // discard |
| 60 11, // systat | 61 11, // systat |
| 61 13, // daytime | 62 13, // daytime |
| 62 15, // netstat | 63 15, // netstat |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // with the literal input. | 632 // with the literal input. |
| 632 out->resize(host_begin_in_output + comp_len); | 633 out->resize(host_begin_in_output + comp_len); |
| 633 for (int i = 0; i < comp_len; i++) | 634 for (int i = 0; i < comp_len; i++) |
| 634 (*out)[host_begin_in_output + i] = comp[i]; | 635 (*out)[host_begin_in_output + i] = comp[i]; |
| 635 } | 636 } |
| 636 | 637 |
| 637 } // namespace | 638 } // namespace |
| 638 | 639 |
| 639 namespace net { | 640 namespace net { |
| 640 | 641 |
| 641 GURL FilePathToFileURL(const std::wstring& file_path) { | 642 GURL FilePathToFileURL(const FilePath& path) { |
| 642 // Produce a URL like "file:///C:/foo" for a regular file, or | 643 // Produce a URL like "file:///C:/foo" for a regular file, or |
| 643 // "file://///server/path" for UNC. The URL canonicalizer will fix up the | 644 // "file://///server/path" for UNC. The URL canonicalizer will fix up the |
| 644 // latter case to be the canonical UNC form: "file://server/path" | 645 // latter case to be the canonical UNC form: "file://server/path" |
| 645 std::wstring url_str(kFileURLPrefix); | 646 FilePath::StringType url_string(kFileURLPrefix); |
| 646 url_str.append(file_path); | 647 url_string.append(path.value()); |
| 647 | 648 |
| 648 // Now do replacement of some characters. Since we assume the input is a | 649 // Now do replacement of some characters. Since we assume the input is a |
| 649 // literal filename, anything the URL parser might consider special should | 650 // literal filename, anything the URL parser might consider special should |
| 650 // be escaped here. | 651 // be escaped here. |
| 651 | 652 |
| 652 // must be the first substitution since others will introduce percents as the | 653 // must be the first substitution since others will introduce percents as the |
| 653 // escape character | 654 // escape character |
| 654 ReplaceSubstringsAfterOffset(&url_str, 0, L"%", L"%25"); | 655 ReplaceSubstringsAfterOffset(&url_string, 0, |
| 656 FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25")); |
| 655 | 657 |
| 656 // semicolon is supposed to be some kind of separator according to RFC 2396 | 658 // semicolon is supposed to be some kind of separator according to RFC 2396 |
| 657 ReplaceSubstringsAfterOffset(&url_str, 0, L";", L"%3B"); | 659 ReplaceSubstringsAfterOffset(&url_string, 0, |
| 660 FILE_PATH_LITERAL(";"), FILE_PATH_LITERAL("%3B")); |
| 658 | 661 |
| 659 ReplaceSubstringsAfterOffset(&url_str, 0, L"#", L"%23"); | 662 ReplaceSubstringsAfterOffset(&url_string, 0, |
| 663 FILE_PATH_LITERAL("#"), FILE_PATH_LITERAL("%23")); |
| 660 | 664 |
| 661 #if defined(WCHAR_T_IS_UTF32) | 665 return GURL(url_string); |
| 662 return GURL(WideToUTF8(url_str)); | 666 } |
| 663 #else | 667 |
| 664 return GURL(url_str); | 668 GURL FilePathToFileURL(const std::wstring& path_str) { |
| 665 #endif | 669 return FilePathToFileURL(FilePath::FromWStringHack(path_str)); |
| 666 } | 670 } |
| 667 | 671 |
| 668 std::wstring GetSpecificHeader(const std::wstring& headers, | 672 std::wstring GetSpecificHeader(const std::wstring& headers, |
| 669 const std::wstring& name) { | 673 const std::wstring& name) { |
| 670 return GetSpecificHeaderT(headers, name); | 674 return GetSpecificHeaderT(headers, name); |
| 671 } | 675 } |
| 672 | 676 |
| 673 std::string GetSpecificHeader(const std::string& headers, | 677 std::string GetSpecificHeader(const std::string& headers, |
| 674 const std::string& name) { | 678 const std::string& name) { |
| 675 return GetSpecificHeaderT(headers, name); | 679 return GetSpecificHeaderT(headers, name); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 949 |
| 946 // Deprecated. | 950 // Deprecated. |
| 947 bool FileURLToFilePath(const GURL& gurl, std::wstring* file_path) { | 951 bool FileURLToFilePath(const GURL& gurl, std::wstring* file_path) { |
| 948 FilePath path; | 952 FilePath path; |
| 949 bool rv = FileURLToFilePath(gurl, &path); | 953 bool rv = FileURLToFilePath(gurl, &path); |
| 950 *file_path = path.ToWStringHack(); | 954 *file_path = path.ToWStringHack(); |
| 951 return rv; | 955 return rv; |
| 952 } | 956 } |
| 953 | 957 |
| 954 } // namespace net | 958 } // namespace net |
| OLD | NEW |