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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ui::ViewAndroid* view_android, | 218 ui::ViewAndroid* view_android, |
218 ui::WindowAndroid* window_android, | 219 ui::WindowAndroid* window_android, |
219 jobject java_bridge_retained_object_set) | 220 jobject java_bridge_retained_object_set) |
220 : WebContentsObserver(web_contents), | 221 : WebContentsObserver(web_contents), |
221 java_ref_(env, obj), | 222 java_ref_(env, obj), |
222 web_contents_(static_cast<WebContentsImpl*>(web_contents)), | 223 web_contents_(static_cast<WebContentsImpl*>(web_contents)), |
223 root_layer_(cc::SolidColorLayer::Create()), | 224 root_layer_(cc::SolidColorLayer::Create()), |
224 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), | 225 dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()), |
225 view_android_(view_android), | 226 view_android_(view_android), |
226 window_android_(window_android), | 227 window_android_(window_android), |
227 device_orientation_(0), | 228 device_orientation_(0) { |
228 geolocation_needs_pause_(false) { | |
229 CHECK(web_contents) << | 229 CHECK(web_contents) << |
230 "A ContentViewCoreImpl should be created with a valid WebContents."; | 230 "A ContentViewCoreImpl should be created with a valid WebContents."; |
231 | 231 |
232 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); | 232 root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj)); |
233 gfx::Size physical_size( | 233 gfx::Size physical_size( |
234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), | 234 Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj), |
235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); | 235 Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj)); |
236 root_layer_->SetBounds(physical_size); | 236 root_layer_->SetBounds(physical_size); |
237 root_layer_->SetIsDrawable(true); | 237 root_layer_->SetIsDrawable(true); |
238 | 238 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 web_contents_->GetRenderViewHost()); | 325 web_contents_->GetRenderViewHost()); |
326 if (new_pid != old_pid) { | 326 if (new_pid != old_pid) { |
327 // Notify the Java side of the change of the current renderer process. | 327 // Notify the Java side of the change of the current renderer process. |
328 JNIEnv* env = AttachCurrentThread(); | 328 JNIEnv* env = AttachCurrentThread(); |
329 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 329 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
330 if (!obj.is_null()) { | 330 if (!obj.is_null()) { |
331 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj()); | 331 Java_ContentViewCore_onRenderProcessSwap(env, obj.obj()); |
332 } | 332 } |
333 } | 333 } |
334 SetFocusInternal(HasFocus()); | 334 SetFocusInternal(HasFocus()); |
335 if (geolocation_needs_pause_) | |
336 PauseOrResumeGeolocation(true); | |
337 break; | 335 break; |
338 } | 336 } |
339 case NOTIFICATION_RENDERER_PROCESS_CREATED: { | 337 case NOTIFICATION_RENDERER_PROCESS_CREATED: { |
340 // Notify the Java side of the current renderer process. | 338 // Notify the Java side of the current renderer process. |
341 RenderProcessHost* source_process_host = | 339 RenderProcessHost* source_process_host = |
342 Source<RenderProcessHost>(source).ptr(); | 340 Source<RenderProcessHost>(source).ptr(); |
343 RenderProcessHost* current_process_host = | 341 RenderProcessHost* current_process_host = |
344 web_contents_->GetRenderViewHost()->GetProcess(); | 342 web_contents_->GetRenderViewHost()->GetProcess(); |
345 | 343 |
346 if (source_process_host == current_process_host) { | 344 if (source_process_host == current_process_host) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 PauseVideo(); | 409 PauseVideo(); |
412 } | 410 } |
413 | 411 |
414 void ContentViewCoreImpl::PauseVideo() { | 412 void ContentViewCoreImpl::PauseVideo() { |
415 RenderViewHost* host = web_contents_->GetRenderViewHost(); | 413 RenderViewHost* host = web_contents_->GetRenderViewHost(); |
416 if (host) | 414 if (host) |
417 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); | 415 host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); |
418 } | 416 } |
419 | 417 |
420 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { | 418 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { |
421 geolocation_needs_pause_ = should_pause; | 419 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause); |
422 RenderViewHostImpl* rvh = | |
423 static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | |
424 if (rvh) { | |
425 scoped_refptr<GeolocationDispatcherHost> geolocation_dispatcher = | |
426 static_cast<RenderProcessHostImpl*>( | |
427 web_contents_->GetRenderProcessHost())-> | |
428 geolocation_dispatcher_host(); | |
429 if (geolocation_dispatcher.get()) { | |
430 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
431 base::Bind(&GeolocationDispatcherHost::PauseOrResume, | |
432 geolocation_dispatcher, | |
433 rvh->GetRoutingID(), | |
434 should_pause)); | |
435 geolocation_needs_pause_ = false; | |
436 } | |
437 } | |
438 } | 420 } |
439 | 421 |
440 // All positions and sizes are in CSS pixels. | 422 // All positions and sizes are in CSS pixels. |
441 // Note that viewport_width/height is a best effort based. | 423 // Note that viewport_width/height is a best effort based. |
442 // ContentViewCore has the actual information about the physical viewport size. | 424 // ContentViewCore has the actual information about the physical viewport size. |
443 void ContentViewCoreImpl::UpdateFrameInfo( | 425 void ContentViewCoreImpl::UpdateFrameInfo( |
444 const gfx::Vector2dF& scroll_offset, | 426 const gfx::Vector2dF& scroll_offset, |
445 float page_scale_factor, | 427 float page_scale_factor, |
446 const gfx::Vector2dF& page_scale_factor_limits, | 428 const gfx::Vector2dF& page_scale_factor_limits, |
447 const gfx::SizeF& content_size, | 429 const gfx::SizeF& content_size, |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1671 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1690 retained_objects_set); | 1672 retained_objects_set); |
1691 return reinterpret_cast<intptr_t>(view); | 1673 return reinterpret_cast<intptr_t>(view); |
1692 } | 1674 } |
1693 | 1675 |
1694 bool RegisterContentViewCore(JNIEnv* env) { | 1676 bool RegisterContentViewCore(JNIEnv* env) { |
1695 return RegisterNativesImpl(env); | 1677 return RegisterNativesImpl(env); |
1696 } | 1678 } |
1697 | 1679 |
1698 } // namespace content | 1680 } // namespace content |
OLD | NEW |