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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 10854251: Allow the creation of partially spoofed user agents (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed flag 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index 9b03d894821987f2057d23a94ef415467377369c..eb0a0149c5c53658668d490e630a5559ec10754d 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -27,12 +27,14 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/content_client.h"
#include "content/public/common/page_transition_types.h"
#include "jni/ContentViewCore_jni.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEventFactory.h"
#include "ui/gfx/android/java_bitmap.h"
+#include "webkit/glue/user_agent.h"
#include "webkit/glue/webmenuitem.h"
using base::android::AttachCurrentThread;
@@ -95,6 +97,15 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj,
notification_registrar_.Add(this,
NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
NotificationService::AllSources());
+
+ // Currently, the only use case we have for overriding a user agent involves
+ // spoofing a desktop Linux user agent for "Request desktop site".
+ // Automatically set it for all WebContents.
Charlie Reis 2012/08/24 21:38:43 I don't understand this comment. Request desktop
gone 2012/08/24 23:50:35 The main reason we set it here is that we don't sa
Charlie Reis 2012/08/25 00:11:10 Sorry if I'm just missing something basic, but is
gone 2012/08/25 00:23:49 D'oh, yeah, that's all that does. It just sets th
+ const char kLinuxInfoStr[] = "X11; Linux x86_64";
+ std::string product = content::GetContentClient()->GetProduct();
+ std::string spoofed_ua =
+ webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
+ web_contents->SetUserAgentOverride(spoofed_ua);
}
ContentViewCoreImpl::~ContentViewCoreImpl() {

Powered by Google App Engine
This is Rietveld 408576698