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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "content/common/browser_plugin/browser_plugin_constants.h" | 9 #include "content/common/browser_plugin/browser_plugin_constants.h" |
10 #include "content/common/browser_plugin/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin/browser_plugin_messages.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( | 42 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( |
43 int browser_plugin_instance_id) const { | 43 int browser_plugin_instance_id) const { |
44 return instances_.Lookup(browser_plugin_instance_id); | 44 return instances_.Lookup(browser_plugin_instance_id); |
45 } | 45 } |
46 | 46 |
47 int BrowserPluginManager::GetNextInstanceID() { | 47 int BrowserPluginManager::GetNextInstanceID() { |
48 return RenderThreadImpl::current()->GenerateRoutingID(); | 48 return RenderThreadImpl::current()->GenerateRoutingID(); |
49 } | 49 } |
50 | 50 |
51 void BrowserPluginManager::UpdateFocusState() { | 51 void BrowserPluginManager::UpdateFocusState() { |
52 IDMap<BrowserPlugin>::iterator iter(&instances_); | 52 IDMap<BrowserPlugin*>::iterator iter(&instances_); |
53 while (!iter.IsAtEnd()) { | 53 while (!iter.IsAtEnd()) { |
54 iter.GetCurrentValue()->UpdateGuestFocusState(blink::WebFocusTypeNone); | 54 iter.GetCurrentValue()->UpdateGuestFocusState(blink::WebFocusTypeNone); |
55 iter.Advance(); | 55 iter.Advance(); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 void BrowserPluginManager::Attach(int browser_plugin_instance_id) { | 59 void BrowserPluginManager::Attach(int browser_plugin_instance_id) { |
60 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); | 60 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); |
61 if (plugin) | 61 if (plugin) |
62 plugin->Attach(); | 62 plugin->Attach(); |
63 } | 63 } |
64 | 64 |
65 void BrowserPluginManager::Detach(int browser_plugin_instance_id) { | 65 void BrowserPluginManager::Detach(int browser_plugin_instance_id) { |
66 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); | 66 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); |
67 if (plugin) | 67 if (plugin) |
68 plugin->Detach(); | 68 plugin->Detach(); |
69 } | 69 } |
70 | 70 |
71 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin( | 71 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin( |
72 RenderFrame* render_frame, | 72 RenderFrame* render_frame, |
73 const base::WeakPtr<BrowserPluginDelegate>& delegate) { | 73 const base::WeakPtr<BrowserPluginDelegate>& delegate) { |
74 return new BrowserPlugin(render_frame, delegate); | 74 return new BrowserPlugin(render_frame, delegate); |
75 } | 75 } |
76 | 76 |
77 void BrowserPluginManager::DidCommitCompositorFrame( | 77 void BrowserPluginManager::DidCommitCompositorFrame( |
78 int render_frame_routing_id) { | 78 int render_frame_routing_id) { |
79 IDMap<BrowserPlugin>::iterator iter(&instances_); | 79 IDMap<BrowserPlugin*>::iterator iter(&instances_); |
80 while (!iter.IsAtEnd()) { | 80 while (!iter.IsAtEnd()) { |
81 if (iter.GetCurrentValue()->render_frame_routing_id() == | 81 if (iter.GetCurrentValue()->render_frame_routing_id() == |
82 render_frame_routing_id) { | 82 render_frame_routing_id) { |
83 iter.GetCurrentValue()->DidCommitCompositorFrame(); | 83 iter.GetCurrentValue()->DidCommitCompositorFrame(); |
84 } | 84 } |
85 iter.Advance(); | 85 iter.Advance(); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 bool BrowserPluginManager::OnControlMessageReceived( | 89 bool BrowserPluginManager::OnControlMessageReceived( |
90 const IPC::Message& message) { | 90 const IPC::Message& message) { |
91 if (!BrowserPlugin::ShouldForwardToBrowserPlugin(message)) | 91 if (!BrowserPlugin::ShouldForwardToBrowserPlugin(message)) |
92 return false; | 92 return false; |
93 | 93 |
94 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; | 94 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; |
95 // All allowed messages must have |browser_plugin_instance_id| as their | 95 // All allowed messages must have |browser_plugin_instance_id| as their |
96 // first parameter. | 96 // first parameter. |
97 base::PickleIterator iter(message); | 97 base::PickleIterator iter(message); |
98 bool success = iter.ReadInt(&browser_plugin_instance_id); | 98 bool success = iter.ReadInt(&browser_plugin_instance_id); |
99 DCHECK(success); | 99 DCHECK(success); |
100 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); | 100 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); |
101 return plugin && plugin->OnMessageReceived(message); | 101 return plugin && plugin->OnMessageReceived(message); |
102 } | 102 } |
103 | 103 |
104 bool BrowserPluginManager::Send(IPC::Message* msg) { | 104 bool BrowserPluginManager::Send(IPC::Message* msg) { |
105 return RenderThreadImpl::current()->Send(msg); | 105 return RenderThreadImpl::current()->Send(msg); |
106 } | 106 } |
107 | 107 |
108 } // namespace content | 108 } // namespace content |
OLD | NEW |