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/command_line.h" |
11 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "cc/layer.h" | 15 #include "cc/layer.h" |
15 #include "content/browser/android/interstitial_page_delegate_android.h" | 16 #include "content/browser/android/interstitial_page_delegate_android.h" |
16 #include "content/browser/android/load_url_params.h" | 17 #include "content/browser/android/load_url_params.h" |
17 #include "content/browser/android/touch_point.h" | 18 #include "content/browser/android/touch_point.h" |
18 #include "content/browser/renderer_host/java/java_bound_object.h" | 19 #include "content/browser/renderer_host/java/java_bound_object.h" |
19 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 20 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
20 #include "content/browser/renderer_host/compositor_impl_android.h" | 21 #include "content/browser/renderer_host/compositor_impl_android.h" |
21 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
22 #include "content/browser/renderer_host/render_widget_host_impl.h" | 23 #include "content/browser/renderer_host/render_widget_host_impl.h" |
23 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 24 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
24 #include "content/browser/ssl/ssl_host_state.h" | 25 #include "content/browser/ssl/ssl_host_state.h" |
25 #include "content/browser/web_contents/interstitial_page_impl.h" | 26 #include "content/browser/web_contents/interstitial_page_impl.h" |
26 #include "content/browser/web_contents/navigation_controller_impl.h" | 27 #include "content/browser/web_contents/navigation_controller_impl.h" |
27 #include "content/browser/web_contents/navigation_entry_impl.h" | 28 #include "content/browser/web_contents/navigation_entry_impl.h" |
28 #include "content/browser/web_contents/web_contents_view_android.h" | 29 #include "content/browser/web_contents/web_contents_view_android.h" |
29 #include "content/common/android/device_info.h" | 30 #include "content/common/android/device_info.h" |
30 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
31 #include "content/public/browser/browser_context.h" | 32 #include "content/public/browser/browser_context.h" |
32 #include "content/public/browser/favicon_status.h" | 33 #include "content/public/browser/favicon_status.h" |
33 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
34 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
36 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
38 #include "content/public/common/content_client.h" | 39 #include "content/public/common/content_client.h" |
| 40 #include "content/public/common/content_switches.h" |
39 #include "content/public/common/page_transition_types.h" | 41 #include "content/public/common/page_transition_types.h" |
40 #include "jni/ContentViewCore_jni.h" | 42 #include "jni/ContentViewCore_jni.h" |
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" |
44 #include "ui/gfx/android/java_bitmap.h" | 46 #include "ui/gfx/android/java_bitmap.h" |
45 #include "ui/gfx/android/window_android.h" | 47 #include "ui/gfx/android/window_android.h" |
46 #include "ui/gfx/screen.h" | 48 #include "ui/gfx/screen.h" |
| 49 #include "ui/gfx/size_conversions.h" |
| 50 #include "ui/gfx/size_f.h" |
47 #include "webkit/glue/webmenuitem.h" | 51 #include "webkit/glue/webmenuitem.h" |
48 #include "webkit/user_agent/user_agent_util.h" | 52 #include "webkit/user_agent/user_agent_util.h" |
49 | 53 |
50 using base::android::AttachCurrentThread; | 54 using base::android::AttachCurrentThread; |
51 using base::android::ConvertJavaStringToUTF16; | 55 using base::android::ConvertJavaStringToUTF16; |
52 using base::android::ConvertJavaStringToUTF8; | 56 using base::android::ConvertJavaStringToUTF8; |
53 using base::android::ConvertUTF16ToJavaString; | 57 using base::android::ConvertUTF16ToJavaString; |
54 using base::android::ConvertUTF8ToJavaString; | 58 using base::android::ConvertUTF8ToJavaString; |
55 using base::android::GetClass; | 59 using base::android::GetClass; |
56 using base::android::HasField; | 60 using base::android::HasField; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // process. We treat it like the tab is crashed. If the content is loaded | 164 // process. We treat it like the tab is crashed. If the content is loaded |
161 // when the tab is shown, tab_crashed_ will be reset. Since | 165 // when the tab is shown, tab_crashed_ will be reset. Since |
162 // RenderWidgetHostView is associated with the lifetime of the renderer | 166 // RenderWidgetHostView is associated with the lifetime of the renderer |
163 // process, we use it to test whether there is a renderer process. | 167 // process, we use it to test whether there is a renderer process. |
164 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); | 168 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); |
165 | 169 |
166 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 170 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
167 | 171 |
168 InitJNI(env, obj); | 172 InitJNI(env, obj); |
169 | 173 |
170 if (!gfx::Screen::GetNativeScreen()->IsDIPEnabled()) { | 174 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 175 switches::kEnableCssTransformPinch)) { |
171 dpi_scale_ = 1; | 176 dpi_scale_ = 1; |
172 } else { | 177 } else { |
173 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); | 178 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); |
174 dpi_scale_ = device_info->GetDPIScale(); | 179 dpi_scale_ = device_info->GetDPIScale(); |
175 } | 180 } |
176 | 181 |
177 notification_registrar_.Add(this, | 182 notification_registrar_.Add(this, |
178 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, | 183 NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, |
179 NotificationService::AllSources()); | 184 NotificationService::AllSources()); |
180 | 185 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 ScopedJavaLocalRef<jobject> java_bitmap = | 605 ScopedJavaLocalRef<jobject> java_bitmap = |
601 gfx::ConvertToJavaBitmap(&zoomed_bitmap); | 606 gfx::ConvertToJavaBitmap(&zoomed_bitmap); |
602 DCHECK(!java_bitmap.is_null()); | 607 DCHECK(!java_bitmap.is_null()); |
603 | 608 |
604 Java_ContentViewCore_showDisambiguationPopup(env, | 609 Java_ContentViewCore_showDisambiguationPopup(env, |
605 obj.obj(), | 610 obj.obj(), |
606 rect_object.obj(), | 611 rect_object.obj(), |
607 java_bitmap.obj()); | 612 java_bitmap.obj()); |
608 } | 613 } |
609 | 614 |
610 gfx::Rect ContentViewCoreImpl::GetBounds() const { | 615 gfx::Size ContentViewCoreImpl::GetPhysicalSize() const { |
611 JNIEnv* env = AttachCurrentThread(); | 616 JNIEnv* env = AttachCurrentThread(); |
612 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 617 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
613 if (j_obj.is_null()) | 618 if (j_obj.is_null()) |
614 return gfx::Rect(); | 619 return gfx::Size(); |
615 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), | 620 return gfx::Size(Java_ContentViewCore_getWidth(env, j_obj.obj()), |
616 Java_ContentViewCore_getHeight(env, j_obj.obj())); | 621 Java_ContentViewCore_getHeight(env, j_obj.obj())); |
617 } | 622 } |
618 | 623 |
| 624 gfx::Size ContentViewCoreImpl::GetDIPSize() const { |
| 625 return gfx::ToCeiledSize(gfx::ScaleSize(GetPhysicalSize(), 1 / DpiScale())); |
| 626 } |
| 627 |
619 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { | 628 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
620 root_layer_->addChild(layer); | 629 root_layer_->addChild(layer); |
621 } | 630 } |
622 | 631 |
623 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { | 632 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
624 layer->removeFromParent(); | 633 layer->removeFromParent(); |
625 } | 634 } |
626 | 635 |
627 void ContentViewCoreImpl::DidProduceRendererFrame() { | 636 void ContentViewCoreImpl::DidProduceRendererFrame() { |
628 renderer_frame_pending_ = true; | 637 renderer_frame_pending_ = true; |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1358 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
1350 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1359 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
1351 return false; | 1360 return false; |
1352 } | 1361 } |
1353 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1362 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
1354 | 1363 |
1355 return RegisterNativesImpl(env) >= 0; | 1364 return RegisterNativesImpl(env) >= 0; |
1356 } | 1365 } |
1357 | 1366 |
1358 } // namespace content | 1367 } // namespace content |
OLD | NEW |