Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Unified Diff: webkit/glue/user_agent.cc

Issue 10827146: crbug.com/127841 - Request Tablet Site on CB with touch screen. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: removed spurious whitespace differences wrt master Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webkit/glue/user_agent.h ('K') | « webkit/glue/user_agent.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/user_agent.cc
diff --git a/webkit/glue/user_agent.cc b/webkit/glue/user_agent.cc
index 516504081f136db4e1551c71f4a3237b020e373e..fb7f7690295682b3f7e7fe72bb490fc16ae21438 100644
--- a/webkit/glue/user_agent.cc
+++ b/webkit/glue/user_agent.cc
@@ -162,4 +162,32 @@ void SetUserAgentOSInfo(const std::string& os_info) {
}
#endif
+std::string BuildUserAgentOverrideForTabletSiteFromUserAgent(
+ const std::string& user_agent) {
+ //
gone 2012/08/03 00:08:26 nit: Remove line
sschmitz 2012/08/03 15:36:58 Done.
+ // 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 "()". In this example:
+ //
+ // Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F)
+ // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2
+ //
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.
+ 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,
+ "(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.
+ return ua_override;
+ }
+ }
+ return std::string();
+}
+
} // namespace webkit_glue
« webkit/glue/user_agent.h ('K') | « webkit/glue/user_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698