| 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 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |