OLD | NEW |
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 "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "cc/layer.h" |
14 #include "content/browser/android/interstitial_page_delegate_android.h" | 15 #include "content/browser/android/interstitial_page_delegate_android.h" |
15 #include "content/browser/android/load_url_params.h" | 16 #include "content/browser/android/load_url_params.h" |
16 #include "content/browser/android/touch_point.h" | 17 #include "content/browser/android/touch_point.h" |
17 #include "content/browser/renderer_host/java/java_bound_object.h" | 18 #include "content/browser/renderer_host/java/java_bound_object.h" |
18 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 19 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
19 #include "content/browser/renderer_host/compositor_impl_android.h" | 20 #include "content/browser/renderer_host/compositor_impl_android.h" |
20 #include "content/browser/renderer_host/render_view_host_impl.h" | 21 #include "content/browser/renderer_host/render_view_host_impl.h" |
21 #include "content/browser/renderer_host/render_widget_host_impl.h" | 22 #include "content/browser/renderer_host/render_widget_host_impl.h" |
22 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 23 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
23 #include "content/browser/ssl/ssl_host_state.h" | 24 #include "content/browser/ssl/ssl_host_state.h" |
(...skipping 29 matching lines...) Expand all Loading... |
53 using base::android::ConvertUTF8ToJavaString; | 54 using base::android::ConvertUTF8ToJavaString; |
54 using base::android::GetClass; | 55 using base::android::GetClass; |
55 using base::android::HasField; | 56 using base::android::HasField; |
56 using base::android::MethodID; | 57 using base::android::MethodID; |
57 using base::android::JavaByteArrayToByteVector; | 58 using base::android::JavaByteArrayToByteVector; |
58 using base::android::ScopedJavaGlobalRef; | 59 using base::android::ScopedJavaGlobalRef; |
59 using base::android::ScopedJavaLocalRef; | 60 using base::android::ScopedJavaLocalRef; |
60 using WebKit::WebGestureEvent; | 61 using WebKit::WebGestureEvent; |
61 using WebKit::WebInputEvent; | 62 using WebKit::WebInputEvent; |
62 using WebKit::WebInputEventFactory; | 63 using WebKit::WebInputEventFactory; |
63 using WebKit::WebLayer; | |
64 | 64 |
65 // Describes the type and enabled state of a select popup item. | 65 // Describes the type and enabled state of a select popup item. |
66 // Keep in sync with the value defined in SelectPopupDialog.java | 66 // Keep in sync with the value defined in SelectPopupDialog.java |
67 enum PopupItemType { | 67 enum PopupItemType { |
68 POPUP_ITEM_TYPE_GROUP = 0, | 68 POPUP_ITEM_TYPE_GROUP = 0, |
69 POPUP_ITEM_TYPE_DISABLED, | 69 POPUP_ITEM_TYPE_DISABLED, |
70 POPUP_ITEM_TYPE_ENABLED | 70 POPUP_ITEM_TYPE_ENABLED |
71 }; | 71 }; |
72 | 72 |
73 namespace content { | 73 namespace content { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return reinterpret_cast<ContentViewCore*>( | 140 return reinterpret_cast<ContentViewCore*>( |
141 env->GetIntField(obj, g_native_content_view)); | 141 env->GetIntField(obj, g_native_content_view)); |
142 } | 142 } |
143 | 143 |
144 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 144 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
145 bool hardware_accelerated, | 145 bool hardware_accelerated, |
146 WebContents* web_contents, | 146 WebContents* web_contents, |
147 ui::WindowAndroid* window_android) | 147 ui::WindowAndroid* window_android) |
148 : java_ref_(env, obj), | 148 : java_ref_(env, obj), |
149 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 149 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
150 root_layer_(WebLayer::create()), | 150 root_layer_(cc::Layer::create()), |
151 tab_crashed_(false), | 151 tab_crashed_(false), |
152 window_android_(window_android) { | 152 window_android_(window_android) { |
153 CHECK(web_contents) << | 153 CHECK(web_contents) << |
154 "A ContentViewCoreImpl should be created with a valid WebContents."; | 154 "A ContentViewCoreImpl should be created with a valid WebContents."; |
155 | 155 |
156 // When a tab is restored (from a saved state), it does not have a renderer | 156 // When a tab is restored (from a saved state), it does not have a renderer |
157 // process. We treat it like the tab is crashed. If the content is loaded | 157 // process. We treat it like the tab is crashed. If the content is loaded |
158 // when the tab is shown, tab_crashed_ will be reset. Since | 158 // when the tab is shown, tab_crashed_ will be reset. Since |
159 // RenderWidgetHostView is associated with the lifetime of the renderer | 159 // RenderWidgetHostView is associated with the lifetime of the renderer |
160 // process, we use it to test whether there is a renderer process. | 160 // process, we use it to test whether there is a renderer process. |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 | 594 |
595 gfx::Rect ContentViewCoreImpl::GetBounds() const { | 595 gfx::Rect ContentViewCoreImpl::GetBounds() const { |
596 JNIEnv* env = AttachCurrentThread(); | 596 JNIEnv* env = AttachCurrentThread(); |
597 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 597 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
598 if (j_obj.is_null()) | 598 if (j_obj.is_null()) |
599 return gfx::Rect(); | 599 return gfx::Rect(); |
600 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), | 600 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), |
601 Java_ContentViewCore_getHeight(env, j_obj.obj())); | 601 Java_ContentViewCore_getHeight(env, j_obj.obj())); |
602 } | 602 } |
603 | 603 |
604 void ContentViewCoreImpl::AttachWebLayer(WebLayer* layer) { | 604 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
605 root_layer_->addChild(layer); | 605 root_layer_->addChild(layer); |
606 } | 606 } |
607 | 607 |
608 void ContentViewCoreImpl::RemoveWebLayer(WebLayer* layer) { | 608 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
609 layer->removeFromParent(); | 609 layer->removeFromParent(); |
610 } | 610 } |
611 | 611 |
612 void ContentViewCoreImpl::LoadUrl( | 612 void ContentViewCoreImpl::LoadUrl( |
613 NavigationController::LoadURLParams& params) { | 613 NavigationController::LoadURLParams& params) { |
614 GetWebContents()->GetController().LoadURLWithParams(params); | 614 GetWebContents()->GetController().LoadURLWithParams(params); |
615 tab_crashed_ = false; | 615 tab_crashed_ = false; |
616 } | 616 } |
617 | 617 |
618 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 618 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
619 return window_android_; | 619 return window_android_; |
620 } | 620 } |
621 | 621 |
622 WebLayer* ContentViewCoreImpl::GetWebLayer() const { | 622 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { |
623 return root_layer_.get(); | 623 return root_layer_.get(); |
624 } | 624 } |
625 | 625 |
626 // ---------------------------------------------------------------------------- | 626 // ---------------------------------------------------------------------------- |
627 // Methods called from Java via JNI | 627 // Methods called from Java via JNI |
628 // ---------------------------------------------------------------------------- | 628 // ---------------------------------------------------------------------------- |
629 | 629 |
630 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, | 630 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, |
631 jintArray indices) { | 631 jintArray indices) { |
632 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 632 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1254 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
1255 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1255 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
1256 return false; | 1256 return false; |
1257 } | 1257 } |
1258 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1258 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
1259 | 1259 |
1260 return RegisterNativesImpl(env) >= 0; | 1260 return RegisterNativesImpl(env) >= 0; |
1261 } | 1261 } |
1262 | 1262 |
1263 } // namespace content | 1263 } // namespace content |
OLD | NEW |