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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: sync + Address Albert's comments. Created 8 years, 3 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
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a14bf00b396de805ab673a83de700799769fe16d..978bc5947287d9ffc2de66bfb3543d1680a6dafd 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -15,6 +15,8 @@
#include "base/sys_info.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
+#include "content/browser/browser_plugin/browser_plugin_embedder.h"
+#include "content/browser/browser_plugin/browser_plugin_guest.h"
#include "content/browser/browser_plugin/old/old_browser_plugin_host.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/debugger/devtools_manager_impl.h"
@@ -35,6 +37,7 @@
#include "content/browser/web_contents/interstitial_page_impl.h"
#include "content/browser/web_contents/navigation_entry_impl.h"
#include "content/browser/webui/web_ui_impl.h"
+#include "content/common/browser_plugin_messages.h"
#include "content/common/intents_messages.h"
#include "content/common/ssl_status_serialization.h"
#include "content/common/view_messages.h"
@@ -687,6 +690,8 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestPpapiBrokerPermission,
OnRequestPpapiBrokerPermission)
+ IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateGuest,
+ OnBrowserPluginNavigateGuest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
message_source_ = NULL;
@@ -2274,6 +2279,27 @@ void WebContentsImpl::OnPpapiBrokerPermissionResult(int request_id,
result));
}
+void WebContentsImpl::OnBrowserPluginNavigateGuest(int instance_id,
+ int64 frame_id,
+ const std::string& src,
+ const gfx::Size& size) {
+ // This is the first 'navigate' to a browser plugin, before WebContents has/is
+ // an 'Embedder'; subsequent navigate messages for this WebContents will
+ // be handled by the BrowserPluginEmbedderHelper of the embedder itself (this
+ // also means any message from browser plugin renderer prior to NavigateGuest
+ // which is not NavigateGuest will be ignored). Therefore
+ // |browser_plugin_embedder_| should not be set.
+ CHECK(!browser_plugin_embedder_.get());
+
+ browser_plugin_embedder_.reset(
+ content::BrowserPluginEmbedder::Create(this, GetRenderViewHost()));
+ browser_plugin_embedder_->NavigateGuest(GetRenderViewHost(),
+ instance_id,
+ frame_id,
+ src,
+ size);
+}
+
// Notifies the RenderWidgetHost instance about the fact that the page is
// loading, or done loading and calls the base implementation.
void WebContentsImpl::SetIsLoading(bool is_loading,
@@ -2430,6 +2456,11 @@ void WebContentsImpl::NotifySwapped() {
content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
content::Source<WebContents>(this),
content::NotificationService::NoDetails());
+
+ // Ensure that the associated embedder gets cleared after a RenderViewHost
+ // gets swapped, so we don't reuse the same embedder next time a
+ // RenderViewHost is attached to this WebContents (for security concerns).
+ RemoveSwappedOutBrowserPluginEmbedder();
awong 2012/09/06 19:55:26 Can we add a test asserting this behavior, both th
lazyboy 2012/09/07 19:33:19 Will this be a similar browsertest that we current
awong 2012/09/07 20:51:03 Yes, something like that. Is there already a test
lazyboy 2012/09/08 02:12:22 No there isn't. I'll be adding one soon. On 2012/
}
void WebContentsImpl::NotifyConnected() {
@@ -2475,6 +2506,13 @@ gfx::Rect WebContentsImpl::GetRootWindowResizerRect() const {
return gfx::Rect();
}
+void WebContentsImpl::RemoveSwappedOutBrowserPluginEmbedder() {
+ if (browser_plugin_embedder_.get() &&
+ !browser_plugin_embedder_->IsForRenderViewHost(GetRenderViewHost())) {
awong 2012/09/06 19:55:26 Is there a case where you get a swapped signal, ha
lazyboy 2012/09/07 19:33:19 This is unnecessary it seems (I had way less idea
+ browser_plugin_embedder_.reset();
+ }
+}
+
void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {
// Don't send notifications if we are just creating a swapped-out RVH for
// the opener chain. These won't be used for view-source or WebUI, so it's
@@ -3263,3 +3301,18 @@ void WebContentsImpl::GetBrowserPluginEmbedderInfo(
embedder_process_id);
}
}
+
+content::BrowserPluginGuest* WebContentsImpl::AssignBrowserPluginGuest(
+ int instance_id) {
+ browser_plugin_guest_.reset(content::BrowserPluginGuest::Create(
+ instance_id, this, GetRenderViewHost()));
+ return browser_plugin_guest_.get();
+}
+
+content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
+ return browser_plugin_guest_.get();
+}
+
+content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
+ return browser_plugin_embedder_.get();
+}

Powered by Google App Engine
This is Rietveld 408576698