Bug 880735 part E - Use the new permissionmanager.updateExpireTime method to make sure that plugin permissions are renewed properly, r=johns

This commit is contained in:
Benjamin Smedberg 2013-06-24 08:51:07 -04:00
parent 02de42afbc
commit 71c97abfa3

View File

@ -56,6 +56,7 @@
#include "nsStyleUtil.h"
#include "nsGUIEvent.h"
#include "nsUnicharUtils.h"
#include "mozilla/Preferences.h"
// Concrete classes
#include "nsFrameLoader.h"
@ -2757,11 +2758,23 @@ nsObjectLoadingContent::CancelPlayPreview()
return NS_OK;
}
static bool sPrefsInitialized;
static uint32_t sSessionTimeoutMinutes;
static uint32_t sPersistentTimeoutDays;
bool
nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentType)
{
nsresult rv;
if (!sPrefsInitialized) {
Preferences::AddUintVarCache(&sSessionTimeoutMinutes,
"plugin.sessionPermissionNow.intervalInMinutes", 60);
Preferences::AddUintVarCache(&sPersistentTimeoutDays,
"plugin.persistentPermissionAlways.intervalInDays", 90);
sPrefsInitialized = true;
}
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
nsCOMPtr<nsIPluginPlayPreviewInfo> playPreviewInfo;
@ -2862,6 +2875,13 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp
permissionString.Data(),
&permission);
NS_ENSURE_SUCCESS(rv, false);
if (permission != nsIPermissionManager::UNKNOWN_ACTION) {
uint64_t nowms = PR_Now() / 1000;
permissionManager->UpdateExpireTime(
topDoc->NodePrincipal(), permissionString.Data(), false,
nowms + sSessionTimeoutMinutes * 60 * 1000,
nowms / 1000 + uint64_t(sPersistentTimeoutDays) * 24 * 60 * 60 * 1000);
}
switch (permission) {
case nsIPermissionManager::ALLOW_ACTION:
return true;