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

Unified Diff: base/path_service.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 side-by-side diff with in-line comments
Download patch
Index: base/path_service.cc
diff --git a/base/path_service.cc b/base/path_service.cc
index 1fd2f6f900402dedc98d07533cf891f0e574fd40..32c6909fe4064b4b930e92eae6f1d2f08747acbd 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -18,6 +18,7 @@
#include "base/synchronization/lock.h"
using base::FilePath;
+using base::MakeAbsoluteFilePath;
namespace base {
bool PathProvider(int key, FilePath* result);
@@ -217,9 +218,9 @@ bool PathService::Get(int key, FilePath* result) {
if (path.ReferencesParent()) {
// Make sure path service never returns a path with ".." in it.
- if (!file_util::AbsolutePath(&path)) {
+ path = MakeAbsoluteFilePath(path);
+ if (path.empty())
return false;
- }
}
*result = path;
@@ -250,17 +251,16 @@ bool PathService::OverrideAndCreateIfNeeded(int key,
// fore we protect this call with a flag.
if (create) {
// Make sure the directory exists. We need to do this before we translate
- // this to the absolute path because on POSIX, AbsolutePath fails if called
- // on a non-existent path.
+ // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails
+ // if called on a non-existent path.
if (!file_util::PathExists(file_path) &&
!file_util::CreateDirectory(file_path))
return false;
}
- // We need to have an absolute path, as extensions and plugins don't like
- // relative paths, and will gladly crash the browser in CHECK()s if they get a
- // relative path.
- if (!file_util::AbsolutePath(&file_path))
+ // We need to have an absolute path.
+ file_path = MakeAbsoluteFilePath(file_path);
+ if (file_path.empty())
return false;
base::AutoLock scoped_lock(path_data->lock);

Powered by Google App Engine
This is Rietveld 408576698