| Index: chrome/browser/extensions/extension_tab_helper.cc
|
| diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc
|
| index df7209c468b61c290238813f72f9e1faf865c426..0d91f82f0016b980004380ce7d5596814cae6df7 100644
|
| --- a/chrome/browser/extensions/extension_tab_helper.cc
|
| +++ b/chrome/browser/extensions/extension_tab_helper.cc
|
| @@ -18,6 +18,7 @@
|
| #include "chrome/common/extensions/extension_icon_set.h"
|
| #include "chrome/common/extensions/extension_messages.h"
|
| #include "chrome/common/extensions/extension_resource.h"
|
| +#include "content/browser/renderer_host/render_view_host.h"
|
| #include "content/browser/renderer_host/render_widget_host_view.h"
|
| #include "content/browser/tab_contents/navigation_details.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| @@ -127,6 +128,8 @@ bool ExtensionTabHelper::OnMessageReceived(const IPC::Message& message) {
|
| OnInstallApplication)
|
| IPC_MESSAGE_HANDLER(ExtensionHostMsg_InlineWebstoreInstall,
|
| OnInlineWebstoreInstall)
|
| + IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel,
|
| + OnGetAppNotifyChannel)
|
| IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| @@ -155,6 +158,48 @@ void ExtensionTabHelper::OnInlineWebstoreInstall(
|
| installer->BeginInstall();
|
| }
|
|
|
| +void ExtensionTabHelper::OnGetAppNotifyChannel(
|
| + int request_id,
|
| + const GURL& requestor_url,
|
| + const std::string& client_id) {
|
| +
|
| + // Check for permission first.
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(tab_contents()->browser_context());
|
| + ExtensionService* extension_service = profile->GetExtensionService();
|
| + ExtensionProcessManager* process_manager =
|
| + profile->GetExtensionProcessManager();
|
| + RenderProcessHost* process =
|
| + tab_contents_wrapper()->render_view_host()->process();
|
| + const Extension* extension =
|
| + extension_service->GetInstalledApp(requestor_url);
|
| + bool allowed =
|
| + extension &&
|
| + extension->is_app() &&
|
| + extension->HasAPIPermission(
|
| + ExtensionAPIPermission::kExperimental) &&
|
| + (extension->is_hosted_app() ||
|
| + process_manager->GetExtensionProcess(requestor_url) == process);
|
| + if (!allowed) {
|
| + AppNotifyChannelSetupComplete(request_id, "", "permission_error");
|
| + return;
|
| + }
|
| +
|
| + scoped_refptr<AppNotifyChannelSetup> channel_setup(
|
| + new AppNotifyChannelSetup(request_id,
|
| + client_id,
|
| + requestor_url,
|
| + this->AsWeakPtr()));
|
| + channel_setup->Start();
|
| + // We'll get called back in AppNotifyChannelSetupComplete.
|
| +}
|
| +
|
| +void ExtensionTabHelper::AppNotifyChannelSetupComplete(
|
| + int request_id, const std::string& client_id, const std::string& error) {
|
| + Send(new ExtensionMsg_GetAppNotifyChannelResponse(
|
| + routing_id(), request_id, client_id, error));
|
| +}
|
| +
|
| void ExtensionTabHelper::OnRequest(
|
| const ExtensionHostMsg_Request_Params& request) {
|
| extension_function_dispatcher_.Dispatch(request,
|
|
|