OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include <sys/sysctl.h> | 9 #include <sys/sysctl.h> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 (os_major_version == version_map[i].major_os_version && | 52 (os_major_version == version_map[i].major_os_version && |
53 os_minor_version >= version_map[i].minor_os_version)) | 53 os_minor_version >= version_map[i].minor_os_version)) |
54 return version_map[i].ua_versions; | 54 return version_map[i].ua_versions; |
55 } | 55 } |
56 NOTREACHED(); | 56 NOTREACHED(); |
57 return version_map[arraysize(version_map) - 1].ua_versions; | 57 return version_map[arraysize(version_map) - 1].ua_versions; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 namespace webkit_glue { | 62 namespace content { |
63 | 63 |
64 std::string BuildOSCpuInfo() { | 64 std::string BuildOSCpuInfo() { |
65 int32 os_major_version = 0; | 65 int32 os_major_version = 0; |
66 int32 os_minor_version = 0; | 66 int32 os_minor_version = 0; |
67 int32 os_bugfix_version = 0; | 67 int32 os_bugfix_version = 0; |
68 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, | 68 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
69 &os_minor_version, | 69 &os_minor_version, |
70 &os_bugfix_version); | 70 &os_bugfix_version); |
71 std::string os_version; | 71 std::string os_version; |
72 if (os_bugfix_version == 0) { | 72 if (os_bugfix_version == 0) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 unsigned int namelen = sizeof(mib) / sizeof(mib[0]); | 107 unsigned int namelen = sizeof(mib) / sizeof(mib[0]); |
108 size_t bufferSize = 0; | 108 size_t bufferSize = 0; |
109 sysctl(mib, namelen, NULL, &bufferSize, NULL, 0); | 109 sysctl(mib, namelen, NULL, &bufferSize, NULL, 0); |
110 char kernel_version[bufferSize]; | 110 char kernel_version[bufferSize]; |
111 int result = sysctl(mib, namelen, kernel_version, &bufferSize, NULL, 0); | 111 int result = sysctl(mib, namelen, kernel_version, &bufferSize, NULL, 0); |
112 DCHECK(result == 0); | 112 DCHECK(result == 0); |
113 | 113 |
114 UAVersions ua_versions = GetUAVersionsForCurrentOS(); | 114 UAVersions ua_versions = GetUAVersionsForCurrentOS(); |
115 | 115 |
116 std::string user_agent; | 116 std::string user_agent; |
117 base::StringAppendF( | 117 base::StringAppendF(&user_agent, |
118 &user_agent, | 118 "Mozilla/5.0 (%s) AppleWebKit/%s" |
119 "Mozilla/5.0 (%s) AppleWebKit/%s" | 119 " (KHTML, like Gecko) %s Mobile/%s Safari/%s", |
120 " (KHTML, like Gecko) %s Mobile/%s Safari/%s", | 120 BuildOSCpuInfo().c_str(), |
121 webkit_glue::BuildOSCpuInfo().c_str(), | 121 ua_versions.webkit_version_string, |
122 ua_versions.webkit_version_string, | 122 product.c_str(), |
123 product.c_str(), | 123 kernel_version, |
124 kernel_version, | 124 ua_versions.safari_version_string); |
125 ua_versions.safari_version_string); | |
126 | 125 |
127 return user_agent; | 126 return user_agent; |
128 } | 127 } |
129 | 128 |
130 } // namespace webkit_glue | 129 } // namespace content |
OLD | NEW |