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 IPC::Message* BrowserPluginGuest::UpdateInstanceIdIfNecessary( | |
568 IPC::Message* msg) const { | |
569 DCHECK(msg); | |
570 | |
571 int msg_browser_plugin_instance_id = browser_plugin::kInstanceIDNone; | |
572 base::PickleIterator iter(*msg); | |
573 if (!iter.ReadInt(&msg_browser_plugin_instance_id) || | |
574 msg_browser_plugin_instance_id != browser_plugin::kInstanceIDNone) { | |
575 return msg; | |
576 } | |
577 | |
578 // This method may be called with no browser_plugin_instance_id in tests. | |
579 if (!browser_plugin_instance_id()) | |
580 return msg; | |
581 | |
582 scoped_ptr<IPC::Message> new_msg( | |
583 new IPC::Message(msg->routing_id(), msg->type(), msg->priority())); | |
584 new_msg->WriteInt(browser_plugin_instance_id()); | |
585 | |
586 // Copy remaining payload from original message. | |
587 // TODO(wjmaclean): it would be nice if IPC::PickleIterator had a method | |
588 // like 'RemainingBytes()' so that we don't have to include implementation- | |
589 // specific details like sizeof() in the next line. | |
590 DCHECK(msg->payload_size() > sizeof(int)); | |
591 size_t remaining_bytes = msg->payload_size() - sizeof(int); | |
592 const char* data = nullptr; | |
593 if (!iter.ReadBytes(&data, remaining_bytes)) { | |
594 LOG(ERROR) << "Unexpected failure reading remaining IPC::Message payload."; | |
lfg
2015/10/16 16:26:36
This should never happen, and if it does, we still
wjmaclean
2015/10/16 16:50:34
Ok. I had sort of thought that falling back to the
| |
595 return msg; | |
596 } | |
597 | |
598 if (!new_msg->WriteBytes(data, remaining_bytes)) { | |
599 LOG(ERROR) << "Unexpected failure writing remaining IPC::Message payload."; | |
600 return msg; | |
601 } | |
602 | |
603 delete msg; | |
604 return new_msg.release(); | |
605 } | |
606 | |
567 void BrowserPluginGuest::SendQueuedMessages() { | 607 void BrowserPluginGuest::SendQueuedMessages() { |
568 if (!attached()) | 608 if (!attached()) |
569 return; | 609 return; |
570 | 610 |
571 while (!pending_messages_.empty()) { | 611 while (!pending_messages_.empty()) { |
572 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); | 612 linked_ptr<IPC::Message> message_ptr = pending_messages_.front(); |
573 pending_messages_.pop_front(); | 613 pending_messages_.pop_front(); |
574 SendMessageToEmbedder(message_ptr.release()); | 614 SendMessageToEmbedder( |
615 UpdateInstanceIdIfNecessary(message_ptr.release())); | |
575 } | 616 } |
576 } | 617 } |
577 | 618 |
578 void BrowserPluginGuest::SendTextInputTypeChangedToView( | 619 void BrowserPluginGuest::SendTextInputTypeChangedToView( |
579 RenderWidgetHostViewBase* guest_rwhv) { | 620 RenderWidgetHostViewBase* guest_rwhv) { |
580 if (!guest_rwhv) | 621 if (!guest_rwhv) |
581 return; | 622 return; |
582 | 623 |
583 if (!owner_web_contents_) { | 624 if (!owner_web_contents_) { |
584 // If we were showing an interstitial, then we can end up here during | 625 // 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); | 1052 range, character_bounds); |
1012 } | 1053 } |
1013 #endif | 1054 #endif |
1014 | 1055 |
1015 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1056 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1016 if (delegate_) | 1057 if (delegate_) |
1017 delegate_->SetContextMenuPosition(position); | 1058 delegate_->SetContextMenuPosition(position); |
1018 } | 1059 } |
1019 | 1060 |
1020 } // namespace content | 1061 } // namespace content |
OLD | NEW |