Bug 1231306 - Handle plugin state changes correctly in content process (r=jimm)

This commit is contained in:
Bill McCloskey 2015-12-23 17:18:57 -08:00
parent 41802e0eef
commit 8e82f52acf
3 changed files with 27 additions and 10 deletions

View File

@ -2426,17 +2426,21 @@ nsPluginHost::FindPluginsInContent(bool aCreatePluginList, bool* aPluginsChanged
}
if (parentEpoch != ChromeEpochForContent()) {
SetChromeEpochForContent(parentEpoch);
*aPluginsChanged = true;
if (!aCreatePluginList) {
return NS_OK;
}
// Don't do this if aCreatePluginList is false. Otherwise, when we actually
// want to create the list, we'll come back here and do nothing.
SetChromeEpochForContent(parentEpoch);
for (size_t i = 0; i < plugins.Length(); i++) {
PluginTag& tag = plugins[i];
// Don't add the same plugin again.
if (PluginWithId(tag.id())) {
if (nsPluginTag* existing = PluginWithId(tag.id())) {
UpdateInMemoryPluginInfo(existing);
continue;
}
@ -2699,14 +2703,9 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch,
return NS_OK;
}
// This function is not relevant for fake plugins.
void
nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
nsPluginHost::UpdateInMemoryPluginInfo(nsPluginTag* aPluginTag)
{
MOZ_ASSERT(XRE_IsParentProcess());
ReadPluginInfo();
WritePluginInfo();
NS_ITERATIVE_UNREF_LIST(RefPtr<nsPluginTag>, mCachedPlugins, mNext);
NS_ITERATIVE_UNREF_LIST(RefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext);
@ -2737,6 +2736,20 @@ nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
obsService->NotifyObservers(nullptr, "plugin-info-updated", nullptr);
}
// This function is not relevant for fake plugins.
void
nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
{
MOZ_ASSERT(XRE_IsParentProcess());
ReadPluginInfo();
WritePluginInfo();
IncrementChromeEpoch();
UpdateInMemoryPluginInfo(aPluginTag);
}
/* static */ bool
nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
{

View File

@ -363,6 +363,8 @@ private:
uint32_t ChromeEpochForContent();
void SetChromeEpochForContent(uint32_t aEpoch);
void UpdateInMemoryPluginInfo(nsPluginTag* aPluginTag);
// On certain platforms, we only want to load certain plugins. This function
// centralizes loading rules.
bool ShouldAddPlugin(nsPluginTag* aPluginTag);

View File

@ -576,7 +576,8 @@ nsPluginTag::GetClicktoplay(bool *aClicktoplay)
}
NS_IMETHODIMP
nsPluginTag::GetEnabledState(uint32_t *aEnabledState) {
nsPluginTag::GetEnabledState(uint32_t *aEnabledState)
{
int32_t enabledState;
nsresult rv = Preferences::GetInt(GetStatePrefNameForPlugin(this).get(),
&enabledState);
@ -601,7 +602,8 @@ nsPluginTag::GetEnabledState(uint32_t *aEnabledState) {
}
NS_IMETHODIMP
nsPluginTag::SetEnabledState(uint32_t aEnabledState) {
nsPluginTag::SetEnabledState(uint32_t aEnabledState)
{
if (aEnabledState >= ePluginState_MaxValue)
return NS_ERROR_ILLEGAL_VALUE;
uint32_t oldState = nsIPluginTag::STATE_DISABLED;