Push Messaging
You’re about to propose a new extension API, what a marvelous road you have
ahead of you. Before you venture forth, though, we’d like to get a sense for
your new API and offer you some guidance on your way. Fill out this proposal and
post it under For Developers > Design Documents > Extensions >
Proposed & Proposing New Changes > API
Proposals
in the list of proposed APIs, then include a link in your Extension Review
request in go/
Proposal Date
2012/
Who will be responsible for this API? (Team please, not an individual)
dcheng@, dimich@, petewil@
Overview
Web apps have the inherent limitation that they're not able to do much when they
aren't running. Today, extensions/
- Authentication
- The invalidation mechanism used
- The features supported
Do you expect this API to be fairly stable? How might it be extended or changed in the future? We expose only a small subset of the cache invalidation service that Chrome uses internally. The main limitation today is that we have a list of hardcoded subchannels that we register on behalf of extensions; in the future, it's possible that we'd allow extensions to specify their own subchannel names. We'd likely have to keep the hardcoded subchannels around forever though, to avoid breaking extensions that use those subchannels.
If multiple extensions used this API at the same time, could they conflict with each others? If so, how do you propose to mitigate this problem? They cannot conflict with each other, since we do not allow extensions to specify any part of the object IDs registered on their behalf. List every UI surface belonging to or potentially affected by your API: No UI elements are involved. Actions taken with extension APIs should be obviously attributable to an extension. Will users be able to tell when this new API is being used? How?
Invalidations may trigger actions that result in UI elements being surfaced. Since we add no new UI elements ourselves, and existing ones should be obviously attributable, the existing UI should be sufficient.
How could this API be abused? See below. Imagine you’re Dr. Evil Extension Writer, list the three worst evil deeds you could commit with your API (if you’ve got good ones, feel free to add more):
- The server could trigger a lot of invalidations. Presumably this would eventually cause the app to get throttled on the server though...
- An extension could claim it will manually acknowledge an invalidation and never acknowledge it, allowing it to be woken up regularly.
- An app writer could always add the pushMessaging to his permissions list,
whether or not he used it, causing the extension API to always register object
IDs for that extension even though they are not used.
What security UI or other mitigations do you propose to limit evilness made
possible by this new API?
To prevent extensions from being able to snoop on invalidations for other
users/
extensions, we do not allow the extensions to actually specify their own object IDs--we generate object IDs for an extension based on the signed-in user
- the extension ID + the subchannel.
In addition, to reduce server load, we always acknowledge receipt of an
invalidation immediately when we receive it from the cache invalidation server.
We re-dispatch invalidations to the extension ourselves and use a backoff policy
to prevent a faulty/
Methods:
getChannelId
chrome.pushMessaging.getChannelId(function callback)
Retrieves the channel ID associated with an extension. This contains the obfuscated user ID combined with the extension ID; the typical usage is for the extension to send the channel ID to its app server to allow the app server to trigger push messages.
callback ( function )
Called when channel ID has been retrieved.
Callback function:
The callback parameter should specify a function that looks like this:
function(string channelID) {...};
channelID ( string )
Contains the channel ID of the extension.
Events:
onMessage
chrome.pushMessaging.onMessage.addListener(function(Message message) { ... });
Fired when a push message is received.
Listener parameters:
message ( Message )
The data associated with the message.
Types:
Message
( object )
Stores data about a push message.
subchannel ( number )
The subchannel the push message was received for.
payload ( string)
The payload associated with the push message. Delivery of the payload is not guaranteed; failure to deliver the payload will result in value being set to an empty string.
willAcknowledge ( function )
An extension can call this to indicate that it will manually acknowledge the receipt of the message. This is useful if the extension wants to do something asynchronous in response to a push message and wants it to be re-delivered if it isn't successfully handled for some reason.
acknowledge ( function ) Allows an extension which called willAcknowledge() to acknowledge receipt of the push message. Open questions willAcknowledge() and acknowledge() may not be possible to implement.