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

Unified Diff: extensions/browser/extension_function.cc

Issue 105553005: Make PepperWebPlugin not use RenderViews. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 7 years 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 | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_function.cc
===================================================================
--- extensions/browser/extension_function.cc (revision 242033)
+++ extensions/browser/extension_function.cc (working copy)
@@ -12,6 +12,7 @@
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
@@ -28,15 +29,18 @@
x->Destruct();
}
-// Helper class to track the lifetime of ExtensionFunction's RenderViewHost
-// pointer and NULL it out when it dies. It also allows us to filter IPC
-// messages coming from the RenderViewHost.
-class UIThreadExtensionFunction::RenderViewHostTracker
+// Helper class to track the lifetime of ExtensionFunction's RenderViewHost or
+// RenderFrameHost pointer and NULL it out when it dies. It also allows us to
+// filter IPC messages coming from the RenderViewHost/RenderFrameHost.
+class UIThreadExtensionFunction::RenderHostTracker
: public content::WebContentsObserver {
public:
- explicit RenderViewHostTracker(UIThreadExtensionFunction* function)
+ explicit RenderHostTracker(UIThreadExtensionFunction* function)
: content::WebContentsObserver(
- WebContents::FromRenderViewHost(function->render_view_host())),
+ function->render_view_host() ?
+ WebContents::FromRenderViewHost(function->render_view_host()) :
+ WebContents::FromRenderFrameHost(
+ function->render_frame_host())),
function_(function) {
}
@@ -49,14 +53,21 @@
function_->SetRenderViewHost(NULL);
}
+ virtual void RenderFrameDeleted(
+ content::RenderFrameHost* render_frame_host) OVERRIDE {
+ if (render_frame_host != function_->render_frame_host())
+ return;
+ function_->SetRenderFrameHost(NULL);
+ }
+
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
- return function_->OnMessageReceivedFromRenderView(message);
+ return function_->OnMessageReceived(message);
}
UIThreadExtensionFunction* function_;
- DISALLOW_COPY_AND_ASSIGN(RenderViewHostTracker);
+ DISALLOW_COPY_AND_ASSIGN(RenderHostTracker);
};
ExtensionFunction::ExtensionFunction()
@@ -146,7 +157,8 @@
}
UIThreadExtensionFunction::UIThreadExtensionFunction()
- : render_view_host_(NULL), context_(NULL), delegate_(NULL) {}
+ : render_view_host_(NULL), render_frame_host_(NULL), context_(NULL),
+ delegate_(NULL) {}
UIThreadExtensionFunction::~UIThreadExtensionFunction() {
if (dispatcher() && render_view_host())
@@ -158,8 +170,7 @@
return this;
}
-bool UIThreadExtensionFunction::OnMessageReceivedFromRenderView(
- const IPC::Message& message) {
+bool UIThreadExtensionFunction::OnMessageReceived(const IPC::Message& message) {
return false;
}
@@ -169,10 +180,18 @@
void UIThreadExtensionFunction::SetRenderViewHost(
RenderViewHost* render_view_host) {
+ DCHECK(!render_frame_host_);
render_view_host_ = render_view_host;
- tracker_.reset(render_view_host ? new RenderViewHostTracker(this) : NULL);
+ tracker_.reset(render_view_host ? new RenderHostTracker(this) : NULL);
}
+void UIThreadExtensionFunction::SetRenderFrameHost(
+ content::RenderFrameHost* render_frame_host) {
+ DCHECK(!render_view_host_);
+ render_frame_host_ = render_frame_host;
+ tracker_.reset(render_frame_host ? new RenderHostTracker(this) : NULL);
+}
+
content::WebContents* UIThreadExtensionFunction::GetAssociatedWebContents() {
content::WebContents* web_contents = NULL;
if (dispatcher())
@@ -191,8 +210,13 @@
void UIThreadExtensionFunction::WriteToConsole(
content::ConsoleMessageLevel level,
const std::string& message) {
- render_view_host_->Send(new ExtensionMsg_AddMessageToConsole(
- render_view_host_->GetRoutingID(), level, message));
+ if (render_view_host_) {
+ render_view_host_->Send(new ExtensionMsg_AddMessageToConsole(
+ render_view_host_->GetRoutingID(), level, message));
+ } else {
+ render_frame_host_->Send(new ExtensionMsg_AddMessageToConsole(
+ render_frame_host_->GetRoutingID(), level, message));
+ }
}
IOThreadExtensionFunction::IOThreadExtensionFunction()
« no previous file with comments | « extensions/browser/extension_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698