OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "content/public/browser/favicon_status.h" | 44 #include "content/public/browser/favicon_status.h" |
45 #include "content/public/browser/notification_details.h" | 45 #include "content/public/browser/notification_details.h" |
46 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
47 #include "content/public/browser/notification_source.h" | 47 #include "content/public/browser/notification_source.h" |
48 #include "content/public/browser/notification_types.h" | 48 #include "content/public/browser/notification_types.h" |
49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
50 #include "content/public/common/content_client.h" | 50 #include "content/public/common/content_client.h" |
51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
52 #include "content/public/common/menu_item.h" | 52 #include "content/public/common/menu_item.h" |
53 #include "content/public/common/page_transition_types.h" | 53 #include "content/public/common/page_transition_types.h" |
| 54 #include "content/public/common/user_agent.h" |
54 #include "jni/ContentViewCore_jni.h" | 55 #include "jni/ContentViewCore_jni.h" |
55 #include "third_party/WebKit/public/web/WebBindings.h" | 56 #include "third_party/WebKit/public/web/WebBindings.h" |
56 #include "third_party/WebKit/public/web/WebInputEvent.h" | 57 #include "third_party/WebKit/public/web/WebInputEvent.h" |
57 #include "ui/base/android/view_android.h" | 58 #include "ui/base/android/view_android.h" |
58 #include "ui/base/android/window_android.h" | 59 #include "ui/base/android/window_android.h" |
59 #include "ui/events/gesture_detection/gesture_config_helper.h" | 60 #include "ui/events/gesture_detection/gesture_config_helper.h" |
60 #include "ui/gfx/android/java_bitmap.h" | 61 #include "ui/gfx/android/java_bitmap.h" |
61 #include "ui/gfx/screen.h" | 62 #include "ui/gfx/screen.h" |
62 #include "ui/gfx/size_conversions.h" | 63 #include "ui/gfx/size_conversions.h" |
63 #include "ui/gfx/size_f.h" | 64 #include "ui/gfx/size_f.h" |
64 #include "webkit/common/user_agent/user_agent_util.h" | |
65 | 65 |
66 using base::android::AttachCurrentThread; | 66 using base::android::AttachCurrentThread; |
67 using base::android::ConvertJavaStringToUTF16; | 67 using base::android::ConvertJavaStringToUTF16; |
68 using base::android::ConvertJavaStringToUTF8; | 68 using base::android::ConvertJavaStringToUTF8; |
69 using base::android::ConvertUTF16ToJavaString; | 69 using base::android::ConvertUTF16ToJavaString; |
70 using base::android::ConvertUTF8ToJavaString; | 70 using base::android::ConvertUTF8ToJavaString; |
71 using base::android::ScopedJavaGlobalRef; | 71 using base::android::ScopedJavaGlobalRef; |
72 using base::android::ScopedJavaLocalRef; | 72 using base::android::ScopedJavaLocalRef; |
73 using blink::WebGestureEvent; | 73 using blink::WebGestureEvent; |
74 using blink::WebInputEvent; | 74 using blink::WebInputEvent; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 CHECK(web_contents) << | 243 CHECK(web_contents) << |
244 "A ContentViewCoreImpl should be created with a valid WebContents."; | 244 "A ContentViewCoreImpl should be created with a valid WebContents."; |
245 | 245 |
246 // Currently, the only use case we have for overriding a user agent involves | 246 // Currently, the only use case we have for overriding a user agent involves |
247 // spoofing a desktop Linux user agent for "Request desktop site". | 247 // spoofing a desktop Linux user agent for "Request desktop site". |
248 // Automatically set it for all WebContents so that it is available when a | 248 // Automatically set it for all WebContents so that it is available when a |
249 // NavigationEntry requires the user agent to be overridden. | 249 // NavigationEntry requires the user agent to be overridden. |
250 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 250 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
251 std::string product = content::GetContentClient()->GetProduct(); | 251 std::string product = content::GetContentClient()->GetProduct(); |
252 std::string spoofed_ua = | 252 std::string spoofed_ua = |
253 webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); | 253 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); |
254 web_contents->SetUserAgentOverride(spoofed_ua); | 254 web_contents->SetUserAgentOverride(spoofed_ua); |
255 | 255 |
256 InitWebContents(); | 256 InitWebContents(); |
257 } | 257 } |
258 | 258 |
259 ContentViewCoreImpl::~ContentViewCoreImpl() { | 259 ContentViewCoreImpl::~ContentViewCoreImpl() { |
260 JNIEnv* env = base::android::AttachCurrentThread(); | 260 JNIEnv* env = base::android::AttachCurrentThread(); |
261 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 261 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
262 java_ref_.reset(); | 262 java_ref_.reset(); |
263 if (!j_obj.is_null()) { | 263 if (!j_obj.is_null()) { |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1770 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1771 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1771 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1772 return reinterpret_cast<intptr_t>(view); | 1772 return reinterpret_cast<intptr_t>(view); |
1773 } | 1773 } |
1774 | 1774 |
1775 bool RegisterContentViewCore(JNIEnv* env) { | 1775 bool RegisterContentViewCore(JNIEnv* env) { |
1776 return RegisterNativesImpl(env); | 1776 return RegisterNativesImpl(env); |
1777 } | 1777 } |
1778 | 1778 |
1779 } // namespace content | 1779 } // namespace content |
OLD | NEW |