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/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_offset_string_conversions.h" | 16 #include "base/strings/utf_offset_string_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 21 #include "build/build_config.h" |
21 #include "cc/blink/web_layer_impl.h" | 22 #include "cc/blink/web_layer_impl.h" |
22 #include "cc/layers/texture_layer.h" | 23 #include "cc/layers/texture_layer.h" |
23 #include "content/common/content_constants_internal.h" | 24 #include "content/common/content_constants_internal.h" |
24 #include "content/common/frame_messages.h" | 25 #include "content/common/frame_messages.h" |
25 #include "content/public/common/content_constants.h" | 26 #include "content/public/common/content_constants.h" |
26 #include "content/public/renderer/content_renderer_client.h" | 27 #include "content/public/renderer/content_renderer_client.h" |
27 #include "content/renderer/pepper/content_decryptor_delegate.h" | 28 #include "content/renderer/pepper/content_decryptor_delegate.h" |
28 #include "content/renderer/pepper/event_conversion.h" | 29 #include "content/renderer/pepper/event_conversion.h" |
29 #include "content/renderer/pepper/fullscreen_container.h" | 30 #include "content/renderer/pepper/fullscreen_container.h" |
30 #include "content/renderer/pepper/gfx_conversion.h" | 31 #include "content/renderer/pepper/gfx_conversion.h" |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // incompatible with the move and backfill scrolling model. | 761 // incompatible with the move and backfill scrolling model. |
761 InvalidateRect(rect); | 762 InvalidateRect(rect); |
762 } | 763 } |
763 } | 764 } |
764 } | 765 } |
765 | 766 |
766 void PepperPluginInstanceImpl::CommitBackingTexture() { | 767 void PepperPluginInstanceImpl::CommitBackingTexture() { |
767 if (!texture_layer_.get()) | 768 if (!texture_layer_.get()) |
768 return; | 769 return; |
769 gpu::Mailbox mailbox; | 770 gpu::Mailbox mailbox; |
770 uint32 sync_point = 0; | 771 uint32_t sync_point = 0; |
771 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 772 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
772 DCHECK(!mailbox.IsZero()); | 773 DCHECK(!mailbox.IsZero()); |
773 DCHECK_NE(sync_point, 0u); | 774 DCHECK_NE(sync_point, 0u); |
774 texture_layer_->SetTextureMailboxWithoutReleaseCallback( | 775 texture_layer_->SetTextureMailboxWithoutReleaseCallback( |
775 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), GL_TEXTURE_2D)); | 776 cc::TextureMailbox(mailbox, gpu::SyncToken(sync_point), GL_TEXTURE_2D)); |
776 texture_layer_->SetNeedsDisplay(); | 777 texture_layer_->SetNeedsDisplay(); |
777 } | 778 } |
778 | 779 |
779 void PepperPluginInstanceImpl::InstanceCrashed() { | 780 void PepperPluginInstanceImpl::InstanceCrashed() { |
780 // Force free all resources and vars. | 781 // Force free all resources and vars. |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 NOTREACHED(); | 1952 NOTREACHED(); |
1952 #endif // ENABLE_PRINTING | 1953 #endif // ENABLE_PRINTING |
1953 return false; | 1954 return false; |
1954 } | 1955 } |
1955 | 1956 |
1956 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { | 1957 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { |
1957 if (!container_) | 1958 if (!container_) |
1958 return; | 1959 return; |
1959 | 1960 |
1960 gpu::Mailbox mailbox; | 1961 gpu::Mailbox mailbox; |
1961 uint32 sync_point = 0; | 1962 uint32_t sync_point = 0; |
1962 if (bound_graphics_3d_.get()) { | 1963 if (bound_graphics_3d_.get()) { |
1963 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 1964 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
1964 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | 1965 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); |
1965 } | 1966 } |
1966 bool want_3d_layer = !mailbox.IsZero(); | 1967 bool want_3d_layer = !mailbox.IsZero(); |
1967 bool want_2d_layer = !!bound_graphics_2d_platform_; | 1968 bool want_2d_layer = !!bound_graphics_2d_platform_; |
1968 bool want_texture_layer = want_3d_layer || want_2d_layer; | 1969 bool want_texture_layer = want_3d_layer || want_2d_layer; |
1969 bool want_compositor_layer = !!bound_compositor_; | 1970 bool want_compositor_layer = !!bound_compositor_; |
1970 | 1971 |
1971 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { | 1972 if (throttler_ && throttler_->IsHiddenForPlaceholder()) { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 return PP_MakeUndefined(); | 2385 return PP_MakeUndefined(); |
2385 return StringVar::StringToPPVar( | 2386 return StringVar::StringToPPVar( |
2386 render_frame_->render_view()->webkit_preferences().default_encoding); | 2387 render_frame_->render_view()->webkit_preferences().default_encoding); |
2387 } | 2388 } |
2388 | 2389 |
2389 // These PPB_ContentDecryptor_Private calls are responses to | 2390 // These PPB_ContentDecryptor_Private calls are responses to |
2390 // PPP_ContentDecryptor_Private calls made on |content_decryptor_delegate_|. | 2391 // PPP_ContentDecryptor_Private calls made on |content_decryptor_delegate_|. |
2391 // Therefore, |content_decryptor_delegate_| must have been initialized when | 2392 // Therefore, |content_decryptor_delegate_| must have been initialized when |
2392 // the following methods are called. | 2393 // the following methods are called. |
2393 void PepperPluginInstanceImpl::PromiseResolved(PP_Instance instance, | 2394 void PepperPluginInstanceImpl::PromiseResolved(PP_Instance instance, |
2394 uint32 promise_id) { | 2395 uint32_t promise_id) { |
2395 content_decryptor_delegate_->OnPromiseResolved(promise_id); | 2396 content_decryptor_delegate_->OnPromiseResolved(promise_id); |
2396 } | 2397 } |
2397 | 2398 |
2398 void PepperPluginInstanceImpl::PromiseResolvedWithSession( | 2399 void PepperPluginInstanceImpl::PromiseResolvedWithSession( |
2399 PP_Instance instance, | 2400 PP_Instance instance, |
2400 uint32 promise_id, | 2401 uint32_t promise_id, |
2401 PP_Var session_id_var) { | 2402 PP_Var session_id_var) { |
2402 content_decryptor_delegate_->OnPromiseResolvedWithSession(promise_id, | 2403 content_decryptor_delegate_->OnPromiseResolvedWithSession(promise_id, |
2403 session_id_var); | 2404 session_id_var); |
2404 } | 2405 } |
2405 | 2406 |
2406 void PepperPluginInstanceImpl::PromiseRejected( | 2407 void PepperPluginInstanceImpl::PromiseRejected( |
2407 PP_Instance instance, | 2408 PP_Instance instance, |
2408 uint32 promise_id, | 2409 uint32_t promise_id, |
2409 PP_CdmExceptionCode exception_code, | 2410 PP_CdmExceptionCode exception_code, |
2410 uint32 system_code, | 2411 uint32_t system_code, |
2411 PP_Var error_description_var) { | 2412 PP_Var error_description_var) { |
2412 content_decryptor_delegate_->OnPromiseRejected( | 2413 content_decryptor_delegate_->OnPromiseRejected( |
2413 promise_id, exception_code, system_code, error_description_var); | 2414 promise_id, exception_code, system_code, error_description_var); |
2414 } | 2415 } |
2415 | 2416 |
2416 void PepperPluginInstanceImpl::SessionMessage(PP_Instance instance, | 2417 void PepperPluginInstanceImpl::SessionMessage(PP_Instance instance, |
2417 PP_Var session_id_var, | 2418 PP_Var session_id_var, |
2418 PP_CdmMessageType message_type, | 2419 PP_CdmMessageType message_type, |
2419 PP_Var message_var, | 2420 PP_Var message_var, |
2420 PP_Var legacy_destination_url) { | 2421 PP_Var legacy_destination_url) { |
(...skipping 21 matching lines...) Expand all Loading... |
2442 | 2443 |
2443 void PepperPluginInstanceImpl::SessionClosed(PP_Instance instance, | 2444 void PepperPluginInstanceImpl::SessionClosed(PP_Instance instance, |
2444 PP_Var session_id_var) { | 2445 PP_Var session_id_var) { |
2445 content_decryptor_delegate_->OnSessionClosed(session_id_var); | 2446 content_decryptor_delegate_->OnSessionClosed(session_id_var); |
2446 } | 2447 } |
2447 | 2448 |
2448 void PepperPluginInstanceImpl::LegacySessionError( | 2449 void PepperPluginInstanceImpl::LegacySessionError( |
2449 PP_Instance instance, | 2450 PP_Instance instance, |
2450 PP_Var session_id_var, | 2451 PP_Var session_id_var, |
2451 PP_CdmExceptionCode exception_code, | 2452 PP_CdmExceptionCode exception_code, |
2452 uint32 system_code, | 2453 uint32_t system_code, |
2453 PP_Var error_description_var) { | 2454 PP_Var error_description_var) { |
2454 content_decryptor_delegate_->OnLegacySessionError( | 2455 content_decryptor_delegate_->OnLegacySessionError( |
2455 session_id_var, exception_code, system_code, error_description_var); | 2456 session_id_var, exception_code, system_code, error_description_var); |
2456 } | 2457 } |
2457 | 2458 |
2458 void PepperPluginInstanceImpl::DeliverBlock( | 2459 void PepperPluginInstanceImpl::DeliverBlock( |
2459 PP_Instance instance, | 2460 PP_Instance instance, |
2460 PP_Resource decrypted_block, | 2461 PP_Resource decrypted_block, |
2461 const PP_DecryptedBlockInfo* block_info) { | 2462 const PP_DecryptedBlockInfo* block_info) { |
2462 content_decryptor_delegate_->DeliverBlock(decrypted_block, block_info); | 2463 content_decryptor_delegate_->DeliverBlock(decrypted_block, block_info); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 } | 2534 } |
2534 | 2535 |
2535 void PepperPluginInstanceImpl::SetTickmarks(PP_Instance instance, | 2536 void PepperPluginInstanceImpl::SetTickmarks(PP_Instance instance, |
2536 const PP_Rect* tickmarks, | 2537 const PP_Rect* tickmarks, |
2537 uint32_t count) { | 2538 uint32_t count) { |
2538 if (!render_frame_ || !render_frame_->GetWebFrame()) | 2539 if (!render_frame_ || !render_frame_->GetWebFrame()) |
2539 return; | 2540 return; |
2540 | 2541 |
2541 blink::WebVector<blink::WebRect> tickmarks_converted( | 2542 blink::WebVector<blink::WebRect> tickmarks_converted( |
2542 static_cast<size_t>(count)); | 2543 static_cast<size_t>(count)); |
2543 for (uint32 i = 0; i < count; ++i) { | 2544 for (uint32_t i = 0; i < count; ++i) { |
2544 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, | 2545 tickmarks_converted[i] = blink::WebRect(tickmarks[i].point.x, |
2545 tickmarks[i].point.y, | 2546 tickmarks[i].point.y, |
2546 tickmarks[i].size.width, | 2547 tickmarks[i].size.width, |
2547 tickmarks[i].size.height); | 2548 tickmarks[i].size.height); |
2548 } | 2549 } |
2549 blink::WebFrame* frame = render_frame_->GetWebFrame(); | 2550 blink::WebFrame* frame = render_frame_->GetWebFrame(); |
2550 frame->setTickmarks(tickmarks_converted); | 2551 frame->setTickmarks(tickmarks_converted); |
2551 } | 2552 } |
2552 | 2553 |
2553 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { | 2554 PP_Bool PepperPluginInstanceImpl::IsFullscreen(PP_Instance instance) { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3274 | 3275 |
3275 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3276 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
3276 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3277 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
3277 javascript_used_ = true; | 3278 javascript_used_ = true; |
3278 RenderThread::Get()->RecordAction( | 3279 RenderThread::Get()->RecordAction( |
3279 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3280 base::UserMetricsAction("Flash.JavaScriptUsed")); |
3280 } | 3281 } |
3281 } | 3282 } |
3282 | 3283 |
3283 } // namespace content | 3284 } // namespace content |
OLD | NEW |