Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 WEBKIT_VERSION_MINOR); | 155 WEBKIT_VERSION_MINOR); |
| 156 return user_agent; | 156 return user_agent; |
| 157 } | 157 } |
| 158 | 158 |
| 159 #if defined(OS_ANDROID) | 159 #if defined(OS_ANDROID) |
| 160 void SetUserAgentOSInfo(const std::string& os_info) { | 160 void SetUserAgentOSInfo(const std::string& os_info) { |
| 161 g_os_info.Get() = os_info; | 161 g_os_info.Get() = os_info; |
| 162 } | 162 } |
| 163 #endif | 163 #endif |
| 164 | 164 |
| 165 std::string BuildUserAgentOverrideForTabletSiteFromUserAgent( | |
| 166 const std::string& user_agent) { | |
| 167 // | |
|
gone
2012/08/03 00:08:26
nit: Remove line
sschmitz
2012/08/03 15:36:58
Done.
| |
| 168 // Example: original user agent text: | |
| 169 // | |
| 170 // Mozilla/5.0 (X11; CrOS x86_64 0.4.0) | |
| 171 // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2 | |
| 172 // | |
| 173 // Copy & Edit to create user agent override text by replacing | |
| 174 // the text within the first pair of "()". In this example: | |
| 175 // | |
| 176 // Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) | |
| 177 // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2 | |
| 178 // | |
|
gone
2012/08/03 00:08:26
Seems relatively fragile, but I don't have a bette
sschmitz
2012/08/03 15:36:58
Yes. I agree. Thanks for looking out.
| |
| 179 size_t p1 = user_agent.find("("); | |
| 180 if (p1 != std::string::npos) { | |
| 181 size_t p2 = user_agent.find(")", p1); | |
| 182 if (p2 != std::string::npos) { | |
| 183 std::string ua_override(user_agent); | |
| 184 ua_override.replace( | |
| 185 p1,p2-p1+1, | |
| 186 "(Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F)"); | |
|
gone
2012/08/03 00:08:26
Yank this literal out of the replace() call and ma
sschmitz
2012/08/03 15:36:58
Done.
| |
| 187 return ua_override; | |
| 188 } | |
| 189 } | |
| 190 return std::string(); | |
| 191 } | |
| 192 | |
| 165 } // namespace webkit_glue | 193 } // namespace webkit_glue |
| OLD | NEW |