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

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
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 36e141c8dcd24300562104c956d79176463485a4..fa891b2bac6f1bc88c0cb1a9fb562d5ae4701fa8 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -194,6 +194,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 && extension_service->is_ready()) {
Matt Perry 2013/02/28 20:28:45 You don't need to check for is_ready.
Sergey Ulanov 2013/03/01 03:15:30 Done.
+ 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);

Powered by Google App Engine
This is Rietveld 408576698