| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "content/common/browser_plugin_messages.h" |
| 9 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/renderer/browser_plugin/browser_plugin.h" | 11 #include "content/renderer/browser_plugin/browser_plugin_impl.h" |
| 11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" | 12 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" |
| 12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 13 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; | 18 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; |
| 18 | 19 |
| 19 BrowserPluginManager* BrowserPluginManager::Create( | 20 BrowserPluginManager* BrowserPluginManager::Create( |
| 20 RenderViewImpl* render_view) { | 21 RenderViewImpl* render_view) { |
| 21 if (factory_) | 22 if (factory_) |
| 22 return factory_->CreateBrowserPluginManager(render_view); | 23 return factory_->CreateBrowserPluginManager(render_view); |
| 23 return new BrowserPluginManagerImpl(render_view); | 24 return new BrowserPluginManagerImpl(render_view); |
| 24 } | 25 } |
| 25 | 26 |
| 26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) | 27 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) |
| 27 : RenderViewObserver(render_view), | 28 : RenderViewObserver(render_view), |
| 28 render_view_(render_view->AsWeakPtr()) { | 29 render_view_(render_view->AsWeakPtr()) { |
| 29 } | 30 } |
| 30 | 31 |
| 31 BrowserPluginManager::~BrowserPluginManager() { | 32 BrowserPluginManager::~BrowserPluginManager() { |
| 32 } | 33 } |
| 33 | 34 |
| 34 void BrowserPluginManager::AddBrowserPlugin( | 35 void BrowserPluginManager::AddBrowserPlugin( |
| 35 int instance_id, | 36 int instance_id, |
| 36 BrowserPlugin* browser_plugin) { | 37 BrowserPluginImpl* browser_plugin) { |
| 37 instances_.AddWithID(browser_plugin, instance_id); | 38 instances_.AddWithID(browser_plugin, instance_id); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { | 41 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { |
| 41 instances_.Remove(instance_id); | 42 instances_.Remove(instance_id); |
| 42 } | 43 } |
| 43 | 44 |
| 44 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { | 45 BrowserPluginImpl* BrowserPluginManager::GetBrowserPlugin( |
| 46 int instance_id) const { |
| 45 return instances_.Lookup(instance_id); | 47 return instances_.Lookup(instance_id); |
| 46 } | 48 } |
| 47 | 49 |
| 48 void BrowserPluginManager::UpdateFocusState() { | 50 void BrowserPluginManager::UpdateFocusState() { |
| 49 IDMap<BrowserPlugin>::iterator iter(&instances_); | 51 IDMap<BrowserPluginImpl>::iterator iter(&instances_); |
| 50 while (!iter.IsAtEnd()) { | 52 while (!iter.IsAtEnd()) { |
| 51 iter.GetCurrentValue()->UpdateGuestFocusState(); | 53 iter.GetCurrentValue()->UpdateGuestFocusState(); |
| 52 iter.Advance(); | 54 iter.Advance(); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 | 57 |
| 56 } // namespace content | 58 } // namespace content |
| OLD | NEW |