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 "webkit/common/user_agent/user_agent_util.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/memory/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" |
16 #include "base/sys_info.h" | 16 #include "base/sys_info.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 struct UAVersions { | 20 struct UAVersions { |
21 const char* safari_version_string; | 21 const char* safari_version_string; |
22 const char* webkit_version_string; | 22 const char* webkit_version_string; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 // Up until iOS 5, the locale was included at the end of the Safari UA. | 103 // Up until iOS 5, the locale was included at the end of the Safari UA. |
104 // TODO(stuartmorgan): Remove this once iOS 4.3 is no longer supported. | 104 // TODO(stuartmorgan): Remove this once iOS 4.3 is no longer supported. |
105 if (os_major_version < 5) { | 105 if (os_major_version < 5) { |
106 // The locale string is not easy to set correctly. Safari uses a language | 106 // The locale string is not easy to set correctly. Safari uses a language |
107 // code and a dialect code. However, there is no setting allowing the user | 107 // code and a dialect code. However, there is no setting allowing the user |
108 // to set the dialect code, and no API to retrieve it. | 108 // to set the dialect code, and no API to retrieve it. |
109 // Note: The NSLocale methods (currentIdentifier:, | 109 // Note: The NSLocale methods (currentIdentifier:, |
110 // objectForKey:NSLocaleLanguageCode and objectForKey:NSLocaleCountryCode) | 110 // objectForKey:NSLocaleLanguageCode and objectForKey:NSLocaleCountryCode) |
111 // are not useful here because they return information related to the | 111 // are not useful here because they return information related to the |
112 // "Region Format" setting, which is different from the "Language" setting. | 112 // "Region Format" setting, which is different from the "Language" setting. |
113 scoped_nsobject<NSDictionary> dialects([[NSDictionary alloc] | 113 base::scoped_nsobject<NSDictionary> dialects([[NSDictionary alloc] |
114 initWithObjectsAndKeys: | 114 initWithObjectsAndKeys: |
Nico
2013/06/25 01:09:50
Also PR16435 and PR16436
| |
115 @"ar", @"ar", // No dialect code in Safari. | 115 @"ar", @"ar", // No dialect code in Safari. |
116 @"ca-es", @"ca", | 116 @"ca-es", @"ca", |
117 @"cs-cz", @"cs", | 117 @"cs-cz", @"cs", |
118 @"da-dk", @"da", | 118 @"da-dk", @"da", |
119 @"el-gr", @"el", | 119 @"el-gr", @"el", |
120 @"en-gb", @"en-GB", | 120 @"en-gb", @"en-GB", |
121 @"en-us", @"en", | 121 @"en-us", @"en", |
122 @"he-il", @"he", | 122 @"he-il", @"he", |
123 @"id", @"id", // No dialect code in Safari. | 123 @"id", @"id", // No dialect code in Safari. |
124 @"ja-jp", @"ja", | 124 @"ja-jp", @"ja", |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 webkit_glue::BuildOSCpuInfo().c_str(), | 170 webkit_glue::BuildOSCpuInfo().c_str(), |
171 ua_versions.webkit_version_string, | 171 ua_versions.webkit_version_string, |
172 product.c_str(), | 172 product.c_str(), |
173 kernel_version, | 173 kernel_version, |
174 ua_versions.safari_version_string); | 174 ua_versions.safari_version_string); |
175 | 175 |
176 return user_agent; | 176 return user_agent; |
177 } | 177 } |
178 | 178 |
179 } // namespace webkit_glue | 179 } // namespace webkit_glue |
OLD | NEW |