• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
6 
7 #include "base/lazy_instance.h"
8 #include "base/threading/thread_local.h"
9 #include "content/public/renderer/render_thread.h"
10 #include "content/renderer/browser_plugin/browser_plugin.h"
11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h"
12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
13 
14 namespace content {
15 
16 // static
17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL;
18 
Create(RenderViewImpl * render_view)19 BrowserPluginManager* BrowserPluginManager::Create(
20     RenderViewImpl* render_view) {
21   if (factory_)
22     return factory_->CreateBrowserPluginManager(render_view);
23   return new BrowserPluginManagerImpl(render_view);
24 }
25 
BrowserPluginManager(RenderViewImpl * render_view)26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view)
27     : RenderViewObserver(render_view),
28       render_view_(render_view->AsWeakPtr()) {
29 }
30 
~BrowserPluginManager()31 BrowserPluginManager::~BrowserPluginManager() {
32 }
33 
AddBrowserPlugin(int guest_instance_id,BrowserPlugin * browser_plugin)34 void BrowserPluginManager::AddBrowserPlugin(
35     int guest_instance_id,
36     BrowserPlugin* browser_plugin) {
37   instances_.AddWithID(browser_plugin, guest_instance_id);
38 }
39 
RemoveBrowserPlugin(int guest_instance_id)40 void BrowserPluginManager::RemoveBrowserPlugin(int guest_instance_id) {
41   instances_.Remove(guest_instance_id);
42 }
43 
GetBrowserPlugin(int guest_instance_id) const44 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(
45     int guest_instance_id) const {
46   return instances_.Lookup(guest_instance_id);
47 }
48 
UpdateDeviceScaleFactor(float device_scale_factor)49 void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor) {
50   IDMap<BrowserPlugin>::iterator iter(&instances_);
51   while (!iter.IsAtEnd()) {
52     iter.GetCurrentValue()->UpdateDeviceScaleFactor(device_scale_factor);
53     iter.Advance();
54   }
55 }
56 
UpdateFocusState()57 void BrowserPluginManager::UpdateFocusState() {
58   IDMap<BrowserPlugin>::iterator iter(&instances_);
59   while (!iter.IsAtEnd()) {
60     iter.GetCurrentValue()->UpdateGuestFocusState();
61     iter.Advance();
62   }
63 }
64 
65 }  // namespace content
66