| 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(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 int64 frame_id, | 100 int instance_id, |
| 133 const std::string& src, | 101 int64 frame_id, |
| 134 const gfx::Size& size) { | 102 const std::string& src, |
| 135 embedder_->NavigateGuest(render_view_host(), instance_id, frame_id, src, | 103 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { |
| 136 size); | 104 embedder_->NavigateGuest(render_view_host(), |
| 105 instance_id, |
| 106 frame_id, |
| 107 src, |
| 108 resize_params); |
| 137 } | 109 } |
| 138 | 110 |
| 139 void BrowserPluginEmbedderHelper::OnUpdateRectACK(int instance_id, | 111 void BrowserPluginEmbedderHelper::OnUpdateRectACK(int instance_id, |
| 140 int message_id, | 112 int message_id, |
| 141 const gfx::Size& size) { | 113 const gfx::Size& size) { |
| 142 embedder_->UpdateRectACK(instance_id, message_id, size); | 114 embedder_->UpdateRectACK(instance_id, message_id, size); |
| 143 } | 115 } |
| 144 | 116 |
| 145 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) { | 117 void BrowserPluginEmbedderHelper::OnSetFocus(int instance_id, bool focused) { |
| 146 embedder_->SetFocus(instance_id, focused); | 118 embedder_->SetFocus(instance_id, focused); |
| 147 } | 119 } |
| 148 | 120 |
| 149 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { | 121 void BrowserPluginEmbedderHelper::OnPluginDestroyed(int instance_id) { |
| 150 embedder_->PluginDestroyed(instance_id); | 122 embedder_->PluginDestroyed(instance_id); |
| 151 } | 123 } |
| 152 | 124 |
| 153 void BrowserPluginEmbedderHelper::OnStop(int instance_id) { | 125 void BrowserPluginEmbedderHelper::OnStop(int instance_id) { |
| 154 embedder_->Stop(instance_id); | 126 embedder_->Stop(instance_id); |
| 155 } | 127 } |
| 156 | 128 |
| 157 void BrowserPluginEmbedderHelper::OnReload(int instance_id) { | 129 void BrowserPluginEmbedderHelper::OnReload(int instance_id) { |
| 158 embedder_->Reload(instance_id); | 130 embedder_->Reload(instance_id); |
| 159 } | 131 } |
| 160 | 132 |
| 161 } // namespace content | 133 } // namespace content |
| OLD | NEW |