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

Unified Diff: chrome/browser/extensions/extension_message_handler.cc

Issue 8113006: Add js api for hosted/pacakged apps to request notification authorization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 9 years, 2 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 | « chrome/browser/extensions/extension_message_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_message_handler.cc
diff --git a/chrome/browser/extensions/extension_message_handler.cc b/chrome/browser/extensions/extension_message_handler.cc
index 88955308667a1748c7b1e44ea29d2c6f2261b062..1f9ed9214847337059f1196fa8c59bbb0b36a394 100644
--- a/chrome/browser/extensions/extension_message_handler.cc
+++ b/chrome/browser/extensions/extension_message_handler.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/extensions/extension_message_handler.h"
+#include "chrome/browser/extensions/app_notify_channel_setup.h"
#include "chrome/browser/extensions/extension_message_service.h"
+#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/browser/child_process_security_policy.h"
@@ -25,6 +27,8 @@ bool ExtensionMessageHandler::OnMessageReceived(
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionMessageHandler, message)
IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnPostMessage)
+ IPC_MESSAGE_HANDLER(ExtensionHostMsg_GetAppNotifyChannel,
+ OnGetAppNotifyChannel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -44,3 +48,37 @@ void ExtensionMessageHandler::OnPostMessage(int port_id,
port_id, message);
}
}
+
+void ExtensionMessageHandler::OnGetAppNotifyChannel(
+ int request_id,
+ const GURL& requestor_url,
+ const std::string& client_id) {
+
+ // Check for permission first.
+ Profile* profile = Profile::FromBrowserContext(
+ render_view_host()->process()->browser_context());
+ ExtensionService* extension_service = profile->GetExtensionService();
+ if (!extension_service || !extension_service->is_ready())
Aaron Boodman 2011/10/04 23:40:36 I don't think that it is possible for either of th
asargent_no_longer_on_chrome 2011/10/06 03:35:32 Ok, removed this.
+ return;
+ const Extension* extension =
+ extension_service->GetInstalledApp(requestor_url);
Aaron Boodman 2011/10/04 23:40:36 Can you also check that the app is running in the
asargent_no_longer_on_chrome 2011/10/06 03:35:32 As discussed in IRC, I've added the process check
+ if (!extension ||
+ !extension->HasAPIPermission(ExtensionAPIPermission::kExperimental)) {
+ 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 ExtensionMessageHandler::AppNotifyChannelSetupComplete(
+ int request_id, const std::string& client_id, const std::string& error) {
+ Send(new ExtensionMsg_GetAppNotifyChannelResponse(
+ routing_id(), request_id, client_id, error));
+}
« no previous file with comments | « chrome/browser/extensions/extension_message_handler.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698