Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 50 using base::android::ConvertJavaStringToUTF16; | 51 using base::android::ConvertJavaStringToUTF16; |
| 51 using base::android::ConvertJavaStringToUTF8; | 52 using base::android::ConvertJavaStringToUTF8; |
| 52 using base::android::ConvertUTF16ToJavaString; | 53 using base::android::ConvertUTF16ToJavaString; |
| 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; |
| 61 using cc::Layer; | |
|
joth
2012/11/29 21:19:38
nit: rather than using, I think saying cc::Layer a
Leandro GraciĆ” Gil
2012/11/30 12:11:11
Done.
| |
| 60 using WebKit::WebGestureEvent; | 62 using WebKit::WebGestureEvent; |
| 61 using WebKit::WebInputEvent; | 63 using WebKit::WebInputEvent; |
| 62 using WebKit::WebInputEventFactory; | 64 using WebKit::WebInputEventFactory; |
| 63 using WebKit::WebLayer; | |
| 64 | 65 |
| 65 // Describes the type and enabled state of a select popup item. | 66 // Describes the type and enabled state of a select popup item. |
| 66 // Keep in sync with the value defined in SelectPopupDialog.java | 67 // Keep in sync with the value defined in SelectPopupDialog.java |
| 67 enum PopupItemType { | 68 enum PopupItemType { |
| 68 POPUP_ITEM_TYPE_GROUP = 0, | 69 POPUP_ITEM_TYPE_GROUP = 0, |
| 69 POPUP_ITEM_TYPE_DISABLED, | 70 POPUP_ITEM_TYPE_DISABLED, |
| 70 POPUP_ITEM_TYPE_ENABLED | 71 POPUP_ITEM_TYPE_ENABLED |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 namespace content { | 74 namespace content { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 return reinterpret_cast<ContentViewCore*>( | 141 return reinterpret_cast<ContentViewCore*>( |
| 141 env->GetIntField(obj, g_native_content_view)); | 142 env->GetIntField(obj, g_native_content_view)); |
| 142 } | 143 } |
| 143 | 144 |
| 144 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, | 145 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, |
| 145 bool hardware_accelerated, | 146 bool hardware_accelerated, |
| 146 WebContents* web_contents, | 147 WebContents* web_contents, |
| 147 ui::WindowAndroid* window_android) | 148 ui::WindowAndroid* window_android) |
| 148 : java_ref_(env, obj), | 149 : java_ref_(env, obj), |
| 149 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 150 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
| 150 root_layer_(WebLayer::create()), | 151 root_layer_(Layer::create()), |
| 151 tab_crashed_(false), | 152 tab_crashed_(false), |
| 152 window_android_(window_android) { | 153 window_android_(window_android) { |
| 153 DCHECK(web_contents) << | 154 DCHECK(web_contents) << |
| 154 "A ContentViewCoreImpl should be created with a valid WebContents."; | 155 "A ContentViewCoreImpl should be created with a valid WebContents."; |
| 155 | 156 |
| 156 // When a tab is restored (from a saved state), it does not have a renderer | 157 // 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 | 158 // 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 | 159 // when the tab is shown, tab_crashed_ will be reset. Since |
| 159 // RenderWidgetHostView is associated with the lifetime of the renderer | 160 // RenderWidgetHostView is associated with the lifetime of the renderer |
| 160 // process, we use it to test whether there is a renderer process. | 161 // process, we use it to test whether there is a renderer process. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 | 594 |
| 594 gfx::Rect ContentViewCoreImpl::GetBounds() const { | 595 gfx::Rect ContentViewCoreImpl::GetBounds() const { |
| 595 JNIEnv* env = AttachCurrentThread(); | 596 JNIEnv* env = AttachCurrentThread(); |
| 596 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 597 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
| 597 if (j_obj.is_null()) | 598 if (j_obj.is_null()) |
| 598 return gfx::Rect(); | 599 return gfx::Rect(); |
| 599 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), | 600 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), |
| 600 Java_ContentViewCore_getHeight(env, j_obj.obj())); | 601 Java_ContentViewCore_getHeight(env, j_obj.obj())); |
| 601 } | 602 } |
| 602 | 603 |
| 603 void ContentViewCoreImpl::AttachWebLayer(WebLayer* layer) { | 604 void ContentViewCoreImpl::AttachLayer(scoped_refptr<Layer> layer) { |
| 604 root_layer_->addChild(layer); | 605 root_layer_->addChild(layer); |
| 605 } | 606 } |
| 606 | 607 |
| 607 void ContentViewCoreImpl::RemoveWebLayer(WebLayer* layer) { | 608 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<Layer> layer) { |
| 608 layer->removeFromParent(); | 609 layer->removeFromParent(); |
| 609 } | 610 } |
| 610 | 611 |
| 611 void ContentViewCoreImpl::LoadUrl( | 612 void ContentViewCoreImpl::LoadUrl( |
| 612 NavigationController::LoadURLParams& params) { | 613 NavigationController::LoadURLParams& params) { |
| 613 GetWebContents()->GetController().LoadURLWithParams(params); | 614 GetWebContents()->GetController().LoadURLWithParams(params); |
| 614 tab_crashed_ = false; | 615 tab_crashed_ = false; |
| 615 } | 616 } |
| 616 | 617 |
| 617 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 618 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
| 618 return window_android_; | 619 return window_android_; |
| 619 } | 620 } |
| 620 | 621 |
| 621 WebLayer* ContentViewCoreImpl::GetWebLayer() const { | 622 scoped_refptr<Layer> ContentViewCoreImpl::GetLayer() const { |
| 622 return root_layer_.get(); | 623 return root_layer_.get(); |
| 623 } | 624 } |
| 624 | 625 |
| 625 // ---------------------------------------------------------------------------- | 626 // ---------------------------------------------------------------------------- |
| 626 // Methods called from Java via JNI | 627 // Methods called from Java via JNI |
| 627 // ---------------------------------------------------------------------------- | 628 // ---------------------------------------------------------------------------- |
| 628 | 629 |
| 629 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, | 630 void ContentViewCoreImpl::SelectPopupMenuItems(JNIEnv* env, jobject obj, |
| 630 jintArray indices) { | 631 jintArray indices) { |
| 631 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 632 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1248 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
| 1248 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1249 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
| 1249 return false; | 1250 return false; |
| 1250 } | 1251 } |
| 1251 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1252 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
| 1252 | 1253 |
| 1253 return RegisterNativesImpl(env) >= 0; | 1254 return RegisterNativesImpl(env) >= 0; |
| 1254 } | 1255 } |
| 1255 | 1256 |
| 1256 } // namespace content | 1257 } // namespace content |
| OLD | NEW |