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 "chrome/browser/update_client/chrome_update_query_params_delegate.h"
7 #include "base/lazy_instance.h"
8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/common/channel_info.h"
11 #include "components/version_info/version_info.h"
15 const char kUnknown
[] = "unknown";
16 const char kStable
[] = "stable";
17 const char kBeta
[] = "beta";
18 const char kDev
[] = "dev";
19 const char kCanary
[] = "canary";
21 base::LazyInstance
<ChromeUpdateQueryParamsDelegate
> g_delegate
=
22 LAZY_INSTANCE_INITIALIZER
;
26 ChromeUpdateQueryParamsDelegate::ChromeUpdateQueryParamsDelegate() {
29 ChromeUpdateQueryParamsDelegate::~ChromeUpdateQueryParamsDelegate() {
33 ChromeUpdateQueryParamsDelegate
*
34 ChromeUpdateQueryParamsDelegate::GetInstance() {
35 return g_delegate
.Pointer();
38 std::string
ChromeUpdateQueryParamsDelegate::GetExtraParams() {
39 return base::StringPrintf(
40 "&prodchannel=%s&prodversion=%s&lang=%s", GetChannelString(),
41 version_info::GetVersionNumber().c_str(), GetLang());
45 const char* ChromeUpdateQueryParamsDelegate::GetChannelString() {
46 switch (chrome::GetChannel()) {
47 case version_info::Channel::STABLE
:
50 case version_info::Channel::BETA
:
53 case version_info::Channel::DEV
:
56 case version_info::Channel::CANARY
:
59 case version_info::Channel::UNKNOWN
:
67 const char* ChromeUpdateQueryParamsDelegate::GetLang() {
68 return g_browser_process
->GetApplicationLocale().c_str();