Chromium Code Reviews| 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 "base/values.h" | 7 #include "base/values.h" |
| 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| 94 void BrowserPluginEmbedder::DidSendScreenRects() { | 94 void BrowserPluginEmbedder::DidSendScreenRects() { |
| 95 GetBrowserPluginGuestManager()->ForEachGuest( | 95 GetBrowserPluginGuestManager()->ForEachGuest( |
| 96 GetWebContents(), base::Bind( | 96 GetWebContents(), base::Bind( |
| 97 &BrowserPluginEmbedder::DidSendScreenRectsCallback)); | 97 &BrowserPluginEmbedder::DidSendScreenRectsCallback)); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { | 100 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { |
| 101 return OnMessageReceived(message, nullptr); | |
| 102 } | |
| 103 | |
| 104 bool BrowserPluginEmbedder::OnMessageReceived( | |
| 105 const IPC::Message& message, | |
| 106 RenderFrameHost* render_frame_host) { | |
| 101 bool handled = true; | 107 bool handled = true; |
| 102 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message) | 108 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BrowserPluginEmbedder, message, |
| 109 render_frame_host) | |
| 103 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach) | 110 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach) |
| 104 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor, | 111 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor, |
| 105 OnUpdateDragCursor(&handled)); | 112 OnUpdateDragCursor(&handled)); |
| 106 IPC_MESSAGE_UNHANDLED(handled = false) | 113 IPC_MESSAGE_UNHANDLED(handled = false) |
| 107 IPC_END_MESSAGE_MAP() | 114 IPC_END_MESSAGE_MAP() |
| 108 return handled; | 115 return handled; |
| 109 } | 116 } |
| 110 | 117 |
| 111 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, | 118 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, |
| 112 int screen_x, int screen_y, blink::WebDragOperation operation) { | 119 int screen_x, int screen_y, blink::WebDragOperation operation) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 128 | 135 |
| 129 guest_dragging_over_.reset(); | 136 guest_dragging_over_.reset(); |
| 130 ClearGuestDragStateIfApplicable(); | 137 ClearGuestDragStateIfApplicable(); |
| 131 } | 138 } |
| 132 | 139 |
| 133 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { | 140 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { |
| 134 *handled = (guest_dragging_over_.get() != NULL); | 141 *handled = (guest_dragging_over_.get() != NULL); |
| 135 } | 142 } |
| 136 | 143 |
| 137 void BrowserPluginEmbedder::OnAttach( | 144 void BrowserPluginEmbedder::OnAttach( |
| 145 RenderFrameHost* render_frame_host, | |
| 138 int browser_plugin_instance_id, | 146 int browser_plugin_instance_id, |
| 139 const BrowserPluginHostMsg_Attach_Params& params) { | 147 const BrowserPluginHostMsg_Attach_Params& params) { |
| 148 // TODO(fsamuel): Change message routing to use the process ID of the | |
| 149 // |render_frame_host| once BrowserPlugin IPCs get routed using the RFH | |
| 150 // routing ID. | |
|
Charlie Reis
2015/02/13 22:36:14
nit: Please add a bug number to track this. (Curr
Fady Samuel
2015/02/13 22:47:09
Done.
| |
| 140 WebContents* guest_web_contents = | 151 WebContents* guest_web_contents = |
| 141 GetBrowserPluginGuestManager()->GetGuestByInstanceID( | 152 GetBrowserPluginGuestManager()->GetGuestByInstanceID( |
| 142 GetWebContents(), browser_plugin_instance_id); | 153 GetWebContents()->GetRenderProcessHost()->GetID(), |
| 154 browser_plugin_instance_id); | |
| 143 if (!guest_web_contents) | 155 if (!guest_web_contents) |
| 144 return; | 156 return; |
| 145 BrowserPluginGuest* guest = static_cast<WebContentsImpl*>(guest_web_contents) | 157 BrowserPluginGuest* guest = static_cast<WebContentsImpl*>(guest_web_contents) |
| 146 ->GetBrowserPluginGuest(); | 158 ->GetBrowserPluginGuest(); |
| 147 guest->Attach(browser_plugin_instance_id, GetWebContents(), params); | 159 guest->Attach(browser_plugin_instance_id, GetWebContents(), params); |
| 148 } | 160 } |
| 149 | 161 |
| 150 bool BrowserPluginEmbedder::HandleKeyboardEvent( | 162 bool BrowserPluginEmbedder::HandleKeyboardEvent( |
| 151 const NativeWebKeyboardEvent& event) { | 163 const NativeWebKeyboardEvent& event) { |
| 152 if ((event.windowsKeyCode != ui::VKEY_ESCAPE) || | 164 if ((event.windowsKeyCode != ui::VKEY_ESCAPE) || |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest() | 223 if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest() |
| 212 ->StopFinding(action)) { | 224 ->StopFinding(action)) { |
| 213 // There can only ever currently be one browser plugin that handles find so | 225 // There can only ever currently be one browser plugin that handles find so |
| 214 // we can break the iteration at this point. | 226 // we can break the iteration at this point. |
| 215 return true; | 227 return true; |
| 216 } | 228 } |
| 217 return false; | 229 return false; |
| 218 } | 230 } |
| 219 | 231 |
| 220 } // namespace content | 232 } // namespace content |
| OLD | NEW |