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_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 seen_embedder_drag_source_ended_at_ = false; | 557 seen_embedder_drag_source_ended_at_ = false; |
| 558 dragged_url_ = GURL(); | 558 dragged_url_ = GURL(); |
| 559 } | 559 } |
| 560 } | 560 } |
| 561 | 561 |
| 562 void BrowserPluginGuest::EmbedderSystemDragEnded() { | 562 void BrowserPluginGuest::EmbedderSystemDragEnded() { |
| 563 seen_embedder_system_drag_ended_ = true; | 563 seen_embedder_system_drag_ended_ = true; |
| 564 EndSystemDragIfApplicable(); | 564 EndSystemDragIfApplicable(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 // TODO(wjmaclean): Replace this approach with ones based on std::function | |
| 568 // as in https://codereview.chromium.org/1404353004/ once all Chrome platforms | |
| 569 // support this. https://crbug.com/544212 | |
| 570 IPC::Message* BrowserPluginGuest::UpdateInstanceIdIfNecessary( | |
| 571 IPC::Message* msg) const { | |
| 572 DCHECK(msg); | |
| 573 | |
| 574 int msg_browser_plugin_instance_id = browser_plugin::kInstanceIDNone; | |
| 575 base::PickleIterator iter(*msg); | |
| 576 if (!iter.ReadInt(&msg_browser_plugin_instance_id) || | |
| 577 msg_browser_plugin_instance_id != browser_plugin::kInstanceIDNone) { | |
| 578 return msg; | |
| 579 } | |
| 580 | |
| 581 // This method may be called with no browser_plugin_instance_id in tests. | |
| 582 if (!browser_plugin_instance_id()) | |
| 583 return msg; | |
| 584 | |
| 585 scoped_ptr<IPC::Message> new_msg( | |
| 586 new IPC::Message(msg->routing_id(), msg->type(), msg->priority())); | |
| 587 new_msg->WriteInt(browser_plugin_instance_id()); | |
| 588 | |
| 589 // Copy remaining payload from original message. | |
| 590 // TODO(wjmaclean): it would be nice if IPC::PickleIterator had a method | |
| 591 // like 'RemainingBytes()' so that we don't have to include implementation- | |
| 592 // specific details like sizeof() in the next line. | |
| 593 DCHECK(msg->payload_size() > sizeof(int)); | |
| 594 size_t remaining_bytes = msg->payload_size() - sizeof(int); | |
| 595 const char* data = nullptr; | |
| 596 CHECK(iter.ReadBytes(&data, remaining_bytes)) | |
|
lfg
2015/10/16 18:25:49
It's not a good idea to have the code inside the C
lazyboy
2015/10/16 18:27:15
+1 Thanks for noticing this.
| |
| 597 << "Unexpected failure reading remaining IPC::Message payload."; | |
| 598 CHECK(new_msg->WriteBytes(data, remaining_bytes)) | |
| 599 << "Unexpected failure writing remaining IPC::Message payload."; | |
| 600 | |
| 601 delete msg; | |
| 602 return new_msg.release(); | |
| 603 } | |
| 604 | |
| 567 void BrowserPluginGuest::SendQueuedMessages() { | 605 void BrowserPluginGuest::SendQueuedMessages() { |
| 568 if (!attached()) | 606 if (!attached()) |
| 569 return; | 607 return; |
| 570 | 608 |
| 571 while (!pending_messages_.empty()) { | 609 while (!pending_messages_.empty()) { |
| 572 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); | 610 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); |
| 573 pending_messages_.pop_front(); | 611 pending_messages_.pop_front(); |
| 574 SendMessageToEmbedder(message_ptr.release()); | 612 SendMessageToEmbedder( |
| 613 UpdateInstanceIdIfNecessary(message_ptr.release())); | |
| 575 } | 614 } |
| 576 } | 615 } |
| 577 | 616 |
| 578 void BrowserPluginGuest::SendTextInputTypeChangedToView( | 617 void BrowserPluginGuest::SendTextInputTypeChangedToView( |
| 579 RenderWidgetHostViewBase* guest_rwhv) { | 618 RenderWidgetHostViewBase* guest_rwhv) { |
| 580 if (!guest_rwhv) | 619 if (!guest_rwhv) |
| 581 return; | 620 return; |
| 582 | 621 |
| 583 if (!owner_web_contents_) { | 622 if (!owner_web_contents_) { |
| 584 // If we were showing an interstitial, then we can end up here during | 623 // If we were showing an interstitial, then we can end up here during |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 range, character_bounds); | 1050 range, character_bounds); |
| 1012 } | 1051 } |
| 1013 #endif | 1052 #endif |
| 1014 | 1053 |
| 1015 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1054 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1016 if (delegate_) | 1055 if (delegate_) |
| 1017 delegate_->SetContextMenuPosition(position); | 1056 delegate_->SetContextMenuPosition(position); |
| 1018 } | 1057 } |
| 1019 | 1058 |
| 1020 } // namespace content | 1059 } // namespace content |
| OLD | NEW |