summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/component_updater/component_updater_configurator.cc44
-rw-r--r--chrome/browser/component_updater/component_updater_service.cc24
-rw-r--r--chrome/browser/component_updater/component_updater_service.h2
-rw-r--r--chrome/browser/component_updater/component_updater_service_unittest.cc10
4 files changed, 73 insertions, 7 deletions
diff --git a/chrome/browser/component_updater/component_updater_configurator.cc b/chrome/browser/component_updater/component_updater_configurator.cc
index 4e10322..297bd22 100644
--- a/chrome/browser/component_updater/component_updater_configurator.cc
+++ b/chrome/browser/component_updater/component_updater_configurator.cc
@@ -12,6 +12,7 @@
#include "base/compiler_specific.h"
#include "base/metrics/histogram.h"
#include "base/string_util.h"
+#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
#include "net/url_request/url_request_context_getter.h"
@@ -30,6 +31,43 @@ bool HasDebugValue(const std::vector<std::string>& vec, const char* test) {
return (std::find(vec.begin(), vec.end(), test) != vec.end());
}
+// The request extra information is the OS and architecture, this helps
+// the server select the right package to be delivered.
+const char kExtraInfo[] =
+#if defined(OS_MACOSX)
+ #if defined(__amd64__)
+ "os=mac&arch=x64";
+ #elif defined(__i386__)
+ "os=mac&arch=x86";
+ #else
+ #error "unknown mac architecture"
+ #endif
+#elif defined(OS_WIN)
+ #if defined(_WIN64)
+ "os=win&arch=x64";
+ #elif defined(_WIN32)
+ "os=win&arch=x86";
+ #else
+ #error "unknown windows architecture"
+ #endif
+#elif defined(OS_LINUX)
+ #if defined(__amd64__)
+ "os=linux&arch=x64";
+ #elif defined(__i386__)
+ "os=linux&arch=x86";
+ #else
+ #error "unknown linux architecture"
+ #endif
+#elif defined(OS_CHROMEOS)
+ #if defined(__i386__)
+ "os=cros&arch=x86";
+ #else
+ #error "unknown chromeOs architecture"
+ #endif
+#else
+ #error "unknown os or architecture"
+#endif
+
} // namespace
class ChromeConfigurator : public ComponentUpdateService::Configurator {
@@ -44,6 +82,7 @@ class ChromeConfigurator : public ComponentUpdateService::Configurator {
virtual int StepDelay() OVERRIDE;
virtual int MinimumReCheckWait() OVERRIDE;
virtual GURL UpdateUrl() OVERRIDE;
+ virtual const char* ExtraRequestParams() OVERRIDE;
virtual size_t UrlSizeLimit() OVERRIDE;
virtual net::URLRequestContextGetter* RequestContext() OVERRIDE;
virtual bool InProcess() OVERRIDE;
@@ -53,6 +92,7 @@ class ChromeConfigurator : public ComponentUpdateService::Configurator {
net::URLRequestContextGetter* url_request_getter_;
bool fast_update_;
bool out_of_process_;
+ std::string extra_info_;
};
ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
@@ -86,6 +126,10 @@ GURL ChromeConfigurator::UpdateUrl() {
return GURL("http://clients2.google.com/service/update2/crx");
}
+const char* ChromeConfigurator::ExtraRequestParams() {
+ return kExtraInfo;
+}
+
size_t ChromeConfigurator::UrlSizeLimit() {
return 1024ul;
}
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index 90b4c9d..8dc6418 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -40,11 +40,27 @@ bool AddQueryString(std::string id, std::string version,
additional = "x=" + net::EscapeQueryParamValue(additional, true);
if ((additional.size() + query->size() + 1) > limit)
return false;
- query->append(1, query->empty()? '?' : '&');
+ if (!query->empty())
+ query->append(1, '&');
query->append(additional);
return true;
}
+// Create the final omaha compatible query. The |extra| is optional and can
+// be null. It should contain top level (non-escaped) parameters.
+std::string MakeFinalQuery(const std::string& host,
+ const std::string& query,
+ const char* extra) {
+ std::string request(host);
+ request.append(1, '?');
+ if (extra) {
+ request.append(extra);
+ request.append(1, '&');
+ }
+ request.append(query);
+ return request;
+}
+
// Produces an extension-like friendly |id|. This might be removed in the
// future if we roll our on packing tools.
static std::string HexStringToID(const std::string& hexstr) {
@@ -530,8 +546,10 @@ void CrxUpdateService::ProcessPendingItems() {
}
// We got components to check. Start the url request.
- GURL url(config_->UpdateUrl().spec() + query);
- url_fetcher_.reset(URLFetcher::Create(0, url, URLFetcher::GET,
+ const std::string full_query = MakeFinalQuery(config_->UpdateUrl().spec(),
+ query,
+ config_->ExtraRequestParams());
+ url_fetcher_.reset(URLFetcher::Create(0, GURL(full_query), URLFetcher::GET,
MakeContextDelegate(this, new UpdateContext())));
StartFetch(url_fetcher_.get(), config_->RequestContext(), false);
}
diff --git a/chrome/browser/component_updater/component_updater_service.h b/chrome/browser/component_updater/component_updater_service.h
index 26200a6..a5f2ed3 100644
--- a/chrome/browser/component_updater/component_updater_service.h
+++ b/chrome/browser/component_updater/component_updater_service.h
@@ -101,6 +101,8 @@ class ComponentUpdateService {
virtual int MinimumReCheckWait() = 0;
// The url that is going to be used update checks over Omaha protocol.
virtual GURL UpdateUrl() = 0;
+ // Parameters added to each url request. It can be null if none are needed.
+ virtual const char* ExtraRequestParams() = 0;
// How big each update request can be. Don't go above 2000.
virtual size_t UrlSizeLimit() = 0;
// The source of contexts for all the url requests.
diff --git a/chrome/browser/component_updater/component_updater_service_unittest.cc b/chrome/browser/component_updater/component_updater_service_unittest.cc
index c3222f5..5190a7d 100644
--- a/chrome/browser/component_updater/component_updater_service_unittest.cc
+++ b/chrome/browser/component_updater/component_updater_service_unittest.cc
@@ -56,6 +56,8 @@ class TestConfigurator : public ComponentUpdateService::Configurator {
virtual GURL UpdateUrl() OVERRIDE { return GURL("http://localhost/upd"); }
+ virtual const char* ExtraRequestParams() OVERRIDE { return "extra=foo"; }
+
virtual size_t UrlSizeLimit() OVERRIDE { return 256; }
virtual net::URLRequestContextGetter* RequestContext() OVERRIDE {
@@ -238,7 +240,7 @@ TEST_F(ComponentUpdaterTest, CheckCrxSleep) {
RegisterComponent(&com, kTestComponent_abag, Version("1.1"));
const char expected_update_url[] =
- "http://localhost/upd?x=id%3D"
+ "http://localhost/upd?extra=foo&x=id%3D"
"abagagagagagagagagagagagagagagag%26v%3D1.1%26uc";
interceptor->SetResponse(expected_update_url,
@@ -324,12 +326,12 @@ TEST_F(ComponentUpdaterTest, InstallCrx) {
RegisterComponent(&com2, kTestComponent_abag, Version("2.2"));
const char expected_update_url_1[] =
- "http://localhost/upd?x=id%3D"
+ "http://localhost/upd?extra=foo&x=id%3D"
"jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc&x=id%3D"
"abagagagagagagagagagagagagagagag%26v%3D2.2%26uc";
const char expected_update_url_2[] =
- "http://localhost/upd?x=id%3D"
+ "http://localhost/upd?extra=foo&x=id%3D"
"abagagagagagagagagagagagagagagag%26v%3D2.2%26uc&x=id%3D"
"jebgalgnebhfojomionfpkfelancnnkf%26v%3D1.0%26uc";
@@ -388,7 +390,7 @@ TEST_F(ComponentUpdaterTest, ProdVersionCheck) {
RegisterComponent(&com, kTestComponent_jebg, Version("0.9"));
const char expected_update_url[] =
- "http://localhost/upd?x=id%3D"
+ "http://localhost/upd?extra=foo&x=id%3D"
"jebgalgnebhfojomionfpkfelancnnkf%26v%3D0.9%26uc";
interceptor->SetResponse(expected_update_url,