OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "webkit/glue/user_agent.h" | 5 #include "webkit/glue/user_agent.h" |
6 | 6 |
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 7 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
8 #include <sys/utsname.h> | 8 #include <sys/utsname.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
18 #endif | 18 #endif |
19 | 19 |
20 // Generated | 20 // Generated |
21 #include "webkit_version.h" // NOLINT | 21 #include "webkit_version.h" // NOLINT |
22 | 22 |
23 #if defined(OS_ANDROID) | |
24 namespace { | |
25 | |
26 base::LazyInstance<std::string>::Leaky g_os_info = LAZY_INSTANCE_INITIALIZER; | |
27 | |
28 } // namespace | |
29 #endif | |
30 | |
31 namespace webkit_glue { | 23 namespace webkit_glue { |
32 | 24 |
33 std::string GetWebKitVersion() { | 25 std::string GetWebKitVersion() { |
34 return base::StringPrintf("%d.%d (%s)", | 26 return base::StringPrintf("%d.%d (%s)", |
35 WEBKIT_VERSION_MAJOR, | 27 WEBKIT_VERSION_MAJOR, |
36 WEBKIT_VERSION_MINOR, | 28 WEBKIT_VERSION_MINOR, |
37 WEBKIT_SVN_REVISION); | 29 WEBKIT_SVN_REVISION); |
38 } | 30 } |
39 | 31 |
40 std::string GetWebKitRevision() { | 32 std::string GetWebKitRevision() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 os_bugfix_version | 88 os_bugfix_version |
97 #elif defined(OS_CHROMEOS) | 89 #elif defined(OS_CHROMEOS) |
98 "CrOS " | 90 "CrOS " |
99 "%s %d.%d.%d", | 91 "%s %d.%d.%d", |
100 cputype.c_str(), // e.g. i686 | 92 cputype.c_str(), // e.g. i686 |
101 os_major_version, | 93 os_major_version, |
102 os_minor_version, | 94 os_minor_version, |
103 os_bugfix_version | 95 os_bugfix_version |
104 #elif defined(OS_ANDROID) | 96 #elif defined(OS_ANDROID) |
105 "Android %s", | 97 "Android %s", |
106 g_os_info.Get().c_str() | 98 base::SysInfo::OperatingSystemInformation().c_str() |
107 #else | 99 #else |
108 "%s %s", | 100 "%s %s", |
109 unixinfo.sysname, // e.g. Linux | 101 unixinfo.sysname, // e.g. Linux |
110 cputype.c_str() // e.g. i686 | 102 cputype.c_str() // e.g. i686 |
111 #endif | 103 #endif |
112 ); // NOLINT | 104 ); // NOLINT |
113 | 105 |
114 return os_cpu; | 106 return os_cpu; |
115 } | 107 } |
116 | 108 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 kUserAgentPlatform, | 141 kUserAgentPlatform, |
150 webkit_glue::BuildOSCpuInfo().c_str(), | 142 webkit_glue::BuildOSCpuInfo().c_str(), |
151 WEBKIT_VERSION_MAJOR, | 143 WEBKIT_VERSION_MAJOR, |
152 WEBKIT_VERSION_MINOR, | 144 WEBKIT_VERSION_MINOR, |
153 product.c_str(), | 145 product.c_str(), |
154 WEBKIT_VERSION_MAJOR, | 146 WEBKIT_VERSION_MAJOR, |
155 WEBKIT_VERSION_MINOR); | 147 WEBKIT_VERSION_MINOR); |
156 return user_agent; | 148 return user_agent; |
157 } | 149 } |
158 | 150 |
159 #if defined(OS_ANDROID) | |
160 void SetUserAgentOSInfo(const std::string& os_info) { | |
161 g_os_info.Get() = os_info; | |
162 } | |
163 #endif | |
164 | 151 |
165 } // namespace webkit_glue | 152 } // namespace webkit_glue |
OLD | NEW |