Chromium Code Reviews| 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); |