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/update_client/update_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/update_client/update_query_params_delegate.h"
13 namespace update_client
{
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 UpdateQueryParamsDelegate
* g_delegate
= NULL
;
66 std::string
UpdateQueryParams::Get(ProdId prod
) {
67 return base::StringPrintf(
68 "os=%s&arch=%s&nacl_arch=%s&prod=%s%s", kOs
, kArch
, GetNaclArch(),
69 GetProdIdString(prod
),
70 g_delegate
? g_delegate
->GetExtraParams().c_str() : "");
74 const char* UpdateQueryParams::GetProdIdString(UpdateQueryParams::ProdId prod
) {
76 case UpdateQueryParams::CHROME
:
79 case UpdateQueryParams::CRX
:
80 #if defined(GOOGLE_CHROME_BUILD)
91 const char* UpdateQueryParams::GetOS() {
96 const char* UpdateQueryParams::GetArch() {
101 const char* UpdateQueryParams::GetNaclArch() {
102 #if defined(ARCH_CPU_X86_FAMILY)
103 #if defined(ARCH_CPU_X86_64)
105 #elif defined(OS_WIN)
106 bool x86_64
= (base::win::OSInfo::GetInstance()->wow64_status() ==
107 base::win::OSInfo::WOW64_ENABLED
);
108 return x86_64
? "x86-64" : "x86-32";
112 #elif defined(ARCH_CPU_ARMEL)
114 #elif defined(ARCH_CPU_ARM64)
116 #elif defined(ARCH_CPU_MIPSEL)
119 // NOTE: when adding new values here, please remember to update the
120 // comment in the .h file about possible return values from this function.
121 #error "You need to add support for your architecture here"
126 void UpdateQueryParams::SetDelegate(UpdateQueryParamsDelegate
* delegate
) {
127 DCHECK(!g_delegate
|| !delegate
|| (delegate
== g_delegate
));
128 g_delegate
= delegate
;
131 } // namespace update_client