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 "base/values.h" | 15 #include "base/values.h" |
15 #include "cc/layer.h" | 16 #include "cc/layer.h" |
16 #include "content/browser/android/interstitial_page_delegate_android.h" | 17 #include "content/browser/android/interstitial_page_delegate_android.h" |
17 #include "content/browser/android/load_url_params.h" | 18 #include "content/browser/android/load_url_params.h" |
18 #include "content/browser/android/touch_point.h" | 19 #include "content/browser/android/touch_point.h" |
19 #include "content/browser/renderer_host/java/java_bound_object.h" | 20 #include "content/browser/renderer_host/java/java_bound_object.h" |
20 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 21 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
21 #include "content/browser/renderer_host/compositor_impl_android.h" | 22 #include "content/browser/renderer_host/compositor_impl_android.h" |
22 #include "content/browser/renderer_host/render_view_host_impl.h" | 23 #include "content/browser/renderer_host/render_view_host_impl.h" |
23 #include "content/browser/renderer_host/render_widget_host_impl.h" | 24 #include "content/browser/renderer_host/render_widget_host_impl.h" |
24 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 25 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
25 #include "content/browser/ssl/ssl_host_state.h" | 26 #include "content/browser/ssl/ssl_host_state.h" |
26 #include "content/browser/web_contents/interstitial_page_impl.h" | 27 #include "content/browser/web_contents/interstitial_page_impl.h" |
27 #include "content/browser/web_contents/navigation_controller_impl.h" | 28 #include "content/browser/web_contents/navigation_controller_impl.h" |
28 #include "content/browser/web_contents/navigation_entry_impl.h" | 29 #include "content/browser/web_contents/navigation_entry_impl.h" |
29 #include "content/browser/web_contents/web_contents_view_android.h" | 30 #include "content/browser/web_contents/web_contents_view_android.h" |
30 #include "content/common/android/device_info.h" | 31 #include "content/common/android/device_info.h" |
31 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
32 #include "content/public/browser/browser_context.h" | 33 #include "content/public/browser/browser_context.h" |
33 #include "content/public/browser/favicon_status.h" | 34 #include "content/public/browser/favicon_status.h" |
34 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
37 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
39 #include "content/public/common/content_client.h" | 40 #include "content/public/common/content_client.h" |
| 41 #include "content/public/common/content_switches.h" |
40 #include "content/public/common/page_transition_types.h" | 42 #include "content/public/common/page_transition_types.h" |
41 #include "jni/ContentViewCore_jni.h" | 43 #include "jni/ContentViewCore_jni.h" |
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 45 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
44 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" | 46 #include "third_party/WebKit/Source/WebKit/chromium/public/android/WebInputEvent
Factory.h" |
45 #include "ui/gfx/android/java_bitmap.h" | 47 #include "ui/gfx/android/java_bitmap.h" |
46 #include "ui/gfx/android/window_android.h" | 48 #include "ui/gfx/android/window_android.h" |
47 #include "ui/gfx/screen.h" | 49 #include "ui/gfx/screen.h" |
| 50 #include "ui/gfx/size_conversions.h" |
| 51 #include "ui/gfx/size_f.h" |
48 #include "webkit/glue/webmenuitem.h" | 52 #include "webkit/glue/webmenuitem.h" |
49 #include "webkit/user_agent/user_agent_util.h" | 53 #include "webkit/user_agent/user_agent_util.h" |
50 | 54 |
51 using base::android::AttachCurrentThread; | 55 using base::android::AttachCurrentThread; |
52 using base::android::ConvertJavaStringToUTF16; | 56 using base::android::ConvertJavaStringToUTF16; |
53 using base::android::ConvertJavaStringToUTF8; | 57 using base::android::ConvertJavaStringToUTF8; |
54 using base::android::ConvertUTF16ToJavaString; | 58 using base::android::ConvertUTF16ToJavaString; |
55 using base::android::ConvertUTF8ToJavaString; | 59 using base::android::ConvertUTF8ToJavaString; |
56 using base::android::GetClass; | 60 using base::android::GetClass; |
57 using base::android::HasField; | 61 using base::android::HasField; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // process. We treat it like the tab is crashed. If the content is loaded | 165 // process. We treat it like the tab is crashed. If the content is loaded |
162 // when the tab is shown, tab_crashed_ will be reset. Since | 166 // when the tab is shown, tab_crashed_ will be reset. Since |
163 // RenderWidgetHostView is associated with the lifetime of the renderer | 167 // RenderWidgetHostView is associated with the lifetime of the renderer |
164 // process, we use it to test whether there is a renderer process. | 168 // process, we use it to test whether there is a renderer process. |
165 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); | 169 tab_crashed_ = !(web_contents->GetRenderWidgetHostView()); |
166 | 170 |
167 // TODO(leandrogracia): make use of the hardware_accelerated argument. | 171 // TODO(leandrogracia): make use of the hardware_accelerated argument. |
168 | 172 |
169 InitJNI(env, obj); | 173 InitJNI(env, obj); |
170 | 174 |
171 if (!gfx::Screen::GetNativeScreen()->IsDIPEnabled()) { | 175 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 176 switches::kEnableCssTransformPinch)) { |
172 dpi_scale_ = 1; | 177 dpi_scale_ = 1; |
173 } else { | 178 } else { |
174 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); | 179 scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); |
175 dpi_scale_ = device_info->GetDPIScale(); | 180 dpi_scale_ = device_info->GetDPIScale(); |
176 } | 181 } |
177 | 182 |
178 // Currently, the only use case we have for overriding a user agent involves | 183 // Currently, the only use case we have for overriding a user agent involves |
179 // spoofing a desktop Linux user agent for "Request desktop site". | 184 // spoofing a desktop Linux user agent for "Request desktop site". |
180 // Automatically set it for all WebContents so that it is available when a | 185 // Automatically set it for all WebContents so that it is available when a |
181 // NavigationEntry requires the user agent to be overridden. | 186 // NavigationEntry requires the user agent to be overridden. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 ScopedJavaLocalRef<jobject> java_bitmap = | 583 ScopedJavaLocalRef<jobject> java_bitmap = |
579 gfx::ConvertToJavaBitmap(&zoomed_bitmap); | 584 gfx::ConvertToJavaBitmap(&zoomed_bitmap); |
580 DCHECK(!java_bitmap.is_null()); | 585 DCHECK(!java_bitmap.is_null()); |
581 | 586 |
582 Java_ContentViewCore_showDisambiguationPopup(env, | 587 Java_ContentViewCore_showDisambiguationPopup(env, |
583 obj.obj(), | 588 obj.obj(), |
584 rect_object.obj(), | 589 rect_object.obj(), |
585 java_bitmap.obj()); | 590 java_bitmap.obj()); |
586 } | 591 } |
587 | 592 |
588 gfx::Rect ContentViewCoreImpl::GetBounds() const { | 593 gfx::Size ContentViewCoreImpl::GetPhysicalSize() const { |
589 JNIEnv* env = AttachCurrentThread(); | 594 JNIEnv* env = AttachCurrentThread(); |
590 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 595 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
591 if (j_obj.is_null()) | 596 if (j_obj.is_null()) |
592 return gfx::Rect(); | 597 return gfx::Size(); |
593 return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()), | 598 return gfx::Size(Java_ContentViewCore_getWidth(env, j_obj.obj()), |
594 Java_ContentViewCore_getHeight(env, j_obj.obj())); | 599 Java_ContentViewCore_getHeight(env, j_obj.obj())); |
595 } | 600 } |
596 | 601 |
| 602 gfx::Size ContentViewCoreImpl::GetDIPSize() const { |
| 603 return gfx::ToCeiledSize(gfx::ScaleSize(GetPhysicalSize(), 1 / DpiScale())); |
| 604 } |
| 605 |
597 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { | 606 void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) { |
598 root_layer_->addChild(layer); | 607 root_layer_->addChild(layer); |
599 } | 608 } |
600 | 609 |
601 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { | 610 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { |
602 layer->removeFromParent(); | 611 layer->removeFromParent(); |
603 } | 612 } |
604 | 613 |
605 void ContentViewCoreImpl::DidProduceRendererFrame() { | 614 void ContentViewCoreImpl::DidProduceRendererFrame() { |
606 renderer_frame_pending_ = true; | 615 renderer_frame_pending_ = true; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { | 1368 if (!HasField(env, clazz, "mNativeContentViewCore", "I")) { |
1360 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; | 1369 DLOG(ERROR) << "Unable to find ContentView.mNativeContentViewCore!"; |
1361 return false; | 1370 return false; |
1362 } | 1371 } |
1363 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); | 1372 g_native_content_view = GetFieldID(env, clazz, "mNativeContentViewCore", "I"); |
1364 | 1373 |
1365 return RegisterNativesImpl(env) >= 0; | 1374 return RegisterNativesImpl(env) >= 0; |
1366 } | 1375 } |
1367 | 1376 |
1368 } // namespace content | 1377 } // namespace content |
OLD | NEW |