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

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

Issue 335042: Revert 30149 - The existing file_util::AbsolutePath() function was already do... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_resource.h" 5 #include "chrome/common/extensions/extension_resource.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/extensions/extension_l10n_util.h" 10 #include "chrome/browser/extensions/extension_l10n_util.h"
(...skipping 22 matching lines...) Expand all
33 full_resource_path_ = GetFilePath(extension_root_, relative_path_); 33 full_resource_path_ = GetFilePath(extension_root_, relative_path_);
34 return full_resource_path_; 34 return full_resource_path_;
35 } 35 }
36 36
37 // Static version... 37 // Static version...
38 FilePath ExtensionResource::GetFilePath(const FilePath& extension_root, 38 FilePath ExtensionResource::GetFilePath(const FilePath& extension_root,
39 const FilePath& relative_path) { 39 const FilePath& relative_path) {
40 std::vector<FilePath> l10n_relative_paths; 40 std::vector<FilePath> l10n_relative_paths;
41 extension_l10n_util::GetL10nRelativePaths(relative_path, 41 extension_l10n_util::GetL10nRelativePaths(relative_path,
42 &l10n_relative_paths); 42 &l10n_relative_paths);
43 // We need to resolve the parent references in the extension_root
44 // path on its own because IsParent doesn't like parent references.
45 FilePath clean_extension_root(extension_root);
46 if (!file_util::AbsolutePath(&clean_extension_root))
47 return FilePath();
48 43
49 // Stat l10n file(s), and return new path if it exists. 44 // Stat l10n file(s), and return new path if it exists.
50 for (size_t i = 0; i < l10n_relative_paths.size(); ++i) { 45 for (size_t i = 0; i < l10n_relative_paths.size(); ++i) {
51 FilePath full_path = clean_extension_root.Append(l10n_relative_paths[i]); 46 FilePath full_path;
52 if (file_util::AbsolutePath(&full_path) && 47 if (extension_root.AppendAndResolveRelative(l10n_relative_paths[i],
53 clean_extension_root.IsParent(full_path) && 48 &full_path) &&
49 extension_root.IsParent(full_path) &&
54 file_util::PathExists(full_path)) { 50 file_util::PathExists(full_path)) {
55 return full_path; 51 return full_path;
56 } 52 }
57 } 53 }
58 54
59 // Fall back to root resource. 55 // Fall back to root resource.
60 FilePath full_path = clean_extension_root.Append(relative_path); 56 FilePath full_path;
61 if (file_util::AbsolutePath(&full_path) && 57 if (extension_root.AppendAndResolveRelative(relative_path, &full_path) &&
62 clean_extension_root.IsParent(full_path)) { 58 extension_root.IsParent(full_path)) {
63 return full_path; 59 return full_path;
64 } 60 }
65 61
66 return FilePath(); 62 return FilePath();
67 } 63 }
68 64
69 // Unittesting helpers. 65 // Unittesting helpers.
70 FilePath::StringType ExtensionResource::NormalizeSeperators( 66 FilePath::StringType ExtensionResource::NormalizeSeperators(
71 FilePath::StringType path) const { 67 FilePath::StringType path) const {
72 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 68 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
(...skipping 10 matching lines...) Expand all
83 // Make sure we have a cached value to test against... 79 // Make sure we have a cached value to test against...
84 if (full_resource_path_.empty()) 80 if (full_resource_path_.empty())
85 GetFilePath(); 81 GetFilePath();
86 if (NormalizeSeperators(path.value()) == 82 if (NormalizeSeperators(path.value()) ==
87 NormalizeSeperators(full_resource_path_.value())) { 83 NormalizeSeperators(full_resource_path_.value())) {
88 return true; 84 return true;
89 } else { 85 } else {
90 return false; 86 return false;
91 } 87 }
92 } 88 }
OLDNEW
« no previous file with comments | « base/file_path_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698