Index: chrome/common/extensions/extension_file_util.cc |
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc |
index a7a5cc91f591ed0b113ebeb36da869c74515cef0..5c2c2233c9de88718d456f69303f32041d970ed1 100644 |
--- a/chrome/common/extensions/extension_file_util.cc |
+++ b/chrome/common/extensions/extension_file_util.cc |
@@ -625,6 +625,26 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { |
return path; |
} |
+FilePath ExtensionResourceURLToFilePath(const GURL& url, const FilePath& root) { |
+ std::string host = net::UnescapeURLComponent(url.host(), |
+ net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); |
+ if (host.empty()) |
+ return FilePath(); |
+ |
+ FilePath relative_path = ExtensionURLToRelativeFilePath(url); |
+ if (relative_path.empty()) |
+ return FilePath(); |
+ |
+ FilePath path = root.AppendASCII(host).Append(relative_path); |
+ base::ThreadRestrictions::ScopedAllowIO allow_io; |
Aaron Boodman
2012/04/18 17:52:24
This shouldn't be needed. If you are hitting a DCH
Peng
2012/04/18 18:29:16
I are hitting a DCHECK here. PathExists() and Abso
Aaron Boodman
2012/04/18 18:51:01
I see. I remember the background on why this is ne
|
+ if (!file_util::PathExists(path) || |
+ !file_util::AbsolutePath(&path) || |
+ !root.IsParent(path)) { |
+ return FilePath(); |
+ } |
+ return path; |
+} |
+ |
FilePath GetUserDataTempDir() { |
// We do file IO in this function, but only when the current profile's |
// Temp directory has never been used before, or in a rare error case. |