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

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

Issue 270793002: webstorePrivate: Support an |authuser| property in beginInstallWithManifest3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Let authuser pass thru as a string rather than forcing int Created 6 years, 7 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
« no previous file with comments | « chrome/browser/extensions/webstore_installer.h ('k') | chrome/common/extensions/api/webstore_private.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_installer.cc
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 07e6e7221d54b839e0e43cb804ae44a45f89b151..25ef1e838135de5053b85cdab684aa7c380a504f 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -86,6 +86,10 @@ const char kInlineInstallSource[] = "inline";
const char kDefaultInstallSource[] = "ondemand";
const char kAppLauncherInstallSource[] = "applauncher";
+// TODO(rockot): Share this duplicated constant with the extension updater.
+// See http://crbug.com/371398.
+const char kAuthUserQueryKey[] = "authuser";
+
const size_t kTimeRemainingMinutesThreshold = 1u;
// Folder for downloading crx files from the webstore. This is used so that the
@@ -140,6 +144,37 @@ bool UseSeparateWebstoreDownloadDirectory() {
return field_trial_group == kSeparateDirectoryUnderUDD;
}
+void MaybeAppendAuthUserParameter(const std::string& authuser, GURL* url) {
+ if (authuser.empty())
+ return;
+ std::string old_query = url->query();
+ url::Component query(0, old_query.length());
+ url::Component key, value;
+ // Ensure that the URL doesn't already specify an authuser parameter.
+ while (url::ExtractQueryKeyValue(
+ old_query.c_str(), &query, &key, &value)) {
+ std::string key_string = old_query.substr(key.begin, key.len);
+ if (key_string == kAuthUserQueryKey) {
+ return;
+ }
+ }
+ if (!old_query.empty()) {
+ old_query += "&";
+ }
+ std::string authuser_param = base::StringPrintf(
+ "%s=%s",
+ kAuthUserQueryKey,
+ authuser.c_str());
+
+ // TODO(rockot): Share this duplicated code with the extension updater.
+ // See http://crbug.com/371398.
+ std::string new_query_string = old_query + authuser_param;
+ url::Component new_query(0, new_query_string.length());
+ url::Replacements<char> replacements;
+ replacements.SetQuery(new_query_string.c_str(), new_query);
+ *url = url->ReplaceComponents(replacements);
+}
+
} // namespace
namespace extensions {
@@ -528,6 +563,7 @@ void WebstoreInstaller::DownloadCrx(
const std::string& extension_id,
InstallSource source) {
download_url_ = GetWebstoreInstallURL(extension_id, source);
+ MaybeAppendAuthUserParameter(approval_->authuser, &download_url_);
base::FilePath download_path;
if (UseSeparateWebstoreDownloadDirectory()) {
« no previous file with comments | « chrome/browser/extensions/webstore_installer.h ('k') | chrome/common/extensions/api/webstore_private.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698