Index: content/renderer/browser_plugin/browser_plugin_manager.cc |
diff --git a/content/renderer/browser_plugin/browser_plugin_manager.cc b/content/renderer/browser_plugin/browser_plugin_manager.cc |
index 03120d82f7889fc70dd1dd958f89e788cdc2ace1..4cfe7bc2e6747fe02dc69058129780084304ff62 100644 |
--- a/content/renderer/browser_plugin/browser_plugin_manager.cc |
+++ b/content/renderer/browser_plugin/browser_plugin_manager.cc |
@@ -5,7 +5,9 @@ |
#include "content/renderer/browser_plugin/browser_plugin_manager.h" |
#include "base/lazy_instance.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/threading/thread_local.h" |
+#include "base/values.h" |
#include "content/public/renderer/render_thread.h" |
#include "content/renderer/browser_plugin/browser_plugin.h" |
#include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" |
@@ -25,6 +27,8 @@ BrowserPluginManager* BrowserPluginManager::Create( |
BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) |
: RenderViewObserver(render_view), |
+ // TODO(lazyboy): 10 is for testing only, change it to 1. |
+ next_instance_id_(10), |
render_view_(render_view->AsWeakPtr()) { |
} |
@@ -34,20 +38,43 @@ BrowserPluginManager::~BrowserPluginManager() { |
void BrowserPluginManager::AddBrowserPlugin( |
int guest_instance_id, |
BrowserPlugin* browser_plugin) { |
- instances_.AddWithID(browser_plugin, guest_instance_id); |
+ instances_by_guest_id_.AddWithID(browser_plugin, guest_instance_id); |
} |
void BrowserPluginManager::RemoveBrowserPlugin(int guest_instance_id) { |
- instances_.Remove(guest_instance_id); |
+ instances_by_guest_id_.Remove(guest_instance_id); |
} |
BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( |
int guest_instance_id) const { |
- return instances_.Lookup(guest_instance_id); |
+ return instances_by_guest_id_.Lookup(guest_instance_id); |
+} |
+ |
+void BrowserPluginManager::AddBrowserPluginInternal( |
+ int browser_plugin_instance_id, |
+ BrowserPlugin* browser_plugin) { |
+ instances_by_browser_plugin_id_.AddWithID(browser_plugin, |
+ browser_plugin_instance_id); |
+} |
+ |
+void BrowserPluginManager::RemoveBrowserPluginInternal( |
+ int browser_plugin_instance_id) { |
+ if (!instances_by_browser_plugin_id_.Lookup(browser_plugin_instance_id)) |
+ return; |
+ instances_by_browser_plugin_id_.Remove(browser_plugin_instance_id); |
+} |
+ |
+BrowserPlugin* BrowserPluginManager::GetBrowserPluginInternal( |
+ int browser_plugin_instance_id) const { |
+ return instances_by_browser_plugin_id_.Lookup(browser_plugin_instance_id); |
+} |
+ |
+int BrowserPluginManager::GetNextInstanceID() { |
+ return next_instance_id_++; |
} |
void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor) { |
- IDMap<BrowserPlugin>::iterator iter(&instances_); |
+ IDMap<BrowserPlugin>::iterator iter(&instances_by_guest_id_); |
while (!iter.IsAtEnd()) { |
iter.GetCurrentValue()->UpdateDeviceScaleFactor(device_scale_factor); |
iter.Advance(); |
@@ -55,11 +82,18 @@ void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor) { |
} |
void BrowserPluginManager::UpdateFocusState() { |
- IDMap<BrowserPlugin>::iterator iter(&instances_); |
+ IDMap<BrowserPlugin>::iterator iter(&instances_by_guest_id_); |
while (!iter.IsAtEnd()) { |
iter.GetCurrentValue()->UpdateGuestFocusState(); |
iter.Advance(); |
} |
} |
+void BrowserPluginManager::Attach(int browser_plugin_instance_id, |
+ int guest_instance_id) { |
+ BrowserPlugin* plugin = GetBrowserPluginInternal(browser_plugin_instance_id); |
+ if (plugin) |
+ plugin->Attach(guest_instance_id); |
+} |
+ |
} // namespace content |