Skip to content

Commit

Permalink
Bug 1354635 - Send permissions to the content process when debugging …
Browse files Browse the repository at this point in the history
…service workers, r=catalinb

MozReview-Commit-ID: 8cUh5znQcFN
  • Loading branch information
mystor committed Apr 18, 2017
1 parent 2fd5e30 commit a133769
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions devtools/server/actors/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ protocol.ActorClassWithSpec(serviceWorkerRegistrationSpec, {
"resource://devtools/server/service-worker-child.js", true);
_serviceWorkerProcessScriptLoaded = true;
}

// XXX: Send the permissions down to the content process before starting
// the service worker within the content process. As we don't know what
// content process we're starting the service worker in (as we're using a
// broadcast channel to talk to it), we just broadcast the permissions to
// everyone as well.
//
// This call should be replaced with a proper implementation when
// ServiceWorker debugging is improved to support multiple content processes
// correctly.
Services.perms.broadcastPermissionsForPrincipalToAllContentProcesses(this._registration.principal);

Services.ppmm.broadcastAsyncMessage("serviceWorkerRegistration:start", {
scope: this._registration.scope
});
Expand Down
13 changes: 13 additions & 0 deletions extensions/cookie/nsPermissionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3089,3 +3089,16 @@ nsPermissionManager::GetAllKeysForPrincipal(nsIPrincipal* aPrincipal)
"Every principal should have at least one key.");
return keys;
}

NS_IMETHODIMP
nsPermissionManager::BroadcastPermissionsForPrincipalToAllContentProcesses(nsIPrincipal* aPrincipal)
{
nsTArray<ContentParent*> cps;
ContentParent::GetAll(cps);
for (ContentParent* cp : cps) {
nsresult rv = cp->TransmitPermissionsForPrincipal(aPrincipal);
NS_ENSURE_SUCCESS(rv, rv);
}

return NS_OK;
}
11 changes: 11 additions & 0 deletions netwerk/base/nsIPermissionManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ interface nsIPermissionManager : nsISupports
* @param perms An array with the permissions which match the given key.
*/
void setPermissionsWithKey(in ACString permissionKey, in IPCPermissionArrayRef perms);

/**
* Broadcasts permissions for the given principal to all content processes.
*
* DO NOT USE THIS METHOD if you can avoid it. It was added in bug XXX to
* handle the current temporary implementation of ServiceWorker debugging. It
* will be removed when service worker debugging is fixed.
*
* @param aPrincipal The principal to broadcast permissions for.
*/
void broadcastPermissionsForPrincipalToAllContentProcesses(in nsIPrincipal aPrincipal);
};

%{ C++
Expand Down

0 comments on commit a133769

Please sign in to comment.