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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "cc/layers/layer.h" | 17 #include "cc/layers/layer.h" |
18 #include "cc/layers/solid_color_layer.h" | 18 #include "cc/layers/solid_color_layer.h" |
19 #include "cc/output/begin_frame_args.h" | 19 #include "cc/output/begin_frame_args.h" |
20 #include "content/browser/android/gesture_event_type.h" | 20 #include "content/browser/android/gesture_event_type.h" |
21 #include "content/browser/android/interstitial_page_delegate_android.h" | 21 #include "content/browser/android/interstitial_page_delegate_android.h" |
22 #include "content/browser/android/load_url_params.h" | 22 #include "content/browser/android/load_url_params.h" |
23 #include "content/browser/frame_host/interstitial_page_impl.h" | 23 #include "content/browser/frame_host/interstitial_page_impl.h" |
24 #include "content/browser/frame_host/navigation_controller_impl.h" | 24 #include "content/browser/frame_host/navigation_controller_impl.h" |
25 #include "content/browser/frame_host/navigation_entry_impl.h" | 25 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 26 #include "content/browser/geolocation/geolocation_dispatcher_host.h" |
26 #include "content/browser/media/android/browser_media_player_manager.h" | 27 #include "content/browser/media/android/browser_media_player_manager.h" |
27 #include "content/browser/renderer_host/compositor_impl_android.h" | 28 #include "content/browser/renderer_host/compositor_impl_android.h" |
28 #include "content/browser/renderer_host/input/motion_event_android.h" | 29 #include "content/browser/renderer_host/input/motion_event_android.h" |
29 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" | 30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h
" |
30 #include "content/browser/renderer_host/input/web_input_event_util.h" | 31 #include "content/browser/renderer_host/input/web_input_event_util.h" |
31 #include "content/browser/renderer_host/java/java_bound_object.h" | 32 #include "content/browser/renderer_host/java/java_bound_object.h" |
32 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" | 33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager
.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
35 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 36 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 WebContents* web_contents, | 216 WebContents* web_contents, |
216 ui::ViewAndroid* view_android, | 217 ui::ViewAndroid* view_android, |
217 ui::WindowAndroid* window_android) | 218 ui::WindowAndroid* window_android) |
218 : WebContentsObserver(web_contents), | 219 : WebContentsObserver(web_contents), |
219 java_ref_(env, obj), | 220 java_ref_(env, obj), |
220 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 221 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
221 root_layer_(cc::SolidColorLayer::Create()), | 222 root_layer_(cc::SolidColorLayer::Create()), |
222 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), | 223 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), |
223 view_android_(view_android), | 224 view_android_(view_android), |
224 window_android_(window_android), | 225 window_android_(window_android), |
225 device_orientation_(0), | |
226 geolocation_needs_pause_(false), | 226 geolocation_needs_pause_(false), |
227 accessibility_enabled_(false) { | 227 accessibility_enabled_(false) { |
228 CHECK(web_contents) << | 228 CHECK(web_contents) << |
229 "A ContentViewCoreImpl should be created with a valid WebContents."; | 229 "A ContentViewCoreImpl should be created with a valid WebContents."; |
230 | 230 |
231 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); | 231 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); |
232 gfx::Size physical_size( | 232 gfx::Size physical_size( |
233 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 233 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
234 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | 234 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); |
235 root_layer_->SetBounds(physical_size); | 235 root_layer_->SetBounds(physical_size); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 PauseVideo(); | 408 PauseVideo(); |
409 } | 409 } |
410 | 410 |
411 void ContentViewCoreImpl::PauseVideo() { | 411 void ContentViewCoreImpl::PauseVideo() { |
412 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 412 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
413 if (host) | 413 if (host) |
414 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); | 414 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); |
415 } | 415 } |
416 | 416 |
417 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { | 417 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { |
418 geolocation_needs_pause_ = should_pause; | 418 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause); |
419 RenderViewHostImpl* rvh = | |
420 static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | |
421 if (rvh) { | |
422 scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher = | |
423 static_cast<RenderProcessHostImpl*>( | |
424 web_contents_->GetRenderProcessHost())-> | |
425 geolocation_dispatcher_host(); | |
426 if (geolocation_dispatcher.get()) { | |
427 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
428 base::Bind(&GeolocationDispatcherHost::PauseOrResume, | |
429 geolocation_dispatcher, | |
430 rvh->GetRoutingID(), | |
431 should_pause)); | |
432 geolocation_needs_pause_ = false; | |
433 } | |
434 } | |
435 } | 419 } |
436 | 420 |
437 // All positions and sizes are in CSS pixels. | 421 // All positions and sizes are in CSS pixels. |
438 // Note that viewport_width/height is a best effort based. | 422 // Note that viewport_width/height is a best effort based. |
439 // ContentViewCore has the actual information about the physical viewport size. | 423 // ContentViewCore has the actual information about the physical viewport size. |
440 void ContentViewCoreImpl::UpdateFrameInfo( | 424 void ContentViewCoreImpl::UpdateFrameInfo( |
441 const gfx::Vector2dF& scroll_offset, | 425 const gfx::Vector2dF& scroll_offset, |
442 float page_scale_factor, | 426 float page_scale_factor, |
443 const gfx::Vector2dF& page_scale_factor_limits, | 427 const gfx::Vector2dF& page_scale_factor_limits, |
444 const gfx::SizeF& content_size, | 428 const gfx::SizeF& content_size, |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1675 reinterpret_cast<ui::ViewAndroid*>(view_android), |
1692 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1676 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
1693 return reinterpret_cast<intptr_t>(view); | 1677 return reinterpret_cast<intptr_t>(view); |
1694 } | 1678 } |
1695 | 1679 |
1696 bool RegisterContentViewCore(JNIEnv* env) { | 1680 bool RegisterContentViewCore(JNIEnv* env) { |
1697 return RegisterNativesImpl(env); | 1681 return RegisterNativesImpl(env); |
1698 } | 1682 } |
1699 | 1683 |
1700 } // namespace content | 1684 } // namespace content |
OLD | NEW |