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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (url.length() <= 8) | 189 if (url.length() <= 8) |
190 return false; | 190 return false; |
191 if (std::string("file:///") != url.substr(0, 8)) | 191 if (std::string("file:///") != url.substr(0, 8)) |
192 return false; // no file:/// prefix | 192 return false; // no file:/// prefix |
193 if (url.find('\\') != std::string::npos) | 193 if (url.find('\\') != std::string::npos) |
194 return false; // contains backslashes | 194 return false; // contains backslashes |
195 | 195 |
196 FilePath derived_path; | 196 FilePath derived_path; |
197 net::FileURLToFilePath(GURL(url), &derived_path); | 197 net::FileURLToFilePath(GURL(url), &derived_path); |
198 | 198 |
199 return FilePath::CompareEqualIgnoreCase(derived_path.value(), | 199 FilePath::StringType derived_path_str = derived_path.value(); |
200 full_file_path.value()); | 200 return (derived_path_str.length() == full_file_path.value().length()) && |
| 201 std::equal(derived_path_str.begin(), |
| 202 derived_path_str.end(), |
| 203 full_file_path.value().begin(), |
| 204 CaseInsensitiveCompare<FilePath::CharType>()); |
201 } | 205 } |
202 | 206 |
203 struct fixup_case { | 207 struct fixup_case { |
204 const std::string input; | 208 const std::string input; |
205 const std::string desired_tld; | 209 const std::string desired_tld; |
206 const std::string output; | 210 const std::string output; |
207 } fixup_cases[] = { | 211 } fixup_cases[] = { |
208 {"www.google.com", "", "http://www.google.com/"}, | 212 {"www.google.com", "", "http://www.google.com/"}, |
209 {" www.google.com ", "", "http://www.google.com/"}, | 213 {" www.google.com ", "", "http://www.google.com/"}, |
210 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"}, | 214 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"}, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // (should resolve to the same file as above) | 459 // (should resolve to the same file as above) |
456 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + | 460 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") + |
457 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); | 461 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value(); |
458 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); | 462 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str)); |
459 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); | 463 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path)); |
460 | 464 |
461 // done with the subdir | 465 // done with the subdir |
462 EXPECT_TRUE(file_util::Delete(full_path, false)); | 466 EXPECT_TRUE(file_util::Delete(full_path, false)); |
463 EXPECT_TRUE(file_util::Delete(new_dir, true)); | 467 EXPECT_TRUE(file_util::Delete(new_dir, true)); |
464 } | 468 } |
OLD | NEW |