summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 17:03:07 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 17:03:07 +0000
commit6dd625e74fdc972f52ab08d39adc22555389e1e8 (patch)
tree77193b19d0da42f31d62b20558281998c3ee7e0e /extensions
parentbd4fdd4f4d129207a7d699768990c50afa126b7d (diff)
downloadchromium_src-6dd625e74fdc972f52ab08d39adc22555389e1e8.zip
chromium_src-6dd625e74fdc972f52ab08d39adc22555389e1e8.tar.gz
chromium_src-6dd625e74fdc972f52ab08d39adc22555389e1e8.tar.bz2
Make PepperWebPlugin not use RenderView.
BUG=304341 R=nasko@chromium.org, yoz@chromium.org, yzshen@chromium.org Review URL: https://codereview.chromium.org/105553005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/extension_function.cc52
-rw-r--r--extensions/browser/extension_function.h18
2 files changed, 52 insertions, 18 deletions
diff --git a/extensions/browser/extension_function.cc b/extensions/browser/extension_function.cc
index a06d2c4..d1e2a9f 100644
--- a/extensions/browser/extension_function.cc
+++ b/extensions/browser/extension_function.cc
@@ -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 @@ void ExtensionFunctionDeleteTraits::Destruct(const ExtensionFunction* x) {
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 @@ class UIThreadExtensionFunction::RenderViewHostTracker
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 @@ void ExtensionFunction::SendResponseImpl(bool success) {
}
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 @@ UIThreadExtensionFunction::AsUIThreadExtensionFunction() {
return this;
}
-bool UIThreadExtensionFunction::OnMessageReceivedFromRenderView(
- const IPC::Message& message) {
+bool UIThreadExtensionFunction::OnMessageReceived(const IPC::Message& message) {
return false;
}
@@ -169,8 +180,16 @@ void UIThreadExtensionFunction::Destruct() const {
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() {
@@ -191,8 +210,13 @@ void UIThreadExtensionFunction::SendResponse(bool success) {
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()
diff --git a/extensions/browser/extension_function.h b/extensions/browser/extension_function.h
index aa0ed03..49d370e 100644
--- a/extensions/browser/extension_function.h
+++ b/extensions/browser/extension_function.h
@@ -35,6 +35,7 @@ class Value;
namespace content {
class BrowserContext;
+class RenderFrameHost;
class RenderViewHost;
class WebContents;
}
@@ -290,7 +291,7 @@ class UIThreadExtensionFunction : public ExtensionFunction {
// Called when a message was received.
// Should return true if it processed the message.
- virtual bool OnMessageReceivedFromRenderView(const IPC::Message& message);
+ virtual bool OnMessageReceived(const IPC::Message& message);
// Set the browser context which contains the extension that has originated
// this function call.
@@ -301,6 +302,10 @@ class UIThreadExtensionFunction : public ExtensionFunction {
content::RenderViewHost* render_view_host() const {
return render_view_host_;
}
+ void SetRenderFrameHost(content::RenderFrameHost* render_frame_host);
+ content::RenderFrameHost* render_frame_host() const {
+ return render_frame_host_;
+ }
void set_dispatcher(
const base::WeakPtr<ExtensionFunctionDispatcher>& dispatcher) {
@@ -330,18 +335,23 @@ class UIThreadExtensionFunction : public ExtensionFunction {
// The dispatcher that will service this extension function call.
base::WeakPtr<ExtensionFunctionDispatcher> dispatcher_;
- // The RenderViewHost we will send responses too.
+ // The RenderViewHost we will send responses to.
content::RenderViewHost* render_view_host_;
+ // The RenderFrameHost we will send responses to.
+ // NOTE: either render_view_host_ or render_frame_host_ will be set, as we
+ // port code to use RenderFrames for OOPIF. See http://crbug.com/304341.
+ content::RenderFrameHost* render_frame_host_;
+
// The content::BrowserContext of this function's extension.
content::BrowserContext* context_;
private:
- class RenderViewHostTracker;
+ class RenderHostTracker;
virtual void Destruct() const OVERRIDE;
- scoped_ptr<RenderViewHostTracker> tracker_;
+ scoped_ptr<RenderHostTracker> tracker_;
DelegateForTests* delegate_;
};