Index: content/browser/browser_plugin/browser_plugin_guest.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc |
index 00529ffab22904afb2517c11d4d8eac2b82d20e6..f9684c6cec0f17fa52db0646a7fb37370c533743 100644 |
--- a/content/browser/browser_plugin/browser_plugin_guest.cc |
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc |
@@ -444,9 +444,10 @@ void BrowserPluginGuest::OnRequireSequence( |
} |
void BrowserPluginGuest::SetContentsOpaque(bool opaque) { |
- SendMessageToEmbedder( |
- new BrowserPluginMsg_SetContentsOpaque( |
- browser_plugin_instance_id(), opaque)); |
+ SendMessageToEmbedder([opaque](int browser_plugin_instance_id) { |
+ return new BrowserPluginMsg_SetContentsOpaque(browser_plugin_instance_id, |
+ opaque); |
+ }); |
} |
bool BrowserPluginGuest::Find(int request_id, |
@@ -504,6 +505,8 @@ gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
return screen_pos; |
} |
+// TODO(wjmaclean): Remove this function once all messages are handled with |
+// functionals. |
void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
// During tests, attache() may be true when there is no owner_web_contents_; |
// in this case just queue any messages we receive. |
@@ -519,6 +522,22 @@ void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
owner_web_contents_->Send(msg); |
} |
+void BrowserPluginGuest::SendMessageToEmbedder( |
+ BrowserPluginMessageFunc msg_func) { |
+ // During tests, attache() may be true when there is no owner_web_contents_; |
lazyboy
2015/10/16 00:15:48
attached()
|
+ // in this case just queue any messages we receive. |
+ if (!attached() || !owner_web_contents_) { |
+ // Some pages such as data URLs, javascript URLs, and about:blank |
+ // do not load external resources and so they load prior to attachment. |
+ // As a result, we must save all these IPCs until attachment and then |
+ // forward them so that the embedder gets a chance to see and process |
+ // the load events. |
+ pending_message_funcs_.push_back(msg_func); |
+ return; |
+ } |
+ owner_web_contents_->Send(msg_func(browser_plugin_instance_id())); |
+} |
+ |
void BrowserPluginGuest::DragSourceEndedAt(int client_x, int client_y, |
int screen_x, int screen_y, blink::WebDragOperation operation) { |
web_contents()->GetRenderViewHost()->DragSourceEndedAt(client_x, client_y, |
@@ -568,11 +587,19 @@ void BrowserPluginGuest::SendQueuedMessages() { |
if (!attached()) |
return; |
+ // TODO(wjmaclean): Remove this block once all messages are handled with |
+ // functionals. |
while (!pending_messages_.empty()) { |
linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); |
Fady Samuel
2015/10/16 02:48:43
Perhaps you can grab the payload of the IPC::Messa
|
pending_messages_.pop_front(); |
SendMessageToEmbedder(message_ptr.release()); |
} |
+ |
+ while (!pending_message_funcs_.empty()) { |
lazyboy
2015/10/16 00:15:48
Having two queues will send messages out of order,
|
+ SendMessageToEmbedder( |
+ pending_message_funcs_.front()(browser_plugin_instance_id())); |
+ pending_message_funcs_.pop_front(); |
+ } |
} |
void BrowserPluginGuest::SendTextInputTypeChangedToView( |