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

Side by Side 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: set UA override for all entries; impl. reviewer comments Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 #include "webkit_version.h" // NOLINT 21 #include "webkit_version.h" // NOLINT
22 22
23 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
24 namespace { 24 namespace {
25 25
26 base::LazyInstance<std::string>::Leaky g_os_info = LAZY_INSTANCE_INITIALIZER; 26 base::LazyInstance<std::string>::Leaky g_os_info = LAZY_INSTANCE_INITIALIZER;
27 27
28 } // namespace 28 } // namespace
29 #endif 29 #endif
30 30
31 namespace {
32 const char kUserAgentOverrideForTabletSite[] =
33 "(Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B)";
Rick Byers 2012/08/03 15:53:06 This string looks fine to me.
sschmitz 2012/08/03 18:11:43 Done.
34 }
35
31 namespace webkit_glue { 36 namespace webkit_glue {
32 37
33 std::string GetWebKitVersion() { 38 std::string GetWebKitVersion() {
34 return base::StringPrintf("%d.%d (%s)", 39 return base::StringPrintf("%d.%d (%s)",
35 WEBKIT_VERSION_MAJOR, 40 WEBKIT_VERSION_MAJOR,
36 WEBKIT_VERSION_MINOR, 41 WEBKIT_VERSION_MINOR,
37 WEBKIT_SVN_REVISION); 42 WEBKIT_SVN_REVISION);
38 } 43 }
39 44
40 std::string GetWebKitRevision() { 45 std::string GetWebKitRevision() {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 WEBKIT_VERSION_MINOR); 160 WEBKIT_VERSION_MINOR);
156 return user_agent; 161 return user_agent;
157 } 162 }
158 163
159 #if defined(OS_ANDROID) 164 #if defined(OS_ANDROID)
160 void SetUserAgentOSInfo(const std::string& os_info) { 165 void SetUserAgentOSInfo(const std::string& os_info) {
161 g_os_info.Get() = os_info; 166 g_os_info.Get() = os_info;
162 } 167 }
163 #endif 168 #endif
164 169
170 std::string BuildUserAgentOverrideForTabletSiteFromUserAgent(
171 const std::string& user_agent) {
172 // Example: original user agent text:
173 //
174 // Mozilla/5.0 (X11; CrOS x86_64 0.4.0)
175 // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2
176 //
177 // Copy & Edit to create user agent override text by replacing
178 // the text within the first pair of "()". For example:
179 //
180 // Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B)
181 // AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1211.0 Safari/537.2
182 //
183 size_t p1 = user_agent.find("(");
184 if (p1 != std::string::npos) {
185 size_t p2 = user_agent.find(")", p1);
186 if (p2 != std::string::npos) {
187 std::string ua_override(user_agent);
188 ua_override.replace(p1, p2-p1+1, kUserAgentOverrideForTabletSite);
189 return ua_override;
190 }
191 }
192 return std::string();
193 }
194
165 } // namespace webkit_glue 195 } // namespace webkit_glue
OLDNEW
« chrome/browser/ui/toolbar/wrench_menu_model.cc ('K') | « webkit/glue/user_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698