Files
palemoon27/dom/plugins/ipc/PluginProcessChild.cpp
roytam1 1e246403c8 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1165052 - Part 9: Use ArraySpeciesCreate in Array.prototype.filter. r=efaust (198da18845)
- Bug 1165052 - Part 10: Use ArraySpeciesCreate in Array.prototype.map. r=efaust (9dcd625daa)
- Bug 1263618: Adapt assertions in RegExp*Raw functions for int32_t; r=arai (8ad46db66d)
- Bug 1263340 - Part 1: Use internal slot for global and sticky flags in RegExpBuiltinExec. r=h4writer (9b5fbe6358)
- Bug 1263340 - Part 2: Use internal slot for sticky flag in @@replace and @@search optimized path. r=h4writer (2b64567c6a)
- Bug 1264264 - Add optimized path for RegExp.prototype[@@replace] with functional replace and substitution. r=till (e55722bc0a)
- Bug 1263340 - Part 3: Use internal slot for sticky flag in RegExp native functions. r=h4writer (725cf7b9b0)
- Bug 1264264 - Part 2: Enable optimization for packers again in RegExp.prototype[@@replace]. r=h4writer (7f4b819e40)
- Bug 1268056 - Check if |this| value is a RegExp object in the optimized path in RegExpSplit. r=h4writer (8891f0a3ef)
- Bug 1263340 - Part 4: Followup for @@split - Apply optimized path for empty string too. r=till (956d1804a5)
- Bug 1261207 - Forward declare js::ScriptSource instead of casting `¦void*` pointers; r=jimb (4914273e96)
- Bug 1041586 - Implement Symbol.isConcatSpreadable. r=arai (238e5f97c6)
- Bug 1041586 - Use IsConcatSpreadable in Array.prototype.concat. r=arai (33333cb30f)
- Bug 1165052 - Part 11: Use ArraySpeciesCreate in Array.prototype.slice. r=efaust (45f34c0a87)
- Bug 1165052 - Part 12: Use ArraySpeciesCreate in Array.prototype.splice. r=efaust,evilpie (096f9ff03d)
- Bug 1165052 - Part 13: Add tests for ArraySpeciesCreate. r=efaust (4403642d3c)
- Bug 1041586 - Tests. r=arai (efc2d06863)
- Bug 1267364 - Check isNative every time in GetStringDataProperty. r=h4writer (6e7898c494)
- Bug 1041586 - Fold away property accesses to not-defined properties. r=jandem (216e6387db)
- add emacs (fa858771bf)
- Bug 1268574 - Check the outparam JSFunction* value after GetGetterPure. r=lth (3d80c79337)
- Bug 1263888 - Push TypeBarrier after ArraySlice. r=jandem (2617518401)
- Bug 1255316 - IonMonkey: Enable folding of MLoadUnboxedObjectOrNull with the stored value, r=jandem (0f75675721)
- Bug 1252313 - Fix wasm i64 shift ops with a constant rhs. r=bbouvier (2c05b901c6)
- Bug 1263609: SharedStubs - Port JSOP_POW to shared stubs, r=efaust (54523590d9)
- Bug 1247880 - Only remove MUrsh operands when the input of MUrsh is guaranteed to be unsigned. r=sunfish (4a29e0b071)
- Bug 1254528: IonMonkey - Check slot before removing load with value of store, r=nbp (3527eb5263)
- Bug 1255316 - IonMonkey: Also take into account the offsetAdjustment when folding MLoadUnboxedObjectOrNull, r=jandem (9cbea97df1)
- Bug 1263558 - Part 1: Self-host Array generics. r=till,bholley (e1dc0c54c8)
- Bug 1103588 - Part 3: Replace deprecated String#contains warning with an expression closure warning in sharedWorker_sharedWorker.js test. r=bz (221ff40ebc)
- Bug 1103588 - Part 4: Replace deprecated String#contains in js tests. r=till (a794c0b385)
- Bug 1103588 - Part 5: Remove deprecated String#contains function; use String#includes instead. r=till (bc1365603e)
- Bug 964709 - Updates Parser regex and tests to support self-closing script tags, r=vporof (f04c475ec8)
- Bug 1224726 - Do not attempt to parse source file when searching in debugger if text > 1MB;r=jlongster (8743b7bf19)
- Bug 1263558 - Part 2: Self-host String generics. r=till (4e5766489b)
- Bug 1263558 - Part 3: Remove JSFUN_GENERIC_NATIVE. r=till (3f94c198b0)
- Bug 1263558 - Part 4: Call initBuiltinConstructor after defining properties in InitStringClass. r=till (f25edc6096)
- Bug 1263558 - Part 0.1: Handle OOM inside BuildDominatorTree at AnalyzeNewScriptDefiniteProperties and AnalyzeArgumentsUsage. r=jandem (0f4745e9d4)
- Bug 1266573 - Add the JS::ubi::dumpPaths debug utility; r=jimb (9a8680d7c7)
- Bug 1266835 - Request names from the rootlist in JS::ubi::dumpPaths and clean up formatting of dumped paths. r=jimb (1e15dd3ab9)
- Bug 1259911: Only add predecessors to the join block once; r=sunfish (53a9522e68)
- Bug 1258905: Remove a bunch of dead IPC code. r=jld (0d9f930a14)
- Bug 1266869 - Print a message when no retaining paths are found in JS::ubi::dumpPaths. r=jimb (77a541b4d1)
2024-04-12 11:51:15 +08:00

