summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 05:17:15 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 05:17:15 +0000
commit154769362a046967efd14bb0a0da5d6f3a301e32 (patch)
tree33e4550cd4f8895b639fabc55b45f5bb6e8d67bc /extensions
parente7a810943e48e9649db8063058fb77ddefaf9f96 (diff)
downloadchromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.zip
chromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.tar.gz
chromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.tar.bz2
Move path functions from file_util to FilePath object.
EnsureEndsWithSeparator used to check whether the file existed. This seems bad and unnecessary so I removed it. I removed file_util::ContainsPath and used the existing file_util::IsParent instead. The functions descriptions are the same but the implementations do slightly different things, which is worrying. The only non-test use of this function to worry about is content/browser/storage_partition_impl_map.cc. As far as I see, the requirements for this seem OK, but I'm not very familiar with this. After some discussion with akalin, I changed sync/internal_api/sync_manager_impl.cc to be a DCHECK that the path is absolute rather than make it absolute. The old code relied on the behavior of the old function that the argument would be unchanged if the file didn't exist, and this (possibly relative) path would be used later. This behavior doesn't make a lot of sense, and it looks like now that the path is always absolute, so I replaced this call with a DCHECK. BUG= Review URL: https://codereview.chromium.org/13196006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/extension_resource.cc20
-rw-r--r--extensions/common/extension_resource_unittest.cc4
2 files changed, 13 insertions, 11 deletions
diff --git a/extensions/common/extension_resource.cc b/extensions/common/extension_resource.cc
index 5a70539..cdd7fce 100644
--- a/extensions/common/extension_resource.cc
+++ b/extensions/common/extension_resource.cc
@@ -52,8 +52,9 @@ base::FilePath ExtensionResource::GetFilePath(
SymlinkPolicy symlink_policy) {
// We need to resolve the parent references in the extension_root
// path on its own because IsParent doesn't like parent references.
- base::FilePath clean_extension_root(extension_root);
- if (!file_util::AbsolutePath(&clean_extension_root))
+ base::FilePath clean_extension_root(
+ base::MakeAbsoluteFilePath(extension_root));
+ if (clean_extension_root.empty())
return base::FilePath();
base::FilePath full_path = clean_extension_root.Append(relative_path);
@@ -80,13 +81,14 @@ base::FilePath ExtensionResource::GetFilePath(
// We must resolve the absolute path of the combined path when
// the relative path contains references to a parent folder (i.e., '..').
- // We also check if the path exists because the posix version of AbsolutePath
- // will fail if the path doesn't exist, and we want the same behavior on
- // Windows... So until the posix and Windows version of AbsolutePath are
- // unified, we need an extra call to PathExists, unfortunately.
- // TODO(mad): Fix this once AbsolutePath is unified.
- if (file_util::AbsolutePath(&full_path) &&
- file_util::PathExists(full_path) &&
+ // We also check if the path exists because the posix version of
+ // MakeAbsoluteFilePath will fail if the path doesn't exist, and we want the
+ // same behavior on Windows... So until the posix and Windows version of
+ // MakeAbsoluteFilePath are unified, we need an extra call to PathExists,
+ // unfortunately.
+ // TODO(mad): Fix this once MakeAbsoluteFilePath is unified.
+ full_path = base::MakeAbsoluteFilePath(full_path);
+ if (file_util::PathExists(full_path) &&
(symlink_policy == FOLLOW_SYMLINKS_ANYWHERE ||
clean_extension_root.IsParent(full_path))) {
return full_path;
diff --git a/extensions/common/extension_resource_unittest.cc b/extensions/common/extension_resource_unittest.cc
index 3791b14..8ec44bb 100644
--- a/extensions/common/extension_resource_unittest.cc
+++ b/extensions/common/extension_resource_unittest.cc
@@ -151,8 +151,8 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) {
base::FilePath expected_path;
// Expect default path only, since fallback logic is disabled.
// See http://crbug.com/27359.
- expected_path = root_resource;
- ASSERT_TRUE(file_util::AbsolutePath(&expected_path));
+ expected_path = base::MakeAbsoluteFilePath(root_resource);
+ ASSERT_FALSE(expected_path.empty());
EXPECT_EQ(ToLower(expected_path.value()), ToLower(resolved_path.value()));
EXPECT_EQ(ToLower(temp.path().value()),