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_messages.h" | 7 #include "content/common/browser_plugin_messages.h" |
8 #include "content/renderer/browser_plugin/browser_plugin.h" | 8 #include "content/public/common/content_client.h" |
9 #include "content/public/renderer/content_renderer_client.h" | |
sadrul
2013/01/09 15:21:54
These includes aren't used?
Fady Samuel
2013/01/09 17:41:24
Done.
| |
10 #include "content/renderer/browser_plugin/browser_plugin_impl.h" | |
9 #include "content/renderer/render_thread_impl.h" | 11 #include "content/renderer/render_thread_impl.h" |
10 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
11 #include "webkit/glue/webcursor.h" | 13 #include "webkit/glue/webcursor.h" |
12 | 14 |
13 namespace content { | 15 namespace content { |
14 | 16 |
15 BrowserPluginManagerImpl::BrowserPluginManagerImpl( | 17 BrowserPluginManagerImpl::BrowserPluginManagerImpl( |
16 RenderViewImpl* render_view) | 18 RenderViewImpl* render_view) |
17 : BrowserPluginManager(render_view) { | 19 : BrowserPluginManager(render_view) { |
18 } | 20 } |
19 | 21 |
20 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { | 22 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { |
21 } | 23 } |
22 | 24 |
23 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( | 25 BrowserPluginImpl* BrowserPluginManagerImpl::CreateBrowserPlugin( |
24 RenderViewImpl* render_view, | 26 RenderViewImpl* render_view, |
25 WebKit::WebFrame* frame, | 27 WebKit::WebFrame* frame, |
26 const WebKit::WebPluginParams& params) { | 28 const WebKit::WebPluginParams& params) { |
27 return new BrowserPlugin(++browser_plugin_counter_, | 29 return new BrowserPluginImpl(++browser_plugin_counter_, |
28 render_view, | 30 render_view, |
29 frame, | 31 frame, |
30 params); | 32 params); |
31 } | 33 } |
32 | 34 |
33 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { | 35 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { |
34 return RenderThread::Get()->Send(msg); | 36 return RenderThread::Get()->Send(msg); |
35 } | 37 } |
36 | 38 |
37 bool BrowserPluginManagerImpl::OnMessageReceived( | 39 bool BrowserPluginManagerImpl::OnMessageReceived( |
38 const IPC::Message& message) { | 40 const IPC::Message& message) { |
39 if (ShouldForwardToBrowserPlugin(message)) { | 41 if (ShouldForwardToBrowserPlugin(message)) { |
40 int instance_id = 0; | 42 int instance_id = 0; |
41 // All allowed messages must have instance_id as their first parameter. | 43 // All allowed messages must have instance_id as their first parameter. |
42 PickleIterator iter(message); | 44 PickleIterator iter(message); |
43 bool success = iter.ReadInt(&instance_id); | 45 bool success = iter.ReadInt(&instance_id); |
44 DCHECK(success); | 46 DCHECK(success); |
45 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); | 47 BrowserPluginImpl* plugin = GetBrowserPlugin(instance_id); |
46 if (plugin && plugin->OnMessageReceived(message)) | 48 if (plugin && plugin->OnMessageReceived(message)) |
47 return true; | 49 return true; |
48 } | 50 } |
49 | 51 |
50 bool handled = true; | 52 bool handled = true; |
51 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message) | 53 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message) |
52 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest, | 54 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest, |
53 OnPluginAtPositionRequest); | 55 OnPluginAtPositionRequest); |
54 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
55 IPC_END_MESSAGE_MAP() | 57 IPC_END_MESSAGE_MAP() |
56 return handled; | 58 return handled; |
57 } | 59 } |
58 | 60 |
59 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( | 61 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( |
60 const IPC::Message& message, | 62 const IPC::Message& message, |
61 int request_id, | 63 int request_id, |
62 const gfx::Point& position) { | 64 const gfx::Point& position) { |
63 int instance_id = -1; | 65 int instance_id = -1; |
64 IDMap<BrowserPlugin>::iterator it(&instances_); | 66 IDMap<BrowserPluginImpl>::iterator it(&instances_); |
65 gfx::Point local_position = position; | 67 gfx::Point local_position = position; |
66 int source_routing_id = message.routing_id(); | 68 int source_routing_id = message.routing_id(); |
67 while (!it.IsAtEnd()) { | 69 while (!it.IsAtEnd()) { |
68 const BrowserPlugin* plugin = it.GetCurrentValue(); | 70 const BrowserPluginImpl* plugin = it.GetCurrentValue(); |
69 // We need to check the plugin's routing id too since BrowserPluginManager | 71 // We need to check the plugin's routing id too since BrowserPluginManager |
70 // can manage plugins from other embedder (in the same process). | 72 // can manage plugins from other embedder (in the same process). |
71 if (plugin->InBounds(position)) { | 73 if (plugin->InBounds(position)) { |
72 source_routing_id = plugin->render_view_routing_id(); | 74 source_routing_id = plugin->render_view_routing_id(); |
73 instance_id = plugin->instance_id(); | 75 instance_id = plugin->instance_id(); |
74 local_position = plugin->ToLocalCoordinates(position); | 76 local_position = plugin->ToLocalCoordinates(position); |
75 break; | 77 break; |
76 } | 78 } |
77 it.Advance(); | 79 it.Advance(); |
78 } | 80 } |
79 | 81 |
80 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( | 82 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( |
81 source_routing_id, | 83 source_routing_id, |
82 instance_id, | 84 instance_id, |
83 request_id, | 85 request_id, |
84 local_position)); | 86 local_position)); |
85 } | 87 } |
86 | 88 |
87 // static | |
88 bool BrowserPluginManagerImpl::ShouldForwardToBrowserPlugin( | |
89 const IPC::Message& message) { | |
90 switch (message.type()) { | |
91 case BrowserPluginMsg_AdvanceFocus::ID: | |
92 case BrowserPluginMsg_GuestContentWindowReady::ID: | |
93 case BrowserPluginMsg_GuestGone::ID: | |
94 case BrowserPluginMsg_GuestResponsive::ID: | |
95 case BrowserPluginMsg_GuestUnresponsive::ID: | |
96 case BrowserPluginMsg_LoadAbort::ID: | |
97 case BrowserPluginMsg_LoadCommit::ID: | |
98 case BrowserPluginMsg_LoadRedirect::ID: | |
99 case BrowserPluginMsg_LoadStart::ID: | |
100 case BrowserPluginMsg_LoadStop::ID: | |
101 case BrowserPluginMsg_SetCursor::ID: | |
102 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: | |
103 case BrowserPluginMsg_UpdateRect::ID: | |
104 return true; | |
105 default: | |
106 break; | |
107 } | |
108 return false; | |
109 } | |
110 | |
111 } // namespace content | 89 } // namespace content |
OLD | NEW |