| 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 "chrome/browser/extensions/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 return; | 587 return; |
| 588 } | 588 } |
| 589 | 589 |
| 590 std::unique_ptr<MessageChannel> channel_ptr = | 590 std::unique_ptr<MessageChannel> channel_ptr = |
| 591 base::MakeUnique<MessageChannel>(); | 591 base::MakeUnique<MessageChannel>(); |
| 592 MessageChannel* channel = channel_ptr.get(); | 592 MessageChannel* channel = channel_ptr.get(); |
| 593 channel->opener.reset(opener.release()); | 593 channel->opener.reset(opener.release()); |
| 594 channel->receiver.reset(params->receiver.release()); | 594 channel->receiver.reset(params->receiver.release()); |
| 595 AddChannel(std::move(channel_ptr), params->receiver_port_id); | 595 AddChannel(std::move(channel_ptr), params->receiver_port_id); |
| 596 | 596 |
| 597 // TODO(robwu): Could |guest_process_id| and |guest_render_frame_routing_id| | |
| 598 // be removed? In the past extension message routing was process-based, but | |
| 599 // now that extensions are routed from a specific RFH, the special casing for | |
| 600 // guest views seems no longer necessary, because the ExtensionMessagePort can | |
| 601 // simply obtain the source process & frame ID directly from the RFH. | |
| 602 int guest_process_id = content::ChildProcessHost::kInvalidUniqueID; | |
| 603 int guest_render_frame_routing_id = MSG_ROUTING_NONE; | |
| 604 if (params->include_guest_process_info) { | |
| 605 guest_process_id = params->source_process_id; | |
| 606 guest_render_frame_routing_id = params->source_routing_id; | |
| 607 | |
| 608 DCHECK(WebViewGuest::FromWebContents( | |
| 609 WebContents::FromRenderFrameHost(source))); | |
| 610 } | |
| 611 | |
| 612 // Send the connect event to the receiver. Give it the opener's port ID (the | 597 // Send the connect event to the receiver. Give it the opener's port ID (the |
| 613 // opener has the opposite port ID). | 598 // opener has the opposite port ID). |
| 614 channel->receiver->DispatchOnConnect( | 599 channel->receiver->DispatchOnConnect( |
| 615 params->channel_name, std::move(params->source_tab), | 600 params->channel_name, std::move(params->source_tab), |
| 616 params->source_frame_id, guest_process_id, guest_render_frame_routing_id, | 601 params->source_frame_id, params->include_guest_process_info, |
| 602 params->source_process_id, params->source_routing_id, |
| 617 params->source_extension_id, params->target_extension_id, | 603 params->source_extension_id, params->target_extension_id, |
| 618 params->source_url, params->tls_channel_id); | 604 params->source_url, params->tls_channel_id); |
| 619 | 605 |
| 620 // Report the event to the event router, if the target is an extension. | 606 // Report the event to the event router, if the target is an extension. |
| 621 // | 607 // |
| 622 // First, determine what event this will be (runtime.onConnect vs | 608 // First, determine what event this will be (runtime.onConnect vs |
| 623 // runtime.onMessage etc), and what the event target is (view vs background | 609 // runtime.onMessage etc), and what the event target is (view vs background |
| 624 // page etc). | 610 // page etc). |
| 625 // | 611 // |
| 626 // Yes - even though this is opening a channel, they may actually be | 612 // Yes - even though this is opening a channel, they may actually be |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); | 1004 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); |
| 1019 if (channel_iter != channels_.end()) { | 1005 if (channel_iter != channels_.end()) { |
| 1020 for (const PendingMessage& message : queue) { | 1006 for (const PendingMessage& message : queue) { |
| 1021 DispatchMessage(message.first, channel_iter->second.get(), | 1007 DispatchMessage(message.first, channel_iter->second.get(), |
| 1022 message.second); | 1008 message.second); |
| 1023 } | 1009 } |
| 1024 } | 1010 } |
| 1025 } | 1011 } |
| 1026 | 1012 |
| 1027 } // namespace extensions | 1013 } // namespace extensions |
| OLD | NEW |