OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/update_client/chrome_update_query_params_delegate.h" | 5 #include "chrome/browser/update_client/chrome_update_query_params_delegate.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/common/channel_info.h" | 10 #include "chrome/common/channel_info.h" |
11 #include "components/version_info/version_info.h" | 11 #include "components/version_info/version_info.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
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"; | |
20 | |
21 base::LazyInstance<ChromeUpdateQueryParamsDelegate> g_delegate = | 15 base::LazyInstance<ChromeUpdateQueryParamsDelegate> g_delegate = |
22 LAZY_INSTANCE_INITIALIZER; | 16 LAZY_INSTANCE_INITIALIZER; |
23 | 17 |
24 } // namespace | 18 } // namespace |
25 | 19 |
26 ChromeUpdateQueryParamsDelegate::ChromeUpdateQueryParamsDelegate() { | 20 ChromeUpdateQueryParamsDelegate::ChromeUpdateQueryParamsDelegate() { |
27 } | 21 } |
28 | 22 |
29 ChromeUpdateQueryParamsDelegate::~ChromeUpdateQueryParamsDelegate() { | 23 ChromeUpdateQueryParamsDelegate::~ChromeUpdateQueryParamsDelegate() { |
30 } | 24 } |
31 | 25 |
32 // static | 26 // static |
33 ChromeUpdateQueryParamsDelegate* | 27 ChromeUpdateQueryParamsDelegate* |
34 ChromeUpdateQueryParamsDelegate::GetInstance() { | 28 ChromeUpdateQueryParamsDelegate::GetInstance() { |
35 return g_delegate.Pointer(); | 29 return g_delegate.Pointer(); |
36 } | 30 } |
37 | 31 |
38 std::string ChromeUpdateQueryParamsDelegate::GetExtraParams() { | 32 std::string ChromeUpdateQueryParamsDelegate::GetExtraParams() { |
39 return base::StringPrintf( | 33 return base::StringPrintf( |
40 "&prodchannel=%s&prodversion=%s&lang=%s", GetChannelString(), | 34 "&prodchannel=%s&prodversion=%s&lang=%s", GetChannelString(), |
41 version_info::GetVersionNumber().c_str(), GetLang()); | 35 version_info::GetVersionNumber().c_str(), GetLang()); |
42 } | 36 } |
43 | 37 |
44 // static | 38 // static |
45 const char* ChromeUpdateQueryParamsDelegate::GetChannelString() { | 39 const char* ChromeUpdateQueryParamsDelegate::GetChannelString() { |
46 switch (chrome::GetChannel()) { | 40 return GetChannelStringHelper(chrome::GetChannel()); |
47 case version_info::Channel::STABLE: | |
48 return kStable; | |
49 break; | |
50 case version_info::Channel::BETA: | |
51 return kBeta; | |
52 break; | |
53 case version_info::Channel::DEV: | |
54 return kDev; | |
55 break; | |
56 case version_info::Channel::CANARY: | |
57 return kCanary; | |
58 break; | |
59 case version_info::Channel::UNKNOWN: | |
60 return kUnknown; | |
61 break; | |
62 } | |
63 return kUnknown; | |
64 } | 41 } |
65 | 42 |
66 // static | 43 // static |
67 const char* ChromeUpdateQueryParamsDelegate::GetLang() { | 44 const char* ChromeUpdateQueryParamsDelegate::GetLang() { |
68 return g_browser_process->GetApplicationLocale().c_str(); | 45 return g_browser_process->GetApplicationLocale().c_str(); |
69 } | 46 } |
OLD | NEW |