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

Unified Diff: chrome/browser/extensions/extension_protocol.cc

Issue 16805: Move Contains() method to file_utils, stop relying on in extensions_protocol (Closed)
Patch Set: Review feedback Created 11 years, 11 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: chrome/browser/extensions/extension_protocol.cc
diff --git a/chrome/browser/extensions/extension_protocol.cc b/chrome/browser/extensions/extension_protocol.cc
index 6eda9ef0f778e2c8f6b25dd422c6dad317e4a318..bb9d0cb839c04baba3a51d933ac359b48547690f 100644
--- a/chrome/browser/extensions/extension_protocol.cc
+++ b/chrome/browser/extensions/extension_protocol.cc
@@ -40,12 +40,12 @@ FilePath GetPathForExtensionResource(const FilePath& extension_path,
if (!net::FileURLToFilePath(file_url, &ret_val))
return FilePath();
- if (!file_util::AbsolutePath(&ret_val))
- return FilePath();
-
// Double-check that the path we ended up with is actually inside the
- // extension root.
- if (!extension_path.Contains(ret_val))
+ // extension root. We can do this with a simple prefix match because:
+ // a) We control the prefix on both sides, and they should match.
+ // b) GURL normalizes things like "../" and "//" before it gets to us.
+ if (ret_val.value().find(extension_path.value() +
+ FilePath::kSeparators[0]) != 0)
return FilePath();
return ret_val;

Powered by Google App Engine
This is Rietveld 408576698