160 lines
5.2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ipc/IOThreadChild.h"
#include "mozilla/plugins/PluginProcessChild.h"
#include "prlink.h"
#include "base/command_line.h"
#include "base/string_util.h"
#include "nsDebugImpl.h"
#if defined(XP_MACOSX)
#include "nsCocoaFeatures.h"
// An undocumented CoreGraphics framework method, present in the same form
// since at least OS X 10.5.
extern "C" CGError CGSSetDebugOptions(int options);
#endif
#ifdef XP_WIN
#include <objbase.h>
bool ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath);
#if defined(MOZ_SANDBOX)
#define TARGET_SANDBOX_EXPORTS
#include "mozilla/sandboxTarget.h"
#endif
#endif
using mozilla::ipc::IOThreadChild;
#ifdef OS_WIN
#include "nsSetDllDirectory.h"
#include <algorithm>
#endif
namespace mozilla {
namespace plugins {
bool
PluginProcessChild::Init()
{
nsDebugImpl::SetMultiprocessMode("NPAPI");
#if defined(XP_MACOSX)
// Remove the trigger for "dyld interposing" that we added in
// GeckoChildProcessHost::PerformAsyncLaunchInternal(), in the host
// process just before we were launched. Dyld interposing will still
// happen in our process (the plugin child process). But we don't want
// it to happen in any processes that the plugin might launch from our
// process.
nsCString interpose(PR_GetEnv("DYLD_INSERT_LIBRARIES"));
if (!interpose.IsEmpty()) {
// If we added the path to libplugin_child_interpose.dylib to an
// existing DYLD_INSERT_LIBRARIES, we appended it to the end, after a
// ":" path seperator.
int32_t lastSeparatorPos = interpose.RFind(":");
int32_t lastTriggerPos = interpose.RFind("libplugin_child_interpose.dylib");
bool needsReset = false;
if (lastTriggerPos != -1) {
if (lastSeparatorPos == -1) {
interpose.Truncate();
needsReset = true;
} else if (lastTriggerPos > lastSeparatorPos) {
interpose.SetLength(lastSeparatorPos);
needsReset = true;
}
}
if (needsReset) {
nsCString setInterpose("DYLD_INSERT_LIBRARIES=");
if (!interpose.IsEmpty()) {
setInterpose.Append(interpose);
}
// Values passed to PR_SetEnv() must be seperately allocated.
char* setInterposePtr = strdup(setInterpose.get());
PR_SetEnv(setInterposePtr);
}
}
#endif
#ifdef XP_WIN
// Drag-and-drop needs OleInitialize to be called, and Silverlight depends
// on the host calling CoInitialize (which is called by OleInitialize).
::OleInitialize(nullptr);
#endif
// Certain plugins, such as flash, steal the unhandled exception filter
// thus we never get crash reports when they fault. This call fixes it.
message_loop()->set_exception_restoration(true);
std::string pluginFilename;
#if defined(OS_POSIX)
// NB: need to be very careful in ensuring that the first arg
// (after the binary name) here is indeed the plugin module path.
// Keep in sync with dom/plugins/PluginModuleParent.
std::vector<std::string> values = CommandLine::ForCurrentProcess()->argv();
MOZ_ASSERT(values.size() >= 2, "not enough args");
pluginFilename = UnmungePluginDsoPath(values[1]);
#elif defined(OS_WIN)
std::vector<std::wstring> values =
CommandLine::ForCurrentProcess()->GetLooseValues();
MOZ_ASSERT(values.size() >= 1, "not enough loose args");
if (ShouldProtectPluginCurrentDirectory(values[0].c_str())) {
SanitizeEnvironmentVariables();
SetDllDirectory(L"");
}
pluginFilename = WideToUTF8(values[0]);
#if defined(MOZ_SANDBOX)
// This is probably the earliest we would want to start the sandbox.
// As we attempt to tighten the sandbox, we may need to consider moving this
// to later in the plugin initialization.
mozilla::SandboxTarget::Instance()->StartSandbox();
#endif
#else
# error Sorry
#endif
if (NS_FAILED(nsRegion::InitStatic())) {
NS_ERROR("Could not initialize nsRegion");
return false;
}
bool retval = mPlugin.InitForChrome(pluginFilename, ParentPid(),
IOThreadChild::message_loop(),
IOThreadChild::channel());
#if defined(XP_MACOSX)
if (nsCocoaFeatures::OnYosemiteOrLater()) {
// Explicitly turn off CGEvent logging. This works around bug 1092855.
// If there are already CGEvents in the log, turning off logging also
// causes those events to be written to disk. But at this point no
// CGEvents have yet been processed. CGEvents are events (usually
// input events) pulled from the WindowServer. An option of 0x80000008
// turns on CGEvent logging.
CGSSetDebugOptions(0x80000007);
}
#endif
return retval;
}
void
PluginProcessChild::CleanUp()
{
#ifdef XP_WIN
::OleUninitialize();
#endif
nsRegion::ShutdownStatic();
}
} // namespace plugins
} // namespace mozilla