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