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