1 // Copyright (c) 2012 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 "chrome/common/omaha_query_params/omaha_query_params.h"
7 #include "base/compiler_specific.h"
8 #include "base/strings/stringprintf.h"
9 #include "base/win/windows_version.h"
10 #include "chrome/common/chrome_version_info.h"
14 const char kUnknown
[] = "unknown";
16 // The request extra information is the OS and architecture, this helps
17 // the server select the right package to be delivered.
19 #if defined(OS_MACOSX)
23 #elif defined(OS_ANDROID)
25 #elif defined(OS_CHROMEOS)
27 #elif defined(OS_LINUX)
29 #elif defined(OS_OPENBSD)
36 #if defined(__amd64__) || defined(_WIN64)
38 #elif defined(__i386__) || defined(_WIN32)
40 #elif defined(__arm__)
42 #elif defined(__mips__)
48 const char kChrome
[] = "chrome";
50 const char kStable
[] = "stable";
51 const char kBeta
[] = "beta";
52 const char kDev
[] = "dev";
53 const char kCanary
[] = "canary";
55 #if defined(GOOGLE_CHROME_BUILD)
56 const char kChromeCrx
[] = "chromecrx";
58 const char kChromiumCrx
[] = "chromiumcrx";
59 #endif // defined(GOOGLE_CHROME_BUILD)
66 std::string
OmahaQueryParams::Get(ProdId prod
) {
67 return base::StringPrintf(
68 "os=%s&arch=%s&nacl_arch=%s&prod=%s&prodchannel=%s&prodversion=%s",
72 GetProdIdString(prod
),
74 chrome::VersionInfo().Version().c_str());
78 const char* OmahaQueryParams::GetProdIdString(
79 chrome::OmahaQueryParams::ProdId prod
) {
81 case chrome::OmahaQueryParams::CHROME
:
84 case chrome::OmahaQueryParams::CRX
:
85 #if defined(GOOGLE_CHROME_BUILD)
96 const char* OmahaQueryParams::getOS() {
101 const char* OmahaQueryParams::getArch() {
106 const char* OmahaQueryParams::getNaclArch() {
107 #if defined(ARCH_CPU_X86_FAMILY)
108 #if defined(ARCH_CPU_X86_64)
110 #elif defined(OS_WIN)
111 bool x86_64
= (base::win::OSInfo::GetInstance()->wow64_status() ==
112 base::win::OSInfo::WOW64_ENABLED
);
113 return x86_64
? "x86-64" : "x86-32";
117 #elif defined(ARCH_CPU_ARMEL)
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"
128 const char* OmahaQueryParams::GetChannelString() {
129 switch (chrome::VersionInfo::GetChannel()) {
130 case chrome::VersionInfo::CHANNEL_STABLE
:
133 case chrome::VersionInfo::CHANNEL_BETA
:
136 case chrome::VersionInfo::CHANNEL_DEV
:
139 case chrome::VersionInfo::CHANNEL_CANARY
:
142 case chrome::VersionInfo::CHANNEL_UNKNOWN
:
149 } // namespace chrome