Bug 1060529, send the enabled state of child process commands to the parent on update, now with improved test, r=smaug,ehsan

This commit is contained in:
Neil Deakin
2014-12-08 08:12:22 -05:00
parent 3378dca433
commit d6ba3abdad
19 changed files with 386 additions and 36 deletions

View File

@@ -188,6 +188,30 @@ nsControllerCommandTable::GetCommandState(const char *aCommandName, nsICommandPa
return commandHandler->GetCommandStateParams(aCommandName, aParams, aCommandRefCon);
}
static PLDHashOperator
AddCommand(const nsACString& aKey, nsIControllerCommand* aData, void* aArg)
{
// aArg is a pointer to a array of strings. It gets incremented after
// allocating each one so that it points to the next location for AddCommand
// to assign a string to.
char*** commands = static_cast<char***>(aArg);
(**commands) = ToNewCString(aKey);
(*commands)++;
return PL_DHASH_NEXT;
}
NS_IMETHODIMP
nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
char*** aCommands)
{
char** commands =
static_cast<char **>(NS_Alloc(sizeof(char *) * mCommandsTable.Count()));
*aCount = mCommandsTable.Count();
*aCommands = commands;
mCommandsTable.EnumerateRead(AddCommand, &commands);
return NS_OK;
}
nsresult
NS_NewControllerCommandTable(nsIControllerCommandTable** aResult)