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

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

Issue 12300041: Add nativeMessaging extension permission (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/common/extensions/api/_permission_features.json » ('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 d531dac772d0287ac617d7b839db17fa78abbc94..31bd77ba2d3a2ba1ab918c0b600c05b47664d467 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -195,6 +195,23 @@ void MessageService::OpenChannelToNativeApp(
return;
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
+ Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
+ bool has_permission = false;
+ if (extension_service) {
+ const Extension* extension =
+ extension_service->GetExtensionById(source_extension_id, false);
+ has_permission = extension && extension->HasAPIPermission(
+ APIPermission::kNativeMessaging);
+ }
+
+ if (!has_permission) {
+ ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, "");
+ port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(receiver_port_id), true);
+ return;
+ }
+
WebContents* source_contents = tab_util::GetWebContentsByID(
source_process_id, source_routing_id);
« no previous file with comments | « no previous file | chrome/common/extensions/api/_permission_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698