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)"; |
Charlie Reis
2012/08/13 20:38:46
Do we really want this hard coded?
gone
2012/08/13 20:45:12
I'm not sure if there's a good option other than s
gone
2012/08/14 01:15:16
Though there is one issue with this: a Galaxy Nexu
sschmitz
2012/09/06 16:44:02
This has been cleaned up & shortened to "Linux; An
|
+} |
+ |
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("("); |
jamesr
2012/08/07 19:49:03
This seems pretty gross.
If you look at what's go
sschmitz
2012/09/06 16:44:02
This has been cleaned up thanks to Dan's work.
Don
|
+ 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 |