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
3 // found in the LICENSE file.
5 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/thread_local.h"
10 #include "base/values.h"
11 #include "content/common/browser_plugin/browser_plugin_constants.h"
12 #include "content/public/renderer/render_thread.h"
13 #include "content/renderer/browser_plugin/browser_plugin.h"
14 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h"
15 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
20 BrowserPluginManagerFactory
* BrowserPluginManager::factory_
= NULL
;
22 BrowserPluginManager
* BrowserPluginManager::Create(
23 RenderViewImpl
* render_view
) {
25 return factory_
->CreateBrowserPluginManager(render_view
);
26 return new BrowserPluginManagerImpl(render_view
);
29 BrowserPluginManager::BrowserPluginManager(RenderViewImpl
* render_view
)
30 : RenderViewObserver(render_view
),
31 current_instance_id_(browser_plugin::kInstanceIDNone
),
32 render_view_(render_view
->AsWeakPtr()) {
35 BrowserPluginManager::~BrowserPluginManager() {
38 void BrowserPluginManager::AddBrowserPlugin(
39 int browser_plugin_instance_id
,
40 BrowserPlugin
* browser_plugin
) {
41 instances_
.AddWithID(browser_plugin
, browser_plugin_instance_id
);
44 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id
) {
45 instances_
.Remove(browser_plugin_instance_id
);
48 BrowserPlugin
* BrowserPluginManager::GetBrowserPlugin(
49 int browser_plugin_instance_id
) const {
50 return instances_
.Lookup(browser_plugin_instance_id
);
53 int BrowserPluginManager::GetNextInstanceID() {
54 return ++current_instance_id_
;
57 void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor
) {
58 IDMap
<BrowserPlugin
>::iterator
iter(&instances_
);
59 while (!iter
.IsAtEnd()) {
60 iter
.GetCurrentValue()->UpdateDeviceScaleFactor(device_scale_factor
);
65 void BrowserPluginManager::UpdateFocusState() {
66 IDMap
<BrowserPlugin
>::iterator
iter(&instances_
);
67 while (!iter
.IsAtEnd()) {
68 iter
.GetCurrentValue()->UpdateGuestFocusState();
73 void BrowserPluginManager::Attach(int browser_plugin_instance_id
) {
74 BrowserPlugin
* plugin
= GetBrowserPlugin(browser_plugin_instance_id
);
79 } // namespace content