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/browser/browser_plugin/browser_plugin_embedder_helper.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h" |
6 | 6 |
7 #include "content/browser/browser_plugin/browser_plugin_embedder.h" | 7 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/common/browser_plugin_messages.h" | 9 #include "content/common/browser_plugin_messages.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop) | 46 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Stop, OnStop) |
47 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) | 47 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Reload, OnReload) |
48 IPC_MESSAGE_UNHANDLED(handled = false) | 48 IPC_MESSAGE_UNHANDLED(handled = false) |
49 IPC_END_MESSAGE_MAP() | 49 IPC_END_MESSAGE_MAP() |
50 return handled; | 50 return handled; |
51 } | 51 } |
52 | 52 |
53 void BrowserPluginEmbedderHelper::OnResizeGuest( | 53 void BrowserPluginEmbedderHelper::OnResizeGuest( |
54 int instance_id, | 54 int instance_id, |
55 const BrowserPluginHostMsg_ResizeGuest_Params& params) { | 55 const BrowserPluginHostMsg_ResizeGuest_Params& params) { |
56 TransportDIB* damage_buffer = NULL; | 56 embedder_->ResizeGuest(render_view_host(), instance_id, params); |
57 #if defined(OS_WIN) | |
58 // On Windows we need to duplicate the handle from the remote process. | |
59 HANDLE section; | |
60 DuplicateHandle(render_view_host()->GetProcess()->GetHandle(), | |
61 params.damage_buffer_id.handle, | |
62 GetCurrentProcess(), | |
63 §ion, | |
64 STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, | |
65 FALSE, 0); | |
66 damage_buffer = TransportDIB::Map(section); | |
67 #elif defined(OS_MACOSX) | |
68 // On OSX, the browser allocates all DIBs and keeps a file descriptor around | |
69 // for each. | |
70 damage_buffer = render_view_host()->GetProcess()-> | |
71 GetTransportDIB(params.damage_buffer_id); | |
72 #elif defined(OS_ANDROID) | |
73 damage_buffer = TransportDIB::Map(params.damage_buffer_id); | |
74 #elif defined(OS_POSIX) | |
75 damage_buffer = TransportDIB::Map(params.damage_buffer_id.shmkey); | |
76 #endif // defined(OS_POSIX) | |
77 DCHECK(damage_buffer); | |
78 // TODO(fsamuel): Schedule this later so that we don't stall the embedder for | |
79 // too long. | |
80 embedder_->ResizeGuest(instance_id, | |
81 damage_buffer, | |
82 #if defined(OS_WIN) | |
83 params.damage_buffer_size, | |
84 #endif | |
85 params.width, | |
86 params.height, | |
87 params.resize_pending, | |
88 params.scale_factor); | |
89 } | 57 } |
90 | 58 |
91 void BrowserPluginEmbedderHelper::OnHandleInputEvent( | 59 void BrowserPluginEmbedderHelper::OnHandleInputEvent( |
92 const IPC::SyncMessage& message, | 60 const IPC::SyncMessage& message, |
93 bool* handled) { | 61 bool* handled) { |
94 *handled = true; | 62 *handled = true; |
95 PickleIterator iter(message); | 63 PickleIterator iter(message); |
96 | 64 |
97 // TODO(fsamuel): This appears to be a monotonically increasing value. | 65 // TODO(fsamuel): This appears to be a monotonically increasing value. |
98 int instance_id = -1; | 66 int instance_id = -1; |
(...skipping 22 matching lines...) Expand all Loading... |
121 | 89 |
122 IPC::Message* reply_message = | 90 IPC::Message* reply_message = |
123 IPC::SyncMessage::GenerateReply(&message); | 91 IPC::SyncMessage::GenerateReply(&message); |
124 embedder_->HandleInputEvent(instance_id, | 92 embedder_->HandleInputEvent(instance_id, |
125 rvh, | 93 rvh, |
126 guest_screen_rect, | 94 guest_screen_rect, |
127 *input_event, | 95 *input_event, |
128 reply_message); | 96 reply_message); |
129 } | 97 } |
130 | 98 |
131 void BrowserPluginEmbedderHelper::OnNavigateGuest(int instance_id, | 99 void BrowserPluginEmbedderHelper::OnNavigateGuest( |
132 const std::string& src, | 100 int instance_id, |
133 const gfx::Size& size) { | 101 const std::string& src, |
134 embedder_->NavigateGuest(render_view_host(), instance_id, src, size); | 102 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { |
| 103 embedder_->NavigateGuest(render_view_host(), |
| 104 instance_id, |
| 105 src, |
| 106 resize_params); |
135 } | 107 } |
136 | 108 |
137 void BrowserPluginEmbedderHelper::OnUpdateRectACK(int instance_id, | 109 void BrowserPluginEmbedderHelper::OnUpdateRectACK(int instance_id, |
138 int message_id, | 110 int message_id, |
139 const gfx::Size& size) { | 111 const gfx::Size& size) { |
140 embedder_->UpdateRectACK(instance_id, message_id, size); | 112 embedder_->UpdateRectACK(instance_id, message_id, size); |
141 } | 113 } |
142 | 114 |
143 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) { | 115 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) { |
144 embedder_->SetFocus(instance_id, focused); | 116 embedder_->SetFocus(instance_id, focused); |
145 } | 117 } |
146 | 118 |
147 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { | 119 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { |
148 embedder_->PluginDestroyed(instance_id); | 120 embedder_->PluginDestroyed(instance_id); |
149 } | 121 } |
150 | 122 |
151 void BrowserPluginEmbedderHelper::OnStop(int instance_id) { | 123 void BrowserPluginEmbedderHelper::OnStop(int instance_id) { |
152 embedder_->Stop(instance_id); | 124 embedder_->Stop(instance_id); |
153 } | 125 } |
154 | 126 |
155 void BrowserPluginEmbedderHelper::OnReload(int instance_id) { | 127 void BrowserPluginEmbedderHelper::OnReload(int instance_id) { |
156 embedder_->Reload(instance_id); | 128 embedder_->Reload(instance_id); |
157 } | 129 } |
158 | 130 |
159 } // namespace content | 131 } // namespace content |
OLD | NEW |