| 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/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/renderer/browser_plugin/browser_plugin.h" | 10 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" | 11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" |
| 12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; | 17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; |
| 18 | 18 |
| 19 BrowserPluginManager* BrowserPluginManager::Create( | 19 BrowserPluginManager* BrowserPluginManager::Create( |
| 20 RenderViewImpl* render_view) { | 20 RenderViewImpl* render_view) { |
| 21 if (factory_) | 21 if (factory_) |
| 22 return factory_->CreateBrowserPluginManager(render_view); | 22 return factory_->CreateBrowserPluginManager(render_view); |
| 23 return new BrowserPluginManagerImpl(render_view); | 23 return new BrowserPluginManagerImpl(render_view); |
| 24 } | 24 } |
| 25 | 25 |
| 26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) | 26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) |
| 27 : RenderViewObserver(render_view), | 27 : RenderViewObserver(render_view), |
| 28 render_view_(render_view->AsWeakPtr()), | 28 render_view_(render_view->AsWeakPtr()) { |
| 29 browser_plugin_counter_(0) { | |
| 30 } | 29 } |
| 31 | 30 |
| 32 BrowserPluginManager::~BrowserPluginManager() { | 31 BrowserPluginManager::~BrowserPluginManager() { |
| 33 } | 32 } |
| 34 | 33 |
| 35 void BrowserPluginManager::AddBrowserPlugin( | 34 void BrowserPluginManager::AddBrowserPlugin( |
| 36 int instance_id, | 35 int instance_id, |
| 37 BrowserPlugin* browser_plugin) { | 36 BrowserPlugin* browser_plugin) { |
| 38 instances_.AddWithID(browser_plugin, instance_id); | 37 instances_.AddWithID(browser_plugin, instance_id); |
| 39 } | 38 } |
| 40 | 39 |
| 41 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { | 40 void BrowserPluginManager::RemoveBrowserPlugin(int instance_id) { |
| 42 instances_.Remove(instance_id); | 41 instances_.Remove(instance_id); |
| 43 } | 42 } |
| 44 | 43 |
| 45 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { | 44 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(int instance_id) const { |
| 46 return instances_.Lookup(instance_id); | 45 return instances_.Lookup(instance_id); |
| 47 } | 46 } |
| 48 | 47 |
| 49 void BrowserPluginManager::UpdateFocusState() { | 48 void BrowserPluginManager::UpdateFocusState() { |
| 50 IDMap<BrowserPlugin>::iterator iter(&instances_); | 49 IDMap<BrowserPlugin>::iterator iter(&instances_); |
| 51 while (!iter.IsAtEnd()) { | 50 while (!iter.IsAtEnd()) { |
| 52 iter.GetCurrentValue()->UpdateGuestFocusState(); | 51 iter.GetCurrentValue()->UpdateGuestFocusState(); |
| 53 iter.Advance(); | 52 iter.Advance(); |
| 54 } | 53 } |
| 55 } | 54 } |
| 56 | 55 |
| 57 } // namespace content | 56 } // namespace content |
| OLD | NEW |