Chromium Code Reviews| Index: content/renderer/render_view_impl.cc |
| diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc |
| index 58cdf35d89b74a57b91cfe0ad80556ae4178ba2b..d127addae0bef6e7dc65c6f0c6bde62eda641a5b 100644 |
| --- a/content/renderer/render_view_impl.cc |
| +++ b/content/renderer/render_view_impl.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| +#include "base/callback.h" |
| #include "base/command_line.h" |
| #include "base/compiler_specific.h" |
| #include "base/json/json_writer.h" |
| @@ -54,6 +55,7 @@ |
| #include "content/public/renderer/navigation_state.h" |
| #include "content/public/renderer/render_view_observer.h" |
| #include "content/public/renderer/render_view_visitor.h" |
| +#include "content/renderer/browser_plugin/guest_to_embedder_channel.h" |
| #include "content/renderer/device_orientation_dispatcher.h" |
| #include "content/renderer/devtools_agent.h" |
| #include "content/renderer/dom_automation_controller.h" |
| @@ -77,8 +79,8 @@ |
| #include "content/renderer/notification_provider.h" |
| #include "content/renderer/p2p/socket_dispatcher.h" |
| #include "content/renderer/plugin_channel_host.h" |
| +#include "content/renderer/browser_plugin/browser_plugin.h" |
| #include "content/renderer/browser_plugin/browser_plugin_constants.h" |
| -#include "content/renderer/browser_plugin/browser_plugin_placeholder.h" |
| #include "content/renderer/render_process.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "content/renderer/render_widget_fullscreen_pepper.h" |
| @@ -453,7 +455,7 @@ RenderViewImpl::RenderViewImpl( |
| bool swapped_out, |
| int32 next_page_id, |
| const WebKit::WebScreenInfo& screen_info, |
| - bool guest, |
| + content::GuestToEmbedderChannel* guest_to_embedder_channel, |
| AccessibilityMode accessibility_mode) |
| : RenderWidget(WebKit::WebPopupTypeNone, screen_info, swapped_out), |
| webkit_preferences_(webkit_prefs), |
| @@ -494,7 +496,9 @@ RenderViewImpl::RenderViewImpl( |
| #if defined(OS_WIN) |
| focused_plugin_id_(-1), |
| #endif |
| - guest_(guest), |
| + guest_to_embedder_channel_(guest_to_embedder_channel), |
| + pp_instance_(0), |
| + uninitialized_context_(NULL), |
| accessibility_mode_(accessibility_mode), |
| ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
| routing_id_ = routing_id; |
| @@ -532,13 +536,14 @@ RenderViewImpl::RenderViewImpl( |
| // If this is a popup, we must wait for the CreatingNew_ACK message before |
| // completing initialization. Otherwise, we can finish it now. |
| - if (opener_id_ == MSG_ROUTING_NONE) { |
| + if (!guest_to_embedder_channel && opener_id_ == MSG_ROUTING_NONE) { |
| did_show_ = true; |
| CompleteInit(parent_hwnd); |
| } |
| g_view_map.Get().insert(std::make_pair(webview(), this)); |
| webkit_preferences_.Apply(webview()); |
| + |
| webview()->initializeMainFrame(this); |
| if (!frame_name.empty()) |
| webview()->mainFrame()->setName(frame_name); |
| @@ -670,7 +675,7 @@ RenderViewImpl* RenderViewImpl::Create( |
| bool swapped_out, |
| int32 next_page_id, |
| const WebKit::WebScreenInfo& screen_info, |
| - bool guest, |
| + content::GuestToEmbedderChannel* guest_to_embedder_channel, |
| AccessibilityMode accessibility_mode) { |
| DCHECK(routing_id != MSG_ROUTING_NONE); |
| return new RenderViewImpl( |
| @@ -687,7 +692,7 @@ RenderViewImpl* RenderViewImpl::Create( |
| swapped_out, |
| next_page_id, |
| screen_info, |
| - guest, |
| + guest_to_embedder_channel, |
| accessibility_mode); |
| } |
| @@ -893,13 +898,11 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
| // Have the super handle all other messages. |
| IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| IPC_END_MESSAGE_MAP() |
| - |
|
jam
2012/05/16 02:22:40
why remove these blank lines?
Fady Samuel
2012/05/16 04:43:54
Restored.
|
| if (!msg_is_ok) { |
| // The message had a handler, but its deserialization failed. |
| // Kill the renderer to avoid potential spoofing attacks. |
| CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| } |
| - |
| return handled; |
| } |
| @@ -1557,7 +1560,7 @@ WebView* RenderViewImpl::createView( |
| false, |
| 1, |
| screen_info_, |
| - guest_, |
| + guest_to_embedder_channel_, |
| accessibility_mode_); |
| view->opened_by_user_gesture_ = params.user_gesture; |
| @@ -1614,6 +1617,18 @@ WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( |
| const WebGraphicsContext3D::Attributes& attributes) { |
| if (!webview()) |
| return NULL; |
| + |
| + if (guest_to_embedder_channel()) { |
| + WebGraphicsContext3DCommandBufferImpl* context = |
| + guest_to_embedder_channel()->CreateWebGraphicsContext3D( |
| + this, attributes, false); |
| + if (!pp_instance()) { |
| + uninitialized_context_ = context; |
| + attributes_ = attributes; |
| + } |
| + return context; |
| + } |
| + |
| // The WebGraphicsContext3DInProcessImpl code path is used for |
| // layout tests (though not through this code) as well as for |
| // debugging and bringing up new ports. |
| @@ -2136,14 +2151,10 @@ void RenderViewImpl::didActivateCompositor(int input_handler_identifier) { |
| WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| const WebPluginParams& params) { |
| - // The browser plugin is a special kind of pepper plugin |
| - // that loads asynchronously. We first create a placeholder here. |
| - // When a guest is ready to be displayed, we swap out the placeholder |
| - // with the guest. |
| const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| if (command_line.HasSwitch(switches::kEnableBrowserPlugin) && |
| UTF16ToASCII(params.mimeType) == kBrowserPluginMimeType) |
| - return BrowserPluginPlaceholder::Create(this, frame, params); |
| + return BrowserPlugin::Create(this, frame, params); |
| WebPlugin* plugin = NULL; |
| if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
| @@ -3638,6 +3649,30 @@ bool RenderViewImpl::IsEditableNode(const WebKit::WebNode& node) const { |
| return is_editable_node; |
| } |
| +void RenderViewImpl::GuestReady(PP_Instance instance) { |
| + pp_instance_ = instance; |
| + if (uninitialized_context_) { |
| + bool success = guest_to_embedder_channel()->CreateGraphicsContext( |
| + uninitialized_context_, |
| + attributes_, |
| + false, |
| + this); |
| + DCHECK(success); |
| + } |
| + CompleteInit(host_window_); |
| +} |
| + |
| +webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin( |
| + const IPC::ChannelHandle& channel_handle, |
| + int guest_process_id, |
| + const WebKit::WebPluginParams& params) { |
| + scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| + pepper_delegate_.CreateBrowserPluginModule(channel_handle, |
| + guest_process_id)); |
| + return new webkit::ppapi::WebPluginImpl( |
| + pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| +} |
| + |
| WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
| WebKit::WebFrame* frame, |
| const webkit::WebPluginInfo& info, |
| @@ -4726,6 +4761,8 @@ void RenderViewImpl::WillInitiatePaint() { |
| void RenderViewImpl::DidInitiatePaint() { |
| // Notify the pepper plugins that we've painted, and are waiting to flush. |
| pepper_delegate_.ViewInitiatedPaint(); |
| + if (guest_to_embedder_channel()) |
| + guest_to_embedder_channel()->IssueSwapBuffers(host_resource()); |
| } |
| void RenderViewImpl::DidFlushPaint() { |