summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_updater.cc
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 21:24:48 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 21:24:48 +0000
commitab417244b7fe6b281eaba42c10a045efd8474bb1 (patch)
treecb665d2c6b5526e9b0b6b76553c8a3ec8a814b40 /chrome/browser/extensions/extension_updater.cc
parent884e3fc7901067c3d320a000fdcb145e65258897 (diff)
downloadchromium_src-ab417244b7fe6b281eaba42c10a045efd8474bb1.zip
chromium_src-ab417244b7fe6b281eaba42c10a045efd8474bb1.tar.gz
chromium_src-ab417244b7fe6b281eaba42c10a045efd8474bb1.tar.bz2
Make extension updates use omaha id when talking to omaha.
BUG=b/2168147 TEST=Extensions auto-updates should still work. Review URL: http://codereview.chromium.org/403026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_updater.cc')
-rw-r--r--chrome/browser/extensions/extension_updater.cc45
1 files changed, 44 insertions, 1 deletions
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc
index a219b0d..a618de9 100644
--- a/chrome/browser/extensions/extension_updater.cc
+++ b/chrome/browser/extensions/extension_updater.cc
@@ -31,6 +31,10 @@
#include "net/base/load_flags.h"
#include "net/url_request/url_request_status.h"
+#if defined(OS_WIN)
+#include "base/registry.h"
+#endif
+
using base::RandDouble;
using base::RandInt;
using base::Time;
@@ -48,6 +52,8 @@ const char* ExtensionUpdater::kBlacklistUpdateUrl =
// Update AppID for extension blacklist.
const char* ExtensionUpdater::kBlacklistAppID = "com.google.crx.blacklist";
+const char* ExtensionUpdater::kUidKey = "uid";
+
// Wait at least 5 minutes after browser startup before we do any checks. If you
// change this value, make sure to update comments where it is used.
const int kStartupWaitSeconds = 60 * 5;
@@ -102,13 +108,41 @@ class ExtensionUpdaterFileHandler
~ExtensionUpdaterFileHandler() {}
};
+class DefaultUidProvider : public ExtensionUpdater::UidProvider {
+ public:
+ DefaultUidProvider() {}
+ virtual ~DefaultUidProvider() {}
+
+ virtual std::string GetUidString() {
+ std::string result;
+#if defined(OS_WIN)
+ // First try looking in HKCU, then try HKLM.
+ HKEY rootKeys[] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
+ for (int i = 0; i < sizeof(rootKeys); i++) {
+ RegKey key(rootKeys[i], L"Software\\Google\\Update");
+ std::wstring value;
+ if (key.ReadValue(L"ui", &value)) {
+ if (IsStringASCII(value) &&
+ value.length() <= UidProvider::maxUidLength) {
+ result = WideToASCII(value);
+ break;
+ } else {
+ NOTREACHED();
+ }
+ }
+ }
+#endif
+ return result;
+ }
+};
+
ExtensionUpdater::ExtensionUpdater(ExtensionUpdateService* service,
PrefService* prefs,
int frequency_seconds)
: service_(service), frequency_seconds_(frequency_seconds),
prefs_(prefs), file_handler_(new ExtensionUpdaterFileHandler()),
- blacklist_checks_enabled_(true) {
+ blacklist_checks_enabled_(true), uid_provider_(new DefaultUidProvider()) {
Init();
}
@@ -527,6 +561,15 @@ void ExtensionUpdater::CheckNow() {
full_url_string.append(update_url.has_query() ? "&" : "?");
AppendExtensionInfo(&full_url_string, *extension);
+ // Send the Omaha uid when doing update checks to Omaha.
+ if (update_url.DomainIs("google.com")) {
+ std::string uid = uid_provider_->GetUidString();
+ if (uid.length() > 0 && uid.length() <= UidProvider::maxUidLength) {
+ full_url_string.append("&" + std::string(ExtensionUpdater::kUidKey) +
+ "=" + EscapeQueryParamValue(uid));
+ }
+ }
+
GURL full_url(full_url_string);
if (!full_url.is_valid()) {
LOG(ERROR) << "invalid url: " << full_url.possibly_invalid_spec();