Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 "Windows NT %d.%d", | 64 "Windows NT %d.%d", |
| 65 os_major_version, | 65 os_major_version, |
| 66 os_minor_version | 66 os_minor_version |
| 67 #elif defined(OS_MACOSX) | 67 #elif defined(OS_MACOSX) |
| 68 "Intel Mac OS X %d_%d_%d", | 68 "Intel Mac OS X %d_%d_%d", |
| 69 os_major_version, | 69 os_major_version, |
| 70 os_minor_version, | 70 os_minor_version, |
| 71 os_bugfix_version | 71 os_bugfix_version |
| 72 #elif defined(OS_CHROMEOS) | 72 #elif defined(OS_CHROMEOS) |
| 73 "CrOS %s %d.%d.%d", | 73 "CrOS %s %d.%d.%d", |
| 74 cputype.c_str(), // e.g. i686 | 74 cputype.c_str(), // e.g. i686 |
| 75 os_major_version, | 75 os_major_version, |
| 76 os_minor_version, | 76 os_minor_version, |
| 77 os_bugfix_version | 77 os_bugfix_version |
| 78 #else | 78 #else |
| 79 "%s %s", | 79 "%s %s", |
| 80 unixinfo.sysname, // e.g. Linux | 80 unixinfo.sysname, // e.g. Linux |
| 81 cputype.c_str() // e.g. i686 | 81 cputype.c_str() // e.g. i686 |
| 82 #endif | 82 #endif |
| 83 ); // NOLINT | 83 ); // NOLINT |
| 84 | 84 |
| 85 return os_cpu; | 85 return os_cpu; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void BuildUserAgent(bool mimic_windows, std::string* result) { | 88 void BuildUserAgent(bool mimic_windows, std::string* result) { |
| 89 const char kUserAgentPlatform[] = | 89 const char kUserAgentPlatform[] = |
| 90 #if defined(OS_WIN) | 90 #if defined(OS_WIN) |
| 91 "Windows"; | 91 ""; |
| 92 #elif defined(OS_MACOSX) | 92 #elif defined(OS_MACOSX) |
| 93 "Macintosh"; | 93 "Macintosh; "; |
| 94 #elif defined(USE_X11) | 94 #elif defined(USE_X11) |
| 95 "X11"; // strange, but that's what Firefox uses | 95 "X11; "; // strange, but that's what Firefox uses |
| 96 #else | 96 #else |
| 97 "?"; | 97 "Unknown; "; |
| 98 #endif | 98 #endif |
| 99 | 99 |
| 100 // Get the product name and version, and replace Safari's Version/X string | 100 // Get the product name and version, and replace Safari's Version/X string |
| 101 // with it. This is done to expose our product name in a manner that is | 101 // with it. This is done to expose our product name in a manner that is |
| 102 // maximally compatible with Safari, we hope!! | 102 // maximally compatible with Safari, we hope!! |
| 103 std::string product = GetProductVersion(); | 103 std::string product = GetProductVersion(); |
| 104 | 104 |
| 105 // Derived from Safari's UA string. | 105 // Derived from Safari's UA string. |
| 106 base::StringAppendF( | 106 base::StringAppendF( |
| 107 result, | 107 result, |
| 108 "Mozilla/5.0 (%s; %s) AppleWebKit/%d.%d" | 108 "Mozilla/5.0 (%s%s) AppleWebKit/%d.%d" |
| 109 " (KHTML, like Gecko) %s Safari/%d.%d", | 109 " (KHTML, like Gecko) %s Safari/%d.%d", |
| 110 mimic_windows ? "Windows" : kUserAgentPlatform, | 110 mimic_windows ? "Windows " : kUserAgentPlatform, |
|
darin (slow to review)
2011/02/25 09:44:08
is this doing the right thing when mimic_windows i
Peter Kasting
2011/02/25 17:37:32
It produces a string that transforms the new Windo
| |
| 111 ((mimic_windows ? "Windows " : "") + BuildOSCpuInfo()).c_str(), | 111 BuildOSCpuInfo().c_str(), |
| 112 WEBKIT_VERSION_MAJOR, | 112 WEBKIT_VERSION_MAJOR, |
| 113 WEBKIT_VERSION_MINOR, | 113 WEBKIT_VERSION_MINOR, |
| 114 product.c_str(), | 114 product.c_str(), |
| 115 WEBKIT_VERSION_MAJOR, | 115 WEBKIT_VERSION_MAJOR, |
| 116 WEBKIT_VERSION_MINOR); | 116 WEBKIT_VERSION_MINOR); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace webkit_glue | 119 } // namespace webkit_glue |
| 120 | 120 |
| OLD | NEW |