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

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..74873162e8c1660745020f27d8eade1d0c3c6fe7 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -188,6 +188,7 @@ void MessageService::OpenChannelToNativeApp(
int receiver_port_id,
const std::string& source_extension_id,
const std::string& native_app_name) {
+#if defined(OS_WIN) || defined(OS_MAXOSX) || defined(OS_LINUX)
content::RenderProcessHost* source =
content::RenderProcessHost::FromID(source_process_id);
if (!source)
@@ -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_MAXOSX) || 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_MAXOSX) || defined(OS_LINUX))
Matt Perry 2013/02/11 22:44:54 nit: These comments seem backwards to me. The endi
Sergey Ulanov 2013/02/13 01:15:25 Done.
}
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