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

Side by Side Diff: webkit/glue/user_agent.cc

Issue 10854251: Allow the creation of partially spoofed user agents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moving namespaces Created 8 years, 3 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
« no previous file with comments | « webkit/glue/user_agent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #elif defined(OS_MACOSX) 148 #elif defined(OS_MACOSX)
149 "Macintosh; "; 149 "Macintosh; ";
150 #elif defined(USE_X11) 150 #elif defined(USE_X11)
151 "X11; "; // strange, but that's what Firefox uses 151 "X11; "; // strange, but that's what Firefox uses
152 #elif defined(OS_ANDROID) 152 #elif defined(OS_ANDROID)
153 "Linux; "; 153 "Linux; ";
154 #else 154 #else
155 "Unknown; "; 155 "Unknown; ";
156 #endif 156 #endif
157 157
158 std::string user_agent; 158 std::string os_info;
159 base::StringAppendF(&os_info, "%s%s", kUserAgentPlatform,
160 webkit_glue::BuildOSCpuInfo().c_str());
161 return BuildUserAgentFromOSAndProduct(os_info, product);
162 }
159 163
164 std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
165 const std::string& product) {
166 // Derived from Safari's UA string.
160 // This is done to expose our product name in a manner that is maximally 167 // This is done to expose our product name in a manner that is maximally
161 // compatible with Safari, we hope!! 168 // compatible with Safari, we hope!!
162 169 std::string user_agent;
163 // Derived from Safari's UA string.
164 base::StringAppendF( 170 base::StringAppendF(
165 &user_agent, 171 &user_agent,
166 "Mozilla/5.0 (%s%s) AppleWebKit/%d.%d" 172 "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
167 " (KHTML, like Gecko) %s Safari/%d.%d", 173 os_info.c_str(),
168 kUserAgentPlatform,
169 webkit_glue::BuildOSCpuInfo().c_str(),
170 WEBKIT_VERSION_MAJOR, 174 WEBKIT_VERSION_MAJOR,
171 WEBKIT_VERSION_MINOR, 175 WEBKIT_VERSION_MINOR,
172 product.c_str(), 176 product.c_str(),
173 WEBKIT_VERSION_MAJOR, 177 WEBKIT_VERSION_MAJOR,
174 WEBKIT_VERSION_MINOR); 178 WEBKIT_VERSION_MINOR);
175 return user_agent; 179 return user_agent;
176 } 180 }
177 181
178 } // namespace webkit_glue 182 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/user_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698