import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1242724: add an export of runnable_utils.h unless/until it gets moved to xpcom/mfbt r=glandium (1d5e839f99)
- Bug 1223240 - Make it easier to set up top-level protocols (r=jld) (3beaf4a6fa)
- Bug 1194259: Make ICE IP restriction to default routes work in E10S r=jesup,mcmanus,drno (cbe463cf27)
- Bug 1239584, Part 1 - Add nsIPushNotifier and nsIPushMessage interfaces. r=dragana (7b71518e7d)
- Bug 1239584, Part 2 - Remove message manager usage from `PushService.jsm`. r=dragana (f76ab36278)
- Bug 1210211 - Part 3: Test for push notification quota with web notifications. r=kitcambridge (f37472f9b2)
- Bug 1189998, Part 3 - Update consolidated Push tests. r=mt (fae3b02e6e)
- Bug 1225968 - Refactor data delivery tests to support addition of new tests, r=kitcambridge (3163083135)
- Bug 1225968 - Adding more messages to the push message tests, r=kitcambridge (7e1bac99ba)
- Bug 1239558 - Exempt system Push subscriptions from quota and permissions checks. r=dragana (0dd8399414)
- Bug 1239584, Part 3 - Update tests. r=dragana (937e339387)
- Bug 1165256 - Make appcache fully work with OriginAttribues. r=jduell (91d666752a)
- reapply Bug 1232506: Make dom/devicestorage really work with e10s. r=alchen (bd77941ea9)
- Bug 1236433 - Part 1: Provide a Native Wrapper to Allow Fallback Whenproperty_get/set is Unavailable; r=edgar (f9026a7f50)
- Bug 1168959 - Memory-safety bugs in NetworkUtils.cpp generally. r=fabrice (13c6c14168)
- Bug 1236433 - Part 2: Adopt Wrapper in Network Utilities; r=edgar (dde58ea083)
- Bug 1209654 - Modify the type of the threshold of addAlarm() and getAllAlarms() to long long from long, and add test cases. r=ettseng, r=bz (79c7e31440)
- Bug 1000040 - Part 1: Add required APIs for Ethernet; r=vicamo,bholley (fcff7c8078)
- Bug 1231306 - Handle plugin state changes correctly in content process (r=jimm) (1f2daa6ad4)
- Bug 1213454: Ensure that mSupportsAsyncInit is propagated from content process; r=jimm (e86f36fe0a)
- Bug 1246574 - Store sandbox level to nsPluginTag for e10s. r=jimm (04617c8d28)
- Bug 1201904 - Force windowless mode for Flash when sandbox level >= 2. r=bsmedberg (662c6612a2)
- Bug 1233619 (part 1) - Remove unneeded gfxContext argument from EndUpdate() and EndUpdateBackground() functions. r=roc. (1f74728aec)
- Bug 1233619 (part 2) - Moz2Dify BeginUpdate() and BeginUpdateBackground() functions. r=roc. (36accc1499)
- Bug 1243656 - Use async for RequestCommitOrCancel. r=masayuki (aa57ea37dc)
- Bug 1243268 - Support ImmSetCandidateWindow(CFS_EXCLUDE) on plugin process. r=masayuki (78975bd3e4)
- Bug 1235573 - Don't post GCS_RESULTSTR when plugin doesn't handle WM_IME_COMPOSITION correctly. r=masayuki (11690062a3)
- Bug 1173371 Part 1: Take Chromium commit 0e49d029d5a1a25d971880b9e44d67ac70b31a80 for sandbox code. r=aklotz (517cb91822)
- Bug 1157864 - Record chromium patch applied in previous commit. r=me (dc1e63191b)
- Bug 1173371 Part 2: Change Chromium sandbox to allow rules for files on network drives to be added. a=aklotz (2bd72777e5)
- Bug 1173371 Part 3: Add sandbox policy rule to allow read access to the Firefox program directory when it is on a network drive. r=aklotz (c0a180d4b8)
- Bug 1244774: Correct wchar_t/char16_t VS2015 compilation problem caused by patches for bug 1173371. r=jimm (d5326694f8)
This commit is contained in:
2023-08-17 14:45:22 +08:00
parent 9af39af6c4
commit c317230594
185 changed files with 4976 additions and 1545 deletions
+4 -5
View File
@@ -299,19 +299,18 @@ PluginPRLibrary::SetBackgroundUnknown(NPP instance)
}
nsresult
PluginPRLibrary::BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext** aCtx)
PluginPRLibrary::BeginUpdateBackground(NPP instance, const nsIntRect&,
DrawTarget** aDrawTarget)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
NS_ERROR("Unexpected use of async APIs for in-process plugin.");
*aCtx = nullptr;
*aDrawTarget = nullptr;
return NS_OK;
}
nsresult
PluginPRLibrary::EndUpdateBackground(NPP instance,
gfxContext*, const nsIntRect&)
PluginPRLibrary::EndUpdateBackground(NPP instance, const nsIntRect&)
{
NS_RUNTIMEABORT("This should never be called");
return NS_ERROR_NOT_AVAILABLE;
+3 -3
View File
@@ -117,10 +117,10 @@ public:
virtual nsresult ContentsScaleFactorChanged(NPP aInstance, double aContentsScaleFactor) override;
#endif
virtual nsresult SetBackgroundUnknown(NPP instance) override;
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext** aCtx) override;
virtual nsresult BeginUpdateBackground(NPP instance, const nsIntRect&,
DrawTarget** aDrawTarget) override;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx, const nsIntRect&) override;
const nsIntRect&) override;
virtual void DidComposite(NPP aInstance) override { }
virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); }
virtual nsresult GetRunID(uint32_t* aRunID) override { return NS_ERROR_NOT_IMPLEMENTED; }
+4 -5
View File
@@ -1250,7 +1250,7 @@ nsNPAPIPluginInstance::SetBackgroundUnknown()
nsresult
nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
gfxContext** aContext)
DrawTarget** aDrawTarget)
{
if (RUNNING != mRunning)
return NS_OK;
@@ -1259,12 +1259,11 @@ nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
if (!library)
return NS_ERROR_FAILURE;
return library->BeginUpdateBackground(&mNPP, *aRect, aContext);
return library->BeginUpdateBackground(&mNPP, *aRect, aDrawTarget);
}
nsresult
nsNPAPIPluginInstance::EndUpdateBackground(gfxContext* aContext,
nsIntRect* aRect)
nsNPAPIPluginInstance::EndUpdateBackground(nsIntRect* aRect)
{
if (RUNNING != mRunning)
return NS_OK;
@@ -1273,7 +1272,7 @@ nsNPAPIPluginInstance::EndUpdateBackground(gfxContext* aContext,
if (!library)
return NS_ERROR_FAILURE;
return library->EndUpdateBackground(&mNPP, aContext, *aRect);
return library->EndUpdateBackground(&mNPP, *aRect);
}
nsresult
+4 -2
View File
@@ -84,6 +84,8 @@ private:
typedef mozilla::PluginLibrary PluginLibrary;
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsNPAPIPluginInstance)
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
@@ -109,8 +111,8 @@ public:
nsresult NotifyPainted(void);
nsresult GetIsOOP(bool* aIsOOP);
nsresult SetBackgroundUnknown();
nsresult BeginUpdateBackground(nsIntRect* aRect, gfxContext** aContext);
nsresult EndUpdateBackground(gfxContext* aContext, nsIntRect* aRect);
nsresult BeginUpdateBackground(nsIntRect* aRect, DrawTarget** aContext);
nsresult EndUpdateBackground(nsIntRect* aRect);
nsresult IsTransparent(bool* isTransparent);
nsresult GetFormValue(nsAString& aValue);
nsresult PushPopupsEnabledState(bool aEnabled);
+27 -10
View File
@@ -2337,17 +2337,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;
}
@@ -2362,8 +2366,10 @@ nsPluginHost::FindPluginsInContent(bool aCreatePluginList, bool* aPluginsChanged
nsTArray<nsCString>(tag.extensions()),
tag.isJavaPlugin(),
tag.isFlashPlugin(),
tag.supportsAsyncInit(),
tag.lastModifiedTime(),
tag.isFromExtension());
tag.isFromExtension(),
tag.sandboxLevel());
AddPluginTag(pluginTag);
}
}
@@ -2606,22 +2612,19 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch,
tag->Extensions(),
tag->mIsJavaPlugin,
tag->mIsFlashPlugin,
tag->mSupportsAsyncInit,
tag->FileName(),
tag->Version(),
tag->mLastModifiedTime,
tag->IsFromExtension()));
tag->IsFromExtension(),
tag->mSandboxLevel));
}
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);
@@ -2652,6 +2655,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)
{
+2
View File
@@ -359,6 +359,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);
+75 -42
View File
@@ -267,25 +267,24 @@ nsPluginInstanceOwner::SetBackgroundUnknown()
}
}
already_AddRefed<gfxContext>
already_AddRefed<mozilla::gfx::DrawTarget>
nsPluginInstanceOwner::BeginUpdateBackground(const nsIntRect& aRect)
{
nsIntRect rect = aRect;
RefPtr<gfxContext> ctx;
RefPtr<DrawTarget> dt;
if (mInstance &&
NS_SUCCEEDED(mInstance->BeginUpdateBackground(&rect, getter_AddRefs(ctx)))) {
return ctx.forget();
NS_SUCCEEDED(mInstance->BeginUpdateBackground(&rect, getter_AddRefs(dt)))) {
return dt.forget();
}
return nullptr;
}
void
nsPluginInstanceOwner::EndUpdateBackground(gfxContext* aContext,
const nsIntRect& aRect)
nsPluginInstanceOwner::EndUpdateBackground(const nsIntRect& aRect)
{
nsIntRect rect = aRect;
if (mInstance) {
mInstance->EndUpdateBackground(aContext, &rect);
mInstance->EndUpdateBackground(&rect);
}
}
@@ -372,6 +371,7 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
#ifdef XP_WIN
mGotCompositionData = false;
mSentStartComposition = false;
mPluginDidNotHandleIMEComposition = false;
#endif
}
@@ -940,7 +940,8 @@ nsPluginInstanceOwner::GetCompositionString(uint32_t aType,
}
bool
nsPluginInstanceOwner::SetCandidateWindow(int32_t aX, int32_t aY)
nsPluginInstanceOwner::SetCandidateWindow(
const widget::CandidateWindowPosition& aPosition)
{
if (NS_WARN_IF(!mPluginFrame)) {
return false;
@@ -954,7 +955,7 @@ nsPluginInstanceOwner::SetCandidateWindow(int32_t aX, int32_t aY)
}
}
widget->SetCandidateWindowForPlugin(aX, aY);
widget->SetCandidateWindowForPlugin(aPosition);
return true;
}
@@ -1827,6 +1828,47 @@ nsPluginInstanceOwner::GetTextComposition()
return composition.forget();
}
void
nsPluginInstanceOwner::HandleNoConsumedCompositionMessage(
WidgetCompositionEvent* aCompositionEvent,
const NPEvent* aPluginEvent)
{
nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
if (!widget) {
widget = GetRootWidgetForPluginFrame(mPluginFrame);
if (NS_WARN_IF(!widget)) {
return;
}
}
NPEvent npevent;
if (aPluginEvent->lParam & GCS_RESULTSTR) {
// GCS_RESULTSTR's default proc will generate WM_CHAR. So emulate it.
for (size_t i = 0; i < aCompositionEvent->mData.Length(); i++) {
WidgetPluginEvent charEvent(true, ePluginInputEvent, widget);
npevent.event = WM_CHAR;
npevent.wParam = aCompositionEvent->mData[i];
npevent.lParam = 0;
charEvent.mPluginEvent.Copy(npevent);
ProcessEvent(charEvent);
}
return;
}
if (!mSentStartComposition) {
// We post WM_IME_COMPOSITION to default proc, but
// WM_IME_STARTCOMPOSITION isn't post yet. We should post it at first.
WidgetPluginEvent startEvent(true, ePluginInputEvent, widget);
npevent.event = WM_IME_STARTCOMPOSITION;
npevent.wParam = 0;
npevent.lParam = 0;
startEvent.mPluginEvent.Copy(npevent);
CallDefaultProc(&startEvent);
mSentStartComposition = true;
}
CallDefaultProc(aCompositionEvent);
}
#endif
nsresult
@@ -1853,6 +1895,24 @@ nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
compositionChangeEventHandlingMarker(composition, compositionEvent);
}
const NPEvent* pPluginEvent =
static_cast<const NPEvent*>(compositionEvent->mPluginEvent);
if (pPluginEvent && pPluginEvent->event == WM_IME_COMPOSITION &&
mPluginDidNotHandleIMEComposition) {
// This is a workaround when running windowed and windowless Flash on
// same process.
// Flash with protected mode calls IMM APIs on own render process. This
// is a bug of Flash's protected mode.
// ImmGetCompositionString with GCS_RESULTSTR returns *LAST* committed
// string. So when windowed mode Flash handles IME composition,
// windowless plugin can get windowed mode's commited string by that API.
// So we never post WM_IME_COMPOSITION when plugin doesn't call
// ImmGetCompositionString() during WM_IME_COMPOSITION correctly.
HandleNoConsumedCompositionMessage(compositionEvent, pPluginEvent);
aEvent->StopImmediatePropagation();
return NS_OK;
}
// Protected mode Flash returns noDefault by NPP_HandleEvent, but
// composition information into plugin is invalid because plugin's bug.
// So if plugin doesn't get composition data by WM_IME_COMPOSITION, we
@@ -1864,8 +1924,7 @@ nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
aEvent->StopImmediatePropagation();
// Composition event isn't handled by plugin, so we have to call default proc.
const NPEvent* pPluginEvent =
static_cast<const NPEvent*>(compositionEvent->mPluginEvent);
if (NS_WARN_IF(!pPluginEvent)) {
return NS_OK;
}
@@ -1880,6 +1939,7 @@ nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
} else {
mSentStartComposition = false;
}
mPluginDidNotHandleIMEComposition = false;
return NS_OK;
}
@@ -1892,38 +1952,11 @@ nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
}
if (pPluginEvent->event == WM_IME_COMPOSITION && !mGotCompositionData) {
nsCOMPtr<nsIWidget> widget = GetContainingWidgetIfOffset();
if (!widget) {
widget = GetRootWidgetForPluginFrame(mPluginFrame);
}
// If plugin doesn't handle WM_IME_COMPOSITION correctly, we don't send
// composition event until end composition.
mPluginDidNotHandleIMEComposition = true;
if (pPluginEvent->lParam & GCS_RESULTSTR) {
// GCS_RESULTSTR's default proc will generate WM_CHAR. So emulate it.
for (size_t i = 0; i < compositionEvent->mData.Length(); i++) {
WidgetPluginEvent charEvent(true, ePluginInputEvent, widget);
NPEvent event;
event.event = WM_CHAR;
event.wParam = compositionEvent->mData[i];
event.lParam = 0;
charEvent.mPluginEvent.Copy(event);
ProcessEvent(charEvent);
}
return NS_OK;
}
if (!mSentStartComposition) {
// We post WM_IME_COMPOSITION to default proc, but
// WM_IME_STARTCOMPOSITION isn't post yet. We should post it at first.
WidgetPluginEvent event(true, ePluginInputEvent, widget);
NPEvent npevent;
npevent.event = WM_IME_STARTCOMPOSITION;
npevent.wParam = 0;
npevent.lParam = 0;
event.mPluginEvent.Copy(npevent);
CallDefaultProc(&event);
mSentStartComposition = true;
}
CallDefaultProc(compositionEvent);
HandleNoConsumedCompositionMessage(compositionEvent, pPluginEvent);
}
#endif // #ifdef XP_WIN
return NS_OK;
+15 -5
View File
@@ -28,6 +28,10 @@ class nsPluginDOMContextMenuListener;
class nsPluginFrame;
class nsDisplayListBuilder;
#if defined(MOZ_X11) || defined(ANDROID)
class gfxContext;
#endif
namespace mozilla {
class TextComposition;
namespace dom {
@@ -54,6 +58,8 @@ class nsPluginInstanceOwner final : public nsIPluginInstanceOwner,
public nsSupportsWeakReference
{
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
nsPluginInstanceOwner();
NS_DECL_ISUPPORTS
@@ -236,9 +242,9 @@ public:
// The eventual target of these operations is PluginInstanceParent,
// but it takes several hops to get there.
void SetBackgroundUnknown();
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect);
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect);
already_AddRefed<DrawTarget> BeginUpdateBackground(const nsIntRect& aRect);
void EndUpdateBackground(const nsIntRect& aRect);
bool UseAsyncRendering();
already_AddRefed<nsIURI> GetBaseURI() const;
@@ -263,7 +269,8 @@ public:
bool GetCompositionString(uint32_t aIndex, nsTArray<uint8_t>* aString,
int32_t* aLength);
bool SetCandidateWindow(int32_t aX, int32_t aY);
bool SetCandidateWindow(
const mozilla::widget::CandidateWindowPosition& aPosition);
bool RequestCommitOrCancel(bool aCommitted);
private:
@@ -289,9 +296,12 @@ private:
#if defined(XP_WIN)
nsIWidget* GetContainingWidgetIfOffset();
already_AddRefed<mozilla::TextComposition> GetTextComposition();
void HandleNoConsumedCompositionMessage(
mozilla::WidgetCompositionEvent* aCompositionEvent,
const NPEvent* aPluginEvent);
bool mGotCompositionData;
bool mSentStartComposition;
bool mPluginDidNotHandleIMEComposition;
#endif
nsPluginNativeWindow *mPluginWindow;
+35 -4
View File
@@ -238,6 +238,7 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo,
mSupportsAsyncInit(false),
mFullPath(aPluginInfo->fFullPath),
mLastModifiedTime(aLastModifiedTime),
mSandboxLevel(0),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
mCachedBlocklistStateValid(false),
mIsFromExtension(fromExtension)
@@ -271,12 +272,14 @@ nsPluginTag::nsPluginTag(const char* aName,
mSupportsAsyncInit(false),
mFullPath(aFullPath),
mLastModifiedTime(aLastModifiedTime),
mSandboxLevel(0),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
mCachedBlocklistStateValid(false),
mIsFromExtension(fromExtension)
{
InitMime(aMimeTypes, aMimeDescriptions, aExtensions,
static_cast<uint32_t>(aVariants));
InitSandboxLevel();
if (!aArgsAreUTF8)
EnsureMembersAreUTF8();
FixupVersion();
@@ -293,8 +296,10 @@ nsPluginTag::nsPluginTag(uint32_t aId,
nsTArray<nsCString> aExtensions,
bool aIsJavaPlugin,
bool aIsFlashPlugin,
bool aSupportsAsyncInit,
int64_t aLastModifiedTime,
bool aFromExtension)
bool aFromExtension,
int32_t aSandboxLevel)
: nsIInternalPluginTag(aName, aDescription, aFileName, aVersion, aMimeTypes,
aMimeDescriptions, aExtensions),
mId(aId),
@@ -302,8 +307,9 @@ nsPluginTag::nsPluginTag(uint32_t aId,
mLibrary(nullptr),
mIsJavaPlugin(aIsJavaPlugin),
mIsFlashPlugin(aIsFlashPlugin),
mSupportsAsyncInit(false),
mSupportsAsyncInit(aSupportsAsyncInit),
mLastModifiedTime(aLastModifiedTime),
mSandboxLevel(aSandboxLevel),
mNiceFileName(),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
mCachedBlocklistStateValid(false),
@@ -412,6 +418,29 @@ void nsPluginTag::InitMime(const char* const* aMimeTypes,
}
}
void
nsPluginTag::InitSandboxLevel()
{
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
nsAutoCString sandboxPref("dom.ipc.plugins.sandbox-level.");
sandboxPref.Append(GetNiceFileName());
if (NS_FAILED(Preferences::GetInt(sandboxPref.get(), &mSandboxLevel))) {
mSandboxLevel = Preferences::GetInt("dom.ipc.plugins.sandbox-level.default"
);
}
#if defined(_AMD64_)
// As level 2 is now the default NPAPI sandbox level for 64-bit flash, we
// don't want to allow a lower setting unless this environment variable is
// set. This should be changed if the firefox.js pref file is changed.
if (mIsFlashPlugin &&
!PR_GetEnv("MOZ_ALLOW_WEAKER_SANDBOX") && mSandboxLevel < 2) {
mSandboxLevel = 2;
}
#endif
#endif
}
#if !defined(XP_WIN) && !defined(XP_MACOSX)
static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
nsAFlatCString& aString)
@@ -578,7 +607,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);
@@ -603,7 +633,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;
+5 -1
View File
@@ -128,8 +128,10 @@ public:
nsTArray<nsCString> aExtensions,
bool aIsJavaPlugin,
bool aIsFlashPlugin,
bool aSupportsAsyncInit,
int64_t aLastModifiedTime,
bool aFromExtension);
bool aFromExtension,
int32_t aSandboxLevel);
void TryUnloadPlugin(bool inShutdown);
@@ -169,6 +171,7 @@ public:
nsCString mFullPath; // UTF-8
int64_t mLastModifiedTime;
nsCOMPtr<nsITimer> mUnloadTimer;
int32_t mSandboxLevel;
void InvalidateBlocklistState();
@@ -184,6 +187,7 @@ private:
const char* const* aMimeDescriptions,
const char* const* aExtensions,
uint32_t aVariantCount);
void InitSandboxLevel();
nsresult EnsureMembersAreUTF8();
void FixupVersion();
+4 -4
View File
@@ -31,6 +31,7 @@ using mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
using nsIntRect from "nsRect.h";
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
using struct DxgiAdapterDesc from "mozilla/D3DMessageUtils.h";
using struct mozilla::widget::CandidateWindowPosition from "ipc/nsGUIEventIPC.h";
namespace mozilla {
namespace plugins {
@@ -264,10 +265,9 @@ parent:
returns (uint8_t[] aDist, int32_t aLength);
// Set candidate window position.
//
// @param aX x position of candidate window
// @param aY y position of candidate window
async SetCandidateWindow(int32_t aX, int32_t aY);
sync RequestCommitOrCancel(bool aCommitted);
// @param aPosition position information of candidate window
async SetCandidateWindow(CandidateWindowPosition aPosition);
async RequestCommitOrCancel(bool aCommitted);
both:
async PPluginScriptableObject();
+13 -5
View File
@@ -2065,14 +2065,22 @@ PluginInstanceChild::ImmSetCandidateWindowProc(HIMC aIMC, LPCANDIDATEFORM aForm)
}
if (!sCurrentPluginInstance ||
aForm->dwIndex != 0 ||
!(aForm->dwStyle & CFS_CANDIDATEPOS)) {
// Flash only uses CFS_CANDIDATEPOS with index == 0.
aForm->dwIndex != 0) {
return FALSE;
}
sCurrentPluginInstance->SendSetCandidateWindow(
aForm->ptCurrentPos.x, aForm->ptCurrentPos.y);
CandidateWindowPosition position;
position.mPoint.x = aForm->ptCurrentPos.x;
position.mPoint.y = aForm->ptCurrentPos.y;
position.mExcludeRect = !!(aForm->dwStyle & CFS_EXCLUDE);
if (position.mExcludeRect) {
position.mRect.x = aForm->rcArea.left;
position.mRect.y = aForm->rcArea.top;
position.mRect.width = aForm->rcArea.right - aForm->rcArea.left;
position.mRect.height = aForm->rcArea.bottom - aForm->rcArea.top;
}
sCurrentPluginInstance->SendSetCandidateWindow(position);
return TRUE;
}
+7 -9
View File
@@ -1149,7 +1149,7 @@ PluginInstanceParent::SetBackgroundUnknown()
nsresult
PluginInstanceParent::BeginUpdateBackground(const nsIntRect& aRect,
gfxContext** aCtx)
DrawTarget** aDrawTarget)
{
PLUGIN_LOG_DEBUG(
("[InstanceParent][%p] BeginUpdateBackground for <x=%d,y=%d, w=%d,h=%d>",
@@ -1163,7 +1163,7 @@ PluginInstanceParent::BeginUpdateBackground(const nsIntRect& aRect,
MOZ_ASSERT(aRect.TopLeft() == nsIntPoint(0, 0),
"Expecting rect for whole frame");
if (!CreateBackground(aRect.Size())) {
*aCtx = nullptr;
*aDrawTarget = nullptr;
return NS_OK;
}
}
@@ -1176,15 +1176,13 @@ PluginInstanceParent::BeginUpdateBackground(const nsIntRect& aRect,
RefPtr<gfx::DrawTarget> dt = gfxPlatform::GetPlatform()->
CreateDrawTargetForSurface(mBackground, gfx::IntSize(sz.width, sz.height));
RefPtr<gfxContext> ctx = new gfxContext(dt);
ctx.forget(aCtx);
dt.forget(aDrawTarget);
return NS_OK;
}
nsresult
PluginInstanceParent::EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect)
PluginInstanceParent::EndUpdateBackground(const nsIntRect& aRect)
{
PLUGIN_LOG_DEBUG(
("[InstanceParent][%p] EndUpdateBackground for <x=%d,y=%d, w=%d,h=%d>",
@@ -2441,13 +2439,13 @@ PluginInstanceParent::RecvGetCompositionString(const uint32_t& aIndex,
}
bool
PluginInstanceParent::RecvSetCandidateWindow(const int32_t& aX,
const int32_t& aY)
PluginInstanceParent::RecvSetCandidateWindow(
const mozilla::widget::CandidateWindowPosition& aPosition)
{
#if defined(OS_WIN)
nsPluginInstanceOwner* owner = GetOwner();
if (owner) {
owner->SetCandidateWindow(aX, aY);
owner->SetCandidateWindow(aPosition);
}
#endif
return true;
+6 -4
View File
@@ -60,6 +60,8 @@ public:
#endif // defined(XP_WIN)
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
PluginInstanceParent(PluginModuleParent* parent,
NPP npp,
const nsCString& mimeType,
@@ -338,9 +340,8 @@ public:
#endif
nsresult SetBackgroundUnknown();
nsresult BeginUpdateBackground(const nsIntRect& aRect,
gfxContext** aCtx);
nsresult EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect);
DrawTarget** aDrawTarget);
nsresult EndUpdateBackground(const nsIntRect& aRect);
void DidComposite();
bool IsUsingDirectDrawing();
@@ -358,7 +359,8 @@ public:
nsTArray<uint8_t>* aBuffer,
int32_t* aLength) override;
virtual bool
RecvSetCandidateWindow(const int32_t& aX, const int32_t& aY) override;
RecvSetCandidateWindow(
const mozilla::widget::CandidateWindowPosition& aPosition) override;
virtual bool
RecvRequestCommitOrCancel(const bool& aCommitted) override;
+7 -5
View File
@@ -17,11 +17,13 @@
#include "nsSize.h"
#include "nsRect.h"
class gfxContext;
class nsCString;
class nsNPAPIPlugin;
namespace mozilla {
namespace gfx {
class DrawTarget;
}
namespace layers {
class Image;
class ImageContainer;
@@ -34,6 +36,8 @@ namespace mozilla {
class PluginLibrary
{
public:
typedef mozilla::gfx::DrawTarget DrawTarget;
virtual ~PluginLibrary() { }
/**
@@ -82,14 +86,12 @@ public:
*/
virtual nsresult SetBackgroundUnknown(NPP instance) = 0;
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext**) = 0;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext*, const nsIntRect&) = 0;
const nsIntRect&, DrawTarget**) = 0;
virtual nsresult EndUpdateBackground(NPP instance, const nsIntRect&) = 0;
virtual nsresult GetRunID(uint32_t* aRunID) = 0;
virtual void SetHasLocalInstance() = 0;
};
} // namespace mozilla
#endif // ifndef mozilla_PluginLibrary_h
+27 -28
View File
@@ -499,33 +499,15 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId,
{
PLUGIN_LOG_DEBUG_FUNCTION;
int32_t sandboxLevel = 0;
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
nsAutoCString sandboxPref("dom.ipc.plugins.sandbox-level.");
sandboxPref.Append(aPluginTag->GetNiceFileName());
if (NS_FAILED(Preferences::GetInt(sandboxPref.get(), &sandboxLevel))) {
sandboxLevel = Preferences::GetInt("dom.ipc.plugins.sandbox-level.default");
}
#if defined(_AMD64_)
// As level 2 is now the default NPAPI sandbox level for 64-bit flash, we
// don't want to allow a lower setting unless this environment variable is
// set. This should be changed if the firefox.js pref file is changed.
if (aPluginTag->mIsFlashPlugin &&
!PR_GetEnv("MOZ_ALLOW_WEAKER_SANDBOX") && sandboxLevel < 2) {
sandboxLevel = 2;
}
#endif
#endif
nsAutoPtr<PluginModuleChromeParent> parent(
new PluginModuleChromeParent(aFilePath, aPluginId, sandboxLevel,
new PluginModuleChromeParent(aFilePath, aPluginId,
aPluginTag->mSandboxLevel,
aPluginTag->mSupportsAsyncInit));
UniquePtr<LaunchCompleteTask> onLaunchedRunnable(new LaunchedTask(parent));
parent->mSubprocess->SetCallRunnableImmediately(!parent->mIsStartingAsync);
TimeStamp launchStart = TimeStamp::Now();
bool launched = parent->mSubprocess->Launch(Move(onLaunchedRunnable),
sandboxLevel);
aPluginTag->mSandboxLevel);
if (!launched) {
// We never reached open
parent->mShutdown = true;
@@ -681,6 +663,7 @@ PluginModuleParent::PluginModuleParent(bool aIsChrome, bool aAllowAsyncInit)
, mNPPIface(nullptr)
, mPlugin(nullptr)
, mTaskFactory(this)
, mSandboxLevel(0)
, mIsFlashPlugin(false)
, mIsStartingAsync(false)
, mNPInitialized(false)
@@ -743,7 +726,6 @@ PluginModuleChromeParent::PluginModuleChromeParent(const char* aFilePath,
, mHangUIParent(nullptr)
, mHangUIEnabled(true)
, mIsTimerReset(true)
, mSandboxLevel(aSandboxLevel)
#ifdef MOZ_CRASHREPORTER
, mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex")
, mCrashReporter(nullptr)
@@ -761,6 +743,7 @@ PluginModuleChromeParent::PluginModuleChromeParent(const char* aFilePath,
{
NS_ASSERTION(mSubprocess, "Out of memory!");
sInstantiated = true;
mSandboxLevel = aSandboxLevel;
mRunID = GeckoChildProcessHost::GetUniqueID();
#ifdef MOZ_ENABLE_PROFILER_SPS
@@ -1397,6 +1380,7 @@ PluginModuleParent::GetPluginDetails()
mPluginVersion = pluginTag->Version();
mPluginFilename = pluginTag->FileName();
mIsFlashPlugin = pluginTag->mIsFlashPlugin;
mSandboxLevel = pluginTag->mSandboxLevel;
return true;
}
@@ -1996,25 +1980,23 @@ PluginModuleParent::SetBackgroundUnknown(NPP instance)
nsresult
PluginModuleParent::BeginUpdateBackground(NPP instance,
const nsIntRect& aRect,
gfxContext** aCtx)
DrawTarget** aDrawTarget)
{
PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->BeginUpdateBackground(aRect, aCtx);
return i->BeginUpdateBackground(aRect, aDrawTarget);
}
nsresult
PluginModuleParent::EndUpdateBackground(NPP instance,
gfxContext* aCtx,
const nsIntRect& aRect)
PluginModuleParent::EndUpdateBackground(NPP instance, const nsIntRect& aRect)
{
PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->EndUpdateBackground(aCtx, aRect);
return i->EndUpdateBackground(aRect);
}
void
@@ -2670,6 +2652,23 @@ PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
if (mIsFlashPlugin) {
parentInstance->InitMetadata(strPluginType, srcAttribute);
#ifdef XP_WIN
// Force windowless mode (bug 1201904) when sandbox level >= 2
if (mSandboxLevel >= 2) {
NS_NAMED_LITERAL_CSTRING(wmodeAttributeName, "wmode");
NS_NAMED_LITERAL_CSTRING(opaqueAttributeValue, "opaque");
auto wmodeAttributeIndex =
names.IndexOf(wmodeAttributeName, 0, comparator);
if (wmodeAttributeIndex != names.NoIndex) {
if (!values[wmodeAttributeIndex].EqualsLiteral("transparent")) {
values[wmodeAttributeIndex].Assign(opaqueAttributeValue);
}
} else {
names.AppendElement(wmodeAttributeName);
values.AppendElement(opaqueAttributeValue);
}
}
#endif
}
// Release the surrogate reference that was in pdata
+9 -3
View File
@@ -81,6 +81,9 @@ class FinishInjectorInitTask;
class PluginModuleParent
: public PPluginModuleParent
, public PluginLibrary
#ifdef MOZ_CRASHREPORTER_INJECTOR
, public CrashReporter::InjectorCrashCallback
#endif
{
protected:
typedef mozilla::PluginLibrary PluginLibrary;
@@ -246,9 +249,8 @@ protected:
virtual nsresult SetBackgroundUnknown(NPP instance) override;
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect& aRect,
gfxContext** aCtx) override;
DrawTarget** aDrawTarget) override;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx,
const nsIntRect& aRect) override;
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
@@ -314,6 +316,7 @@ protected:
TimeDuration mTimeBlocked;
nsCString mPluginName;
nsCString mPluginVersion;
int32_t mSandboxLevel;
bool mIsFlashPlugin;
#ifdef MOZ_X11
@@ -361,6 +364,10 @@ class PluginModuleContentParent : public PluginModuleParent
virtual bool ShouldContinueFromReplyTimeout() override;
virtual void OnExitedSyncSend() override;
#ifdef MOZ_CRASHREPORTER_INJECTOR
void OnCrash(DWORD processID) override {}
#endif
static PluginModuleContentParent* sSavedModuleParent;
uint32_t mPluginId;
@@ -533,7 +540,6 @@ private:
PluginHangUIParent *mHangUIParent;
bool mHangUIEnabled;
bool mIsTimerReset;
int32_t mSandboxLevel;
#ifdef MOZ_CRASHREPORTER
/**
* This mutex protects the crash reporter when the Plugin Hang UI event
+2
View File
@@ -16,10 +16,12 @@ struct PluginTag
nsCString[] extensions;
bool isJavaPlugin;
bool isFlashPlugin;
bool supportsAsyncInit;
nsCString filename;
nsCString version;
int64_t lastModifiedTime;
bool isFromExtension;
int32_t sandboxLevel;
};
union PluginIdentifier