| 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.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
| 6 | 6 |
| 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 7 #include "content/browser/browser_plugin/browser_plugin_guest.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/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/browser_plugin/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Not handled => Iterate over all guests. | 109 // Not handled => Iterate over all guests. |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void BrowserPluginEmbedder::DidSendScreenRects() { | 113 void BrowserPluginEmbedder::DidSendScreenRects() { |
| 114 GetBrowserPluginGuestManager()->ForEachGuest( | 114 GetBrowserPluginGuestManager()->ForEachGuest( |
| 115 web_contents(), | 115 web_contents(), |
| 116 base::Bind(&BrowserPluginEmbedder::DidSendScreenRectsCallback)); | 116 base::Bind(&BrowserPluginEmbedder::DidSendScreenRectsCallback)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { | |
| 120 return OnMessageReceived(message, nullptr); | |
| 121 } | |
| 122 | |
| 123 bool BrowserPluginEmbedder::OnMessageReceived( | 119 bool BrowserPluginEmbedder::OnMessageReceived( |
| 124 const IPC::Message& message, | 120 const IPC::Message& message, |
| 125 RenderFrameHost* render_frame_host) { | 121 RenderFrameHost* render_frame_host) { |
| 126 bool handled = true; | 122 bool handled = true; |
| 127 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BrowserPluginEmbedder, message, | 123 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BrowserPluginEmbedder, message, |
| 128 render_frame_host) | 124 render_frame_host) |
| 129 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach) | 125 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach) |
| 130 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor, | |
| 131 OnUpdateDragCursor(&handled)); | |
| 132 IPC_MESSAGE_UNHANDLED(handled = false) | 126 IPC_MESSAGE_UNHANDLED(handled = false) |
| 133 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
| 134 return handled; | 128 return handled; |
| 135 } | 129 } |
| 136 | 130 |
| 137 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, | 131 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, |
| 138 int screen_x, int screen_y, blink::WebDragOperation operation) { | 132 int screen_x, int screen_y, blink::WebDragOperation operation) { |
| 139 if (guest_started_drag_) { | 133 if (guest_started_drag_) { |
| 140 gfx::Point guest_offset = | 134 gfx::Point guest_offset = |
| 141 guest_started_drag_->GetScreenCoordinates(gfx::Point()); | 135 guest_started_drag_->GetScreenCoordinates(gfx::Point()); |
| 142 guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(), | 136 guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(), |
| 143 client_y - guest_offset.y(), screen_x, screen_y, operation); | 137 client_y - guest_offset.y(), screen_x, screen_y, operation); |
| 144 } | 138 } |
| 145 ClearGuestDragStateIfApplicable(); | 139 ClearGuestDragStateIfApplicable(); |
| 146 } | 140 } |
| 147 | 141 |
| 148 void BrowserPluginEmbedder::SystemDragEnded() { | 142 void BrowserPluginEmbedder::SystemDragEnded() { |
| 149 // When the embedder's drag/drop operation ends, we need to pass the message | 143 // When the embedder's drag/drop operation ends, we need to pass the message |
| 150 // to the guest that initiated the drag/drop operation. This will ensure that | 144 // to the guest that initiated the drag/drop operation. This will ensure that |
| 151 // the guest's RVH state is reset properly. | 145 // the guest's RVH state is reset properly. |
| 152 if (guest_started_drag_) | 146 if (guest_started_drag_) |
| 153 guest_started_drag_->EmbedderSystemDragEnded(); | 147 guest_started_drag_->EmbedderSystemDragEnded(); |
| 154 | 148 |
| 155 guest_dragging_over_.reset(); | 149 guest_dragging_over_.reset(); |
| 156 ClearGuestDragStateIfApplicable(); | 150 ClearGuestDragStateIfApplicable(); |
| 157 } | 151 } |
| 158 | 152 |
| 159 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { | 153 bool BrowserPluginEmbedder::OnUpdateDragCursor() { |
| 160 *handled = !!guest_dragging_over_; | 154 return !!guest_dragging_over_; |
| 161 } | 155 } |
| 162 | 156 |
| 163 void BrowserPluginEmbedder::OnAttach( | 157 void BrowserPluginEmbedder::OnAttach( |
| 164 RenderFrameHost* render_frame_host, | 158 RenderFrameHost* render_frame_host, |
| 165 int browser_plugin_instance_id, | 159 int browser_plugin_instance_id, |
| 166 const BrowserPluginHostMsg_Attach_Params& params) { | 160 const BrowserPluginHostMsg_Attach_Params& params) { |
| 167 WebContents* guest_web_contents = | 161 WebContents* guest_web_contents = |
| 168 GetBrowserPluginGuestManager()->GetGuestByInstanceID( | 162 GetBrowserPluginGuestManager()->GetGuestByInstanceID( |
| 169 render_frame_host->GetProcess()->GetID(), | 163 render_frame_host->GetProcess()->GetID(), |
| 170 browser_plugin_instance_id); | 164 browser_plugin_instance_id); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 ->GetBrowserPluginGuest() | 257 ->GetBrowserPluginGuest() |
| 264 ->HandleStopFindingForEmbedder(action)) { | 258 ->HandleStopFindingForEmbedder(action)) { |
| 265 // There can only ever currently be one browser plugin that handles find so | 259 // There can only ever currently be one browser plugin that handles find so |
| 266 // we can break the iteration at this point. | 260 // we can break the iteration at this point. |
| 267 return true; | 261 return true; |
| 268 } | 262 } |
| 269 return false; | 263 return false; |
| 270 } | 264 } |
| 271 | 265 |
| 272 } // namespace content | 266 } // namespace content |
| OLD | NEW |