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

Unified Diff: content/renderer/render_view_impl.cc

Issue 9609008: Implemented Browser Plugin (NOT FOR REVIEW) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Initial plumbing of a guest flag to RenderViewImpl (cleaner than early prototype) Created 8 years, 9 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_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 3e59c4a9b643091fd8e35480b4daf5dfc1b9df4f..fc3c7abe9b544791e24f5d1ee9df600080d34f55 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -55,6 +55,7 @@
#include "content/renderer/dom_automation_controller.h"
#include "content/renderer/external_popup_menu.h"
#include "content/renderer/geolocation_dispatcher.h"
+#include "content/renderer/guest_render_view_observer.h"
#include "content/renderer/idle_user_detector.h"
#include "content/renderer/input_tag_speech_dispatcher.h"
#include "content/renderer/web_intents_host.h"
@@ -73,6 +74,7 @@
#include "content/renderer/notification_provider.h"
#include "content/renderer/p2p/socket_dispatcher.h"
#include "content/renderer/plugin_channel_host.h"
+#include "content/renderer/plugins/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"
@@ -165,6 +167,7 @@
#include "webkit/plugins/npapi/plugin_list.h"
#include "webkit/plugins/npapi/webplugin_delegate.h"
#include "webkit/plugins/npapi/webplugin_delegate_impl.h"
+#include "webkit/plugins/plugin_constants.h"
#include "webkit/plugins/npapi/webplugin_impl.h"
#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
@@ -419,7 +422,8 @@ RenderViewImpl::RenderViewImpl(
int64 session_storage_namespace_id,
const string16& frame_name,
int32 next_page_id,
- const WebKit::WebScreenInfo& screen_info)
+ const WebKit::WebScreenInfo& screen_info,
+ bool guest)
: RenderWidget(WebKit::WebPopupTypeNone, screen_info),
webkit_preferences_(webkit_prefs),
send_content_state_immediately_(false),
@@ -444,6 +448,7 @@ RenderViewImpl::RenderViewImpl(
queried_for_swapbuffers_complete_callback_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
geolocation_dispatcher_(NULL),
+ guest_observer_(NULL),
input_tag_speech_dispatcher_(NULL),
device_orientation_dispatcher_(NULL),
media_stream_dispatcher_(NULL),
@@ -456,6 +461,7 @@ RenderViewImpl::RenderViewImpl(
#if defined(OS_WIN)
focused_plugin_id_(-1),
#endif
+ guest_(guest),
ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) {
routing_id_ = routing_id;
surface_id_ = surface_id;
@@ -492,11 +498,21 @@ RenderViewImpl::RenderViewImpl(
// completing initialization. Otherwise, we can finish it now.
if (opener_id == MSG_ROUTING_NONE) {
did_show_ = true;
- CompleteInit(parent_hwnd);
+ // TODO(fsamuel): Telling the RenderView to delay
+ // deferred updates doesn't seem to work correctly.
+ // This needs more investigation.
+ CompleteInit(parent_hwnd, false);
}
g_view_map.Get().insert(std::make_pair(webview(), this));
webkit_preferences_.Apply(webview());
+
+ // This needs to be before initializeMainFrame it seems.
+ // PpapiMsg_CreateChannel messages can get lost if the guest
+ // observer has not been constructed before a sync message.
+ if (!guest_observer_)
+ guest_observer_ = new GuestRenderViewObserver(this);
+
webview()->initializeMainFrame(this);
if (!frame_name.empty())
webview()->mainFrame()->setName(frame_name);
@@ -619,7 +635,8 @@ RenderViewImpl* RenderViewImpl::Create(
int64 session_storage_namespace_id,
const string16& frame_name,
int32 next_page_id,
- const WebKit::WebScreenInfo& screen_info) {
+ const WebKit::WebScreenInfo& screen_info,
+ bool guest) {
DCHECK(routing_id != MSG_ROUTING_NONE);
return new RenderViewImpl(
parent_hwnd,
@@ -632,7 +649,8 @@ RenderViewImpl* RenderViewImpl::Create(
session_storage_namespace_id,
frame_name,
next_page_id,
- screen_info);
+ screen_info,
+ guest);
}
WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
@@ -826,13 +844,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()
-
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;
}
@@ -1466,6 +1482,9 @@ WebView* RenderViewImpl::createView(
if (routing_id == MSG_ROUTING_NONE)
return NULL;
+ // TODO(fsamuel): The host renderer needs to be able to
+ // control whether the guest renderer is allowed to do this
+ // or not. This current behavior is not well defined.
RenderViewImpl* view = RenderViewImpl::Create(
0,
routing_id_,
@@ -1477,7 +1496,8 @@ WebView* RenderViewImpl::createView(
cloned_session_storage_namespace_id,
frame_name,
1,
- screen_info_);
+ screen_info_,
+ guest_);
view->opened_by_user_gesture_ = params.user_gesture;
// Record whether the creator frame is trying to suppress the opener field.
@@ -1549,6 +1569,9 @@ WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D(
bool direct) {
if (!webview())
return NULL;
+
+ if (guest_observer_ && guest_observer_->GetWebGraphicsContext3D())
+ return guest_observer_->GetWebGraphicsContext3D();
// The WebGraphicsContext3DInProcessImpl code path is used for
// layout tests (though not through this code) as well as for
// debugging and bringing up new ports.
@@ -2063,6 +2086,14 @@ bool RenderViewImpl::isPointerLocked() {
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.
+ if (UTF16ToASCII(params.mimeType) == kBrowserPluginMimeType)
+ return BrowserPluginPlaceholder::Create(this, frame, params);
+
WebPlugin* plugin = NULL;
if (content::GetContentClient()->renderer()->OverrideCreatePlugin(
this, frame, params, &plugin)) {
@@ -3432,10 +3463,24 @@ bool RenderViewImpl::IsEditableNode(const WebKit::WebNode& node) {
return is_editable_node;
}
+WebKit::WebPlugin* RenderViewImpl::CreateBrowserPlugin(
+ base::ProcessHandle process_handle,
+ const IPC::ChannelHandle& channel_handle,
+ const WebKit::WebPluginParams& params) {
+ // We do not currently support guests hosting guests.
+ DCHECK(!guest_);
+ scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
+ pepper_delegate_.CreateBrowserPluginModule(process_handle,
+ channel_handle));
+ return new webkit::ppapi::WebPluginImpl(
+ pepper_module.get(), params, pepper_delegate_.AsWeakPtr());
+}
+
WebKit::WebPlugin* RenderViewImpl::CreatePlugin(
WebKit::WebFrame* frame,
const webkit::WebPluginInfo& info,
const WebKit::WebPluginParams& params) {
+
bool pepper_plugin_was_registered = false;
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
pepper_delegate_.CreatePepperPluginModule(info,
@@ -4485,6 +4530,11 @@ void RenderViewImpl::OnViewContextSwapBuffersAborted() {
RenderWidget::OnSwapBuffersAborted();
}
+void RenderViewImpl::OnGuestReady() {
+ host_window_set_ = true;
+ DoDeferredUpdate();
+}
+
webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint(
const gfx::Rect& paint_bounds,
TransportDIB** dib,
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698