Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_manager.cc

Issue 444813002: Remove BrowserPlugin's -internal-attach method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comment Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/scoped_ptr.h"
8 #include "base/threading/thread_local.h" 9 #include "base/threading/thread_local.h"
10 #include "base/values.h"
9 #include "content/public/renderer/render_thread.h" 11 #include "content/public/renderer/render_thread.h"
10 #include "content/renderer/browser_plugin/browser_plugin.h" 12 #include "content/renderer/browser_plugin/browser_plugin.h"
11 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h" 13 #include "content/renderer/browser_plugin/browser_plugin_manager_factory.h"
12 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" 14 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
13 15
14 namespace content { 16 namespace content {
15 17
16 // static 18 // static
17 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL; 19 BrowserPluginManagerFactory* BrowserPluginManager::factory_ = NULL;
18 20
19 BrowserPluginManager* BrowserPluginManager::Create( 21 BrowserPluginManager* BrowserPluginManager::Create(
20 RenderViewImpl* render_view) { 22 RenderViewImpl* render_view) {
21 if (factory_) 23 if (factory_)
22 return factory_->CreateBrowserPluginManager(render_view); 24 return factory_->CreateBrowserPluginManager(render_view);
23 return new BrowserPluginManagerImpl(render_view); 25 return new BrowserPluginManagerImpl(render_view);
24 } 26 }
25 27
26 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) 28 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view)
27 : RenderViewObserver(render_view), 29 : RenderViewObserver(render_view),
30 // TODO(lazyboy): 10 is for testing only, change it to 1.
31 next_instance_id_(10),
28 render_view_(render_view->AsWeakPtr()) { 32 render_view_(render_view->AsWeakPtr()) {
29 } 33 }
30 34
31 BrowserPluginManager::~BrowserPluginManager() { 35 BrowserPluginManager::~BrowserPluginManager() {
32 } 36 }
33 37
34 void BrowserPluginManager::AddBrowserPlugin( 38 void BrowserPluginManager::AddBrowserPlugin(
35 int guest_instance_id, 39 int guest_instance_id,
36 BrowserPlugin* browser_plugin) { 40 BrowserPlugin* browser_plugin) {
37 instances_.AddWithID(browser_plugin, guest_instance_id); 41 instances_by_guest_id_.AddWithID(browser_plugin, guest_instance_id);
38 } 42 }
39 43
40 void BrowserPluginManager::RemoveBrowserPlugin(int guest_instance_id) { 44 void BrowserPluginManager::RemoveBrowserPlugin(int guest_instance_id) {
41 instances_.Remove(guest_instance_id); 45 instances_by_guest_id_.Remove(guest_instance_id);
42 } 46 }
43 47
44 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( 48 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(
45 int guest_instance_id) const { 49 int guest_instance_id) const {
46 return instances_.Lookup(guest_instance_id); 50 return instances_by_guest_id_.Lookup(guest_instance_id);
51 }
52
53 void BrowserPluginManager::AddBrowserPluginInternal(
54 int browser_plugin_instance_id,
55 BrowserPlugin* browser_plugin) {
56 instances_by_browser_plugin_id_.AddWithID(browser_plugin,
57 browser_plugin_instance_id);
58 }
59
60 void BrowserPluginManager::RemoveBrowserPluginInternal(
61 int browser_plugin_instance_id) {
62 if (!instances_by_browser_plugin_id_.Lookup(browser_plugin_instance_id))
63 return;
64 instances_by_browser_plugin_id_.Remove(browser_plugin_instance_id);
65 }
66
67 BrowserPlugin* BrowserPluginManager::GetBrowserPluginInternal(
68 int browser_plugin_instance_id) const {
69 return instances_by_browser_plugin_id_.Lookup(browser_plugin_instance_id);
70 }
71
72 int BrowserPluginManager::GetNextInstanceID() {
73 return next_instance_id_++;
47 } 74 }
48 75
49 void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor) { 76 void BrowserPluginManager::UpdateDeviceScaleFactor(float device_scale_factor) {
50 IDMap<BrowserPlugin>::iterator iter(&instances_); 77 IDMap<BrowserPlugin>::iterator iter(&instances_by_guest_id_);
51 while (!iter.IsAtEnd()) { 78 while (!iter.IsAtEnd()) {
52 iter.GetCurrentValue()->UpdateDeviceScaleFactor(device_scale_factor); 79 iter.GetCurrentValue()->UpdateDeviceScaleFactor(device_scale_factor);
53 iter.Advance(); 80 iter.Advance();
54 } 81 }
55 } 82 }
56 83
57 void BrowserPluginManager::UpdateFocusState() { 84 void BrowserPluginManager::UpdateFocusState() {
58 IDMap<BrowserPlugin>::iterator iter(&instances_); 85 IDMap<BrowserPlugin>::iterator iter(&instances_by_guest_id_);
59 while (!iter.IsAtEnd()) { 86 while (!iter.IsAtEnd()) {
60 iter.GetCurrentValue()->UpdateGuestFocusState(); 87 iter.GetCurrentValue()->UpdateGuestFocusState();
61 iter.Advance(); 88 iter.Advance();
62 } 89 }
63 } 90 }
64 91
92 void BrowserPluginManager::Attach(int browser_plugin_instance_id,
93 int guest_instance_id) {
94 BrowserPlugin* plugin = GetBrowserPluginInternal(browser_plugin_instance_id);
95 if (plugin)
96 plugin->Attach(guest_instance_id);
97 }
98
65 } // namespace content 99 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698