diff options
author | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 21:39:23 +0000 |
---|---|---|
committer | asargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 21:39:23 +0000 |
commit | a31df3d3488f90bd60055fe7d42b3d51fb7ac72a (patch) | |
tree | ca9a449ced2a795d9f807aee9bd2a3421cf1f613 /chrome/browser/extensions/extension_updater.cc | |
parent | 0f0fffbc359d4e5693ee5139794518e589d0fdd0 (diff) | |
download | chromium_src-a31df3d3488f90bd60055fe7d42b3d51fb7ac72a.zip chromium_src-a31df3d3488f90bd60055fe7d42b3d51fb7ac72a.tar.gz chromium_src-a31df3d3488f90bd60055fe7d42b3d51fb7ac72a.tar.bz2 |
Fix 2 bugs in extensions autoupdate request parameters.
-Separator that should be between id and version parameters was at the end of version
-Missing the "uc" parameter which the gallery server code was expecting as indication
of an update check
BUG=http://crbug.com/17469
TEST=extensions auto-update should work
Review URL: http://codereview.chromium.org/159224
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_updater.cc')
-rw-r--r-- | chrome/browser/extensions/extension_updater.cc | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index a6a5ca5..bb14931 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -19,6 +19,7 @@ #include "chrome/common/extensions/extension_error_reporter.h" #include "chrome/common/libxml_utils.h" #include "googleurl/src/gurl.h" +#include "net/base/escape.h" #include "net/url_request/url_request_status.h" #include "libxml/tree.h" @@ -225,8 +226,40 @@ void ExtensionUpdater::OnExtensionInstallFinished(const FilePath& path, file_handler_.get(), &ExtensionUpdaterFileHandler::DeleteFile, path)); } -static const char* kURLEncodedEquals = "%3D"; // '=' -static const char* kURLEncodedAnd = "%26"; // '&' + +// Helper function for building up request parameters in update check urls. It +// appends information about one extension to a request parameter string. The +// format for request parameters in update checks is: +// +// ?x=EXT1_INFO&x=EXT2_INFO +// +// where EXT1_INFO and EXT2_INFO are url-encoded strings of the form: +// +// id=EXTENSION_ID&v=VERSION&uc +// +// So for two extensions like: +// Extension 1- id:aaaa version:1.1 +// Extension 2- id:bbbb version:2.0 +// +// the full update url would be: +// http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc +// +// (Note that '=' is %3D and '&' is %26 when urlencoded.) +// +// Again, this function would just append one extension's worth of data, e.g. +// "x=id%3Daaaa%26v%3D1.1%26uc" +void AppendExtensionInfo(std::string* str, const Extension& extension) { + const Version* version = extension.version(); + DCHECK(version); + std::vector<std::string> parts; + + // Push extension id, version, and uc (indicates an update check to Omaha). + parts.push_back("id=" + extension.id()); + parts.push_back("v=" + version->GetString()); + parts.push_back("uc"); + + str->append("x=" + EscapeQueryParamValue(JoinString(parts, '&'))); +} void ExtensionUpdater::TimerFired() { // Generate a set of update urls for loaded extensions. @@ -246,18 +279,7 @@ void ExtensionUpdater::TimerFired() { // Append extension information to the url. std::string full_url_string = update_url.spec(); full_url_string.append(update_url.has_query() ? "&" : "?"); - full_url_string.append("x="); - - full_url_string.append("id"); - full_url_string.append(kURLEncodedEquals); - full_url_string.append(extension->id()); - - const Version* version = extension->version(); - DCHECK(version); - full_url_string.append("v"); - full_url_string.append(kURLEncodedEquals); - full_url_string.append(version->GetString()); - full_url_string.append(kURLEncodedAnd); + AppendExtensionInfo(&full_url_string, *extension); GURL full_url(full_url_string); if (!full_url.is_valid()) { |