OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 return true; | 545 return true; |
546 } | 546 } |
547 | 547 |
548 FilePath ExtensionURLToRelativeFilePath(const GURL& url) { | 548 FilePath ExtensionURLToRelativeFilePath(const GURL& url) { |
549 std::string url_path = url.path(); | 549 std::string url_path = url.path(); |
550 if (url_path.empty() || url_path[0] != '/') | 550 if (url_path.empty() || url_path[0] != '/') |
551 return FilePath(); | 551 return FilePath(); |
552 | 552 |
553 // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. | 553 // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. |
554 std::string file_path = net::UnescapeURLComponent(url_path, | 554 std::string file_path = net::UnescapeURLComponent(url_path, |
555 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); | 555 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); |
556 size_t skip = file_path.find_first_not_of("/\\"); | 556 size_t skip = file_path.find_first_not_of("/\\"); |
557 if (skip != file_path.npos) | 557 if (skip != file_path.npos) |
558 file_path = file_path.substr(skip); | 558 file_path = file_path.substr(skip); |
559 | 559 |
560 FilePath path = | 560 FilePath path = |
561 #if defined(OS_POSIX) | 561 #if defined(OS_POSIX) |
562 FilePath(file_path); | 562 FilePath(file_path); |
563 #elif defined(OS_WIN) | 563 #elif defined(OS_WIN) |
564 FilePath(UTF8ToWide(file_path)); | 564 FilePath(UTF8ToWide(file_path)); |
565 #else | 565 #else |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 return temp_path; | 640 return temp_path; |
641 | 641 |
642 return FilePath(); | 642 return FilePath(); |
643 } | 643 } |
644 | 644 |
645 void DeleteFile(const FilePath& path, bool recursive) { | 645 void DeleteFile(const FilePath& path, bool recursive) { |
646 file_util::Delete(path, recursive); | 646 file_util::Delete(path, recursive); |
647 } | 647 } |
648 | 648 |
649 } // namespace extension_file_util | 649 } // namespace extension_file_util |
OLD | NEW |