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_impl.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
6 | 6 |
7 #include "content/common/browser_plugin/browser_plugin_constants.h" | 7 #include "content/common/browser_plugin/browser_plugin_constants.h" |
8 #include "content/common/browser_plugin/browser_plugin_messages.h" | 8 #include "content/common/browser_plugin/browser_plugin_messages.h" |
9 #include "content/common/cursors/webcursor.h" | 9 #include "content/common/cursors/webcursor.h" |
10 #include "content/renderer/browser_plugin/browser_plugin.h" | 10 #include "content/renderer/browser_plugin/browser_plugin.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 bool auto_navigate) { | 26 bool auto_navigate) { |
27 return new BrowserPlugin(render_view, frame, auto_navigate); | 27 return new BrowserPlugin(render_view, frame, auto_navigate); |
28 } | 28 } |
29 | 29 |
30 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { | 30 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { |
31 return RenderThread::Get()->Send(msg); | 31 return RenderThread::Get()->Send(msg); |
32 } | 32 } |
33 | 33 |
34 bool BrowserPluginManagerImpl::OnMessageReceived( | 34 bool BrowserPluginManagerImpl::OnMessageReceived( |
35 const IPC::Message& message) { | 35 const IPC::Message& message) { |
| 36 if (message.type() == BrowserPluginMsg_Attach_ACK::ID) { |
| 37 // BrowserPluginMsg_Attach_ACK has BPID as param. |
| 38 // Until this ACK is received, BrowserPlugin doesn't know about |
| 39 // its guest instance ID, and so the BPID is used for routing. |
| 40 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; |
| 41 PickleIterator iter(message); |
| 42 bool success = iter.ReadInt(&browser_plugin_instance_id); |
| 43 DCHECK(success); |
| 44 BrowserPlugin* plugin = |
| 45 GetBrowserPluginInternal(browser_plugin_instance_id); |
| 46 if (plugin && plugin->OnMessageReceived(message)) { |
| 47 return true; |
| 48 } |
| 49 return false; |
| 50 } |
| 51 |
36 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) { | 52 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) { |
37 int guest_instance_id = browser_plugin::kInstanceIDNone; | 53 int guest_instance_id = browser_plugin::kInstanceIDNone; |
38 // All allowed messages must have |guest_instance_id| as their first | 54 // All allowed messages must have |guest_instance_id| as their first |
39 // parameter. | 55 // parameter. |
40 PickleIterator iter(message); | 56 PickleIterator iter(message); |
41 bool success = iter.ReadInt(&guest_instance_id); | 57 bool success = iter.ReadInt(&guest_instance_id); |
42 DCHECK(success); | 58 DCHECK(success); |
43 BrowserPlugin* plugin = GetBrowserPlugin(guest_instance_id); | 59 BrowserPlugin* plugin = GetBrowserPlugin(guest_instance_id); |
44 if (plugin && plugin->OnMessageReceived(message)) | 60 if (plugin && plugin->OnMessageReceived(message)) |
45 return true; | 61 return true; |
46 } | 62 } |
47 | 63 |
48 return false; | 64 return false; |
49 } | 65 } |
50 | 66 |
51 void BrowserPluginManagerImpl::DidCommitCompositorFrame() { | 67 void BrowserPluginManagerImpl::DidCommitCompositorFrame() { |
52 IDMap<BrowserPlugin>::iterator iter(&instances_); | 68 IDMap<BrowserPlugin>::iterator iter(&instances_); |
53 while (!iter.IsAtEnd()) { | 69 while (!iter.IsAtEnd()) { |
54 iter.GetCurrentValue()->DidCommitCompositorFrame(); | 70 iter.GetCurrentValue()->DidCommitCompositorFrame(); |
55 iter.Advance(); | 71 iter.Advance(); |
56 } | 72 } |
57 } | 73 } |
58 | 74 |
59 } // namespace content | 75 } // namespace content |
OLD | NEW |