Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/common/extensions/extension_file_util.cc

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698