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

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: Moving namespaces 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
« no previous file with comments | « chrome/common/chrome_content_client_unittest.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..904d96a814a3723077e4cf51de757a3847393a94 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,16 @@ 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 so that it is available when a
+ // NavigationEntry requires the user agent to be overridden.
+ 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() {
« no previous file with comments | « chrome/common/chrome_content_client_unittest.cc ('k') | content/public/common/content_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698