| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 int GetWebKitMajorVersion() { | 108 int GetWebKitMajorVersion() { |
| 109 return WEBKIT_VERSION_MAJOR; | 109 return WEBKIT_VERSION_MAJOR; |
| 110 } | 110 } |
| 111 | 111 |
| 112 int GetWebKitMinorVersion() { | 112 int GetWebKitMinorVersion() { |
| 113 return WEBKIT_VERSION_MINOR; | 113 return WEBKIT_VERSION_MINOR; |
| 114 } | 114 } |
| 115 | 115 |
| 116 std::string BuildUserAgentFromProduct(const std::string& product) { | 116 std::string BuildUserAgentHelper(bool mimic_windows, |
| 117 const std::string& product) { |
| 117 const char kUserAgentPlatform[] = | 118 const char kUserAgentPlatform[] = |
| 118 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
| 119 ""; | 120 ""; |
| 120 #elif defined(OS_MACOSX) | 121 #elif defined(OS_MACOSX) |
| 121 "Macintosh; "; | 122 "Macintosh; "; |
| 122 #elif defined(USE_X11) | 123 #elif defined(USE_X11) |
| 123 "X11; "; // strange, but that's what Firefox uses | 124 "X11; "; // strange, but that's what Firefox uses |
| 124 #else | 125 #else |
| 125 "Unknown; "; | 126 "Unknown; "; |
| 126 #endif | 127 #endif |
| 127 | 128 |
| 128 std::string user_agent; | 129 std::string user_agent; |
| 129 | 130 |
| 131 // Replace Safari's Version/X string with the product name/version passed in. |
| 130 // This is done to expose our product name in a manner that is maximally | 132 // This is done to expose our product name in a manner that is maximally |
| 131 // compatible with Safari, we hope!! | 133 // compatible with Safari, we hope!! |
| 132 | 134 |
| 133 // Derived from Safari's UA string. | 135 // Derived from Safari's UA string. |
| 134 base::StringAppendF( | 136 base::StringAppendF( |
| 135 &user_agent, | 137 &user_agent, |
| 136 "Mozilla/5.0 (%s%s) AppleWebKit/%d.%d" | 138 "Mozilla/5.0 (%s%s) AppleWebKit/%d.%d" |
| 137 " (KHTML, like Gecko) %s Safari/%d.%d", | 139 " (KHTML, like Gecko) %s Safari/%d.%d", |
| 138 kUserAgentPlatform, | 140 mimic_windows ? "Windows " : kUserAgentPlatform, |
| 139 webkit_glue::BuildOSCpuInfo().c_str(), | 141 webkit_glue::BuildOSCpuInfo().c_str(), |
| 140 WEBKIT_VERSION_MAJOR, | 142 WEBKIT_VERSION_MAJOR, |
| 141 WEBKIT_VERSION_MINOR, | 143 WEBKIT_VERSION_MINOR, |
| 142 product.c_str(), | 144 product.c_str(), |
| 143 WEBKIT_VERSION_MAJOR, | 145 WEBKIT_VERSION_MAJOR, |
| 144 WEBKIT_VERSION_MINOR); | 146 WEBKIT_VERSION_MINOR); |
| 145 return user_agent; | 147 return user_agent; |
| 146 } | 148 } |
| 147 | 149 |
| 148 } // namespace webkit_glue | 150 } // namespace webkit_glue |
| 149 | 151 |
| OLD | NEW |