Commit 379801dc authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Disable native messaging in non-supported configurations.

Native Messaging API is useful only on desktop OSes, i.e. on Linux, OSX and 
Windows. Disable it in all other configurations. Also improved how we handle 
the case when native messaging is disabled is handled: now the app will get 
disconnect notification.

BUG=142915
TBR=thakis@chromium.org


Review URL: https://chromiumcodereview.appspot.com/12218099

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182197 0039d316-1c4b-4281-b951-d872f2087c98
parent fd0b1b53
......@@ -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(
......
......@@ -771,11 +771,6 @@
['include', '^browser/extensions/api/extension_action/extension_page_actions_api_constants.cc'],
['include', '^browser/extensions/api/messaging/extension_message_port.cc'],
['include', '^browser/extensions/api/messaging/message_service.cc'],
['include', '^browser/extensions/api/messaging/native_message_process_host.cc'],
['include', '^browser/extensions/api/messaging/native_process_launcher.cc'],
['include', '^browser/extensions/api/messaging/native_process_launcher_posix.cc'],
['include', '^browser/extensions/api/messaging/native_process_launcher_win.cc'],
['include', '^browser/extensions/api/messaging/native_message_port.cc'],
['include', '^browser/extensions/api/omnibox/omnibox_api.cc'],
['include', '^browser/extensions/api/processes/processes_api.cc'],
['include', '^browser/extensions/api/processes/processes_api_constants.cc'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment