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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 return; | 442 return; |
443 } | 443 } |
444 | 444 |
445 scoped_ptr<MessageChannel> channel(new MessageChannel()); | 445 scoped_ptr<MessageChannel> channel(new MessageChannel()); |
446 channel->opener.reset( | 446 channel->opener.reset( |
447 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), | 447 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), |
448 GET_OPPOSITE_PORT_ID(receiver_port_id), | 448 GET_OPPOSITE_PORT_ID(receiver_port_id), |
449 source_extension_id, source, false)); | 449 source_extension_id, source, false)); |
450 if (!channel->opener->IsValidPort()) | 450 if (!channel->opener->IsValidPort()) |
451 return; | 451 return; |
| 452 channel->opener->OpenPort(source_process_id, source_routing_id); |
452 | 453 |
453 // Get handle of the native view and pass it to the native messaging host. | 454 // Get handle of the native view and pass it to the native messaging host. |
454 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr; | 455 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr; |
455 | 456 |
456 std::string error = kReceivingEndDoesntExistError; | 457 std::string error = kReceivingEndDoesntExistError; |
457 scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create( | 458 scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create( |
458 native_view, | 459 native_view, |
459 source_extension_id, | 460 source_extension_id, |
460 native_app_name, | 461 native_app_name, |
461 policy_permission == ALLOW_ALL, | 462 policy_permission == ALLOW_ALL, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 kReceivingEndDoesntExistError); | 569 kReceivingEndDoesntExistError); |
569 return; | 570 return; |
570 } | 571 } |
571 | 572 |
572 scoped_ptr<MessagePort> opener( | 573 scoped_ptr<MessagePort> opener( |
573 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), | 574 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), |
574 GET_OPPOSITE_PORT_ID(params->receiver_port_id), | 575 GET_OPPOSITE_PORT_ID(params->receiver_port_id), |
575 params->source_extension_id, source, false)); | 576 params->source_extension_id, source, false)); |
576 if (!opener->IsValidPort()) | 577 if (!opener->IsValidPort()) |
577 return; | 578 return; |
| 579 opener->OpenPort(params->source_process_id, params->source_routing_id); |
578 | 580 |
579 params->receiver->RemoveCommonFrames(*opener); | 581 params->receiver->RemoveCommonFrames(*opener); |
580 if (!params->receiver->IsValidPort()) { | 582 if (!params->receiver->IsValidPort()) { |
581 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); | 583 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); |
582 return; | 584 return; |
583 } | 585 } |
584 | 586 |
585 MessageChannel* channel(new MessageChannel()); | 587 MessageChannel* channel(new MessageChannel()); |
586 channel->opener.reset(opener.release()); | 588 channel->opener.reset(opener.release()); |
587 channel->receiver.reset(params->receiver.release()); | 589 channel->receiver.reset(params->receiver.release()); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 | 1010 |
1009 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); | 1011 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); |
1010 if (channel_iter != channels_.end()) { | 1012 if (channel_iter != channels_.end()) { |
1011 for (const PendingMessage& message : queue) { | 1013 for (const PendingMessage& message : queue) { |
1012 DispatchMessage(message.first, channel_iter->second, message.second); | 1014 DispatchMessage(message.first, channel_iter->second, message.second); |
1013 } | 1015 } |
1014 } | 1016 } |
1015 } | 1017 } |
1016 | 1018 |
1017 } // namespace extensions | 1019 } // namespace extensions |
OLD | NEW |