Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Unified Diff: content/renderer/render_widget.cc

Issue 1962923002: Fix rendering of flash content inside an out-of-process iframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for android builds Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_owner_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index fb309d7b86e37e32daf668e308166df76f4c2284..8776bd017319f196dc5fb5dbdd8b7567b403fd0a 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -32,6 +32,7 @@
#include "components/scheduler/renderer/render_widget_scheduling_state.h"
#include "components/scheduler/renderer/renderer_scheduler.h"
#include "content/common/content_switches_internal.h"
+#include "content/common/frame_messages.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu_process_launch_causes.h"
#include "content/common/input/synthetic_gesture_packet.h"
@@ -81,6 +82,7 @@
#include "third_party/WebKit/public/web/WebRange.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebView.h"
+#include "third_party/WebKit/public/web/WebWidget.h"
#include "third_party/skia/include/core/SkShader.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -96,6 +98,11 @@
#include "content/renderer/android/synchronous_compositor_output_surface.h"
#endif
+#if defined(ENABLE_PLUGINS)
+#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
+#include "content/renderer/pepper/pepper_plugin_registry.h"
+#endif
+
#if defined(OS_POSIX)
#include "ipc/ipc_channel_posix.h"
#include "third_party/skia/include/core/SkMallocPixelRef.h"
@@ -107,8 +114,6 @@
#include "content/renderer/mus/render_widget_mus_connection.h"
#endif
-#include "third_party/WebKit/public/web/WebWidget.h"
-
using blink::WebCompositionUnderline;
using blink::WebCursorInfo;
using blink::WebDeviceEmulationParams;
@@ -247,6 +252,10 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
popup_origin_scale_for_emulation_(0.f),
frame_swap_message_queue_(new FrameSwapMessageQueue()),
resizing_mode_selector_(new ResizingModeSelector()),
+#if defined(ENABLE_PLUGINS)
+ focused_pepper_plugin_(nullptr),
+ pepper_last_mouse_event_target_(nullptr),
+#endif
has_host_context_menu_location_(false) {
if (!swapped_out)
RenderProcess::current()->AddRefProcess();
@@ -614,6 +623,12 @@ void RenderWidget::OnWasHidden() {
SetHidden(true);
FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
WasHidden());
+
+#if defined(ENABLE_PLUGINS)
+ for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
dcheng 2016/05/10 18:57:58 Drive-by: I know the original code was written lik
+ i != active_pepper_instances_.end(); ++i)
+ (*i)->PageVisibilityChanged(false);
+#endif // ENABLE_PLUGINS
}
void RenderWidget::OnWasShown(bool needs_repainting,
@@ -639,6 +654,12 @@ void RenderWidget::OnWasShown(bool needs_repainting,
compositor_->SetNeedsForcedRedraw();
}
ScheduleComposite();
+
+#if defined(ENABLE_PLUGINS)
+ for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
+ i != active_pepper_instances_.end(); ++i)
+ (*i)->PageVisibilityChanged(true);
+#endif // ENABLE_PLUGINS
}
void RenderWidget::OnRequestMoveAck() {
@@ -673,6 +694,13 @@ void RenderWidget::OnMouseCaptureLost() {
void RenderWidget::OnSetFocus(bool enable) {
if (webwidget_)
webwidget_->setFocus(enable);
+
+#if defined(ENABLE_PLUGINS)
+ // Notify all Pepper plugins.
+ for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
+ i != active_pepper_instances_.end(); ++i)
+ (*i)->SetContentAreaFocus(enable);
+#endif
}
///////////////////////////////////////////////////////////////////////////////
@@ -1057,6 +1085,17 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
}
bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) {
+#if defined(ENABLE_PLUGINS)
+ // This method is called for every mouse event that the RenderWidget receives.
+ // And then the mouse event is forwarded to blink, which dispatches it to the
+ // event target. Potentially a Pepper plugin will receive the event.
+ // In order to tell whether a plugin gets the last mouse event and which it
+ // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
+ // the event, it will notify us via DidReceiveMouseEvent() and set itself as
+ // |pepper_last_mouse_event_target_|.
+ pepper_last_mouse_event_target_ = nullptr;
+#endif
+
if (owner_delegate_)
return owner_delegate_->RenderWidgetWillHandleGestureEvent(event);
@@ -1694,8 +1733,16 @@ void RenderWidget::OnOrientationChange() {
}
void RenderWidget::DidInitiatePaint() {
- if (owner_delegate_)
- owner_delegate_->RenderWidgetDidCommitAndDrawCompositorFrame();
+#if defined(ENABLE_PLUGINS)
+ // Notify all instances that we painted. The same caveats apply as for
+ // ViewFlushedPaint regarding instances closing themselves, so we take
+ // similar precautions.
+ PepperPluginSet plugins = active_pepper_instances_;
+ for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) {
+ if (active_pepper_instances_.find(*i) != active_pepper_instances_.end())
+ (*i)->ViewInitiatedPaint();
+ }
+#endif
}
void RenderWidget::DidFlushPaint() {
@@ -2080,4 +2127,40 @@ float RenderWidget::GetOriginalDeviceScaleFactor() const {
device_scale_factor_;
}
+#if defined(ENABLE_PLUGINS)
+void RenderWidget::PepperInstanceCreated(PepperPluginInstanceImpl* instance) {
+ active_pepper_instances_.insert(instance);
+
+ RenderFrameImpl* const render_frame = instance->render_frame();
+ render_frame->Send(
+ new FrameHostMsg_PepperInstanceCreated(render_frame->GetRoutingID()));
+}
+
+void RenderWidget::PepperInstanceDeleted(PepperPluginInstanceImpl* instance) {
+ active_pepper_instances_.erase(instance);
+
+ if (pepper_last_mouse_event_target_ == instance)
+ pepper_last_mouse_event_target_ = nullptr;
+ if (focused_pepper_plugin_ == instance)
+ PepperFocusChanged(instance, false);
+
+ RenderFrameImpl* const render_frame = instance->render_frame();
+ if (render_frame)
+ render_frame->Send(
+ new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID()));
+}
+
+void RenderWidget::PepperFocusChanged(PepperPluginInstanceImpl* instance,
+ bool focused) {
+ if (focused)
+ focused_pepper_plugin_ = instance;
+ else if (focused_pepper_plugin_ == instance)
+ focused_pepper_plugin_ = nullptr;
+
+ UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
+ UpdateSelectionBounds();
+}
+
+#endif // ENABLE_PLUGINS
+
} // namespace content
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_owner_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698