OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 std::string host = net::UnescapeURLComponent(url.host(), | 485 std::string host = net::UnescapeURLComponent(url.host(), |
486 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); | 486 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); |
487 if (host.empty()) | 487 if (host.empty()) |
488 return base::FilePath(); | 488 return base::FilePath(); |
489 | 489 |
490 base::FilePath relative_path = ExtensionURLToRelativeFilePath(url); | 490 base::FilePath relative_path = ExtensionURLToRelativeFilePath(url); |
491 if (relative_path.empty()) | 491 if (relative_path.empty()) |
492 return base::FilePath(); | 492 return base::FilePath(); |
493 | 493 |
494 base::FilePath path = root.AppendASCII(host).Append(relative_path); | 494 base::FilePath path = root.AppendASCII(host).Append(relative_path); |
495 if (!file_util::PathExists(path) || | 495 if (!file_util::PathExists(path)) |
496 !file_util::AbsolutePath(&path) || | |
497 !root.IsParent(path)) { | |
498 return base::FilePath(); | 496 return base::FilePath(); |
499 } | 497 path = base::MakeAbsoluteFilePath(path); |
| 498 if (path.empty() || !root.IsParent(path)) |
| 499 return base::FilePath(); |
500 return path; | 500 return path; |
501 } | 501 } |
502 | 502 |
503 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir) { | 503 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir) { |
504 // We do file IO in this function, but only when the current profile's | 504 // We do file IO in this function, but only when the current profile's |
505 // Temp directory has never been used before, or in a rare error case. | 505 // Temp directory has never been used before, or in a rare error case. |
506 // Developers are not likely to see these situations often, so do an | 506 // Developers are not likely to see these situations often, so do an |
507 // explicit thread check. | 507 // explicit thread check. |
508 base::ThreadRestrictions::AssertIOAllowed(); | 508 base::ThreadRestrictions::AssertIOAllowed(); |
509 | 509 |
(...skipping 20 matching lines...) Expand all Loading... |
530 return base::FilePath(); | 530 return base::FilePath(); |
531 } | 531 } |
532 return temp_path; | 532 return temp_path; |
533 } | 533 } |
534 | 534 |
535 void DeleteFile(const base::FilePath& path, bool recursive) { | 535 void DeleteFile(const base::FilePath& path, bool recursive) { |
536 file_util::Delete(path, recursive); | 536 file_util::Delete(path, recursive); |
537 } | 537 } |
538 | 538 |
539 } // namespace extension_file_util | 539 } // namespace extension_file_util |
OLD | NEW |