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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 "Could not establish connection. Receiving end does not exist."; | 120 "Could not establish connection. Receiving end does not exist."; |
121 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 121 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
122 const char kMissingPermissionError[] = | 122 const char kMissingPermissionError[] = |
123 "Access to native messaging requires nativeMessaging permission."; | 123 "Access to native messaging requires nativeMessaging permission."; |
124 const char kProhibitedByPoliciesError[] = | 124 const char kProhibitedByPoliciesError[] = |
125 "Access to the native messaging host was disabled by the system " | 125 "Access to the native messaging host was disabled by the system " |
126 "administrator."; | 126 "administrator."; |
127 #endif | 127 #endif |
128 | 128 |
129 struct MessageService::MessageChannel { | 129 struct MessageService::MessageChannel { |
130 scoped_ptr<MessagePort> opener; | 130 std::unique_ptr<MessagePort> opener; |
131 scoped_ptr<MessagePort> receiver; | 131 std::unique_ptr<MessagePort> receiver; |
132 }; | 132 }; |
133 | 133 |
134 struct MessageService::OpenChannelParams { | 134 struct MessageService::OpenChannelParams { |
135 int source_process_id; | 135 int source_process_id; |
136 int source_routing_id; | 136 int source_routing_id; |
137 scoped_ptr<base::DictionaryValue> source_tab; | 137 std::unique_ptr<base::DictionaryValue> source_tab; |
138 int source_frame_id; | 138 int source_frame_id; |
139 scoped_ptr<MessagePort> receiver; | 139 std::unique_ptr<MessagePort> receiver; |
140 int receiver_port_id; | 140 int receiver_port_id; |
141 std::string source_extension_id; | 141 std::string source_extension_id; |
142 std::string target_extension_id; | 142 std::string target_extension_id; |
143 GURL source_url; | 143 GURL source_url; |
144 std::string channel_name; | 144 std::string channel_name; |
145 bool include_tls_channel_id; | 145 bool include_tls_channel_id; |
146 std::string tls_channel_id; | 146 std::string tls_channel_id; |
147 bool include_guest_process_info; | 147 bool include_guest_process_info; |
148 | 148 |
149 // Takes ownership of receiver. | 149 // Takes ownership of receiver. |
150 OpenChannelParams(int source_process_id, | 150 OpenChannelParams(int source_process_id, |
151 int source_routing_id, | 151 int source_routing_id, |
152 scoped_ptr<base::DictionaryValue> source_tab, | 152 std::unique_ptr<base::DictionaryValue> source_tab, |
153 int source_frame_id, | 153 int source_frame_id, |
154 MessagePort* receiver, | 154 MessagePort* receiver, |
155 int receiver_port_id, | 155 int receiver_port_id, |
156 const std::string& source_extension_id, | 156 const std::string& source_extension_id, |
157 const std::string& target_extension_id, | 157 const std::string& target_extension_id, |
158 const GURL& source_url, | 158 const GURL& source_url, |
159 const std::string& channel_name, | 159 const std::string& channel_name, |
160 bool include_tls_channel_id, | 160 bool include_tls_channel_id, |
161 bool include_guest_process_info) | 161 bool include_guest_process_info) |
162 : source_process_id(source_process_id), | 162 : source_process_id(source_process_id), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 return; | 317 return; |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 WebContents* source_contents = tab_util::GetWebContentsByFrameID( | 321 WebContents* source_contents = tab_util::GetWebContentsByFrameID( |
322 source_process_id, source_routing_id); | 322 source_process_id, source_routing_id); |
323 | 323 |
324 bool include_guest_process_info = false; | 324 bool include_guest_process_info = false; |
325 | 325 |
326 // Include info about the opener's tab (if it was a tab). | 326 // Include info about the opener's tab (if it was a tab). |
327 scoped_ptr<base::DictionaryValue> source_tab; | 327 std::unique_ptr<base::DictionaryValue> source_tab; |
328 int source_frame_id = -1; | 328 int source_frame_id = -1; |
329 if (source_contents && ExtensionTabUtil::GetTabId(source_contents) >= 0) { | 329 if (source_contents && ExtensionTabUtil::GetTabId(source_contents) >= 0) { |
330 // Only the tab id is useful to platform apps for internal use. The | 330 // Only the tab id is useful to platform apps for internal use. The |
331 // unnecessary bits will be stripped out in | 331 // unnecessary bits will be stripped out in |
332 // MessagingBindings::DispatchOnConnect(). | 332 // MessagingBindings::DispatchOnConnect(). |
333 source_tab.reset(ExtensionTabUtil::CreateTabObject(source_contents) | 333 source_tab.reset(ExtensionTabUtil::CreateTabObject(source_contents) |
334 ->ToValue() | 334 ->ToValue() |
335 .release()); | 335 .release()); |
336 | 336 |
337 content::RenderFrameHost* rfh = | 337 content::RenderFrameHost* rfh = |
338 content::RenderFrameHost::FromID(source_process_id, source_routing_id); | 338 content::RenderFrameHost::FromID(source_process_id, source_routing_id); |
339 if (rfh) | 339 if (rfh) |
340 source_frame_id = ExtensionApiFrameIdMap::GetFrameId(rfh); | 340 source_frame_id = ExtensionApiFrameIdMap::GetFrameId(rfh); |
341 } else { | 341 } else { |
342 // Check to see if it was a WebView making the request. | 342 // Check to see if it was a WebView making the request. |
343 // Sending messages from WebViews to extensions breaks webview isolation, | 343 // Sending messages from WebViews to extensions breaks webview isolation, |
344 // so only allow component extensions to receive messages from WebViews. | 344 // so only allow component extensions to receive messages from WebViews. |
345 bool is_web_view = !!WebViewGuest::FromWebContents(source_contents); | 345 bool is_web_view = !!WebViewGuest::FromWebContents(source_contents); |
346 if (is_web_view && extensions::Manifest::IsComponentLocation( | 346 if (is_web_view && extensions::Manifest::IsComponentLocation( |
347 target_extension->location())) { | 347 target_extension->location())) { |
348 include_guest_process_info = true; | 348 include_guest_process_info = true; |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 scoped_ptr<OpenChannelParams> params(new OpenChannelParams( | 352 std::unique_ptr<OpenChannelParams> params(new OpenChannelParams( |
353 source_process_id, source_routing_id, std::move(source_tab), | 353 source_process_id, source_routing_id, std::move(source_tab), |
354 source_frame_id, nullptr, receiver_port_id, source_extension_id, | 354 source_frame_id, nullptr, receiver_port_id, source_extension_id, |
355 target_extension_id, source_url, channel_name, include_tls_channel_id, | 355 target_extension_id, source_url, channel_name, include_tls_channel_id, |
356 include_guest_process_info)); | 356 include_guest_process_info)); |
357 | 357 |
358 pending_incognito_channels_[GET_CHANNEL_ID(params->receiver_port_id)] = | 358 pending_incognito_channels_[GET_CHANNEL_ID(params->receiver_port_id)] = |
359 PendingMessagesQueue(); | 359 PendingMessagesQueue(); |
360 if (context->IsOffTheRecord() && | 360 if (context->IsOffTheRecord() && |
361 !util::IsIncognitoEnabled(target_extension_id, context)) { | 361 !util::IsIncognitoEnabled(target_extension_id, context)) { |
362 // Give the user a chance to accept an incognito connection from the web if | 362 // Give the user a chance to accept an incognito connection from the web if |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 PrefService* pref_service = profile->GetPrefs(); | 437 PrefService* pref_service = profile->GetPrefs(); |
438 | 438 |
439 // Verify that the host is not blocked by policies. | 439 // Verify that the host is not blocked by policies. |
440 PolicyPermission policy_permission = | 440 PolicyPermission policy_permission = |
441 IsNativeMessagingHostAllowed(pref_service, native_app_name); | 441 IsNativeMessagingHostAllowed(pref_service, native_app_name); |
442 if (policy_permission == DISALLOW) { | 442 if (policy_permission == DISALLOW) { |
443 DispatchOnDisconnect(source, receiver_port_id, kProhibitedByPoliciesError); | 443 DispatchOnDisconnect(source, receiver_port_id, kProhibitedByPoliciesError); |
444 return; | 444 return; |
445 } | 445 } |
446 | 446 |
447 scoped_ptr<MessageChannel> channel(new MessageChannel()); | 447 std::unique_ptr<MessageChannel> channel(new MessageChannel()); |
448 channel->opener.reset( | 448 channel->opener.reset( |
449 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), | 449 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), |
450 GET_OPPOSITE_PORT_ID(receiver_port_id), | 450 GET_OPPOSITE_PORT_ID(receiver_port_id), |
451 source_extension_id, source, false)); | 451 source_extension_id, source, false)); |
452 if (!channel->opener->IsValidPort()) | 452 if (!channel->opener->IsValidPort()) |
453 return; | 453 return; |
454 channel->opener->OpenPort(source_process_id, source_routing_id); | 454 channel->opener->OpenPort(source_process_id, source_routing_id); |
455 | 455 |
456 // Get handle of the native view and pass it to the native messaging host. | 456 // Get handle of the native view and pass it to the native messaging host. |
457 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr; | 457 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr; |
458 | 458 |
459 std::string error = kReceivingEndDoesntExistError; | 459 std::string error = kReceivingEndDoesntExistError; |
460 scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create( | 460 std::unique_ptr<NativeMessageHost> native_host = NativeMessageHost::Create( |
461 native_view, | 461 native_view, source_extension_id, native_app_name, |
462 source_extension_id, | 462 policy_permission == ALLOW_ALL, &error); |
463 native_app_name, | |
464 policy_permission == ALLOW_ALL, | |
465 &error); | |
466 | 463 |
467 // Abandon the channel. | 464 // Abandon the channel. |
468 if (!native_host.get()) { | 465 if (!native_host.get()) { |
469 LOG(ERROR) << "Failed to create native process."; | 466 LOG(ERROR) << "Failed to create native process."; |
470 DispatchOnDisconnect(source, receiver_port_id, error); | 467 DispatchOnDisconnect(source, receiver_port_id, error); |
471 return; | 468 return; |
472 } | 469 } |
473 channel->receiver.reset(new NativeMessagePort( | 470 channel->receiver.reset(new NativeMessagePort( |
474 weak_factory_.GetWeakPtr(), receiver_port_id, std::move(native_host))); | 471 weak_factory_.GetWeakPtr(), receiver_port_id, std::move(native_host))); |
475 | 472 |
(...skipping 20 matching lines...) Expand all Loading... |
496 DCHECK_GE(frame_id, -1); | 493 DCHECK_GE(frame_id, -1); |
497 | 494 |
498 content::RenderFrameHost* source = | 495 content::RenderFrameHost* source = |
499 content::RenderFrameHost::FromID(source_process_id, source_routing_id); | 496 content::RenderFrameHost::FromID(source_process_id, source_routing_id); |
500 if (!source) | 497 if (!source) |
501 return; | 498 return; |
502 Profile* profile = | 499 Profile* profile = |
503 Profile::FromBrowserContext(source->GetProcess()->GetBrowserContext()); | 500 Profile::FromBrowserContext(source->GetProcess()->GetBrowserContext()); |
504 | 501 |
505 WebContents* contents = NULL; | 502 WebContents* contents = NULL; |
506 scoped_ptr<MessagePort> receiver; | 503 std::unique_ptr<MessagePort> receiver; |
507 if (!ExtensionTabUtil::GetTabById(tab_id, profile, true, NULL, NULL, | 504 if (!ExtensionTabUtil::GetTabById(tab_id, profile, true, NULL, NULL, |
508 &contents, NULL) || | 505 &contents, NULL) || |
509 contents->GetController().NeedsReload()) { | 506 contents->GetController().NeedsReload()) { |
510 // The tab isn't loaded yet. Don't attempt to connect. | 507 // The tab isn't loaded yet. Don't attempt to connect. |
511 DispatchOnDisconnect( | 508 DispatchOnDisconnect( |
512 source, receiver_port_id, kReceivingEndDoesntExistError); | 509 source, receiver_port_id, kReceivingEndDoesntExistError); |
513 return; | 510 return; |
514 } | 511 } |
515 | 512 |
516 // Frame ID -1 is every frame in the tab. | 513 // Frame ID -1 is every frame in the tab. |
(...skipping 14 matching lines...) Expand all Loading... |
531 | 528 |
532 const Extension* extension = nullptr; | 529 const Extension* extension = nullptr; |
533 if (!extension_id.empty()) { | 530 if (!extension_id.empty()) { |
534 // Source extension == target extension so the extension must exist, or | 531 // Source extension == target extension so the extension must exist, or |
535 // where did the IPC come from? | 532 // where did the IPC come from? |
536 extension = ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( | 533 extension = ExtensionRegistry::Get(profile)->enabled_extensions().GetByID( |
537 extension_id); | 534 extension_id); |
538 DCHECK(extension); | 535 DCHECK(extension); |
539 } | 536 } |
540 | 537 |
541 scoped_ptr<OpenChannelParams> params(new OpenChannelParams( | 538 std::unique_ptr<OpenChannelParams> params(new OpenChannelParams( |
542 source_process_id, | 539 source_process_id, source_routing_id, |
543 source_routing_id, | 540 std::unique_ptr<base::DictionaryValue>(), // Source tab doesn't make |
544 scoped_ptr<base::DictionaryValue>(), // Source tab doesn't make sense | 541 // sense |
545 // for opening to tabs. | 542 // for opening to tabs. |
546 -1, // If there is no tab, then there is no frame either. | 543 -1, // If there is no tab, then there is no frame either. |
547 receiver.release(), receiver_port_id, extension_id, extension_id, | 544 receiver.release(), receiver_port_id, extension_id, extension_id, |
548 GURL(), // Source URL doesn't make sense for opening to tabs. | 545 GURL(), // Source URL doesn't make sense for opening to tabs. |
549 channel_name, | 546 channel_name, |
550 false, // Connections to tabs don't get TLS channel IDs. | 547 false, // Connections to tabs don't get TLS channel IDs. |
551 false)); // Connections to tabs aren't webview guests. | 548 false)); // Connections to tabs aren't webview guests. |
552 OpenChannelImpl(contents->GetBrowserContext(), std::move(params), extension, | 549 OpenChannelImpl(contents->GetBrowserContext(), std::move(params), extension, |
553 false /* did_enqueue */); | 550 false /* did_enqueue */); |
554 } | 551 } |
555 | 552 |
556 void MessageService::OpenChannelImpl(BrowserContext* browser_context, | 553 void MessageService::OpenChannelImpl(BrowserContext* browser_context, |
557 scoped_ptr<OpenChannelParams> params, | 554 std::unique_ptr<OpenChannelParams> params, |
558 const Extension* target_extension, | 555 const Extension* target_extension, |
559 bool did_enqueue) { | 556 bool did_enqueue) { |
560 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 557 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
561 DCHECK_EQ(target_extension != nullptr, !params->target_extension_id.empty()); | 558 DCHECK_EQ(target_extension != nullptr, !params->target_extension_id.empty()); |
562 | 559 |
563 content::RenderFrameHost* source = | 560 content::RenderFrameHost* source = |
564 content::RenderFrameHost::FromID(params->source_process_id, | 561 content::RenderFrameHost::FromID(params->source_process_id, |
565 params->source_routing_id); | 562 params->source_routing_id); |
566 if (!source) | 563 if (!source) |
567 return; // Closed while in flight. | 564 return; // Closed while in flight. |
568 | 565 |
569 if (!params->receiver || !params->receiver->IsValidPort()) { | 566 if (!params->receiver || !params->receiver->IsValidPort()) { |
570 DispatchOnDisconnect(source, params->receiver_port_id, | 567 DispatchOnDisconnect(source, params->receiver_port_id, |
571 kReceivingEndDoesntExistError); | 568 kReceivingEndDoesntExistError); |
572 return; | 569 return; |
573 } | 570 } |
574 | 571 |
575 scoped_ptr<MessagePort> opener( | 572 std::unique_ptr<MessagePort> opener( |
576 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), | 573 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), |
577 GET_OPPOSITE_PORT_ID(params->receiver_port_id), | 574 GET_OPPOSITE_PORT_ID(params->receiver_port_id), |
578 params->source_extension_id, source, false)); | 575 params->source_extension_id, source, false)); |
579 if (!opener->IsValidPort()) | 576 if (!opener->IsValidPort()) |
580 return; | 577 return; |
581 opener->OpenPort(params->source_process_id, params->source_routing_id); | 578 opener->OpenPort(params->source_process_id, params->source_routing_id); |
582 | 579 |
583 params->receiver->RemoveCommonFrames(*opener); | 580 params->receiver->RemoveCommonFrames(*opener); |
584 if (!params->receiver->IsValidPort()) { | 581 if (!params->receiver->IsValidPort()) { |
585 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); | 582 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 int dest_port_id = GET_OPPOSITE_PORT_ID(source_port_id); | 811 int dest_port_id = GET_OPPOSITE_PORT_ID(source_port_id); |
815 MessagePort* port = IS_OPENER_PORT_ID(dest_port_id) ? | 812 MessagePort* port = IS_OPENER_PORT_ID(dest_port_id) ? |
816 channel->opener.get() : channel->receiver.get(); | 813 channel->opener.get() : channel->receiver.get(); |
817 | 814 |
818 port->DispatchOnMessage(message); | 815 port->DispatchOnMessage(message); |
819 } | 816 } |
820 | 817 |
821 bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask( | 818 bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask( |
822 BrowserContext* context, | 819 BrowserContext* context, |
823 const Extension* extension, | 820 const Extension* extension, |
824 scoped_ptr<OpenChannelParams>* params, | 821 std::unique_ptr<OpenChannelParams>* params, |
825 const PendingMessagesQueue& pending_messages) { | 822 const PendingMessagesQueue& pending_messages) { |
826 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 823 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
827 | 824 |
828 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) | 825 if (!BackgroundInfo::HasLazyBackgroundPage(extension)) |
829 return false; | 826 return false; |
830 | 827 |
831 // If the extension uses spanning incognito mode, make sure we're always | 828 // If the extension uses spanning incognito mode, make sure we're always |
832 // using the original profile since that is what the extension process | 829 // using the original profile since that is what the extension process |
833 // will use. | 830 // will use. |
834 if (!IncognitoInfo::IsSplitMode(extension)) | 831 if (!IncognitoInfo::IsSplitMode(extension)) |
(...skipping 11 matching lines...) Expand all Loading... |
846 base::Bind(&MessageService::PendingLazyBackgroundPageOpenChannel, | 843 base::Bind(&MessageService::PendingLazyBackgroundPageOpenChannel, |
847 weak_factory_.GetWeakPtr(), base::Passed(params), source_id)); | 844 weak_factory_.GetWeakPtr(), base::Passed(params), source_id)); |
848 | 845 |
849 for (const PendingMessage& message : pending_messages) { | 846 for (const PendingMessage& message : pending_messages) { |
850 EnqueuePendingMessageForLazyBackgroundLoad(message.first, channel_id, | 847 EnqueuePendingMessageForLazyBackgroundLoad(message.first, channel_id, |
851 message.second); | 848 message.second); |
852 } | 849 } |
853 return true; | 850 return true; |
854 } | 851 } |
855 | 852 |
856 void MessageService::OnOpenChannelAllowed(scoped_ptr<OpenChannelParams> params, | 853 void MessageService::OnOpenChannelAllowed( |
857 bool allowed) { | 854 std::unique_ptr<OpenChannelParams> params, |
| 855 bool allowed) { |
858 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 856 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
859 | 857 |
860 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); | 858 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); |
861 | 859 |
862 PendingChannelMap::iterator pending_for_incognito = | 860 PendingChannelMap::iterator pending_for_incognito = |
863 pending_incognito_channels_.find(channel_id); | 861 pending_incognito_channels_.find(channel_id); |
864 if (pending_for_incognito == pending_incognito_channels_.end()) { | 862 if (pending_for_incognito == pending_incognito_channels_.end()) { |
865 NOTREACHED(); | 863 NOTREACHED(); |
866 return; | 864 return; |
867 } | 865 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 // if it is loaded and ready, and if not, queue up the task and load the | 925 // if it is loaded and ready, and if not, queue up the task and load the |
928 // page. | 926 // page. |
929 if (!MaybeAddPendingLazyBackgroundPageOpenChannelTask( | 927 if (!MaybeAddPendingLazyBackgroundPageOpenChannelTask( |
930 context, target_extension, ¶ms, pending_messages)) { | 928 context, target_extension, ¶ms, pending_messages)) { |
931 OpenChannelImpl(context, std::move(params), target_extension, | 929 OpenChannelImpl(context, std::move(params), target_extension, |
932 false /* did_enqueue */); | 930 false /* did_enqueue */); |
933 DispatchPendingMessages(pending_messages, channel_id); | 931 DispatchPendingMessages(pending_messages, channel_id); |
934 } | 932 } |
935 } | 933 } |
936 | 934 |
937 void MessageService::GotChannelID(scoped_ptr<OpenChannelParams> params, | 935 void MessageService::GotChannelID(std::unique_ptr<OpenChannelParams> params, |
938 const std::string& tls_channel_id) { | 936 const std::string& tls_channel_id) { |
939 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 937 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
940 | 938 |
941 params->tls_channel_id.assign(tls_channel_id); | 939 params->tls_channel_id.assign(tls_channel_id); |
942 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); | 940 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); |
943 | 941 |
944 PendingChannelMap::iterator pending_for_tls_channel_id = | 942 PendingChannelMap::iterator pending_for_tls_channel_id = |
945 pending_tls_channel_id_channels_.find(channel_id); | 943 pending_tls_channel_id_channels_.find(channel_id); |
946 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { | 944 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { |
947 NOTREACHED(); | 945 NOTREACHED(); |
(...skipping 23 matching lines...) Expand all Loading... |
971 | 969 |
972 if (!MaybeAddPendingLazyBackgroundPageOpenChannelTask( | 970 if (!MaybeAddPendingLazyBackgroundPageOpenChannelTask( |
973 context, target_extension, ¶ms, pending_messages)) { | 971 context, target_extension, ¶ms, pending_messages)) { |
974 OpenChannelImpl(context, std::move(params), target_extension, | 972 OpenChannelImpl(context, std::move(params), target_extension, |
975 false /* did_enqueue */); | 973 false /* did_enqueue */); |
976 DispatchPendingMessages(pending_messages, channel_id); | 974 DispatchPendingMessages(pending_messages, channel_id); |
977 } | 975 } |
978 } | 976 } |
979 | 977 |
980 void MessageService::PendingLazyBackgroundPageOpenChannel( | 978 void MessageService::PendingLazyBackgroundPageOpenChannel( |
981 scoped_ptr<OpenChannelParams> params, | 979 std::unique_ptr<OpenChannelParams> params, |
982 int source_process_id, | 980 int source_process_id, |
983 ExtensionHost* host) { | 981 ExtensionHost* host) { |
984 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 982 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
985 | 983 |
986 if (!host) | 984 if (!host) |
987 return; // TODO(mpcomplete): notify source of disconnect? | 985 return; // TODO(mpcomplete): notify source of disconnect? |
988 | 986 |
989 params->receiver.reset( | 987 params->receiver.reset( |
990 new ExtensionMessagePort( | 988 new ExtensionMessagePort( |
991 weak_factory_.GetWeakPtr(), params->receiver_port_id, | 989 weak_factory_.GetWeakPtr(), params->receiver_port_id, |
(...skipping 20 matching lines...) Expand all Loading... |
1012 | 1010 |
1013 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); | 1011 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); |
1014 if (channel_iter != channels_.end()) { | 1012 if (channel_iter != channels_.end()) { |
1015 for (const PendingMessage& message : queue) { | 1013 for (const PendingMessage& message : queue) { |
1016 DispatchMessage(message.first, channel_iter->second, message.second); | 1014 DispatchMessage(message.first, channel_iter->second, message.second); |
1017 } | 1015 } |
1018 } | 1016 } |
1019 } | 1017 } |
1020 | 1018 |
1021 } // namespace extensions | 1019 } // namespace extensions |
OLD | NEW |