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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "content/public/browser/favicon_status.h" | 43 #include "content/public/browser/favicon_status.h" |
44 #include "content/public/browser/notification_details.h" | 44 #include "content/public/browser/notification_details.h" |
45 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/notification_source.h" | 46 #include "content/public/browser/notification_source.h" |
47 #include "content/public/browser/notification_types.h" | 47 #include "content/public/browser/notification_types.h" |
48 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
49 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
50 #include "content/public/common/content_switches.h" | 50 #include "content/public/common/content_switches.h" |
51 #include "content/public/common/menu_item.h" | 51 #include "content/public/common/menu_item.h" |
52 #include "content/public/common/page_transition_types.h" | 52 #include "content/public/common/page_transition_types.h" |
| 53 #include "content/public/common/user_agent.h" |
53 #include "jni/ContentViewCore_jni.h" | 54 #include "jni/ContentViewCore_jni.h" |
54 #include "third_party/WebKit/public/web/WebBindings.h" | 55 #include "third_party/WebKit/public/web/WebBindings.h" |
55 #include "third_party/WebKit/public/web/WebInputEvent.h" | 56 #include "third_party/WebKit/public/web/WebInputEvent.h" |
56 #include "ui/base/android/view_android.h" | 57 #include "ui/base/android/view_android.h" |
57 #include "ui/base/android/window_android.h" | 58 #include "ui/base/android/window_android.h" |
58 #include "ui/gfx/android/java_bitmap.h" | 59 #include "ui/gfx/android/java_bitmap.h" |
59 #include "ui/gfx/screen.h" | 60 #include "ui/gfx/screen.h" |
60 #include "ui/gfx/size_conversions.h" | 61 #include "ui/gfx/size_conversions.h" |
61 #include "ui/gfx/size_f.h" | 62 #include "ui/gfx/size_f.h" |
62 #include "webkit/common/user_agent/user_agent_util.h" | |
63 | 63 |
64 using base::android::AttachCurrentThread; | 64 using base::android::AttachCurrentThread; |
65 using base::android::ConvertJavaStringToUTF16; | 65 using base::android::ConvertJavaStringToUTF16; |
66 using base::android::ConvertJavaStringToUTF8; | 66 using base::android::ConvertJavaStringToUTF8; |
67 using base::android::ConvertUTF16ToJavaString; | 67 using base::android::ConvertUTF16ToJavaString; |
68 using base::android::ConvertUTF8ToJavaString; | 68 using base::android::ConvertUTF8ToJavaString; |
69 using base::android::ScopedJavaGlobalRef; | 69 using base::android::ScopedJavaGlobalRef; |
70 using base::android::ScopedJavaLocalRef; | 70 using base::android::ScopedJavaLocalRef; |
71 using blink::WebGestureEvent; | 71 using blink::WebGestureEvent; |
72 using blink::WebInputEvent; | 72 using blink::WebInputEvent; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 CHECK(web_contents) << | 234 CHECK(web_contents) << |
235 "A ContentViewCoreImpl should be created with a valid WebContents."; | 235 "A ContentViewCoreImpl should be created with a valid WebContents."; |
236 | 236 |
237 // Currently, the only use case we have for overriding a user agent involves | 237 // Currently, the only use case we have for overriding a user agent involves |
238 // spoofing a desktop Linux user agent for "Request desktop site". | 238 // spoofing a desktop Linux user agent for "Request desktop site". |
239 // Automatically set it for all WebContents so that it is available when a | 239 // Automatically set it for all WebContents so that it is available when a |
240 // NavigationEntry requires the user agent to be overridden. | 240 // NavigationEntry requires the user agent to be overridden. |
241 const char kLinuxInfoStr[] = "X11; Linux x86_64"; | 241 const char kLinuxInfoStr[] = "X11; Linux x86_64"; |
242 std::string product = content::GetContentClient()->GetProduct(); | 242 std::string product = content::GetContentClient()->GetProduct(); |
243 std::string spoofed_ua = | 243 std::string spoofed_ua = |
244 webkit_glue::BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); | 244 BuildUserAgentFromOSAndProduct(kLinuxInfoStr, product); |
245 web_contents->SetUserAgentOverride(spoofed_ua); | 245 web_contents->SetUserAgentOverride(spoofed_ua); |
246 | 246 |
247 InitWebContents(); | 247 InitWebContents(); |
248 } | 248 } |
249 | 249 |
250 ContentViewCoreImpl::~ContentViewCoreImpl() { | 250 ContentViewCoreImpl::~ContentViewCoreImpl() { |
251 JNIEnv* env = base::android::AttachCurrentThread(); | 251 JNIEnv* env = base::android::AttachCurrentThread(); |
252 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 252 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
253 java_ref_.reset(); | 253 java_ref_.reset(); |
254 if (!j_obj.is_null()) { | 254 if (!j_obj.is_null()) { |
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1712 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1713 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1713 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1714 return reinterpret_cast<intptr_t>(view); | 1714 return reinterpret_cast<intptr_t>(view); |
1715 } | 1715 } |
1716 | 1716 |
1717 bool RegisterContentViewCore(JNIEnv* env) { | 1717 bool RegisterContentViewCore(JNIEnv* env) { |
1718 return RegisterNativesImpl(env); | 1718 return RegisterNativesImpl(env); |
1719 } | 1719 } |
1720 | 1720 |
1721 } // namespace content | 1721 } // namespace content |
OLD | NEW |