| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/file_util.h" | 5 #include "extensions/common/file_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 return base::FilePath(); | 429 return base::FilePath(); |
| 430 } | 430 } |
| 431 return temp_path; | 431 return temp_path; |
| 432 } | 432 } |
| 433 | 433 |
| 434 void DeleteFile(const base::FilePath& path, bool recursive) { | 434 void DeleteFile(const base::FilePath& path, bool recursive) { |
| 435 base::DeleteFile(path, recursive); | 435 base::DeleteFile(path, recursive); |
| 436 } | 436 } |
| 437 | 437 |
| 438 base::FilePath ExtensionURLToRelativeFilePath(const GURL& url) { | 438 base::FilePath ExtensionURLToRelativeFilePath(const GURL& url) { |
| 439 std::string url_path = url.path(); | 439 base::StringPiece url_path = url.path(); |
| 440 if (url_path.empty() || url_path[0] != '/') | 440 if (url_path.empty() || url_path[0] != '/') |
| 441 return base::FilePath(); | 441 return base::FilePath(); |
| 442 | 442 |
| 443 // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. | 443 // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. |
| 444 std::string file_path = net::UnescapeURLComponent( | 444 std::string file_path = net::UnescapeURLComponent( |
| 445 url_path, | 445 url_path.as_string(), |
| 446 net::UnescapeRule::SPACES | | 446 net::UnescapeRule::SPACES | |
| 447 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); | 447 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); |
| 448 size_t skip = file_path.find_first_not_of("/\\"); | 448 size_t skip = file_path.find_first_not_of("/\\"); |
| 449 if (skip != file_path.npos) | 449 if (skip != file_path.npos) |
| 450 file_path = file_path.substr(skip); | 450 file_path = file_path.substr(skip); |
| 451 | 451 |
| 452 base::FilePath path = base::FilePath::FromUTF8Unsafe(file_path); | 452 base::FilePath path = base::FilePath::FromUTF8Unsafe(file_path); |
| 453 | 453 |
| 454 // It's still possible for someone to construct an annoying URL whose path | 454 // It's still possible for someone to construct an annoying URL whose path |
| 455 // would still wind up not being considered relative at this point. | 455 // would still wind up not being considered relative at this point. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { | 620 base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { |
| 621 return extension_path.Append(kMetadataFolder) | 621 return extension_path.Append(kMetadataFolder) |
| 622 .Append(kVerifiedContentsFilename); | 622 .Append(kVerifiedContentsFilename); |
| 623 } | 623 } |
| 624 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { | 624 base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { |
| 625 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); | 625 return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); |
| 626 } | 626 } |
| 627 | 627 |
| 628 } // namespace file_util | 628 } // namespace file_util |
| 629 } // namespace extensions | 629 } // namespace extensions |
| OLD | NEW |