1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/omaha_query_params/omaha_query_params.h"
7 #include "base/compiler_specific.h"
8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/win/windows_version.h"
11 #include "components/omaha_query_params/omaha_query_params_delegate.h"
13 namespace omaha_query_params
{
17 const char kUnknown
[] = "unknown";
19 // The request extra information is the OS and architecture, this helps
20 // the server select the right package to be delivered.
22 #if defined(OS_MACOSX)
26 #elif defined(OS_ANDROID)
28 #elif defined(OS_CHROMEOS)
30 #elif defined(OS_LINUX)
32 #elif defined(OS_OPENBSD)
39 #if defined(__amd64__) || defined(_WIN64)
41 #elif defined(__i386__) || defined(_WIN32)
43 #elif defined(__arm__)
45 #elif defined(__aarch64__)
47 #elif defined(__mips__)
53 const char kChrome
[] = "chrome";
55 #if defined(GOOGLE_CHROME_BUILD)
56 const char kChromeCrx
[] = "chromecrx";
58 const char kChromiumCrx
[] = "chromiumcrx";
59 #endif // defined(GOOGLE_CHROME_BUILD)
61 OmahaQueryParamsDelegate
* g_delegate
= NULL
;
66 std::string
OmahaQueryParams::Get(ProdId prod
) {
67 return base::StringPrintf(
68 "os=%s&arch=%s&nacl_arch=%s&prod=%s%s",
72 GetProdIdString(prod
),
73 g_delegate
? g_delegate
->GetExtraParams().c_str() : "");
77 const char* OmahaQueryParams::GetProdIdString(OmahaQueryParams::ProdId prod
) {
79 case OmahaQueryParams::CHROME
:
82 case OmahaQueryParams::CRX
:
83 #if defined(GOOGLE_CHROME_BUILD)
94 const char* OmahaQueryParams::GetOS() {
99 const char* OmahaQueryParams::GetArch() {
104 const char* OmahaQueryParams::GetNaclArch() {
105 #if defined(ARCH_CPU_X86_FAMILY)
106 #if defined(ARCH_CPU_X86_64)
108 #elif defined(OS_WIN)
109 bool x86_64
= (base::win::OSInfo::GetInstance()->wow64_status() ==
110 base::win::OSInfo::WOW64_ENABLED
);
111 return x86_64
? "x86-64" : "x86-32";
115 #elif defined(ARCH_CPU_ARMEL)
117 #elif defined(ARCH_CPU_ARM64)
119 #elif defined(ARCH_CPU_MIPSEL)
122 // NOTE: when adding new values here, please remember to update the
123 // comment in the .h file about possible return values from this function.
124 #error "You need to add support for your architecture here"
129 void OmahaQueryParams::SetDelegate(OmahaQueryParamsDelegate
* delegate
) {
130 DCHECK(!g_delegate
|| !delegate
);
131 g_delegate
= delegate
;
134 } // namespace omaha_query_params