Bug 1128768: Part 5 - Update plugin code to retrieve SWF file for hang annotations; r=jimm

This commit is contained in:
Aaron Klotz
2015-02-25 17:38:09 -07:00
parent 52ddbad516
commit 17f21295f6
6 changed files with 261 additions and 23 deletions

View File

@@ -7,6 +7,7 @@
#include "mozilla/DebugOnly.h"
#include <stdint.h> // for intptr_t
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "PluginInstanceParent.h"
#include "BrowserStreamParent.h"
@@ -21,6 +22,7 @@
#include "gfxContext.h"
#include "gfxPlatform.h"
#include "gfxSharedImageSurface.h"
#include "nsNetUtil.h"
#include "nsNPAPIPluginInstance.h"
#include "nsPluginInstanceOwner.h"
#include "nsFocusManager.h"
@@ -54,6 +56,10 @@ extern const wchar_t* kFlashFullscreenClass;
#include <ApplicationServices/ApplicationServices.h>
#endif // defined(XP_MACOSX)
// This is the pref used to determine whether to use Shumway on a Flash object
// (when Shumway is enabled).
static const char kShumwayWhitelistPref[] = "shumway.swf.whitelist";
using namespace mozilla::plugins;
using namespace mozilla::layers;
using namespace mozilla::gl;
@@ -104,6 +110,7 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
, mUseSurrogate(true)
, mNPP(npp)
, mNPNIface(npniface)
, mIsWhitelistedForShumway(false)
, mWindowType(NPWindowTypeWindow)
, mDrawingModel(kDefaultDrawingModel)
#if defined(OS_WIN)
@@ -143,9 +150,38 @@ PluginInstanceParent::~PluginInstanceParent()
}
bool
PluginInstanceParent::Init()
PluginInstanceParent::InitMetadata(const nsACString& aMimeType,
const nsACString& aSrcAttribute)
{
return true;
if (aSrcAttribute.IsEmpty()) {
return false;
}
// Ensure that the src attribute is absolute
nsRefPtr<nsPluginInstanceOwner> owner = GetOwner();
if (!owner) {
return false;
}
nsCOMPtr<nsIURI> baseUri(owner->GetBaseURI());
nsresult rv = NS_MakeAbsoluteURI(mSrcAttribute, aSrcAttribute, baseUri);
if (NS_FAILED(rv)) {
return false;
}
// Check the whitelist
nsAutoCString baseUrlSpec;
rv = baseUri->GetSpec(baseUrlSpec);
if (NS_FAILED(rv)) {
return false;
}
auto whitelist = Preferences::GetCString(kShumwayWhitelistPref);
// Empty whitelist is interpreted by CheckWhitelist as "allow everything,"
// which is not valid for our use case and should be treated as a failure.
if (whitelist.IsEmpty()) {
return false;
}
rv = nsPluginPlayPreviewInfo::CheckWhitelist(baseUrlSpec, mSrcAttribute,
whitelist,
&mIsWhitelistedForShumway);
return NS_SUCCEEDED(rv);
}
void