| Index: webkit/glue/user_agent.cc
|
| diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc
|
| index 516504081f136db4e1551c71f4a3237b020e373e..79151e547dd76205621667b26ad56f0313ab5cca 100644
|
| --- a/webkit/glue/user_agent.cc
|
| +++ b/webkit/glue/user_agent.cc
|
| @@ -28,6 +28,11 @@ base::LazyInstance<std::string>::Leaky g_os_info = LAZY_INSTANCE_INITIALIZER;
|
| } // namespace
|
| #endif
|
|
|
| +namespace {
|
| +const char kUserAgentOverrideForTabletSite[] =
|
| + "(Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B)";
|
| +}
|
| +
|
| namespace webkit_glue {
|
|
|
| std::string GetWebKitVersion() {
|
| @@ -162,4 +167,29 @@ void SetUserAgentOSInfo(const std::string& os_info) {
|
| }
|
| #endif
|
|
|
| +std::string BuildUserAgentOverrideForTabletSiteFromUserAgent(
|
| + const std::string& user_agent) {
|
| + // Example: original user agent text:
|
| + //
|
| + // Mozilla/5.0 (X11; CrOS x86_64 0.4.0)
|
| + // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2
|
| + //
|
| + // Copy & Edit to create user agent override text by replacing
|
| + // the text within the first pair of "()". For example:
|
| + //
|
| + // Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B)
|
| + // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2
|
| + //
|
| + size_t p1 = user_agent.find("(");
|
| + if (p1 != std::string::npos) {
|
| + size_t p2 = user_agent.find(")", p1);
|
| + if (p2 != std::string::npos) {
|
| + std::string ua_override(user_agent);
|
| + ua_override.replace(p1, p2-p1+1, kUserAgentOverrideForTabletSite);
|
| + return ua_override;
|
| + }
|
| + }
|
| + return std::string();
|
| +}
|
| +
|
| } // namespace webkit_glue
|
|
|