Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2376)

Unified Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 12218099: Disable native messaging in non-supported configurations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/messaging/message_service.cc
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 5592fad351da08eb25018cf27ed8d1bbc8fd7fa1..e449bcfce73d125042eb151e0e1790b81feb7d5e 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -193,6 +193,7 @@ void MessageService::OpenChannelToNativeApp(
if (!source)
return;
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
WebContents* source_contents = tab_util::GetWebContentsByID(
source_process_id, source_routing_id);
@@ -217,6 +218,9 @@ void MessageService::OpenChannelToNativeApp(
// Abandon the channel
if (!native_process.get()) {
LOG(ERROR) << "Failed to create native process.";
+ // Treat it as a disconnect.
+ ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
+ port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true);
return;
}
channel->receiver.reset(new NativeMessagePort(native_process.release()));
@@ -225,6 +229,10 @@ void MessageService::OpenChannelToNativeApp(
channel->opener->IncrementLazyKeepaliveCount();
AddChannel(channel.release(), receiver_port_id);
+#else // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
+ ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
+ port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true);
+#endif // !(defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX))
}
void MessageService::OpenChannelToTab(
« no previous file with comments | « no previous file | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698