Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: content/common/user_agent_util.cc

Issue 186883002: Move user_agent code from webkit/ to content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/common/user_agent/user_agent_util.h" 5 #include "content/public/common/user_agent_util.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/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/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 namespace webkit_glue { 23 namespace content {
24 24
25 std::string GetWebKitVersion() { 25 std::string GetWebKitVersion() {
26 return base::StringPrintf("%d.%d (%s)", 26 return base::StringPrintf("%d.%d (%s)",
27 WEBKIT_VERSION_MAJOR, 27 WEBKIT_VERSION_MAJOR,
28 WEBKIT_VERSION_MINOR, 28 WEBKIT_VERSION_MINOR,
29 WEBKIT_SVN_REVISION); 29 WEBKIT_SVN_REVISION);
30 } 30 }
31 31
32 std::string GetWebKitRevision() { 32 std::string GetWebKitRevision() {
33 return WEBKIT_SVN_REVISION; 33 return WEBKIT_SVN_REVISION;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 "Macintosh; "; 159 "Macintosh; ";
160 #elif defined(USE_X11) 160 #elif defined(USE_X11)
161 "X11; "; // strange, but that's what Firefox uses 161 "X11; "; // strange, but that's what Firefox uses
162 #elif defined(OS_ANDROID) 162 #elif defined(OS_ANDROID)
163 "Linux; "; 163 "Linux; ";
164 #else 164 #else
165 "Unknown; "; 165 "Unknown; ";
166 #endif 166 #endif
167 167
168 std::string os_info; 168 std::string os_info;
169 base::StringAppendF(&os_info, "%s%s", kUserAgentPlatform, 169 base::StringAppendF(
170 webkit_glue::BuildOSCpuInfo().c_str()); 170 &os_info, "%s%s", kUserAgentPlatform, BuildOSCpuInfo().c_str());
171 return BuildUserAgentFromOSAndProduct(os_info, product); 171 return BuildUserAgentFromOSAndProduct(os_info, product);
172 } 172 }
173 173
174 std::string BuildUserAgentFromOSAndProduct(const std::string& os_info, 174 std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
175 const std::string& product) { 175 const std::string& product) {
176 // Derived from Safari's UA string. 176 // Derived from Safari's UA string.
177 // This is done to expose our product name in a manner that is maximally 177 // This is done to expose our product name in a manner that is maximally
178 // compatible with Safari, we hope!! 178 // compatible with Safari, we hope!!
179 std::string user_agent; 179 std::string user_agent;
180 base::StringAppendF( 180 base::StringAppendF(
181 &user_agent, 181 &user_agent,
182 "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d", 182 "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
183 os_info.c_str(), 183 os_info.c_str(),
184 WEBKIT_VERSION_MAJOR, 184 WEBKIT_VERSION_MAJOR,
185 WEBKIT_VERSION_MINOR, 185 WEBKIT_VERSION_MINOR,
186 product.c_str(), 186 product.c_str(),
187 WEBKIT_VERSION_MAJOR, 187 WEBKIT_VERSION_MAJOR,
188 WEBKIT_VERSION_MINOR); 188 WEBKIT_VERSION_MINOR);
189 return user_agent; 189 return user_agent;
190 } 190 }
191 191
192 } // namespace webkit_glue 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698