diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 20:48:59 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 20:48:59 +0000 |
commit | eab9b45f79f18963793e0f4d666a83b311caabd3 (patch) | |
tree | 8ba9b44119deb7652f55838e494664cf395ae94c /chrome/browser/extensions/extension_protocols.cc | |
parent | 3418ebed0b079864abd37cf3d6d622ef4aa3b42c (diff) | |
download | chromium_src-eab9b45f79f18963793e0f4d666a83b311caabd3.zip chromium_src-eab9b45f79f18963793e0f4d666a83b311caabd3.tar.gz chromium_src-eab9b45f79f18963793e0f4d666a83b311caabd3.tar.bz2 |
Try again to commit r8486, which updates the manifest
parsing in the Extension class to also parse out user
script details.
The problem was that extension_protocols.cc appears to
link OK if you don't refer to anything in it, but as
soon as you try to use something defined in it, a bunch
of other symbols it refers to turn up undefined.
To avoid this problem in the future, I stopped compiling
extensions_protocol.cc so that we would realize if we
tried to use it.
Also in this change, I absolutified paths in
ExtensionsService before creating Extension instances.
On Linux, the path that PathService was giving us was
not absolute.
Review URL: http://codereview.chromium.org/18704
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8576 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_protocols.cc')
-rw-r--r-- | chrome/browser/extensions/extension_protocols.cc | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc index 1643c4d6..bc33592 100644 --- a/chrome/browser/extensions/extension_protocols.cc +++ b/chrome/browser/extensions/extension_protocols.cc @@ -5,51 +5,15 @@ #include "chrome/browser/extensions/extension_protocols.h" #include "base/string_util.h" +#include "chrome/browser/extensions/extension.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "googleurl/src/url_util.h" #include "net/base/net_util.h" #include "net/url_request/url_request_file_job.h" -const char kExtensionURLScheme[] = "chrome-extension"; -const char kUserScriptURLScheme[] = "chrome-user-script"; - -FilePath GetPathForExtensionResource(const FilePath& extension_path, - const std::string& url_path) { - DCHECK(extension_path.IsAbsolute()); - DCHECK(url_path.length() > 0 && url_path[0] == '/'); - - // Build up a file:// URL and convert that back to a FilePath. This avoids - // URL encoding and path separator issues. - - // Convert the extension's root to a file:// URL. - GURL extension_url = net::FilePathToFileURL(extension_path); - if (!extension_url.is_valid()) - return FilePath(); - - // Append the requested path. - GURL::Replacements replacements; - std::string new_path(extension_url.path()); - new_path += url_path; - replacements.SetPathStr(new_path); - GURL file_url = extension_url.ReplaceComponents(replacements); - if (!file_url.is_valid()) - return FilePath(); - - // Convert the result back to a FilePath. - FilePath ret_val; - if (!net::FileURLToFilePath(file_url, &ret_val)) - return FilePath(); - - // Double-check that the path we ended up with is actually inside the - // 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; -} +// Defined in extension.h. +extern const char kExtensionURLScheme[]; +extern const char kUserScriptURLScheme[]; // Factory registered with URLRequest to create URLRequestJobs for extension:// // URLs. @@ -64,7 +28,7 @@ static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request, return NULL; std::string resource = request->url().path(); - FilePath path = GetPathForExtensionResource(directory_path, resource); + FilePath path = Extension::GetResourcePath(directory_path, resource); return new URLRequestFileJob(request, path); } @@ -80,7 +44,7 @@ static URLRequestJob* CreateUserScriptURLRequestJob(URLRequest* request, FilePath directory_path = context->user_script_dir_path(); std::string resource = request->url().path(); - FilePath path = GetPathForExtensionResource(directory_path, resource); + FilePath path = Extension::GetResourcePath(directory_path, resource); return new URLRequestFileJob(request, path); } |