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

Side by Side 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, 3 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "content/browser/android/content_view_client.h" 12 #include "content/browser/android/content_view_client.h"
13 #include "content/browser/android/load_url_params.h" 13 #include "content/browser/android/load_url_params.h"
14 #include "content/browser/android/touch_point.h" 14 #include "content/browser/android/touch_point.h"
15 #include "content/browser/renderer_host/java/java_bound_object.h" 15 #include "content/browser/renderer_host/java/java_bound_object.h"
16 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 16 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
17 #include "content/browser/renderer_host/render_view_host_impl.h" 17 #include "content/browser/renderer_host/render_view_host_impl.h"
18 #include "content/browser/renderer_host/render_widget_host_impl.h" 18 #include "content/browser/renderer_host/render_widget_host_impl.h"
19 #include "content/browser/renderer_host/render_widget_host_view_android.h" 19 #include "content/browser/renderer_host/render_widget_host_view_android.h"
20 #include "content/browser/web_contents/navigation_controller_impl.h" 20 #include "content/browser/web_contents/navigation_controller_impl.h"
21 #include "content/public/browser/browser_context.h" 21 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/favicon_status.h" 22 #include "content/public/browser/favicon_status.h"
23 #include "content/public/browser/interstitial_page.h" 23 #include "content/public/browser/interstitial_page.h"
24 #include "content/public/browser/navigation_entry.h" 24 #include "content/public/browser/navigation_entry.h"
25 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/notification_source.h" 27 #include "content/public/browser/notification_source.h"
28 #include "content/public/browser/notification_types.h" 28 #include "content/public/browser/notification_types.h"
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/common/content_client.h"
30 #include "content/public/common/page_transition_types.h" 31 #include "content/public/common/page_transition_types.h"
31 #include "jni/ContentViewCore_jni.h" 32 #include "jni/ContentViewCore_jni.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent Factory.h"
35 #include "ui/gfx/android/java_bitmap.h" 36 #include "ui/gfx/android/java_bitmap.h"
37 #include "webkit/glue/user_agent.h"
36 #include "webkit/glue/webmenuitem.h" 38 #include "webkit/glue/webmenuitem.h"
37 39
38 using base::android::AttachCurrentThread; 40 using base::android::AttachCurrentThread;
39 using base::android::ConvertJavaStringToUTF16; 41 using base::android::ConvertJavaStringToUTF16;
40 using base::android::ConvertJavaStringToUTF8; 42 using base::android::ConvertJavaStringToUTF8;
41 using base::android::ConvertUTF16ToJavaString; 43 using base::android::ConvertUTF16ToJavaString;
42 using base::android::ConvertUTF8ToJavaString; 44 using base::android::ConvertUTF8ToJavaString;
43 using base::android::GetClass; 45 using base::android::GetClass;
44 using base::android::HasField; 46 using base::android::HasField;
45 using base::android::JavaByteArrayToByteVector; 47 using base::android::JavaByteArrayToByteVector;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 90 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
89 tab_crashed_(false) { 91 tab_crashed_(false) {
90 DCHECK(web_contents) << 92 DCHECK(web_contents) <<
91 "A ContentViewCoreImpl should be created with a valid WebContents."; 93 "A ContentViewCoreImpl should be created with a valid WebContents.";
92 94
93 InitJNI(env, obj); 95 InitJNI(env, obj);
94 96
95 notification_registrar_.Add(this, 97 notification_registrar_.Add(this,
96 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 98 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
97 NotificationService::AllSources()); 99 NotificationService::AllSources());
100
101 // Currently, the only use case we have for overriding a user agent involves
102 // spoofing a desktop Linux user agent for "Request desktop site".
103 // Automatically set it for all WebContents so that it is available when a
104 // NavigationEntry requires the user agent to be overridden.
105 const char kLinuxInfoStr[] = "X11; Linux x86_64";
106 std::string product = content::GetContentClient()->GetProduct();
107 std::string spoofed_ua =
108 webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product);
109 web_contents->SetUserAgentOverride(spoofed_ua);
98 } 110 }
99 111
100 ContentViewCoreImpl::~ContentViewCoreImpl() { 112 ContentViewCoreImpl::~ContentViewCoreImpl() {
101 // Make sure nobody calls back into this object while we are tearing things 113 // Make sure nobody calls back into this object while we are tearing things
102 // down. 114 // down.
103 notification_registrar_.RemoveAll(); 115 notification_registrar_.RemoveAll();
104 116
105 delete java_object_; 117 delete java_object_;
106 java_object_ = NULL; 118 java_object_ = NULL;
107 java_ref_.reset(); 119 java_ref_.reset();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { 628 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) {
617 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; 629 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!";
618 return false; 630 return false;
619 } 631 }
620 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); 632 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I");
621 633
622 return RegisterNativesImpl(env) >= 0; 634 return RegisterNativesImpl(env) >= 0;
623 } 635 }
624 636
625 } // namespace content 637 } // namespace content
OLDNEW
« 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