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

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 558073002: Hook up guest browser plugins to the accessibility tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cross_process_iframes_plugins_3
Patch Set: Rebase Created 6 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/renderer/browser_plugin/browser_plugin.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 424a4ce5c17aa41fa203efde1c7e6535243b0b8e..c0a2e8a96c5be93804bfffb2fcaf05474c9bf8fe 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -41,8 +41,26 @@ using blink::WebRect;
using blink::WebURL;
using blink::WebVector;
+namespace {
+typedef std::map<blink::WebPluginContainer*, content::BrowserPlugin*>
+ PluginContainerMap;
+static base::LazyInstance<PluginContainerMap> g_plugin_container_map =
+ LAZY_INSTANCE_INITIALIZER;
+} // namespace
+
namespace content {
+// static
+BrowserPlugin* BrowserPlugin::GetFromNode(blink::WebNode& node) {
+ blink::WebPluginContainer* container = node.pluginContainer();
+ if (!container)
+ return NULL;
+
+ PluginContainerMap* browser_plugins = g_plugin_container_map.Pointer();
+ PluginContainerMap::iterator it = browser_plugins->find(container);
+ return it == browser_plugins->end() ? NULL : it->second;
+}
+
BrowserPlugin::BrowserPlugin(RenderViewImpl* render_view,
blink::WebFrame* frame,
scoped_ptr<BrowserPluginDelegate> delegate)
@@ -378,6 +396,8 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) {
container_ = container;
container_->setWantsWheelEvents(true);
+ g_plugin_container_map.Get().insert(std::make_pair(container_, this));
+
// This is a way to notify observers of our attributes that this plugin is
// available in render tree.
// TODO(lazyboy): This should be done through the delegate instead. Perhaps
@@ -418,6 +438,10 @@ void BrowserPlugin::destroy() {
if (container_)
container_->clearScriptObjects();
+ // The BrowserPlugin's WebPluginContainer is deleted immediately after this
+ // call returns, so let's not keep a reference to it around.
+ g_plugin_container_map.Get().erase(container_);
+
if (compositing_helper_.get())
compositing_helper_->OnContainerDestroy();
container_ = NULL;
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698