2016-01-08 23:40:26 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2012-06-28 04:15:32 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2010-08-21 03:24:40 +04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
#include "ContentChild.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2014-11-18 20:50:25 +03:00
|
|
|
#include "GeckoProfiler.h"
|
2009-08-12 20:18:08 +04:00
|
|
|
#include "TabChild.h"
|
2015-08-26 02:42:21 +03:00
|
|
|
#include "HandlerServiceChild.h"
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2012-09-05 04:36:16 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2014-06-11 09:44:06 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2015-01-17 05:34:47 +03:00
|
|
|
#include "mozilla/ProcessHangMonitorIPC.h"
|
2016-09-02 10:12:24 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2015-09-22 22:09:42 +03:00
|
|
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperChild.h"
|
2014-11-13 03:31:00 +03:00
|
|
|
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/dom/ContentBridgeChild.h"
|
|
|
|
#include "mozilla/dom/ContentBridgeParent.h"
|
2016-11-08 05:21:35 +03:00
|
|
|
#include "mozilla/dom/VideoDecoderManagerChild.h"
|
2015-03-24 17:29:16 +03:00
|
|
|
#include "mozilla/dom/ContentParent.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
2016-11-04 21:13:52 +03:00
|
|
|
#include "mozilla/dom/DocGroup.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "mozilla/dom/ExternalHelperAppChild.h"
|
2017-02-08 12:19:01 +03:00
|
|
|
#include "mozilla/dom/FileCreatorHelper.h"
|
2016-06-07 12:46:03 +03:00
|
|
|
#include "mozilla/dom/FlyWebPublishedServerIPC.h"
|
2016-07-14 10:04:21 +03:00
|
|
|
#include "mozilla/dom/GetFilesHelper.h"
|
2017-04-24 13:16:49 +03:00
|
|
|
#include "mozilla/dom/IPCBlobUtils.h"
|
2017-01-27 03:35:53 +03:00
|
|
|
#include "mozilla/dom/MemoryReportRequest.h"
|
2015-02-20 04:13:02 +03:00
|
|
|
#include "mozilla/dom/ProcessGlobal.h"
|
2016-09-01 21:17:03 +03:00
|
|
|
#include "mozilla/dom/PushNotifier.h"
|
2017-05-17 08:01:14 +03:00
|
|
|
#include "mozilla/dom/LocalStorage.h"
|
2017-01-04 16:53:01 +03:00
|
|
|
#include "mozilla/dom/StorageIPC.h"
|
2016-11-04 21:13:52 +03:00
|
|
|
#include "mozilla/dom/TabGroup.h"
|
2016-07-11 01:28:13 +03:00
|
|
|
#include "mozilla/dom/workers/ServiceWorkerManager.h"
|
2014-06-11 09:44:06 +04:00
|
|
|
#include "mozilla/dom/nsIContentChild.h"
|
2016-11-19 00:54:57 +03:00
|
|
|
#include "mozilla/dom/URLClassifierChild.h"
|
2016-08-04 21:33:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2015-04-22 22:55:23 +03:00
|
|
|
#include "mozilla/psm/PSMContentListener.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "mozilla/hal_sandbox/PHalChild.h"
|
2013-11-27 11:59:41 +04:00
|
|
|
#include "mozilla/ipc/BackgroundChild.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ipc/FileDescriptorSetChild.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "mozilla/ipc/FileDescriptorUtils.h"
|
2013-01-18 00:06:36 +04:00
|
|
|
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
2016-04-11 11:12:33 +03:00
|
|
|
#include "mozilla/ipc/ProcessChild.h"
|
2017-03-14 14:28:58 +03:00
|
|
|
#include "mozilla/ipc/PChildToParentStreamChild.h"
|
Bug 1348042 - Refactor LocaleService to operate in server-client mode. r=Ehsan,qdot
LocaleService serves two main functions. It is a central place for all code in the
engine to learn about locales, but it also does the language negotiation and selection.
The former is relevant in all processes, but the latter should only be performed
by the "main" process. In case of current Desktop Firefox, the parent process
is the one performing all the language negotiation, and content processes should
operate in the "client" mode.
In Fennec, there's a Java app on top of Gecko which should work as a "server"
and then all processes, including parent process of Gecko is merely a "client" for that.
This refactor finalizes this duality making it easily configurable to define in
which mode a given LocaleService operates.
The server-client model allows all clients to stay in sync with the server,
but operate transparently for all callers just returning the right values.
In order to initialize LocaleService in the client mode in child process with the
right locales I'm adding the list of app locales to the XPCOMInitData,
and then fire LocaleService::SetAppLocales in the child process initialization.
In order to keep the list up to date, I'm adding intl:app-locales-changed to
the list of observed topics, and when triggered, I send the updated list
to the child process, which updates LocaleService::SetAppLocales with the new
list.
MozReview-Commit-ID: K9X6berF3IO
--HG--
extra : rebase_source : ca5e502d064023fddfd63fe6fe5eccefce8dee52
2017-03-26 08:09:45 +03:00
|
|
|
#include "mozilla/intl/LocaleService.h"
|
2009-08-12 22:31:48 +04:00
|
|
|
#include "mozilla/ipc/TestShellChild.h"
|
2015-01-27 00:32:18 +03:00
|
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
2017-06-15 00:28:01 +03:00
|
|
|
#include "mozilla/jsipc/PJavaScript.h"
|
2016-01-08 22:17:39 +03:00
|
|
|
#include "mozilla/layers/APZChild.h"
|
2017-06-14 18:39:59 +03:00
|
|
|
#include "mozilla/layers/CompositorManagerChild.h"
|
2016-08-11 02:51:45 +03:00
|
|
|
#include "mozilla/layers/ContentProcessController.h"
|
2012-08-29 16:24:48 +04:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2015-10-30 02:30:57 +03:00
|
|
|
#include "mozilla/layout/RenderFrameChild.h"
|
2017-05-03 03:17:52 +03:00
|
|
|
#include "mozilla/loader/ScriptCacheActors.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2016-11-17 19:35:24 +03:00
|
|
|
#include "mozilla/net/CaptivePortalService.h"
|
2015-04-07 16:17:27 +03:00
|
|
|
#include "mozilla/plugins/PluginInstanceParent.h"
|
2014-10-29 18:05:36 +03:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
2017-03-09 14:30:26 +03:00
|
|
|
#include "mozilla/widget/ScreenManager.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "mozilla/widget/WidgetMessageUtils.h"
|
2016-05-19 00:17:34 +03:00
|
|
|
#include "nsBaseDragService.h"
|
2015-06-18 18:46:36 +03:00
|
|
|
#include "mozilla/media/MediaChild.h"
|
2015-06-10 19:48:22 +03:00
|
|
|
#include "mozilla/BasePrincipal.h"
|
2015-09-21 15:54:00 +03:00
|
|
|
#include "mozilla/WebBrowserPersistDocumentChild.h"
|
2016-06-07 01:23:43 +03:00
|
|
|
#include "imgLoader.h"
|
2016-11-01 06:25:19 +03:00
|
|
|
#include "GMPServiceChild.h"
|
2017-07-05 22:57:47 +03:00
|
|
|
#include "NullPrincipal.h"
|
2014-02-14 20:07:16 +04:00
|
|
|
|
2017-05-30 22:06:14 +03:00
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
#include "ChildProfilerController.h"
|
|
|
|
#endif
|
|
|
|
|
2014-03-13 02:48:15 +04:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
2017-05-13 00:04:42 +03:00
|
|
|
#include "mozilla/SandboxSettings.h"
|
2014-03-13 02:48:15 +04:00
|
|
|
#if defined(XP_WIN)
|
2014-02-14 20:07:16 +04:00
|
|
|
#define TARGET_SANDBOX_EXPORTS
|
|
|
|
#include "mozilla/sandboxTarget.h"
|
2014-11-25 02:22:13 +03:00
|
|
|
#elif defined(XP_LINUX)
|
|
|
|
#include "mozilla/Sandbox.h"
|
|
|
|
#include "mozilla/SandboxInfo.h"
|
2016-05-12 15:35:11 +03:00
|
|
|
|
|
|
|
// Remove this include with Bug 1104619
|
|
|
|
#include "CubebUtils.h"
|
2014-11-25 02:22:13 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
2014-02-28 01:18:01 +04:00
|
|
|
#include "mozilla/Sandbox.h"
|
2014-02-14 20:07:16 +04:00
|
|
|
#endif
|
2014-03-13 02:48:15 +04:00
|
|
|
#endif
|
2014-02-14 20:07:16 +04:00
|
|
|
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2009-08-12 22:31:48 +04:00
|
|
|
|
2014-10-03 18:52:37 +04:00
|
|
|
#include "mozInlineSpellChecker.h"
|
2016-02-18 11:33:07 +03:00
|
|
|
#include "nsDocShell.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIConsoleListener.h"
|
2017-06-20 16:57:08 +03:00
|
|
|
#include "nsIContentViewer.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "nsICycleCollectorListener.h"
|
2016-08-22 15:52:45 +03:00
|
|
|
#include "nsIIdlePeriod.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "nsIDragService.h"
|
2013-11-27 11:59:41 +04:00
|
|
|
#include "nsIIPCBackgroundChildCreateCallback.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2011-02-16 21:43:23 +03:00
|
|
|
#include "nsIMemoryReporter.h"
|
2012-10-30 04:41:14 +04:00
|
|
|
#include "nsIMemoryInfoDumper.h"
|
2013-01-10 22:16:40 +04:00
|
|
|
#include "nsIMutable.h"
|
2010-07-21 22:42:32 +04:00
|
|
|
#include "nsIObserverService.h"
|
2012-08-09 06:58:06 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2014-07-03 02:59:02 +04:00
|
|
|
#include "nsMemoryInfoDumper.h"
|
2010-07-21 22:42:32 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-08-27 21:10:39 +04:00
|
|
|
#include "nsStyleSheetService.h"
|
2015-10-07 18:17:42 +03:00
|
|
|
#include "nsVariant.h"
|
2009-08-26 03:39:30 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2010-09-24 05:39:32 +04:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2011-09-13 21:53:51 +04:00
|
|
|
#include "nsJSEnvironment.h"
|
2011-10-06 02:15:45 +04:00
|
|
|
#include "SandboxHal.h"
|
2012-04-10 23:57:20 +04:00
|
|
|
#include "nsDebugImpl.h"
|
2013-04-26 04:53:26 +04:00
|
|
|
#include "nsHashPropertyBag.h"
|
2012-08-16 05:46:03 +04:00
|
|
|
#include "nsLayoutStylesheetCache.h"
|
2014-02-01 03:02:30 +04:00
|
|
|
#include "nsThreadManager.h"
|
2014-06-24 21:11:36 +04:00
|
|
|
#include "nsAnonymousTemporaryFile.h"
|
2014-10-03 18:52:37 +04:00
|
|
|
#include "nsISpellChecker.h"
|
2014-10-22 13:50:00 +04:00
|
|
|
#include "nsClipboardProxy.h"
|
2016-02-26 02:26:13 +03:00
|
|
|
#include "nsDirectoryService.h"
|
2015-02-18 16:10:27 +03:00
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2015-04-14 04:08:00 +03:00
|
|
|
#include "nsContentPermissionHelper.h"
|
2017-06-06 20:39:46 +03:00
|
|
|
#include "nsPluginHost.h"
|
2016-05-19 13:25:22 +03:00
|
|
|
#ifdef NS_PRINTING
|
2016-05-16 12:40:54 +03:00
|
|
|
#include "nsPrintingProxy.h"
|
2016-05-19 13:25:22 +03:00
|
|
|
#endif
|
2009-08-26 03:07:22 +04:00
|
|
|
|
2012-11-09 13:55:54 +04:00
|
|
|
#include "IHistory.h"
|
2010-07-02 19:50:41 +04:00
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "base/message_loop.h"
|
2012-07-18 03:59:45 +04:00
|
|
|
#include "base/process_util.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "base/task.h"
|
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
#include "nsChromeRegistryContent.h"
|
2010-08-31 22:58:35 +04:00
|
|
|
#include "nsFrameMessageManager.h"
|
2010-03-11 08:33:00 +03:00
|
|
|
|
2010-09-21 08:16:37 +04:00
|
|
|
#include "nsIGeolocationProvider.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "mozilla/dom/PCycleCollectWithLogsChild.h"
|
2010-09-21 08:16:37 +04:00
|
|
|
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2016-07-17 17:50:50 +03:00
|
|
|
#include "nsHostObjectProtocolHandler.h"
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
#include "signaling/src/peerconnection/WebrtcGlobalChild.h"
|
|
|
|
#endif
|
|
|
|
|
2015-03-24 17:29:16 +03:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
2010-10-09 22:07:38 +04:00
|
|
|
#include "nsPermission.h"
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-06 21:21:15 +04:00
|
|
|
#include "PermissionMessageUtils.h"
|
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-24 17:15:03 +03:00
|
|
|
#include "APKOpen.h"
|
|
|
|
#endif
|
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <process.h>
|
|
|
|
#define getpid _getpid
|
2016-03-13 16:25:23 +03:00
|
|
|
#include "mozilla/widget/AudioSession.h"
|
2017-07-25 07:34:14 +03:00
|
|
|
#include "mozilla/audio/AudioNotificationReceiver.h"
|
2011-02-16 21:43:23 +03:00
|
|
|
#endif
|
|
|
|
|
2014-02-05 20:37:26 +04:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
#include "mozilla/X11Util.h"
|
|
|
|
#endif
|
|
|
|
|
2011-07-21 08:37:32 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2016-08-08 18:35:56 +03:00
|
|
|
#include "nsAccessibilityService.h"
|
Bug 1303060: Changes to a11y to enable the serving of a COM handler; r=tbsaunde
MozReview-Commit-ID: GTQF3x1pBtX
A general outline of the COM handler (a.k.a. the "smart proxy"):
COM handlers are pieces of code that are loaded by the COM runtime along with
a proxy and are layered above that proxy. This enables the COM handler to
interpose itself between the caller and the proxy, thus providing the
opportunity for the handler to manipulate an interface's method calls before
those calls reach the proxy.
Handlers are regular COM components that live in DLLs and are declared in the
Windows registry. In order to allow for the specifying of a handler (and an
optional payload to be sent with the proxy), the mscom library allows its
clients to specify an implementation of the IHandlerProvider interface.
IHandlerProvider consists of 5 functions:
* GetHandler returns the CLSID of the component that should be loaded into
the COM client's process. If GetHandler returns a failure code, then no
handler is loaded.
* GetHandlerPayloadSize and WriteHandlerPayload are for obtaining the payload
data. These calls are made on a background thread but need to do their work
on the main thread. We declare the payload struct in IDL. MIDL generates two
functions, IA2Payload_Encode and IA2Payload_Decode, which are used by
mscom::StructToStream to read and write that struct to and from buffers.
* The a11y payload struct also includes an interface, IGeckoBackChannel, that
allows the handler to communicate directly with Gecko. IGeckoBackChannel
currently provides two methods: one to allow the handler to request fresh
cache information, and the other to provide Gecko with its IHandlerControl
interface.
* MarshalAs accepts an IID that specifies the interface that is about to be
proxied. We may want to send a more sophisticated proxy than the one that
is requested. The desired IID is returned by this function. In the case of
a11y interfaces, we should always return IAccessible2_3 if we are asked for
one of its parent interfaces. This allows us to eliminate round trips to
resolve more sophisticated interfaces later on.
* NewInstance, which is needed to ensure that all descendent proxies are also
imbued with the same handler code.
The main focus of this patch is as follows:
1. Provide an implementation of the IHandlerProvider interface;
2. Populate the handler payload (ie, the cache) with data;
3. Modify CreateHolderFromAccessible to specify the HandlerPayload object;
4. Receive the IHandlerControl interface from the handler DLL and move it
into the chrome process.
Some more information about IHandlerControl:
There is one IHandlerControl per handler DLL instance. It is the interface that
we call in Gecko when we need to dispatch an event to the handler. In order to
ensure that events are dispatched in the correct order, we need to dispatch
those events from the chrome main thread so that they occur in sequential order
with calls to NotifyWinEvent.
--HG--
extra : rebase_source : acb44dead7cc5488424720e1bf58862b7b30374f
2017-04-05 00:23:55 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "mozilla/a11y/AccessibleWrap.h"
|
|
|
|
#endif
|
2011-07-21 08:37:32 +04:00
|
|
|
#endif
|
|
|
|
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2015-03-26 06:16:21 +03:00
|
|
|
#include "mozilla/dom/PPresentationChild.h"
|
2015-03-30 10:46:11 +03:00
|
|
|
#include "mozilla/dom/PresentationIPCService.h"
|
2013-01-18 00:17:33 +04:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2012-08-02 10:02:29 +04:00
|
|
|
|
2013-04-04 02:13:17 +04:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
#include "mozilla/dom/PSpeechSynthesisChild.h"
|
|
|
|
#endif
|
|
|
|
|
2012-09-11 08:30:33 +04:00
|
|
|
#include "ProcessUtils.h"
|
2012-08-23 23:33:46 +04:00
|
|
|
#include "URIUtils.h"
|
2012-08-25 20:53:48 +04:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsIPrincipal.h"
|
2015-03-24 17:29:16 +03:00
|
|
|
#include "DomainPolicy.h"
|
2015-09-10 23:50:58 +03:00
|
|
|
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
2014-02-14 12:43:51 +04:00
|
|
|
#include "mozilla/dom/time/DateCacheCleaner.h"
|
2013-10-19 00:57:55 +04:00
|
|
|
#include "mozilla/net/NeckoMessageUtils.h"
|
2015-04-11 01:18:05 +03:00
|
|
|
#include "mozilla/widget/PuppetBidiKeyboard.h"
|
2014-07-02 02:24:27 +04:00
|
|
|
#include "mozilla/RemoteSpellCheckEngineChild.h"
|
2015-02-10 13:49:03 +03:00
|
|
|
#include "GMPServiceChild.h"
|
2017-01-17 07:05:46 +03:00
|
|
|
#include "GfxInfoBase.h"
|
2015-07-30 10:23:53 +03:00
|
|
|
#include "gfxPlatform.h"
|
2015-07-31 22:11:48 +03:00
|
|
|
#include "nscore.h" // for NS_FREE_PERMANENT_DATA
|
2015-09-18 00:23:13 +03:00
|
|
|
#include "VRManagerChild.h"
|
2017-03-14 02:06:04 +03:00
|
|
|
#include "private/pprio.h"
|
2017-03-30 00:43:21 +03:00
|
|
|
#include "nsString.h"
|
2011-11-21 02:40:53 +04:00
|
|
|
|
2017-02-07 16:34:23 +03:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
#include "nsAppRunner.h"
|
|
|
|
#endif
|
2017-02-17 05:44:16 +03:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "mozilla/ipc/CrashReporterClient.h"
|
|
|
|
#endif
|
2017-02-07 16:34:23 +03:00
|
|
|
|
2017-06-14 11:50:44 +03:00
|
|
|
#ifdef MOZ_CODE_COVERAGE
|
|
|
|
#include "mozilla/CodeCoverageHandler.h"
|
|
|
|
#endif
|
2017-02-07 16:34:23 +03:00
|
|
|
|
2012-12-15 04:01:34 +04:00
|
|
|
using namespace mozilla;
|
2010-10-20 21:12:32 +04:00
|
|
|
using namespace mozilla::docshell;
|
2013-01-27 01:14:01 +04:00
|
|
|
using namespace mozilla::dom::ipc;
|
2016-07-11 01:28:13 +03:00
|
|
|
using namespace mozilla::dom::workers;
|
2015-06-18 18:46:36 +03:00
|
|
|
using namespace mozilla::media;
|
2014-10-28 18:59:08 +03:00
|
|
|
using namespace mozilla::embedding;
|
2015-02-10 13:49:03 +03:00
|
|
|
using namespace mozilla::gmp;
|
2012-07-18 03:59:45 +04:00
|
|
|
using namespace mozilla::hal_sandbox;
|
|
|
|
using namespace mozilla::ipc;
|
Bug 1348042 - Refactor LocaleService to operate in server-client mode. r=Ehsan,qdot
LocaleService serves two main functions. It is a central place for all code in the
engine to learn about locales, but it also does the language negotiation and selection.
The former is relevant in all processes, but the latter should only be performed
by the "main" process. In case of current Desktop Firefox, the parent process
is the one performing all the language negotiation, and content processes should
operate in the "client" mode.
In Fennec, there's a Java app on top of Gecko which should work as a "server"
and then all processes, including parent process of Gecko is merely a "client" for that.
This refactor finalizes this duality making it easily configurable to define in
which mode a given LocaleService operates.
The server-client model allows all clients to stay in sync with the server,
but operate transparently for all callers just returning the right values.
In order to initialize LocaleService in the client mode in child process with the
right locales I'm adding the list of app locales to the XPCOMInitData,
and then fire LocaleService::SetAppLocales in the child process initialization.
In order to keep the list up to date, I'm adding intl:app-locales-changed to
the list of observed topics, and when triggered, I send the updated list
to the child process, which updates LocaleService::SetAppLocales with the new
list.
MozReview-Commit-ID: K9X6berF3IO
--HG--
extra : rebase_source : ca5e502d064023fddfd63fe6fe5eccefce8dee52
2017-03-26 08:09:45 +03:00
|
|
|
using namespace mozilla::intl;
|
2012-07-18 03:59:45 +04:00
|
|
|
using namespace mozilla::layers;
|
2015-10-30 02:30:57 +03:00
|
|
|
using namespace mozilla::layout;
|
2012-07-18 03:59:45 +04:00
|
|
|
using namespace mozilla::net;
|
2013-07-03 11:24:32 +04:00
|
|
|
using namespace mozilla::jsipc;
|
2015-04-22 22:55:23 +03:00
|
|
|
using namespace mozilla::psm;
|
2015-04-11 01:18:05 +03:00
|
|
|
using namespace mozilla::widget;
|
2017-05-03 03:17:52 +03:00
|
|
|
using mozilla::loader::PScriptCacheChild;
|
2009-08-12 22:31:48 +04:00
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace mozilla {
|
2017-01-26 21:59:50 +03:00
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace dom {
|
2011-02-16 21:43:23 +03:00
|
|
|
|
2014-05-13 21:13:00 +04:00
|
|
|
// IPC sender for remote GC/CC logging.
|
2015-03-21 19:28:04 +03:00
|
|
|
class CycleCollectWithLogsChild final
|
2016-01-05 12:59:30 +03:00
|
|
|
: public PCycleCollectWithLogsChild
|
|
|
|
, public nsICycleCollectorLogSink
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
CycleCollectWithLogsChild(const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
|
|
|
{
|
|
|
|
mGCLog = FileDescriptorToFILE(aGCLog, "w");
|
|
|
|
mCCLog = FileDescriptorToFILE(aCCLog, "w");
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD Open(FILE** aGCLog, FILE** aCCLog) override
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!mGCLog) || NS_WARN_IF(!mCCLog)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2014-05-13 21:13:00 +04:00
|
|
|
}
|
2016-01-05 12:59:30 +03:00
|
|
|
*aGCLog = mGCLog;
|
|
|
|
*aCCLog = mCCLog;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD CloseGCLog() override
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGCLog);
|
|
|
|
fclose(mGCLog);
|
|
|
|
mGCLog = nullptr;
|
|
|
|
SendCloseGCLog();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD CloseCCLog() override
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mCCLog);
|
|
|
|
fclose(mCCLog);
|
|
|
|
mCCLog = nullptr;
|
|
|
|
SendCloseCCLog();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD GetFilenameIdentifier(nsAString& aIdentifier) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD SetFilenameIdentifier(const nsAString& aIdentifier) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD GetProcessIdentifier(int32_t *aIdentifier) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD SetProcessIdentifier(int32_t aIdentifier) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD GetGcLog(nsIFile** aPath) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_IMETHOD GetCcLog(nsIFile** aPath) override
|
|
|
|
{
|
|
|
|
return UnimplementedProperty();
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
|
|
|
private:
|
2016-11-15 14:09:07 +03:00
|
|
|
~CycleCollectWithLogsChild() override
|
2016-01-05 12:59:30 +03:00
|
|
|
{
|
|
|
|
if (mGCLog) {
|
|
|
|
fclose(mGCLog);
|
|
|
|
mGCLog = nullptr;
|
|
|
|
}
|
|
|
|
if (mCCLog) {
|
|
|
|
fclose(mCCLog);
|
|
|
|
mCCLog = nullptr;
|
|
|
|
}
|
|
|
|
// The XPCOM refcount drives the IPC lifecycle; see also
|
|
|
|
// DeallocPCycleCollectWithLogsChild.
|
|
|
|
Unused << Send__delete__(this);
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsresult UnimplementedProperty()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(false, "This object is a remote GC/CC logger;"
|
|
|
|
" this property isn't meaningful.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
FILE* mGCLog;
|
|
|
|
FILE* mCCLog;
|
2014-05-13 21:13:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(CycleCollectWithLogsChild, nsICycleCollectorLogSink);
|
|
|
|
|
2010-09-15 20:44:57 +04:00
|
|
|
class AlertObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
AlertObserver(nsIObserver *aObserver, const nsString& aData)
|
|
|
|
: mObserver(aObserver)
|
|
|
|
, mData(aData)
|
|
|
|
{
|
|
|
|
}
|
2010-09-15 20:44:57 +04:00
|
|
|
|
2016-11-14 12:40:37 +03:00
|
|
|
~AlertObserver() = default;
|
2010-09-15 20:44:57 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
bool ShouldRemoveFrom(nsIObserver* aObserver,
|
|
|
|
const nsString& aData) const
|
|
|
|
{
|
|
|
|
return (mObserver == aObserver && mData == aData);
|
|
|
|
}
|
2010-09-15 20:44:57 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
bool Observes(const nsString& aData) const
|
|
|
|
{
|
|
|
|
return mData.Equals(aData);
|
|
|
|
}
|
2010-09-15 20:44:57 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
bool Notify(const nsCString& aType) const
|
|
|
|
{
|
|
|
|
mObserver->Observe(nullptr, aType.get(), mData.get());
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-15 20:44:57 +04:00
|
|
|
|
|
|
|
private:
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIObserver> mObserver;
|
|
|
|
nsString mData;
|
2010-09-15 20:44:57 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class ConsoleListener final : public nsIConsoleListener
|
2010-09-24 05:39:32 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-01-05 12:59:30 +03:00
|
|
|
explicit ConsoleListener(ContentChild* aChild)
|
|
|
|
: mChild(aChild) {}
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLELISTENER
|
2010-09-24 05:39:32 +04:00
|
|
|
|
|
|
|
private:
|
2016-11-14 12:40:37 +03:00
|
|
|
~ConsoleListener() = default;
|
2014-06-23 23:56:07 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
ContentChild* mChild;
|
|
|
|
friend class ContentChild;
|
2010-09-24 05:39:32 +04:00
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ConsoleListener, nsIConsoleListener)
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2016-04-18 19:49:26 +03:00
|
|
|
// Before we send the error to the parent process (which
|
|
|
|
// involves copying the memory), truncate any long lines. CSS
|
|
|
|
// errors in particular share the memory for long lines with
|
|
|
|
// repeated errors, but the IPC communication we're about to do
|
|
|
|
// will break that sharing, so we better truncate now.
|
|
|
|
static void
|
|
|
|
TruncateString(nsAString& aString)
|
|
|
|
{
|
|
|
|
if (aString.Length() > 1000) {
|
|
|
|
aString.Truncate(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 05:39:32 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ConsoleListener::Observe(nsIConsoleMessage* aMessage)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!mChild) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
|
|
|
|
if (scriptError) {
|
2016-04-19 16:59:03 +03:00
|
|
|
nsAutoString msg, sourceName, sourceLine;
|
2016-01-05 12:59:30 +03:00
|
|
|
nsXPIDLCString category;
|
|
|
|
uint32_t lineNum, colNum, flags;
|
|
|
|
|
|
|
|
nsresult rv = scriptError->GetErrorMessage(msg);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-04-18 19:49:26 +03:00
|
|
|
TruncateString(msg);
|
2016-01-05 12:59:30 +03:00
|
|
|
rv = scriptError->GetSourceName(sourceName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-04-18 19:49:26 +03:00
|
|
|
TruncateString(sourceName);
|
2016-01-05 12:59:30 +03:00
|
|
|
rv = scriptError->GetSourceLine(sourceLine);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-04-18 19:49:26 +03:00
|
|
|
TruncateString(sourceLine);
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
rv = scriptError->GetCategory(getter_Copies(category));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetLineNumber(&lineNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetColumnNumber(&colNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetFlags(&flags);
|
2010-09-24 05:39:32 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2016-04-18 19:49:26 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
mChild->SendScriptError(msg, sourceName, sourceLine,
|
|
|
|
lineNum, colNum, flags, category);
|
2010-09-24 05:39:32 +04:00
|
|
|
return NS_OK;
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsXPIDLString msg;
|
|
|
|
nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mChild->SendConsoleMessage(msg);
|
|
|
|
return NS_OK;
|
2010-09-24 05:39:32 +04:00
|
|
|
}
|
2010-07-21 22:42:32 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class BackgroundChildPrimer final :
|
2013-11-27 11:59:41 +04:00
|
|
|
public nsIIPCBackgroundChildCreateCallback
|
|
|
|
{
|
|
|
|
public:
|
2016-01-05 12:59:30 +03:00
|
|
|
BackgroundChildPrimer()
|
|
|
|
{ }
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
2013-11-27 11:59:41 +04:00
|
|
|
|
|
|
|
private:
|
2016-11-14 12:40:37 +03:00
|
|
|
~BackgroundChildPrimer() = default;
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
void
|
2016-01-05 12:59:30 +03:00
|
|
|
ActorCreated(PBackgroundChild* aActor) override
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor, "Failed to create a PBackgroundChild actor!");
|
|
|
|
}
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2016-11-15 14:09:07 +03:00
|
|
|
void
|
2016-01-05 12:59:30 +03:00
|
|
|
ActorFailed() override
|
|
|
|
{
|
|
|
|
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
|
|
|
|
}
|
2013-11-27 11:59:41 +04:00
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild* ContentChild::sSingleton;
|
2009-08-13 04:32:50 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild::ContentChild()
|
2013-01-11 15:19:02 +04:00
|
|
|
: mID(uint64_t(-1))
|
2016-10-20 21:34:16 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
2017-06-07 02:35:51 +03:00
|
|
|
, mMainChromeTid(0)
|
2016-10-20 21:34:16 +03:00
|
|
|
, mMsaaID(0)
|
|
|
|
#endif
|
2016-01-05 12:59:30 +03:00
|
|
|
, mCanOverrideProcessName(true)
|
|
|
|
, mIsAlive(true)
|
2016-09-03 02:23:00 +03:00
|
|
|
, mShuttingDown(false)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// This process is a content process, so it's clearly running in
|
|
|
|
// multiprocess mode!
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Child");
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2016-12-03 00:46:53 +03:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable:4722) /* Silence "destructor never returns" warning */
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild::~ContentChild()
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2016-07-29 10:13:10 +03:00
|
|
|
#ifndef NS_FREE_PERMANENT_DATA
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Content Child shouldn't be destroyed.");
|
2016-07-29 10:13:10 +03:00
|
|
|
#endif
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2016-12-03 00:46:53 +03:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2014-06-11 09:44:06 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(ContentChild)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentChild)
|
2015-10-30 02:30:57 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWindowProvider)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentChild)
|
2014-06-11 09:44:06 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
|
|
|
|
const StructuredCloneData& aInitialData,
|
|
|
|
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
|
|
|
|
{
|
|
|
|
mLookAndFeelCache = aLookAndFeelIntCache;
|
2017-06-28 00:04:17 +03:00
|
|
|
gfx::gfxVars::SetValuesForInitialize(aXPCOMInit.gfxNonDefaultVarUpdates());
|
2017-02-05 08:52:38 +03:00
|
|
|
InitXPCOM(aXPCOMInit, aInitialData);
|
2017-06-22 20:45:48 +03:00
|
|
|
InitGraphicsDeviceData(aXPCOMInit.contentDeviceData());
|
2017-03-29 08:43:44 +03:00
|
|
|
|
|
|
|
#ifdef NS_PRINTING
|
|
|
|
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
|
|
|
|
// PrintingParent, is always available for printing initiated from the parent.
|
|
|
|
// Create nsPrintingProxy instance later than the SystemGroup initialization.
|
|
|
|
RefPtr<nsPrintingProxy> printingProxy = nsPrintingProxy::GetInstance();
|
|
|
|
#endif
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild::Init(MessageLoop* aIOLoop,
|
2015-04-01 11:40:35 +03:00
|
|
|
base::ProcessId aParentPid,
|
2017-02-05 08:52:38 +03:00
|
|
|
IPC::Channel* aChannel,
|
|
|
|
uint64_t aChildID,
|
|
|
|
bool aIsForBrowser)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2012-06-28 04:15:32 +04:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2015-12-23 06:11:45 +03:00
|
|
|
// We need to pass a display down to gtk_init because it's not going to
|
|
|
|
// use the one from the environment on its own when deciding which backend
|
|
|
|
// to use, and when starting under XWayland, it may choose to start with
|
|
|
|
// the wayland backend instead of the x11 backend.
|
|
|
|
// The DISPLAY environment variable is normally set by the parent process.
|
2017-04-27 00:29:32 +03:00
|
|
|
if (!gfxPlatform::IsHeadless()) {
|
|
|
|
const char* display_name = DetectDisplay();
|
|
|
|
if (display_name) {
|
|
|
|
int argc = 3;
|
|
|
|
char option_name[] = "--display";
|
|
|
|
char* argv[] = {
|
|
|
|
// argv0 is unused because g_set_prgname() was called in
|
|
|
|
// XRE_InitChildProcess().
|
|
|
|
nullptr,
|
|
|
|
option_name,
|
|
|
|
const_cast<char*>(display_name),
|
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
char** argvp = argv;
|
|
|
|
gtk_init(&argc, &argvp);
|
|
|
|
} else {
|
|
|
|
gtk_init(nullptr, nullptr);
|
|
|
|
}
|
2015-12-23 06:11:45 +03:00
|
|
|
}
|
2010-08-21 03:24:40 +04:00
|
|
|
#endif
|
2010-10-09 01:48:37 +04:00
|
|
|
|
2010-09-10 05:25:26 +04:00
|
|
|
#ifdef MOZ_X11
|
2017-04-27 00:29:32 +03:00
|
|
|
if (!gfxPlatform::IsHeadless()) {
|
|
|
|
// Do this after initializing GDK, or GDK will install its own handler.
|
|
|
|
XRE_InstallX11ErrorHandler();
|
|
|
|
}
|
2010-09-10 05:25:26 +04:00
|
|
|
#endif
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_ASSERTION(!sSingleton, "only one ContentChild per child");
|
2010-11-05 19:38:17 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
// Once we start sending IPC messages, we need the thread manager to be
|
|
|
|
// initialized so we can deal with the responses. Do that here before we
|
|
|
|
// try to construct the crash reporter.
|
2016-06-10 09:04:49 +03:00
|
|
|
nsresult rv = nsThreadManager::get().Init();
|
2016-01-05 12:59:30 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-02-01 03:02:30 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!Open(aChannel, aParentPid, aIOLoop)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
sSingleton = this;
|
2009-08-13 04:32:50 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
// If communications with the parent have broken down, take the process
|
|
|
|
// down so it's not hanging around.
|
2016-08-02 15:54:00 +03:00
|
|
|
GetIPCChannel()->SetAbortOnError(true);
|
2016-08-03 20:54:35 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
|
|
|
GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_A11Y_REENTRY);
|
|
|
|
#endif
|
2015-02-13 22:10:56 +03:00
|
|
|
|
2017-03-11 04:01:38 +03:00
|
|
|
// This must be sent before any IPDL message, which may hit sentinel
|
|
|
|
// errors due to parent and content processes having different
|
|
|
|
// versions.
|
|
|
|
GetIPCChannel()->SendBuildID();
|
|
|
|
|
2014-02-05 20:37:26 +04:00
|
|
|
#ifdef MOZ_X11
|
2017-04-27 00:29:32 +03:00
|
|
|
if (!gfxPlatform::IsHeadless()) {
|
|
|
|
// Send the parent our X socket to act as a proxy reference for our X
|
|
|
|
// resources.
|
|
|
|
int xSocketFd = ConnectionNumber(DefaultXDisplay());
|
|
|
|
SendBackUpXResources(FileDescriptor(xSocketFd));
|
|
|
|
}
|
2014-02-05 20:37:26 +04:00
|
|
|
#endif
|
|
|
|
|
2011-06-08 23:56:31 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2017-02-17 05:44:16 +03:00
|
|
|
CrashReporterClient::InitSingleton(this);
|
2010-11-24 17:15:03 +03:00
|
|
|
#endif
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
mID = aChildID;
|
|
|
|
mIsForBrowser = aIsForBrowser;
|
2014-02-13 14:42:41 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
SetProcessName(NS_LITERAL_STRING("Web Content"), true);
|
2016-10-19 04:54:12 +03:00
|
|
|
|
|
|
|
return true;
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2012-10-06 01:54:54 +04:00
|
|
|
void
|
2014-03-26 08:56:35 +04:00
|
|
|
ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
|
2012-10-06 01:54:54 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!mCanOverrideProcessName) {
|
|
|
|
return;
|
|
|
|
}
|
2014-03-26 08:56:35 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
char* name;
|
|
|
|
if ((name = PR_GetEnv("MOZ_DEBUG_APP_PROCESS")) &&
|
|
|
|
aName.EqualsASCII(name)) {
|
2012-12-13 03:30:44 +04:00
|
|
|
#ifdef OS_POSIX
|
2016-01-05 12:59:30 +03:00
|
|
|
printf_stderr("\n\nCHILDCHILDCHILDCHILD\n [%s] debug me @%d\n\n", name,
|
|
|
|
getpid());
|
|
|
|
sleep(30);
|
2012-12-13 03:30:44 +04:00
|
|
|
#elif defined(OS_WIN)
|
2016-01-05 12:59:30 +03:00
|
|
|
// Windows has a decent JIT debugging story, so NS_DebugBreak does the
|
|
|
|
// right thing.
|
|
|
|
NS_DebugBreak(NS_DEBUG_BREAK,
|
|
|
|
"Invoking NS_DebugBreak() to debug child process",
|
|
|
|
nullptr, __FILE__, __LINE__);
|
2012-12-13 03:30:44 +04:00
|
|
|
#endif
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2012-12-13 03:30:44 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
mProcessName = aName;
|
|
|
|
mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get());
|
2014-03-26 08:56:35 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (aDontOverride) {
|
|
|
|
mCanOverrideProcessName = false;
|
|
|
|
}
|
2012-10-06 01:54:54 +04:00
|
|
|
}
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
NS_IMETHODIMP
|
2016-01-30 20:05:36 +03:00
|
|
|
ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
2015-10-30 02:30:57 +03:00
|
|
|
uint32_t aChromeFlags,
|
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified,
|
|
|
|
bool aSizeSpecified,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
2016-10-27 19:37:44 +03:00
|
|
|
bool aForceNoOpener,
|
2015-10-30 02:30:57 +03:00
|
|
|
bool* aWindowIsNew,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindowProxy** aReturn)
|
2015-10-30 02:30:57 +03:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
|
|
|
|
aCalledFromJS, aPositionSpecified,
|
|
|
|
aSizeSpecified, aURI, aName, aFeatures,
|
2016-10-27 19:37:44 +03:00
|
|
|
aForceNoOpener, aWindowIsNew, aReturn);
|
2015-10-30 02:30:57 +03:00
|
|
|
}
|
|
|
|
|
2016-11-24 18:08:31 +03:00
|
|
|
static nsresult
|
|
|
|
GetWindowParamsFromParent(mozIDOMWindowProxy* aParent,
|
2017-07-05 22:57:47 +03:00
|
|
|
nsACString& aBaseURIString, float* aFullZoom,
|
|
|
|
nsIPrincipal** aTriggeringPrincipal)
|
2016-11-24 18:08:31 +03:00
|
|
|
{
|
|
|
|
*aFullZoom = 1.0f;
|
|
|
|
auto* opener = nsPIDOMWindowOuter::From(aParent);
|
|
|
|
if (!opener) {
|
2017-07-05 22:57:47 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> nullPrincipal = NullPrincipal::Create();
|
|
|
|
NS_ADDREF(*aTriggeringPrincipal = nullPrincipal);
|
2016-11-24 18:08:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = opener->GetDoc();
|
2017-07-05 22:57:47 +03:00
|
|
|
NS_ADDREF(*aTriggeringPrincipal = doc->NodePrincipal());
|
2016-11-24 18:08:31 +03:00
|
|
|
nsCOMPtr<nsIURI> baseURI = doc->GetDocBaseURI();
|
|
|
|
if (!baseURI) {
|
|
|
|
NS_ERROR("nsIDocument didn't return a base URI");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
baseURI->GetSpec(aBaseURIString);
|
|
|
|
|
|
|
|
RefPtr<nsDocShell> openerDocShell =
|
|
|
|
static_cast<nsDocShell*>(opener->GetDocShell());
|
|
|
|
if (!openerDocShell) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
nsresult rv = openerDocShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
if (NS_SUCCEEDED(rv) && cv) {
|
|
|
|
cv->GetFullZoom(aFullZoom);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
nsresult
|
|
|
|
ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindowProxy* aParent,
|
2015-10-30 02:30:57 +03:00
|
|
|
bool aIframeMoz,
|
|
|
|
uint32_t aChromeFlags,
|
|
|
|
bool aCalledFromJS,
|
|
|
|
bool aPositionSpecified,
|
|
|
|
bool aSizeSpecified,
|
|
|
|
nsIURI* aURI,
|
|
|
|
const nsAString& aName,
|
|
|
|
const nsACString& aFeatures,
|
2016-10-27 19:37:44 +03:00
|
|
|
bool aForceNoOpener,
|
2015-10-30 02:30:57 +03:00
|
|
|
bool* aWindowIsNew,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindowProxy** aReturn)
|
2015-10-30 02:30:57 +03:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
*aReturn = nullptr;
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsAutoPtr<IPCTabContext> ipcContext;
|
|
|
|
TabId openerTabId = TabId(0);
|
2016-11-24 18:08:31 +03:00
|
|
|
nsAutoCString features(aFeatures);
|
2017-06-05 20:31:19 +03:00
|
|
|
nsAutoString name(aName);
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-11-24 18:08:31 +03:00
|
|
|
nsresult rv;
|
2017-06-05 20:31:19 +03:00
|
|
|
|
|
|
|
MOZ_ASSERT(!aParent || aTabOpener,
|
|
|
|
"If aParent is non-null, we should have an aTabOpener");
|
|
|
|
|
|
|
|
// Cache the boolean preference for allowing noopener windows to open in a
|
|
|
|
// separate process.
|
|
|
|
static bool sNoopenerNewProcess = false;
|
|
|
|
static bool sNoopenerNewProcessInited = false;
|
|
|
|
if (!sNoopenerNewProcessInited) {
|
|
|
|
Preferences::AddBoolVarCache(&sNoopenerNewProcess,
|
|
|
|
"dom.noopener.newprocess.enabled");
|
|
|
|
sNoopenerNewProcessInited = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we should load in a different process. We always want to load in a
|
|
|
|
// different process if we have noopener set, but we also might if we can't
|
|
|
|
// load in the current process.
|
|
|
|
bool loadInDifferentProcess = aForceNoOpener && sNoopenerNewProcess;
|
2017-07-05 20:11:33 +03:00
|
|
|
if (aTabOpener && !loadInDifferentProcess && aURI) {
|
2016-11-24 18:08:31 +03:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome3> browserChrome3;
|
|
|
|
rv = aTabOpener->GetWebBrowserChrome(getter_AddRefs(browserChrome3));
|
|
|
|
if (NS_SUCCEEDED(rv) && browserChrome3) {
|
|
|
|
bool shouldLoad;
|
|
|
|
rv = browserChrome3->ShouldLoadURIInThisProcess(aURI, &shouldLoad);
|
2017-06-05 20:31:19 +03:00
|
|
|
loadInDifferentProcess = NS_SUCCEEDED(rv) && !shouldLoad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we're in a content process and we have noopener set, there's no reason
|
|
|
|
// to load in our process, so let's load it elsewhere!
|
|
|
|
if (loadInDifferentProcess) {
|
|
|
|
nsAutoCString baseURIString;
|
|
|
|
float fullZoom;
|
2017-07-05 22:57:47 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
|
|
|
rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
|
|
|
|
getter_AddRefs(triggeringPrincipal));
|
2017-06-05 20:31:19 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
2016-11-24 18:08:31 +03:00
|
|
|
}
|
|
|
|
|
2017-06-05 20:31:19 +03:00
|
|
|
URIParams uriToLoad;
|
|
|
|
SerializeURI(aURI, uriToLoad);
|
|
|
|
Unused << SendCreateWindowInDifferentProcess(aTabOpener,
|
|
|
|
aChromeFlags,
|
|
|
|
aCalledFromJS,
|
|
|
|
aPositionSpecified,
|
|
|
|
aSizeSpecified,
|
|
|
|
uriToLoad,
|
|
|
|
features,
|
|
|
|
baseURIString,
|
|
|
|
fullZoom,
|
2017-07-05 22:57:47 +03:00
|
|
|
name,
|
|
|
|
Principal(triggeringPrincipal));
|
2017-06-05 20:31:19 +03:00
|
|
|
|
|
|
|
// We return NS_ERROR_ABORT, so that the caller knows that we've abandoned
|
|
|
|
// the window open as far as it is concerned.
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTabOpener) {
|
2016-01-05 12:59:30 +03:00
|
|
|
PopupIPCTabContext context;
|
|
|
|
openerTabId = aTabOpener->GetTabId();
|
|
|
|
context.opener() = openerTabId;
|
2016-02-18 07:35:45 +03:00
|
|
|
context.isMozBrowserElement() = aTabOpener->IsMozBrowserElement();
|
2016-01-05 12:59:30 +03:00
|
|
|
ipcContext = new IPCTabContext(context);
|
|
|
|
} else {
|
|
|
|
// It's possible to not have a TabChild opener in the case
|
|
|
|
// of ServiceWorker::OpenWindow.
|
|
|
|
UnsafeIPCTabContext unsafeTabContext;
|
|
|
|
ipcContext = new IPCTabContext(unsafeTabContext);
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT(ipcContext);
|
2017-04-05 13:42:00 +03:00
|
|
|
TabId tabId(nsContentUtils::GenerateTabId());
|
2016-01-05 12:59:30 +03:00
|
|
|
|
2017-04-07 02:46:18 +03:00
|
|
|
// We need to assign a TabGroup to the PBrowser actor before we send it to the
|
|
|
|
// parent. Otherwise, the parent could send messages to us before we have a
|
|
|
|
// proper TabGroup for that actor.
|
|
|
|
RefPtr<TabGroup> tabGroup;
|
|
|
|
if (aTabOpener && !aForceNoOpener) {
|
|
|
|
// The new actor will use the same tab group as the opener.
|
|
|
|
tabGroup = aTabOpener->TabGroup();
|
|
|
|
} else {
|
|
|
|
tabGroup = new TabGroup();
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
|
2017-04-07 02:46:18 +03:00
|
|
|
RefPtr<TabChild> newChild = new TabChild(this, tabId, tabGroup,
|
2016-01-05 12:59:30 +03:00
|
|
|
newTabContext, aChromeFlags);
|
|
|
|
if (NS_FAILED(newChild->Init())) {
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aTabOpener) {
|
|
|
|
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
|
|
|
|
ipcContext->get_PopupIPCTabContext().opener() = aTabOpener;
|
|
|
|
}
|
|
|
|
|
2016-11-04 21:13:52 +03:00
|
|
|
nsCOMPtr<nsIEventTarget> target = tabGroup->EventTargetFor(TaskCategory::Other);
|
|
|
|
SetEventTargetForActor(newChild, target);
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
Unused << SendPBrowserConstructor(
|
|
|
|
// We release this ref in DeallocPBrowserChild
|
|
|
|
RefPtr<TabChild>(newChild).forget().take(),
|
2017-04-07 02:46:18 +03:00
|
|
|
tabId, TabId(0), *ipcContext, aChromeFlags,
|
2016-10-15 04:46:26 +03:00
|
|
|
GetID(), IsForBrowser());
|
2016-01-05 12:59:30 +03:00
|
|
|
|
|
|
|
nsTArray<FrameScriptInfo> frameScripts;
|
|
|
|
nsCString urlToLoad;
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-03-29 21:32:41 +03:00
|
|
|
PRenderFrameChild* renderFrame = newChild->SendPRenderFrameConstructor();
|
|
|
|
TextureFactoryIdentifier textureFactoryIdentifier;
|
|
|
|
uint64_t layersId = 0;
|
2017-04-10 00:30:27 +03:00
|
|
|
CompositorOptions compositorOptions;
|
2017-03-15 02:48:41 +03:00
|
|
|
uint32_t maxTouchPoints = 0;
|
2017-06-07 21:36:46 +03:00
|
|
|
DimensionInfo dimensionInfo;
|
2016-03-29 21:32:41 +03:00
|
|
|
|
2017-06-15 20:28:11 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> parentTopInnerWindow;
|
|
|
|
if (aParent) {
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> parentTopWindow =
|
|
|
|
nsPIDOMWindowOuter::From(aParent)->GetTop();
|
|
|
|
if (parentTopWindow) {
|
|
|
|
parentTopInnerWindow = parentTopWindow->GetCurrentInnerWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send down the request to open the window.
|
|
|
|
RefPtr<CreateWindowPromise> windowCreated;
|
2016-01-05 12:59:30 +03:00
|
|
|
if (aIframeMoz) {
|
|
|
|
MOZ_ASSERT(aTabOpener);
|
2016-05-03 18:15:07 +03:00
|
|
|
nsAutoCString url;
|
|
|
|
if (aURI) {
|
|
|
|
aURI->GetSpec(url);
|
|
|
|
} else {
|
|
|
|
// We can't actually send a nullptr up as the URI, since IPDL doesn't let us
|
|
|
|
// send nullptr's for primitives. We indicate that the nsString for the URI
|
|
|
|
// should be converted to a nullptr by voiding the string.
|
|
|
|
url.SetIsVoid(true);
|
|
|
|
}
|
|
|
|
|
2017-06-15 20:28:11 +03:00
|
|
|
// NOTE: BrowserFrameOpenWindowPromise is the same type as
|
|
|
|
// CreateWindowPromise, and this code depends on that fact.
|
|
|
|
windowCreated =
|
|
|
|
newChild->SendBrowserFrameOpenWindow(aTabOpener, renderFrame, NS_ConvertUTF8toUTF16(url),
|
|
|
|
name, NS_ConvertUTF8toUTF16(features));
|
2016-01-05 12:59:30 +03:00
|
|
|
} else {
|
|
|
|
nsAutoCString baseURIString;
|
2016-11-24 18:08:31 +03:00
|
|
|
float fullZoom;
|
2017-07-05 22:57:47 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
|
|
|
rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
|
|
|
|
getter_AddRefs(triggeringPrincipal));
|
2016-11-24 18:08:31 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return rv;
|
2016-02-18 11:33:07 +03:00
|
|
|
}
|
|
|
|
|
2017-06-15 20:28:11 +03:00
|
|
|
windowCreated =
|
|
|
|
SendCreateWindow(aTabOpener, newChild, renderFrame,
|
|
|
|
aChromeFlags, aCalledFromJS, aPositionSpecified,
|
|
|
|
aSizeSpecified,
|
|
|
|
features,
|
|
|
|
baseURIString,
|
2017-07-05 22:57:47 +03:00
|
|
|
fullZoom,
|
|
|
|
Principal(triggeringPrincipal));
|
2017-06-15 20:28:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Await the promise being resolved. When the promise is resolved, we'll set
|
|
|
|
// the `ready` local variable, which will cause us to exit our nested event
|
|
|
|
// loop.
|
|
|
|
//
|
|
|
|
// NOTE: We need to run this callback on the StableStateEventTarget because we
|
|
|
|
// need to resolve our runnable and exit from the nested event loop before
|
|
|
|
// processing any events which were sent after the reply to CreateWindow was
|
|
|
|
// sent.
|
|
|
|
bool ready = false;
|
|
|
|
windowCreated->Then(nsContentUtils::GetStableStateEventTarget(), __func__,
|
|
|
|
[&] (const CreatedWindowInfo& info) {
|
|
|
|
MOZ_RELEASE_ASSERT(NS_IsMainThread(),
|
|
|
|
"windowCreated->Then must run on the main thread");
|
|
|
|
rv = info.rv();
|
|
|
|
*aWindowIsNew = info.windowOpened();
|
|
|
|
frameScripts = info.frameScripts();
|
|
|
|
urlToLoad = info.urlToLoad();
|
|
|
|
textureFactoryIdentifier = info.textureFactoryIdentifier();
|
|
|
|
layersId = info.layersId();
|
|
|
|
compositorOptions = info.compositorOptions();
|
|
|
|
maxTouchPoints = info.maxTouchPoints();
|
|
|
|
dimensionInfo = info.dimensions();
|
|
|
|
ready = true;
|
|
|
|
},
|
|
|
|
[&] (const CreateWindowPromise::RejectValueType aReason) {
|
|
|
|
MOZ_RELEASE_ASSERT(NS_IsMainThread(),
|
|
|
|
"windowCreated->Then must run on the main thread");
|
|
|
|
NS_WARNING("windowCreated promise rejected");
|
|
|
|
rv = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
ready = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
// =======================
|
|
|
|
// Begin Nested Event Loop
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
// We have to wait for a response from either SendCreateWindow or
|
|
|
|
// SendBrowserFrameOpenWindow with information we're going to need to return
|
|
|
|
// from this function, So we spin a nested event loop until they get back to
|
|
|
|
// us.
|
|
|
|
|
|
|
|
// Prevent the docshell from becoming active while the nested event loop is
|
|
|
|
// spinning.
|
|
|
|
newChild->AddPendingDocShellBlocker();
|
|
|
|
auto removePendingDocShellBlocker = MakeScopeExit([&] {
|
|
|
|
if (newChild) {
|
|
|
|
newChild->RemovePendingDocShellBlocker();
|
2015-10-30 02:30:57 +03:00
|
|
|
}
|
2017-06-15 20:28:11 +03:00
|
|
|
});
|
2017-06-15 20:28:11 +03:00
|
|
|
|
2017-06-15 20:28:11 +03:00
|
|
|
// Suspend our window if we have one to make sure we don't re-enter it.
|
|
|
|
if (parentTopInnerWindow) {
|
|
|
|
parentTopInnerWindow->Suspend();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
AutoNoJSAPI nojsapi;
|
|
|
|
|
|
|
|
// Spin the event loop until we get a response. Callers of this function
|
|
|
|
// already have to guard against an inner event loop spinning in the
|
|
|
|
// non-e10s case because of the need to spin one to create a new chrome
|
|
|
|
// window.
|
|
|
|
SpinEventLoopUntil([&] () { return ready; });
|
|
|
|
MOZ_RELEASE_ASSERT(ready,
|
|
|
|
"We are on the main thread, so we should not exit this "
|
|
|
|
"loop without ready being true.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentTopInnerWindow) {
|
|
|
|
parentTopInnerWindow->Resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
// =====================
|
|
|
|
// End Nested Event Loop
|
|
|
|
// =====================
|
|
|
|
|
|
|
|
// Handle the error which we got back from the parent process, if we got
|
|
|
|
// one.
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2017-06-15 20:28:11 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!*aWindowIsNew) {
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
2017-07-12 17:20:13 +03:00
|
|
|
// If the TabChild has been torn down, we don't need to do this anymore.
|
|
|
|
if (NS_WARN_IF(!newChild->IPCOpen())) {
|
|
|
|
return NS_ERROR_ABORT;
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (layersId == 0) { // if renderFrame is invalid.
|
|
|
|
renderFrame = nullptr;
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-09-27 09:37:07 +03:00
|
|
|
ShowInfo showInfo(EmptyString(), false, false, true, false, 0, 0, 0);
|
2016-01-30 20:05:36 +03:00
|
|
|
auto* opener = nsPIDOMWindowOuter::From(aParent);
|
2015-10-30 16:24:57 +03:00
|
|
|
nsIDocShell* openerShell;
|
|
|
|
if (opener && (openerShell = opener->GetDocShell())) {
|
|
|
|
nsCOMPtr<nsILoadContext> context = do_QueryInterface(openerShell);
|
|
|
|
showInfo = ShowInfo(EmptyString(), false,
|
2016-05-16 05:56:09 +03:00
|
|
|
context->UsePrivateBrowsing(), true, false,
|
2017-05-19 13:20:18 +03:00
|
|
|
aTabOpener->WebWidget()->GetDPI(),
|
|
|
|
aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),
|
|
|
|
aTabOpener->WebWidget()->GetDefaultScale().scale);
|
2015-10-30 16:24:57 +03:00
|
|
|
}
|
|
|
|
|
2017-03-15 02:48:41 +03:00
|
|
|
newChild->SetMaxTouchPoints(maxTouchPoints);
|
|
|
|
|
2016-10-07 21:59:59 +03:00
|
|
|
// Set the opener window for this window before we start loading the document
|
|
|
|
// inside of it. We have to do this before loading the remote scripts, because
|
|
|
|
// they can poke at the document and cause the nsDocument to be created before
|
|
|
|
// the openerwindow
|
|
|
|
nsCOMPtr<mozIDOMWindowProxy> windowProxy = do_GetInterface(newChild->WebNavigation());
|
2016-10-27 19:37:44 +03:00
|
|
|
if (!aForceNoOpener && windowProxy && aParent) {
|
2016-10-07 21:59:59 +03:00
|
|
|
nsPIDOMWindowOuter* outer = nsPIDOMWindowOuter::From(windowProxy);
|
|
|
|
nsPIDOMWindowOuter* parent = nsPIDOMWindowOuter::From(aParent);
|
|
|
|
outer->SetOpenerWindow(parent, *aWindowIsNew);
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
// Unfortunately we don't get a window unless we've shown the frame. That's
|
|
|
|
// pretty bogus; see bug 763602.
|
2017-04-10 00:30:27 +03:00
|
|
|
newChild->DoFakeShow(textureFactoryIdentifier, layersId, compositorOptions,
|
|
|
|
renderFrame, showInfo);
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2017-06-07 21:36:46 +03:00
|
|
|
newChild->RecvUpdateDimensions(dimensionInfo);
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
for (size_t i = 0; i < frameScripts.Length(); i++) {
|
|
|
|
FrameScriptInfo& info = frameScripts[i];
|
|
|
|
if (!newChild->RecvLoadRemoteScript(info.url(), info.runInGlobalScope())) {
|
|
|
|
MOZ_CRASH();
|
2015-10-30 02:30:57 +03:00
|
|
|
}
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!urlToLoad.IsEmpty()) {
|
2016-07-11 01:28:13 +03:00
|
|
|
newChild->RecvLoadURL(urlToLoad, showInfo);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<mozIDOMWindowProxy> win = do_GetInterface(newChild->WebNavigation());
|
2016-01-05 12:59:30 +03:00
|
|
|
win.forget(aReturn);
|
|
|
|
return NS_OK;
|
2015-10-30 02:30:57 +03:00
|
|
|
}
|
|
|
|
|
2013-10-25 07:47:48 +04:00
|
|
|
void
|
2016-01-05 12:59:30 +03:00
|
|
|
ContentChild::GetProcessName(nsAString& aName) const
|
2012-10-06 01:54:54 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
aName.Assign(mProcessName);
|
2012-10-06 01:54:54 +04:00
|
|
|
}
|
|
|
|
|
2014-10-14 01:28:00 +04:00
|
|
|
bool
|
2016-01-05 12:59:30 +03:00
|
|
|
ContentChild::IsAlive() const
|
2014-10-14 01:28:00 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return mIsAlive;
|
2014-10-14 01:28:00 +04:00
|
|
|
}
|
|
|
|
|
2016-09-03 02:23:00 +03:00
|
|
|
bool
|
|
|
|
ContentChild::IsShuttingDown() const
|
|
|
|
{
|
|
|
|
return mShuttingDown;
|
|
|
|
}
|
|
|
|
|
2013-10-25 07:47:48 +04:00
|
|
|
void
|
2016-01-05 12:59:30 +03:00
|
|
|
ContentChild::GetProcessName(nsACString& aName) const
|
2013-10-25 07:47:48 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
aName.Assign(NS_ConvertUTF16toUTF8(mProcessName));
|
2013-10-25 07:47:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
ContentChild::AppendProcessId(nsACString& aName)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!aName.IsEmpty()) {
|
|
|
|
aName.Append(' ');
|
|
|
|
}
|
|
|
|
unsigned pid = getpid();
|
|
|
|
aName.Append(nsPrintfCString("(pid %u)", pid));
|
2013-10-25 07:47:48 +04:00
|
|
|
}
|
|
|
|
|
2015-08-02 23:59:33 +03:00
|
|
|
void
|
2017-06-22 20:45:48 +03:00
|
|
|
ContentChild::InitGraphicsDeviceData(const ContentDeviceData& aData)
|
2015-08-02 23:59:33 +03:00
|
|
|
{
|
2017-06-22 20:45:48 +03:00
|
|
|
gfxPlatform::InitChild(aData);
|
2015-08-02 23:59:33 +03:00
|
|
|
}
|
|
|
|
|
2010-09-24 05:39:32 +04:00
|
|
|
void
|
2017-02-05 08:52:38 +03:00
|
|
|
ContentChild::InitXPCOM(const XPCOMInitData& aXPCOMInit,
|
|
|
|
const mozilla::dom::ipc::StructuredCloneData& aInitialData)
|
2010-09-24 05:39:32 +04:00
|
|
|
{
|
2017-02-05 08:52:38 +03:00
|
|
|
SET_PREF_PHASE(pref_initPhase::BEGIN_ALL_PREFS);
|
|
|
|
for (unsigned int i = 0; i < aXPCOMInit.prefs().Length(); i++) {
|
|
|
|
Preferences::SetPreference(aXPCOMInit.prefs().ElementAt(i));
|
|
|
|
}
|
|
|
|
SET_PREF_PHASE(pref_initPhase::END_ALL_PREFS);
|
2016-01-05 12:59:30 +03:00
|
|
|
// Do this as early as possible to get the parent process to initialize the
|
|
|
|
// background thread since we'll likely need database information very soon.
|
|
|
|
BackgroundChild::Startup();
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback =
|
|
|
|
new BackgroundChildPrimer();
|
|
|
|
if (!BackgroundChild::GetOrCreateForCurrentThread(callback)) {
|
|
|
|
MOZ_CRASH("Failed to create PBackgroundChild!");
|
|
|
|
}
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!svc) {
|
|
|
|
NS_WARNING("Couldn't acquire console service");
|
|
|
|
return;
|
|
|
|
}
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
mConsoleListener = new ConsoleListener(this);
|
|
|
|
if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
|
|
|
|
NS_WARNING("Couldn't register console listener for child process");
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
mAvailableDictionaries = aXPCOMInit.dictionaries();
|
|
|
|
|
|
|
|
RecvSetOffline(aXPCOMInit.isOffline());
|
|
|
|
RecvSetConnectivity(aXPCOMInit.isConnected());
|
Bug 1348042 - Refactor LocaleService to operate in server-client mode. r=Ehsan,qdot
LocaleService serves two main functions. It is a central place for all code in the
engine to learn about locales, but it also does the language negotiation and selection.
The former is relevant in all processes, but the latter should only be performed
by the "main" process. In case of current Desktop Firefox, the parent process
is the one performing all the language negotiation, and content processes should
operate in the "client" mode.
In Fennec, there's a Java app on top of Gecko which should work as a "server"
and then all processes, including parent process of Gecko is merely a "client" for that.
This refactor finalizes this duality making it easily configurable to define in
which mode a given LocaleService operates.
The server-client model allows all clients to stay in sync with the server,
but operate transparently for all callers just returning the right values.
In order to initialize LocaleService in the client mode in child process with the
right locales I'm adding the list of app locales to the XPCOMInitData,
and then fire LocaleService::SetAppLocales in the child process initialization.
In order to keep the list up to date, I'm adding intl:app-locales-changed to
the list of observed topics, and when triggered, I send the updated list
to the child process, which updates LocaleService::SetAppLocales with the new
list.
MozReview-Commit-ID: K9X6berF3IO
--HG--
extra : rebase_source : ca5e502d064023fddfd63fe6fe5eccefce8dee52
2017-03-26 08:09:45 +03:00
|
|
|
LocaleService::GetInstance()->AssignAppLocales(aXPCOMInit.appLocales());
|
|
|
|
LocaleService::GetInstance()->AssignRequestedLocales(aXPCOMInit.requestedLocales());
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
RecvSetCaptivePortalState(aXPCOMInit.captivePortalState());
|
|
|
|
RecvBidiKeyboardNotify(aXPCOMInit.isLangRTL(), aXPCOMInit.haveBidiKeyboards());
|
2016-01-05 12:59:30 +03:00
|
|
|
|
|
|
|
// Create the CPOW manager as soon as possible.
|
|
|
|
SendPJavaScriptConstructor();
|
|
|
|
|
2017-02-05 08:52:38 +03:00
|
|
|
if (aXPCOMInit.domainPolicy().active()) {
|
2016-01-05 12:59:30 +03:00
|
|
|
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
|
|
|
MOZ_ASSERT(ssm);
|
|
|
|
ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
|
|
|
|
if (!mPolicy) {
|
|
|
|
MOZ_CRASH("Failed to activate domain policy.");
|
|
|
|
}
|
2017-02-05 08:52:38 +03:00
|
|
|
mPolicy->ApplyClone(&aXPCOMInit.domainPolicy());
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
|
|
|
|
if (nsCOMPtr<nsIClipboardProxy> clipboardProxy = do_QueryInterface(clipboard)) {
|
2017-02-05 08:52:38 +03:00
|
|
|
clipboardProxy->SetCapabilities(aXPCOMInit.clipboardCaps());
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2014-10-22 13:50:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
{
|
|
|
|
AutoJSAPI jsapi;
|
|
|
|
if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
|
|
|
|
MOZ_CRASH();
|
2015-05-01 04:20:51 +03:00
|
|
|
}
|
2016-01-05 12:59:30 +03:00
|
|
|
ErrorResult rv;
|
|
|
|
JS::RootedValue data(jsapi.cx());
|
2017-02-05 08:52:38 +03:00
|
|
|
mozilla::dom::ipc::StructuredCloneData id;
|
|
|
|
id.Copy(aInitialData);
|
|
|
|
id.Read(jsapi.cx(), &data, rv);
|
2016-01-05 12:59:30 +03:00
|
|
|
if (NS_WARN_IF(rv.Failed())) {
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
ProcessGlobal* global = ProcessGlobal::Get();
|
|
|
|
global->SetInitialProcessData(data);
|
|
|
|
}
|
2015-05-01 04:20:51 +03:00
|
|
|
|
2016-07-21 13:57:35 +03:00
|
|
|
// The stylesheet cache is not ready yet. Store this URL for future use.
|
2017-02-05 08:52:38 +03:00
|
|
|
nsCOMPtr<nsIURI> ucsURL = DeserializeURI(aXPCOMInit.userContentSheetURL());
|
2016-07-21 13:57:35 +03:00
|
|
|
nsLayoutStylesheetCache::SetUserContentCSSURL(ucsURL);
|
|
|
|
|
2016-08-02 15:54:00 +03:00
|
|
|
// This will register cross-process observer.
|
|
|
|
mozilla::dom::time::InitializeDateCacheCleaner();
|
2017-02-11 02:46:59 +03:00
|
|
|
|
|
|
|
GfxInfoBase::SetFeatureStatus(aXPCOMInit.gfxFeatureStatus());
|
2017-02-25 19:14:04 +03:00
|
|
|
|
|
|
|
DataStorage::SetCachedStorageEntries(aXPCOMInit.dataStorage());
|
2010-09-24 05:39:32 +04:00
|
|
|
}
|
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvRequestMemoryReport(const uint32_t& aGeneration,
|
|
|
|
const bool& aAnonymize,
|
|
|
|
const bool& aMinimizeMemoryUsage,
|
|
|
|
const MaybeFileDesc& aDMDFile)
|
2011-02-16 21:43:23 +03:00
|
|
|
{
|
2017-01-27 03:35:53 +03:00
|
|
|
nsCString process;
|
|
|
|
GetProcessName(process);
|
|
|
|
AppendProcessId(process);
|
|
|
|
|
2017-01-27 03:35:54 +03:00
|
|
|
MemoryReportRequestClient::Start(
|
|
|
|
aGeneration, aAnonymize, aMinimizeMemoryUsage, aDMDFile, process);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-03-05 06:27:13 +04:00
|
|
|
}
|
|
|
|
|
2014-05-13 21:13:00 +04:00
|
|
|
PCycleCollectWithLogsChild*
|
|
|
|
ContentChild::AllocPCycleCollectWithLogsChild(const bool& aDumpAllTraces,
|
|
|
|
const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
|
|
|
{
|
2016-11-14 12:35:58 +03:00
|
|
|
auto* actor = new CycleCollectWithLogsChild(aGCLog, aCCLog);
|
2016-01-05 12:59:30 +03:00
|
|
|
// Return actor with refcount 0, which is safe because it has a non-XPCOM type.
|
|
|
|
return actor;
|
2014-05-13 21:13:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-05-13 21:13:00 +04:00
|
|
|
ContentChild::RecvPCycleCollectWithLogsConstructor(PCycleCollectWithLogsChild* aActor,
|
|
|
|
const bool& aDumpAllTraces,
|
|
|
|
const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
2012-10-16 06:12:14 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// Take a reference here, where the XPCOM type is regained.
|
|
|
|
RefPtr<CycleCollectWithLogsChild> sink = static_cast<CycleCollectWithLogsChild*>(aActor);
|
|
|
|
nsCOMPtr<nsIMemoryInfoDumper> dumper = do_GetService("@mozilla.org/memory-info-dumper;1");
|
2012-10-30 04:41:14 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
dumper->DumpGCAndCCLogsToSink(aDumpAllTraces, sink);
|
2014-05-13 21:13:00 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
// The actor's destructor is called when the last reference goes away...
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-13 21:13:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPCycleCollectWithLogsChild(PCycleCollectWithLogsChild* /* aActor */)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// ...so when we get here, there's nothing for us to do.
|
|
|
|
//
|
|
|
|
// Also, we're already in ~CycleCollectWithLogsChild (q.v.) at
|
|
|
|
// this point, so we shouldn't touch the actor in any case.
|
|
|
|
return true;
|
2012-10-16 06:12:14 +04:00
|
|
|
}
|
|
|
|
|
2017-01-27 01:40:17 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvInitContentBridgeChild(Endpoint<PContentBridgeChild>&& aEndpoint)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
2017-01-27 01:40:17 +03:00
|
|
|
ContentBridgeChild::Create(Move(aEndpoint));
|
|
|
|
return IPC_OK();
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
2017-01-05 23:55:57 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvInitGMPService(Endpoint<PGMPServiceChild>&& aGMPService)
|
2015-02-10 13:49:03 +03:00
|
|
|
{
|
2017-01-05 23:55:57 +03:00
|
|
|
if (!GMPServiceChild::Create(Move(aGMPService))) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2015-02-10 13:49:03 +03:00
|
|
|
}
|
|
|
|
|
2017-05-30 22:06:14 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvInitProfiler(Endpoint<PProfilerChild>&& aEndpoint)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
|
|
|
mProfilerController = ChildProfilerController::Create(Move(aEndpoint));
|
|
|
|
#endif
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-11-01 06:25:19 +03:00
|
|
|
ContentChild::RecvGMPsChanged(nsTArray<GMPCapabilityData>&& capabilities)
|
|
|
|
{
|
|
|
|
GeckoMediaPluginServiceChild::UpdateGMPCapabilities(Move(capabilities));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-11-01 06:25:19 +03:00
|
|
|
}
|
|
|
|
|
2017-01-05 23:54:52 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvInitProcessHangMonitor(Endpoint<PProcessHangMonitorChild>&& aHangMonitor)
|
|
|
|
{
|
|
|
|
CreateHangMonitorChild(Move(aHangMonitor));
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-06-14 18:39:59 +03:00
|
|
|
ContentChild::RecvInitRendering(Endpoint<PCompositorManagerChild>&& aCompositor,
|
2016-09-20 11:15:49 +03:00
|
|
|
Endpoint<PImageBridgeChild>&& aImageBridge,
|
2016-11-08 05:21:35 +03:00
|
|
|
Endpoint<PVRManagerChild>&& aVRBridge,
|
2017-04-14 11:06:09 +03:00
|
|
|
Endpoint<PVideoDecoderManagerChild>&& aVideoManager,
|
|
|
|
nsTArray<uint32_t>&& namespaces)
|
2012-07-18 03:59:45 +04:00
|
|
|
{
|
2017-06-14 18:39:59 +03:00
|
|
|
MOZ_ASSERT(namespaces.Length() == 3);
|
2017-04-14 11:06:09 +03:00
|
|
|
|
2017-06-14 18:39:59 +03:00
|
|
|
if (!CompositorManagerChild::Init(Move(aCompositor), namespaces[0])) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:15:49 +03:00
|
|
|
}
|
2017-06-14 18:39:59 +03:00
|
|
|
if (!CompositorManagerChild::CreateContentCompositorBridge(namespaces[1])) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
if (!ImageBridgeChild::InitForContent(Move(aImageBridge), namespaces[2])) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:15:49 +03:00
|
|
|
}
|
|
|
|
if (!gfx::VRManagerChild::InitForContent(Move(aVRBridge))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:15:49 +03:00
|
|
|
}
|
2016-11-08 05:21:35 +03:00
|
|
|
VideoDecoderManagerChild::InitForContent(Move(aVideoManager));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-21 10:14:59 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-06-14 18:39:59 +03:00
|
|
|
ContentChild::RecvReinitRendering(Endpoint<PCompositorManagerChild>&& aCompositor,
|
2016-09-20 11:18:50 +03:00
|
|
|
Endpoint<PImageBridgeChild>&& aImageBridge,
|
2016-11-08 05:21:35 +03:00
|
|
|
Endpoint<PVRManagerChild>&& aVRBridge,
|
2017-04-14 11:06:09 +03:00
|
|
|
Endpoint<PVideoDecoderManagerChild>&& aVideoManager,
|
|
|
|
nsTArray<uint32_t>&& namespaces)
|
2016-09-20 11:18:50 +03:00
|
|
|
{
|
2017-06-14 18:39:59 +03:00
|
|
|
MOZ_ASSERT(namespaces.Length() == 3);
|
2016-09-20 11:19:32 +03:00
|
|
|
nsTArray<RefPtr<TabChild>> tabs = TabChild::GetAll();
|
|
|
|
|
|
|
|
// Zap all the old layer managers we have lying around.
|
|
|
|
for (const auto& tabChild : tabs) {
|
|
|
|
if (tabChild->LayersId()) {
|
|
|
|
tabChild->InvalidateLayers();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Re-establish singleton bridges to the compositor.
|
2017-06-14 18:39:59 +03:00
|
|
|
if (!CompositorManagerChild::Init(Move(aCompositor), namespaces[0])) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
if (!CompositorManagerChild::CreateContentCompositorBridge(namespaces[1])) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:18:50 +03:00
|
|
|
}
|
2017-06-14 18:39:59 +03:00
|
|
|
if (!ImageBridgeChild::ReinitForContent(Move(aImageBridge), namespaces[2])) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:18:50 +03:00
|
|
|
}
|
|
|
|
if (!gfx::VRManagerChild::ReinitForContent(Move(aVRBridge))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-09-20 11:18:50 +03:00
|
|
|
}
|
2017-06-28 19:27:03 +03:00
|
|
|
gfxPlatform::GetPlatform()->CompositorUpdated();
|
2016-09-20 11:19:32 +03:00
|
|
|
|
|
|
|
// Establish new PLayerTransactions.
|
|
|
|
for (const auto& tabChild : tabs) {
|
|
|
|
if (tabChild->LayersId()) {
|
|
|
|
tabChild->ReinitRendering();
|
|
|
|
}
|
|
|
|
}
|
2016-11-08 05:21:35 +03:00
|
|
|
|
|
|
|
VideoDecoderManagerChild::InitForContent(Move(aVideoManager));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-09-20 11:18:50 +03:00
|
|
|
}
|
|
|
|
|
2017-07-18 05:42:59 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvAudioDefaultDeviceChange()
|
|
|
|
{
|
2017-07-25 07:34:14 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
audio::AudioNotificationReceiver::NotifyDefaultDeviceChanged();
|
|
|
|
#endif
|
2017-07-18 05:42:59 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-05-12 08:44:27 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvReinitRenderingForDeviceReset()
|
|
|
|
{
|
|
|
|
gfxPlatform::GetPlatform()->CompositorUpdated();
|
|
|
|
|
|
|
|
nsTArray<RefPtr<TabChild>> tabs = TabChild::GetAll();
|
|
|
|
for (const auto& tabChild : tabs) {
|
|
|
|
if (tabChild->LayersId()) {
|
|
|
|
tabChild->ReinitRenderingForDeviceReset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2014-11-10 19:59:43 +03:00
|
|
|
#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
|
2015-02-18 16:10:27 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2014-11-10 19:59:43 +03:00
|
|
|
static bool
|
2015-02-18 16:10:27 +03:00
|
|
|
GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath, nsCString &aAppDir)
|
2014-11-10 19:59:43 +03:00
|
|
|
{
|
|
|
|
nsAutoCString appPath;
|
|
|
|
nsAutoCString appBinaryPath(
|
|
|
|
(CommandLine::ForCurrentProcess()->argv()[0]).c_str());
|
|
|
|
|
|
|
|
nsAutoCString::const_iterator start, end;
|
|
|
|
appBinaryPath.BeginReading(start);
|
|
|
|
appBinaryPath.EndReading(end);
|
|
|
|
if (RFindInReadable(NS_LITERAL_CSTRING(".app/Contents/MacOS/"), start, end)) {
|
|
|
|
end = start;
|
|
|
|
++end; ++end; ++end; ++end;
|
|
|
|
appBinaryPath.BeginReading(start);
|
|
|
|
appPath.Assign(Substring(start, end));
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> app, appBinary;
|
|
|
|
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath),
|
|
|
|
true, getter_AddRefs(app));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath),
|
|
|
|
true, getter_AddRefs(appBinary));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:10:27 +03:00
|
|
|
nsCOMPtr<nsIFile> appDir;
|
|
|
|
nsCOMPtr<nsIProperties> dirSvc =
|
|
|
|
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
|
|
|
if (!dirSvc) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-07 21:53:19 +03:00
|
|
|
rv = dirSvc->Get(NS_GRE_DIR,
|
2015-02-18 16:10:27 +03:00
|
|
|
NS_GET_IID(nsIFile), getter_AddRefs(appDir));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool exists;
|
|
|
|
rv = appDir->Exists(&exists);
|
|
|
|
if (NS_FAILED(rv) || !exists) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-02 18:59:43 +03:00
|
|
|
// appDir points to .app/Contents/Resources, for our purposes we want
|
|
|
|
// .app/Contents.
|
|
|
|
nsCOMPtr<nsIFile> appDirParent;
|
|
|
|
rv = appDir->GetParent(getter_AddRefs(appDirParent));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-12 03:03:23 +03:00
|
|
|
rv = app->Normalize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
2014-11-10 19:59:43 +03:00
|
|
|
}
|
2017-07-12 03:03:23 +03:00
|
|
|
app->GetNativePath(aAppPath);
|
|
|
|
|
|
|
|
rv = appBinary->Normalize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
2014-11-10 19:59:43 +03:00
|
|
|
}
|
2017-07-12 03:03:23 +03:00
|
|
|
appBinary->GetNativePath(aAppBinaryPath);
|
|
|
|
|
|
|
|
rv = appDirParent->Normalize();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
2015-02-18 16:10:27 +03:00
|
|
|
}
|
2017-07-12 03:03:23 +03:00
|
|
|
appDirParent->GetNativePath(aAppDir);
|
2014-11-10 19:59:43 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-05-02 18:07:10 +03:00
|
|
|
// This function is only used in an |#ifdef DEBUG| path.
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Given a path to a file, return the directory which contains it.
|
|
|
|
static nsAutoCString
|
|
|
|
GetDirectoryPath(const char *aPath) {
|
|
|
|
nsCOMPtr<nsIFile> file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
|
|
|
if (!file ||
|
|
|
|
NS_FAILED(file->InitWithNativePath(nsDependentCString(aPath)))) {
|
|
|
|
MOZ_CRASH("Failed to create or init an nsIFile");
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIFile> directoryFile;
|
|
|
|
if (NS_FAILED(file->GetParent(getter_AddRefs(directoryFile))) ||
|
|
|
|
!directoryFile) {
|
|
|
|
MOZ_CRASH("Failed to get parent for an nsIFile");
|
|
|
|
}
|
|
|
|
directoryFile->Normalize();
|
|
|
|
nsAutoCString directoryPath;
|
|
|
|
if (NS_FAILED(directoryFile->GetNativePath(directoryPath))) {
|
|
|
|
MOZ_CRASH("Failed to get path for an nsIFile");
|
|
|
|
}
|
|
|
|
return directoryPath;
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2016-07-25 14:21:00 +03:00
|
|
|
static bool
|
2014-11-10 19:59:43 +03:00
|
|
|
StartMacOSContentSandbox()
|
|
|
|
{
|
2017-05-13 00:04:42 +03:00
|
|
|
int sandboxLevel = GetEffectiveContentSandboxLevel();
|
2016-07-25 14:21:00 +03:00
|
|
|
if (sandboxLevel < 1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:10:27 +03:00
|
|
|
nsAutoCString appPath, appBinaryPath, appDir;
|
|
|
|
if (!GetAppPaths(appPath, appBinaryPath, appDir)) {
|
2014-11-10 19:59:43 +03:00
|
|
|
MOZ_CRASH("Error resolving child process path");
|
|
|
|
}
|
|
|
|
|
2016-02-26 02:26:13 +03:00
|
|
|
// During sandboxed content process startup, before reaching
|
|
|
|
// this point, NS_OS_TEMP_DIR is modified to refer to a sandbox-
|
|
|
|
// writable temporary directory
|
|
|
|
nsCOMPtr<nsIFile> tempDir;
|
|
|
|
nsresult rv = nsDirectoryService::gService->Get(NS_OS_TEMP_DIR,
|
|
|
|
NS_GET_IID(nsIFile), getter_AddRefs(tempDir));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
MOZ_CRASH("Failed to get NS_OS_TEMP_DIR");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString tempDirPath;
|
2017-06-08 03:40:58 +03:00
|
|
|
tempDir->Normalize();
|
2016-02-26 02:26:13 +03:00
|
|
|
rv = tempDir->GetNativePath(tempDirPath);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
MOZ_CRASH("Failed to get NS_OS_TEMP_DIR path");
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:20:08 +03:00
|
|
|
ContentChild* cc = ContentChild::GetSingleton();
|
|
|
|
|
2016-08-30 23:32:21 +03:00
|
|
|
nsCOMPtr<nsIFile> profileDir;
|
2017-01-25 02:20:08 +03:00
|
|
|
cc->GetProfileDir(getter_AddRefs(profileDir));
|
2016-08-30 23:32:21 +03:00
|
|
|
nsCString profileDirPath;
|
|
|
|
if (profileDir) {
|
2017-01-25 07:06:35 +03:00
|
|
|
profileDir->Normalize();
|
2016-08-30 23:32:21 +03:00
|
|
|
rv = profileDir->GetNativePath(profileDirPath);
|
|
|
|
if (NS_FAILED(rv) || profileDirPath.IsEmpty()) {
|
|
|
|
MOZ_CRASH("Failed to get profile path");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 02:20:08 +03:00
|
|
|
bool isFileProcess = cc->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
|
|
|
|
|
2014-11-10 19:59:43 +03:00
|
|
|
MacSandboxInfo info;
|
|
|
|
info.type = MacSandboxType_Content;
|
2017-01-25 02:20:08 +03:00
|
|
|
info.level = sandboxLevel;
|
|
|
|
info.hasFilePrivileges = isFileProcess;
|
2017-01-23 23:46:49 +03:00
|
|
|
info.shouldLog = Preferences::GetBool("security.sandbox.logging.enabled") ||
|
|
|
|
PR_GetEnv("MOZ_SANDBOX_LOGGING");
|
2015-04-03 19:51:41 +03:00
|
|
|
info.appPath.assign(appPath.get());
|
|
|
|
info.appBinaryPath.assign(appBinaryPath.get());
|
2017-06-21 17:19:28 +03:00
|
|
|
info.appDir.assign(appDir.get());
|
2016-02-26 02:26:13 +03:00
|
|
|
info.appTempDir.assign(tempDirPath.get());
|
2014-11-10 19:59:43 +03:00
|
|
|
|
2017-06-21 17:19:28 +03:00
|
|
|
// These paths are used to whitelist certain directories used by the testing
|
|
|
|
// system. They should not be considered a public API, and are only intended
|
|
|
|
// for use in automation.
|
2017-07-31 07:28:48 +03:00
|
|
|
nsAutoCString testingReadPath1;
|
|
|
|
Preferences::GetCString("security.sandbox.content.mac.testing_read_path1",
|
|
|
|
testingReadPath1);
|
2017-06-21 17:19:28 +03:00
|
|
|
if (!testingReadPath1.IsEmpty()) {
|
|
|
|
info.testingReadPath1.assign(testingReadPath1.get());
|
|
|
|
}
|
2017-07-31 07:28:48 +03:00
|
|
|
nsAutoCString testingReadPath2;
|
|
|
|
Preferences::GetCString("security.sandbox.content.mac.testing_read_path2",
|
|
|
|
testingReadPath2);
|
2017-06-21 17:19:28 +03:00
|
|
|
if (!testingReadPath2.IsEmpty()) {
|
|
|
|
info.testingReadPath2.assign(testingReadPath2.get());
|
|
|
|
}
|
2017-07-15 02:32:53 +03:00
|
|
|
|
2017-07-19 19:16:09 +03:00
|
|
|
if (mozilla::IsDevelopmentBuild()) {
|
|
|
|
nsCOMPtr<nsIFile> repoDir;
|
|
|
|
rv = mozilla::GetRepoDir(getter_AddRefs(repoDir));
|
2017-07-15 02:32:53 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2017-07-19 19:16:09 +03:00
|
|
|
MOZ_CRASH("Failed to get path to repo dir");
|
2017-07-15 02:32:53 +03:00
|
|
|
}
|
2017-07-19 19:16:09 +03:00
|
|
|
nsCString repoDirPath;
|
|
|
|
Unused << repoDir->GetNativePath(repoDirPath);
|
2017-07-15 02:32:53 +03:00
|
|
|
info.testingReadPath3.assign(repoDirPath.get());
|
|
|
|
|
2017-07-19 19:16:09 +03:00
|
|
|
nsCOMPtr<nsIFile> objDir;
|
|
|
|
rv = mozilla::GetObjDir(getter_AddRefs(objDir));
|
2017-07-15 02:32:53 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
2017-07-19 19:16:09 +03:00
|
|
|
MOZ_CRASH("Failed to get path to build object dir");
|
2017-07-15 02:32:53 +03:00
|
|
|
}
|
2017-07-19 19:16:09 +03:00
|
|
|
|
|
|
|
nsCString objDirPath;
|
|
|
|
Unused << objDir->GetNativePath(objDirPath);
|
2017-07-15 02:32:53 +03:00
|
|
|
info.testingReadPath4.assign(objDirPath.get());
|
2017-06-21 17:19:28 +03:00
|
|
|
}
|
|
|
|
|
2016-08-30 23:32:21 +03:00
|
|
|
if (profileDir) {
|
|
|
|
info.hasSandboxedProfile = true;
|
|
|
|
info.profileDir.assign(profileDirPath.get());
|
|
|
|
} else {
|
|
|
|
info.hasSandboxedProfile = false;
|
|
|
|
}
|
|
|
|
|
2017-05-02 18:07:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// When a content process dies intentionally (|NoteIntentionalCrash|), for
|
|
|
|
// tests it wants to log that it did this. Allow writing to this location
|
|
|
|
// that the testrunner wants.
|
|
|
|
char *bloatLog = PR_GetEnv("XPCOM_MEM_BLOAT_LOG");
|
|
|
|
if (bloatLog != nullptr) {
|
|
|
|
// |bloatLog| points to a specific file, but we actually write to a sibling
|
|
|
|
// of that path.
|
|
|
|
nsAutoCString bloatDirectoryPath = GetDirectoryPath(bloatLog);
|
|
|
|
info.debugWriteDir.assign(bloatDirectoryPath.get());
|
|
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2015-04-03 19:51:41 +03:00
|
|
|
std::string err;
|
2014-11-10 19:59:43 +03:00
|
|
|
if (!mozilla::StartMacSandbox(info, err)) {
|
2015-04-03 19:51:41 +03:00
|
|
|
NS_WARNING(err.c_str());
|
2014-11-10 19:59:43 +03:00
|
|
|
MOZ_CRASH("sandbox_init() failed");
|
|
|
|
}
|
2016-07-25 14:21:00 +03:00
|
|
|
|
|
|
|
return true;
|
2014-11-10 19:59:43 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-10-08 08:13:09 +03:00
|
|
|
ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker)
|
2013-01-18 00:06:36 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// We may want to move the sandbox initialization somewhere else
|
|
|
|
// at some point; see bug 880808.
|
2014-03-13 02:48:15 +04:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX)
|
2016-07-25 14:21:00 +03:00
|
|
|
bool sandboxEnabled = true;
|
2014-03-13 02:48:15 +04:00
|
|
|
#if defined(XP_LINUX)
|
2016-01-05 12:59:30 +03:00
|
|
|
// Otherwise, sandboxing is best-effort.
|
|
|
|
if (!SandboxInfo::Get().CanSandboxContent()) {
|
2016-07-25 14:21:00 +03:00
|
|
|
sandboxEnabled = false;
|
|
|
|
} else {
|
|
|
|
// This triggers the initialization of cubeb, which needs to happen
|
|
|
|
// before seccomp is enabled (Bug 1259508). It also increases the startup
|
|
|
|
// time of the content process, because cubeb is usually initialized
|
|
|
|
// when it is actually needed. This call here is no longer required
|
|
|
|
// once Bug 1104619 (remoting audio) is resolved.
|
|
|
|
Unused << CubebUtils::GetCubebContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sandboxEnabled) {
|
|
|
|
int brokerFd = -1;
|
|
|
|
if (aBroker.type() == MaybeFileDesc::TFileDescriptor) {
|
2016-05-27 11:12:51 +03:00
|
|
|
auto fd = aBroker.get_FileDescriptor().ClonePlatformHandle();
|
|
|
|
brokerFd = fd.release();
|
2016-01-05 12:59:30 +03:00
|
|
|
// brokerFd < 0 means to allow direct filesystem access, so
|
|
|
|
// make absolutely sure that doesn't happen if the parent
|
|
|
|
// didn't intend it.
|
|
|
|
MOZ_RELEASE_ASSERT(brokerFd >= 0);
|
2016-07-25 14:21:00 +03:00
|
|
|
}
|
2017-01-26 21:59:50 +03:00
|
|
|
// Allow user overrides of seccomp-bpf syscall filtering
|
|
|
|
std::vector<int> syscallWhitelist;
|
2017-07-31 07:28:48 +03:00
|
|
|
nsAutoCString extraSyscalls;
|
|
|
|
nsresult rv =
|
|
|
|
Preferences::GetCString("security.sandbox.content.syscall_whitelist",
|
|
|
|
extraSyscalls);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2017-06-20 12:19:52 +03:00
|
|
|
for (const nsACString& callNrString : extraSyscalls.Split(',')) {
|
2017-01-26 21:59:50 +03:00
|
|
|
int callNr = PromiseFlatCString(callNrString).ToInteger(&rv);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
syscallWhitelist.push_back(callNr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-24 17:32:22 +03:00
|
|
|
ContentChild* cc = ContentChild::GetSingleton();
|
|
|
|
bool isFileProcess = cc->GetRemoteType().EqualsLiteral(FILE_REMOTE_TYPE);
|
|
|
|
sandboxEnabled = SetContentProcessSandbox(brokerFd, isFileProcess,
|
|
|
|
syscallWhitelist);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2014-03-13 02:48:15 +04:00
|
|
|
#elif defined(XP_WIN)
|
2016-01-05 12:59:30 +03:00
|
|
|
mozilla::SandboxTarget::Instance()->StartSandbox();
|
2014-11-10 19:59:43 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
2016-07-25 14:21:00 +03:00
|
|
|
sandboxEnabled = StartMacOSContentSandbox();
|
2013-08-12 23:58:35 +04:00
|
|
|
#endif
|
2016-07-25 14:21:00 +03:00
|
|
|
|
|
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("ContentSandboxEnabled"),
|
|
|
|
sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0"));
|
|
|
|
#if defined(XP_LINUX) && !defined(OS_ANDROID)
|
2016-10-27 01:57:10 +03:00
|
|
|
nsAutoCString flagsString;
|
|
|
|
flagsString.AppendInt(SandboxInfo::Get().AsInteger());
|
|
|
|
|
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString);
|
2016-07-25 14:21:00 +03:00
|
|
|
#endif /* XP_LINUX && !OS_ANDROID */
|
2017-06-01 12:16:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"),
|
|
|
|
NS_ConvertUTF16toUTF8(GetRemoteType()));
|
2016-07-25 14:21:00 +03:00
|
|
|
#endif /* MOZ_CRASHREPORTER */
|
|
|
|
#endif /* MOZ_CONTENT_SANDBOX */
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-01-18 00:06:36 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-06-03 12:56:04 +03:00
|
|
|
ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
|
|
|
|
const bool& aHaveBidiKeyboards)
|
2015-04-11 01:18:05 +03:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// bidi is always of type PuppetBidiKeyboard* (because in the child, the only
|
|
|
|
// possible implementation of nsIBidiKeyboard is PuppetBidiKeyboard).
|
|
|
|
PuppetBidiKeyboard* bidi = static_cast<PuppetBidiKeyboard*>(nsContentUtils::GetBidiKeyboard());
|
|
|
|
if (bidi) {
|
2016-06-03 12:56:04 +03:00
|
|
|
bidi->SetBidiKeyboardInfo(aIsLangRTL, aHaveBidiKeyboards);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-11 01:18:05 +03:00
|
|
|
}
|
|
|
|
|
2017-02-01 15:34:24 +03:00
|
|
|
static StaticRefPtr<CancelableRunnable> gFirstIdleTask;
|
|
|
|
|
|
|
|
static void
|
|
|
|
FirstIdle(void)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(gFirstIdleTask);
|
|
|
|
gFirstIdleTask = nullptr;
|
|
|
|
ContentChild::GetSingleton()->SendFirstIdle();
|
|
|
|
}
|
2012-10-09 08:46:19 +04:00
|
|
|
|
2013-07-03 11:24:32 +04:00
|
|
|
mozilla::jsipc::PJavaScriptChild *
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPJavaScriptChild()
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT(ManagedPJavaScriptChild().IsEmpty());
|
2014-05-09 02:43:53 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
return nsIContentChild::AllocPJavaScriptChild();
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-06-11 09:44:06 +04:00
|
|
|
ContentChild::DeallocPJavaScriptChild(PJavaScriptChild *aChild)
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return nsIContentChild::DeallocPJavaScriptChild(aChild);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
PBrowserChild*
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentChild::AllocPBrowserChild(const TabId& aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
const TabId& aSameTabGroupAs,
|
2014-10-29 21:11:00 +03:00
|
|
|
const IPCTabContext& aContext,
|
2014-06-04 01:15:27 +04:00
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-04 01:15:27 +04:00
|
|
|
const bool& aIsForBrowser)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return nsIContentChild::AllocPBrowserChild(aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
aSameTabGroupAs,
|
2016-01-05 12:59:30 +03:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aCpID,
|
|
|
|
aIsForBrowser);
|
2014-06-11 09:44:06 +04:00
|
|
|
}
|
2013-02-23 08:24:28 +04:00
|
|
|
|
2014-06-11 09:44:06 +04:00
|
|
|
bool
|
|
|
|
ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
const TabId& aSameTabGroupAs,
|
2014-06-11 09:44:06 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-11 09:44:06 +04:00
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
2017-01-17 05:33:48 +03:00
|
|
|
if (IsShuttingDown()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
return PContentChild::SendPBrowserConstructor(aActor,
|
|
|
|
aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
aSameTabGroupAs,
|
2016-01-05 12:59:30 +03:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aCpID,
|
|
|
|
aIsForBrowser);
|
2013-02-23 08:24:28 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-06-04 01:15:27 +04:00
|
|
|
ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2017-04-07 02:46:18 +03:00
|
|
|
const TabId& aSameTabGroupAs,
|
2014-06-04 01:15:27 +04:00
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const uint32_t& aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
const ContentParentId& aCpID,
|
2014-06-04 01:15:27 +04:00
|
|
|
const bool& aIsForBrowser)
|
2013-02-23 08:24:28 +04:00
|
|
|
{
|
2017-01-17 05:33:48 +03:00
|
|
|
MOZ_ASSERT(!IsShuttingDown());
|
|
|
|
|
2017-02-01 15:34:24 +03:00
|
|
|
static bool hasRunOnce = false;
|
|
|
|
if (!hasRunOnce) {
|
|
|
|
hasRunOnce = true;
|
|
|
|
MOZ_ASSERT(!gFirstIdleTask);
|
|
|
|
RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
|
|
|
|
gFirstIdleTask = firstIdleTask;
|
|
|
|
NS_IdleDispatchToCurrentThread(firstIdleTask.forget());
|
|
|
|
}
|
|
|
|
|
2017-04-07 02:46:18 +03:00
|
|
|
return nsIContentChild::RecvPBrowserConstructor(aActor,
|
|
|
|
aTabId,
|
|
|
|
aSameTabGroupAs,
|
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
|
|
|
aCpID,
|
|
|
|
aIsForBrowser);
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2014-10-03 18:52:37 +04:00
|
|
|
void
|
|
|
|
ContentChild::GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
aDictionaries = mAvailableDictionaries;
|
2014-10-03 18:52:37 +04:00
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:26 +03:00
|
|
|
PFileDescriptorSetChild*
|
|
|
|
ContentChild::SendPFileDescriptorSetConstructor(const FileDescriptor& aFD)
|
|
|
|
{
|
2017-01-17 05:33:48 +03:00
|
|
|
if (IsShuttingDown()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-09-21 13:27:26 +03:00
|
|
|
return PContentChild::SendPFileDescriptorSetConstructor(aFD);
|
|
|
|
}
|
|
|
|
|
2014-03-25 22:37:13 +04:00
|
|
|
PFileDescriptorSetChild*
|
|
|
|
ContentChild::AllocPFileDescriptorSetChild(const FileDescriptor& aFD)
|
|
|
|
{
|
2016-09-21 13:27:26 +03:00
|
|
|
return nsIContentChild::AllocPFileDescriptorSetChild(aFD);
|
2014-03-25 22:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPFileDescriptorSetChild(PFileDescriptorSetChild* aActor)
|
|
|
|
{
|
2016-09-21 13:27:26 +03:00
|
|
|
return nsIContentChild::DeallocPFileDescriptorSetChild(aActor);
|
2014-03-25 22:37:13 +04:00
|
|
|
}
|
2013-02-23 08:24:28 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2014-06-11 09:44:06 +04:00
|
|
|
ContentChild::DeallocPBrowserChild(PBrowserChild* aIframe)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return nsIContentChild::DeallocPBrowserChild(aIframe);
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
Bug 1353629 - PBlob refactoring - part 4 - IPCBlobInputStream, r=smaug
IPCBlobInputStream is a new type of nsIInputStream that is used only in content
process when a Blob is sent from parent to child. This inputStream is for now,
just cloneable.
When the parent process sends a Blob to a content process, it has the Blob and
its inputStream. With its inputStream it creates a IPCBlobInputStreamParent
actor. This actor keeps the inputStream alive for following uses (not part of
this patch).
On the child side we will have, of course, a IPCBlobInputStreamChild actor.
This actor is able to create a IPCBlobInputStream when CreateStream() is
called. This means that 1 IPCBlobInputStreamChild can manage multiple
IPCBlobInputStreams each time one of them is cloned. When the last one of this
stream is released, the child actor sends a __delete__ request to the parent
side; the parent will be deleted, and the original inputStream, on the parent
side, will be released as well.
IPCBlobInputStream is a special inputStream because each method, except for
Available() fails. Basically, this inputStream cannot be used on the content
process for nothing else than knowing the size of the original stream.
In the following patches, I'll introduce an async way to use it.
2017-04-24 13:09:40 +03:00
|
|
|
PIPCBlobInputStreamChild*
|
|
|
|
ContentChild::AllocPIPCBlobInputStreamChild(const nsID& aID,
|
|
|
|
const uint64_t& aSize)
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPIPCBlobInputStreamChild(aID, aSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPIPCBlobInputStreamChild(PIPCBlobInputStreamChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPIPCBlobInputStreamChild(aActor);
|
|
|
|
}
|
|
|
|
|
2014-07-02 02:24:27 +04:00
|
|
|
mozilla::PRemoteSpellcheckEngineChild *
|
|
|
|
ContentChild::AllocPRemoteSpellcheckEngineChild()
|
|
|
|
{
|
2016-01-08 23:40:26 +03:00
|
|
|
MOZ_CRASH("Default Constructor for PRemoteSpellcheckEngineChild should never be called");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2014-07-02 02:24:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPRemoteSpellcheckEngineChild(PRemoteSpellcheckEngineChild *child)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete child;
|
|
|
|
return true;
|
2014-07-02 02:24:27 +04:00
|
|
|
}
|
|
|
|
|
2015-03-26 06:16:21 +03:00
|
|
|
PPresentationChild*
|
|
|
|
ContentChild::AllocPPresentationChild()
|
|
|
|
{
|
2016-01-08 23:40:26 +03:00
|
|
|
MOZ_CRASH("We should never be manually allocating PPresentationChild actors");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2015-03-26 06:16:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPPresentationChild(PPresentationChild* aActor)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete aActor;
|
|
|
|
return true;
|
2015-03-26 06:16:21 +03:00
|
|
|
}
|
|
|
|
|
2016-06-07 12:46:03 +03:00
|
|
|
PFlyWebPublishedServerChild*
|
|
|
|
ContentChild::AllocPFlyWebPublishedServerChild(const nsString& name,
|
|
|
|
const FlyWebPublishOptions& params)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("We should never be manually allocating PFlyWebPublishedServerChild actors");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPFlyWebPublishedServerChild(PFlyWebPublishedServerChild* aActor)
|
|
|
|
{
|
|
|
|
RefPtr<FlyWebPublishedServerChild> actor =
|
|
|
|
dont_AddRef(static_cast<FlyWebPublishedServerChild*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-03-26 06:16:21 +03:00
|
|
|
ContentChild::RecvNotifyPresentationReceiverLaunched(PBrowserChild* aIframe,
|
|
|
|
const nsString& aSessionId)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell =
|
|
|
|
do_GetInterface(static_cast<TabChild*>(aIframe)->WebNavigation());
|
2016-09-02 10:12:24 +03:00
|
|
|
NS_WARNING_ASSERTION(docShell, "WebNavigation failed");
|
2015-03-30 10:46:11 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIPresentationService> service =
|
|
|
|
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
|
2016-09-02 10:12:24 +03:00
|
|
|
NS_WARNING_ASSERTION(service, "presentation service is missing");
|
2015-03-30 10:46:11 +03:00
|
|
|
|
2016-09-02 10:12:24 +03:00
|
|
|
Unused << NS_WARN_IF(NS_FAILED(static_cast<PresentationIPCService*>(service.get())->MonitorResponderLoading(aSessionId, docShell)));
|
2015-03-26 06:16:21 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-26 06:16:21 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-08-31 08:24:35 +03:00
|
|
|
ContentChild::RecvNotifyPresentationReceiverCleanUp(const nsString& aSessionId)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresentationService> service =
|
2016-01-05 12:59:30 +03:00
|
|
|
do_GetService(PRESENTATION_SERVICE_CONTRACTID);
|
2016-09-02 10:12:24 +03:00
|
|
|
NS_WARNING_ASSERTION(service, "presentation service is missing");
|
2015-08-31 08:24:35 +03:00
|
|
|
|
2016-09-02 10:12:24 +03:00
|
|
|
Unused << NS_WARN_IF(NS_FAILED(service->UntrackSessionInfo(aSessionId, nsIPresentationService::ROLE_RECEIVER)));
|
2015-08-31 08:24:35 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-08-31 08:24:35 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-08-08 06:04:55 +03:00
|
|
|
ContentChild::RecvNotifyEmptyHTTPCache()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
obs->NotifyObservers(nullptr, "cacheservice:empty-cache", nullptr);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-08-08 06:04:55 +03:00
|
|
|
}
|
|
|
|
|
2011-10-06 02:15:45 +04:00
|
|
|
PHalChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPHalChild()
|
2011-10-06 02:15:45 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return CreateHalChild();
|
2011-10-06 02:15:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::DeallocPHalChild(PHalChild* aHal)
|
2011-10-06 02:15:45 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete aHal;
|
|
|
|
return true;
|
2011-10-06 02:15:45 +04:00
|
|
|
}
|
|
|
|
|
2015-09-22 22:09:42 +03:00
|
|
|
devtools::PHeapSnapshotTempFileHelperChild*
|
|
|
|
ContentChild::AllocPHeapSnapshotTempFileHelperChild()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return devtools::HeapSnapshotTempFileHelperChild::Create();
|
2015-09-22 22:09:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPHeapSnapshotTempFileHelperChild(
|
2016-01-05 12:59:30 +03:00
|
|
|
devtools::PHeapSnapshotTempFileHelperChild* aHeapSnapshotHelper)
|
2015-09-22 22:09:42 +03:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete aHeapSnapshotHelper;
|
|
|
|
return true;
|
2015-09-22 22:09:42 +03:00
|
|
|
}
|
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
PTestShellChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPTestShellChild()
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return new TestShellChild();
|
2009-08-12 22:31:48 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::DeallocPTestShellChild(PTestShellChild* shell)
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete shell;
|
|
|
|
return true;
|
2009-08-26 03:07:22 +04:00
|
|
|
}
|
|
|
|
|
2015-01-27 00:32:18 +03:00
|
|
|
jsipc::CPOWManager*
|
2013-07-03 11:24:32 +04:00
|
|
|
ContentChild::GetCPOWManager()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (PJavaScriptChild* c = LoneManagedOrNullAsserts(ManagedPJavaScriptChild())) {
|
|
|
|
return CPOWManagerFor(c);
|
|
|
|
}
|
|
|
|
return CPOWManagerFor(SendPJavaScriptConstructor());
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild::RecvPTestShellConstructor(PTestShellChild* actor)
|
2009-11-06 23:43:39 +03:00
|
|
|
{
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2009-11-06 23:43:39 +03:00
|
|
|
}
|
|
|
|
|
2017-05-03 03:17:52 +03:00
|
|
|
PScriptCacheChild*
|
|
|
|
ContentChild::AllocPScriptCacheChild(const FileDescOrError& cacheFile, const bool& wantCacheData)
|
|
|
|
{
|
|
|
|
return new loader::ScriptCacheChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPScriptCacheChild(PScriptCacheChild* cache)
|
|
|
|
{
|
|
|
|
delete static_cast<loader::ScriptCacheChild*>(cache);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvPScriptCacheConstructor(PScriptCacheChild* actor, const FileDescOrError& cacheFile, const bool& wantCacheData)
|
|
|
|
{
|
|
|
|
Maybe<FileDescriptor> fd;
|
|
|
|
if (cacheFile.type() == cacheFile.TFileDescriptor) {
|
|
|
|
fd.emplace(cacheFile.get_FileDescriptor());
|
|
|
|
}
|
|
|
|
|
|
|
|
static_cast<loader::ScriptCacheChild*>(actor)->Init(fd, wantCacheData);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
PNeckoChild*
|
|
|
|
ContentChild::AllocPNeckoChild()
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return new NeckoChild();
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool
|
|
|
|
ContentChild::DeallocPNeckoChild(PNeckoChild* necko)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
delete necko;
|
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2014-10-28 18:59:08 +03:00
|
|
|
PPrintingChild*
|
|
|
|
ContentChild::AllocPPrintingChild()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// The ContentParent should never attempt to allocate the nsPrintingProxy,
|
|
|
|
// which implements PPrintingChild. Instead, the nsPrintingProxy service is
|
|
|
|
// requested and instantiated via XPCOM, and the constructor of
|
|
|
|
// nsPrintingProxy sets up the IPC connection.
|
2016-01-08 23:40:26 +03:00
|
|
|
MOZ_CRASH("Should never get here!");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2014-10-28 18:59:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPPrintingChild(PPrintingChild* printing)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
return true;
|
2014-10-28 18:59:08 +03:00
|
|
|
}
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
PChildToParentStreamChild*
|
|
|
|
ContentChild::SendPChildToParentStreamConstructor(PChildToParentStreamChild* aActor)
|
2016-09-21 13:27:26 +03:00
|
|
|
{
|
2017-01-17 05:33:48 +03:00
|
|
|
if (IsShuttingDown()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
return PContentChild::SendPChildToParentStreamConstructor(aActor);
|
2016-09-21 13:27:26 +03:00
|
|
|
}
|
|
|
|
|
2017-03-14 14:28:58 +03:00
|
|
|
PChildToParentStreamChild*
|
|
|
|
ContentChild::AllocPChildToParentStreamChild()
|
2016-05-15 20:32:09 +03:00
|
|
|
{
|
2017-03-14 14:28:58 +03:00
|
|
|
return nsIContentChild::AllocPChildToParentStreamChild();
|
2016-05-15 20:32:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-03-14 14:28:58 +03:00
|
|
|
ContentChild::DeallocPChildToParentStreamChild(PChildToParentStreamChild* aActor)
|
2016-05-15 20:32:09 +03:00
|
|
|
{
|
2017-03-14 14:28:58 +03:00
|
|
|
return nsIContentChild::DeallocPChildToParentStreamChild(aActor);
|
2016-05-15 20:32:09 +03:00
|
|
|
}
|
|
|
|
|
2017-03-14 14:29:43 +03:00
|
|
|
PParentToChildStreamChild*
|
|
|
|
ContentChild::AllocPParentToChildStreamChild()
|
|
|
|
{
|
|
|
|
return nsIContentChild::AllocPParentToChildStreamChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPParentToChildStreamChild(PParentToChildStreamChild* aActor)
|
|
|
|
{
|
|
|
|
return nsIContentChild::DeallocPParentToChildStreamChild(aActor);
|
|
|
|
}
|
|
|
|
|
2015-04-22 22:55:23 +03:00
|
|
|
PPSMContentDownloaderChild*
|
|
|
|
ContentChild::AllocPPSMContentDownloaderChild(const uint32_t& aCertType)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// NB: We don't need aCertType in the child actor.
|
|
|
|
RefPtr<PSMContentDownloaderChild> child = new PSMContentDownloaderChild();
|
|
|
|
return child.forget().take();
|
2015-04-22 22:55:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPPSMContentDownloaderChild(PPSMContentDownloaderChild* aListener)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
auto* listener = static_cast<PSMContentDownloaderChild*>(aListener);
|
|
|
|
RefPtr<PSMContentDownloaderChild> child = dont_AddRef(listener);
|
|
|
|
return true;
|
2015-04-22 22:55:23 +03:00
|
|
|
}
|
|
|
|
|
2010-09-16 02:55:08 +04:00
|
|
|
PExternalHelperAppChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPExternalHelperAppChild(const OptionalURIParams& uri,
|
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
2014-02-14 02:43:58 +04:00
|
|
|
const uint32_t& aContentDispositionHint,
|
|
|
|
const nsString& aContentDispositionFilename,
|
2013-07-08 19:48:39 +04:00
|
|
|
const bool& aForceSave,
|
|
|
|
const int64_t& aContentLength,
|
2017-01-11 04:49:16 +03:00
|
|
|
const bool& aWasFileChannel,
|
2013-09-12 23:24:10 +04:00
|
|
|
const OptionalURIParams& aReferrer,
|
|
|
|
PBrowserChild* aBrowser)
|
2010-09-16 02:55:08 +04:00
|
|
|
{
|
2016-11-14 12:35:58 +03:00
|
|
|
auto *child = new ExternalHelperAppChild();
|
2016-01-05 12:59:30 +03:00
|
|
|
child->AddRef();
|
|
|
|
return child;
|
2010-09-16 02:55:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::DeallocPExternalHelperAppChild(PExternalHelperAppChild* aService)
|
2010-09-16 02:55:08 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
|
|
|
|
child->Release();
|
|
|
|
return true;
|
2010-09-16 02:55:08 +04:00
|
|
|
}
|
|
|
|
|
2015-08-26 02:42:21 +03:00
|
|
|
PHandlerServiceChild*
|
|
|
|
ContentChild::AllocPHandlerServiceChild()
|
|
|
|
{
|
2016-11-14 12:35:58 +03:00
|
|
|
auto* actor = new HandlerServiceChild();
|
2016-01-05 12:59:30 +03:00
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
2015-08-26 02:42:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ContentChild::DeallocPHandlerServiceChild(PHandlerServiceChild* aHandlerServiceChild)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
static_cast<HandlerServiceChild*>(aHandlerServiceChild)->Release();
|
|
|
|
return true;
|
2015-08-26 02:42:21 +03:00
|
|
|
}
|
|
|
|
|
2015-06-18 18:46:36 +03:00
|
|
|
media::PMediaChild*
|
|
|
|
ContentChild::AllocPMediaChild()
|
|
|
|
{
|
|
|
|
return media::AllocPMediaChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPMediaChild(media::PMediaChild *aActor)
|
|
|
|
{
|
|
|
|
return media::DeallocPMediaChild(aActor);
|
|
|
|
}
|
|
|
|
|
2010-11-19 04:15:23 +03:00
|
|
|
PStorageChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPStorageChild()
|
2010-11-19 04:15:23 +03:00
|
|
|
{
|
2016-01-08 23:40:26 +03:00
|
|
|
MOZ_CRASH("We should never be manually allocating PStorageChild actors");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2010-11-19 04:15:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::DeallocPStorageChild(PStorageChild* aActor)
|
2010-11-19 04:15:23 +03:00
|
|
|
{
|
2017-01-04 16:53:01 +03:00
|
|
|
StorageDBChild* child = static_cast<StorageDBChild*>(aActor);
|
2016-01-05 12:59:30 +03:00
|
|
|
child->ReleaseIPDLReference();
|
|
|
|
return true;
|
2010-11-19 04:15:23 +03:00
|
|
|
}
|
|
|
|
|
2013-04-04 02:13:17 +04:00
|
|
|
PSpeechSynthesisChild*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::AllocPSpeechSynthesisChild()
|
2013-04-04 02:13:17 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_CRASH("No one should be allocating PSpeechSynthesisChild actors");
|
2013-04-04 02:13:17 +04:00
|
|
|
#else
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2013-04-04 02:13:17 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentChild::DeallocPSpeechSynthesisChild(PSpeechSynthesisChild* aActor)
|
2013-04-04 02:13:17 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
2016-01-05 12:59:30 +03:00
|
|
|
delete aActor;
|
|
|
|
return true;
|
2013-04-04 02:13:17 +04:00
|
|
|
#else
|
2016-01-05 12:59:30 +03:00
|
|
|
return false;
|
2013-04-04 02:13:17 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-22 01:29:18 +03:00
|
|
|
PWebrtcGlobalChild *
|
|
|
|
ContentChild::AllocPWebrtcGlobalChild()
|
|
|
|
{
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2016-11-14 12:35:58 +03:00
|
|
|
auto *child = new WebrtcGlobalChild();
|
2016-01-05 12:59:30 +03:00
|
|
|
return child;
|
2015-05-06 19:29:33 +03:00
|
|
|
#else
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2015-05-06 19:29:33 +03:00
|
|
|
#endif
|
2015-04-22 01:29:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPWebrtcGlobalChild(PWebrtcGlobalChild *aActor)
|
|
|
|
{
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2016-01-05 12:59:30 +03:00
|
|
|
delete static_cast<WebrtcGlobalChild*>(aActor);
|
|
|
|
return true;
|
2015-05-06 19:29:33 +03:00
|
|
|
#else
|
2016-01-05 12:59:30 +03:00
|
|
|
return false;
|
2015-05-06 19:29:33 +03:00
|
|
|
#endif
|
2015-04-22 01:29:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-01-16 22:58:52 +03:00
|
|
|
ContentChild::RecvRegisterChrome(InfallibleTArray<ChromePackage>&& packages,
|
2015-07-17 01:50:07 +03:00
|
|
|
InfallibleTArray<SubstitutionMapping>&& resources,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<OverrideMapping>&& overrides,
|
2014-07-26 00:17:36 +04:00
|
|
|
const nsCString& locale,
|
|
|
|
const bool& reset)
|
2010-03-11 08:33:00 +03:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
|
|
|
chromeRegistry->RegisterRemoteChrome(packages, resources, overrides,
|
|
|
|
locale, reset);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-07-26 00:17:36 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-07-26 00:17:36 +04:00
|
|
|
ContentChild::RecvRegisterChromeItem(const ChromeRegistryItem& item)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
|
|
|
switch (item.type()) {
|
|
|
|
case ChromeRegistryItem::TChromePackage:
|
|
|
|
chromeRegistry->RegisterPackage(item.get_ChromePackage());
|
|
|
|
break;
|
2014-07-26 00:17:36 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
case ChromeRegistryItem::TOverrideMapping:
|
|
|
|
chromeRegistry->RegisterOverride(item.get_OverrideMapping());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ChromeRegistryItem::TSubstitutionMapping:
|
|
|
|
chromeRegistry->RegisterSubstitution(item.get_SubstitutionMapping());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "bad chrome item");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-03-11 08:33:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-06-07 01:23:43 +03:00
|
|
|
ContentChild::RecvClearImageCache(const bool& privateLoader, const bool& chrome)
|
|
|
|
{
|
|
|
|
imgLoader* loader = privateLoader ? imgLoader::PrivateBrowsingLoader() :
|
|
|
|
imgLoader::NormalLoader();
|
|
|
|
|
|
|
|
loader->ClearCache(chrome);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-06-07 01:23:43 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2011-09-29 10:19:26 +04:00
|
|
|
ContentChild::RecvSetOffline(const bool& offline)
|
2010-05-11 16:44:12 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIIOService> io (do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "IO Service can not be null");
|
2010-05-11 16:44:12 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
io->SetOffline(offline);
|
2011-02-15 01:34:46 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-05-11 16:44:12 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-05-02 00:14:39 +03:00
|
|
|
ContentChild::RecvSetConnectivity(const bool& connectivity)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIIOService> io(do_GetIOService());
|
|
|
|
nsCOMPtr<nsIIOServiceInternal> ioInternal(do_QueryInterface(io));
|
|
|
|
NS_ASSERTION(ioInternal, "IO Service can not be null");
|
2015-05-02 00:14:39 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
ioInternal->SetConnectivity(connectivity);
|
2015-05-02 00:14:39 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-02 00:14:39 +03:00
|
|
|
}
|
|
|
|
|
2016-11-17 19:35:24 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvSetCaptivePortalState(const int32_t& aState)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsICaptivePortalService> cps = do_GetService(NS_CAPTIVEPORTAL_CID);
|
|
|
|
if (!cps) {
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::net::CaptivePortalService *portal =
|
|
|
|
static_cast<mozilla::net::CaptivePortalService*>(cps.get());
|
|
|
|
portal->SetStateInChild(aState);
|
|
|
|
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2009-12-07 09:03:49 +03:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentChild::ActorDestroy(ActorDestroyReason why)
|
2009-09-03 04:18:27 +04:00
|
|
|
{
|
2016-06-02 15:52:17 +03:00
|
|
|
if (mForceKillTimer) {
|
|
|
|
mForceKillTimer->Cancel();
|
|
|
|
mForceKillTimer = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (AbnormalShutdown == why) {
|
|
|
|
NS_WARNING("shutting down early because of crash!");
|
2016-04-11 11:12:33 +03:00
|
|
|
ProcessChild::QuickExit();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2010-08-21 03:24:40 +04:00
|
|
|
|
2015-07-31 22:11:48 +03:00
|
|
|
#ifndef NS_FREE_PERMANENT_DATA
|
2016-01-05 12:59:30 +03:00
|
|
|
// In release builds, there's no point in the content process
|
|
|
|
// going through the full XPCOM shutdown path, because it doesn't
|
|
|
|
// keep persistent state.
|
2016-04-11 11:12:33 +03:00
|
|
|
ProcessChild::QuickExit();
|
2015-11-09 08:41:40 +03:00
|
|
|
#else
|
2017-02-01 15:34:24 +03:00
|
|
|
if (gFirstIdleTask) {
|
|
|
|
gFirstIdleTask->Cancel();
|
|
|
|
}
|
2012-11-28 00:43:52 +04:00
|
|
|
|
2016-07-18 12:13:31 +03:00
|
|
|
nsHostObjectProtocolHandler::RemoveDataEntries();
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
mAlertObservers.Clear();
|
2011-02-15 01:34:46 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
mIdleObservers.Clear();
|
2014-04-21 21:18:53 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (svc) {
|
|
|
|
svc->UnregisterListener(mConsoleListener);
|
|
|
|
mConsoleListener->mChild = nullptr;
|
|
|
|
}
|
|
|
|
mIsAlive = false;
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2017-02-17 05:44:16 +03:00
|
|
|
# ifdef MOZ_CRASHREPORTER
|
|
|
|
CrashReporterClient::DestroySingleton();
|
|
|
|
# endif
|
2016-01-05 12:59:30 +03:00
|
|
|
XRE_ShutdownChildProcess();
|
2015-11-09 08:41:40 +03:00
|
|
|
#endif // NS_FREE_PERMANENT_DATA
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
|
|
|
|
2010-08-21 03:24:40 +04:00
|
|
|
void
|
2015-02-03 20:09:27 +03:00
|
|
|
ContentChild::ProcessingError(Result aCode, const char* aReason)
|
2010-08-21 03:24:40 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
switch (aCode) {
|
|
|
|
case MsgDropped:
|
|
|
|
NS_WARNING("MsgDropped in ContentChild");
|
|
|
|
return;
|
|
|
|
|
|
|
|
case MsgNotKnown:
|
|
|
|
case MsgNotAllowed:
|
|
|
|
case MsgPayloadError:
|
|
|
|
case MsgProcessingError:
|
|
|
|
case MsgRouteError:
|
|
|
|
case MsgValueError:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("not reached");
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-02-08 21:37:21 +03:00
|
|
|
|
|
|
|
#if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
|
2017-02-17 05:44:16 +03:00
|
|
|
nsDependentCString reason(aReason);
|
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ipc_channel_error"), reason);
|
2015-02-08 21:37:21 +03:00
|
|
|
#endif
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Content child abort due to IPC error");
|
2010-08-21 03:24:40 +04:00
|
|
|
}
|
|
|
|
|
2010-09-15 20:44:57 +04:00
|
|
|
nsresult
|
|
|
|
ContentChild::AddRemoteAlertObserver(const nsString& aData,
|
|
|
|
nsIObserver* aObserver)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
NS_ASSERTION(aObserver, "Adding a null observer?");
|
|
|
|
mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
|
|
|
|
return NS_OK;
|
2010-09-15 20:44:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-08-23 00:00:21 +04:00
|
|
|
ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
|
2010-07-21 22:42:32 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
Preferences::SetPreference(aPref);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-05-26 04:13:47 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-08-04 21:33:42 +03:00
|
|
|
ContentChild::RecvVarUpdate(const GfxVarUpdate& aVar)
|
|
|
|
{
|
|
|
|
gfx::gfxVars::ApplyUpdate(aVar);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-08-04 21:33:42 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-10-30 22:30:00 +03:00
|
|
|
ContentChild::RecvDataStoragePut(const nsString& aFilename,
|
|
|
|
const DataStorageItem& aItem)
|
|
|
|
{
|
2017-03-16 05:19:14 +03:00
|
|
|
RefPtr<DataStorage> storage = DataStorage::GetFromRawFileName(aFilename);
|
2016-01-05 12:59:30 +03:00
|
|
|
if (storage) {
|
|
|
|
storage->Put(aItem.key(), aItem.value(), aItem.type());
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-10-30 22:30:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-10-30 22:30:00 +03:00
|
|
|
ContentChild::RecvDataStorageRemove(const nsString& aFilename,
|
|
|
|
const nsCString& aKey,
|
|
|
|
const DataStorageType& aType)
|
|
|
|
{
|
2017-03-16 05:19:14 +03:00
|
|
|
RefPtr<DataStorage> storage = DataStorage::GetFromRawFileName(aFilename);
|
2016-01-05 12:59:30 +03:00
|
|
|
if (storage) {
|
|
|
|
storage->Remove(aKey, aType);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-10-30 22:30:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-10-30 22:30:00 +03:00
|
|
|
ContentChild::RecvDataStorageClear(const nsString& aFilename)
|
|
|
|
{
|
2017-03-16 05:19:14 +03:00
|
|
|
RefPtr<DataStorage> storage = DataStorage::GetFromRawFileName(aFilename);
|
2016-01-05 12:59:30 +03:00
|
|
|
if (storage) {
|
|
|
|
storage->Clear();
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-10-30 22:30:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-09-15 20:44:57 +04:00
|
|
|
ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
for (uint32_t i = 0; i < mAlertObservers.Length();
|
|
|
|
/*we mutate the array during the loop; ++i iff no mutation*/) {
|
|
|
|
AlertObserver* observer = mAlertObservers[i];
|
|
|
|
if (observer->Observes(aData) && observer->Notify(aType)) {
|
|
|
|
// if aType == alertfinished, this alert is done. we can
|
|
|
|
// remove the observer.
|
|
|
|
if (aType.Equals(nsDependentCString("alertfinished"))) {
|
|
|
|
mAlertObservers.RemoveElementAt(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-15 20:44:57 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-08-23 23:33:46 +04:00
|
|
|
ContentChild::RecvNotifyVisited(const URIParams& aURI)
|
2010-07-02 19:50:41 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
|
|
|
if (!newURI) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
|
|
|
history->NotifyVisited(newURI);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-07-02 19:50:41 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-02-20 04:13:02 +03:00
|
|
|
ContentChild::RecvLoadProcessScript(const nsString& aURL)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
ProcessGlobal* global = ProcessGlobal::Get();
|
|
|
|
global->LoadScript(aURL);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-20 04:13:02 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-08-02 10:02:29 +04:00
|
|
|
ContentChild::RecvAsyncMessage(const nsString& aMsg,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2016-04-09 16:50:59 +03:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const ClonedMessageData& aData)
|
2010-08-31 22:58:35 +04:00
|
|
|
{
|
2017-03-30 00:43:21 +03:00
|
|
|
NS_LossyConvertUTF16toASCII messageNameCStr(aMsg);
|
Bug 1375392 - Tweak the PROFILER_LABEL* macros. r=mstange.
This patch makes the following changes to the macros.
- Removes PROFILER_LABEL_FUNC. It's only suitable for use in functions outside
classes, due to PROFILER_FUNCTION_NAME not getting class names, and it was
mostly misused.
- Removes PROFILER_FUNCTION_NAME. It's no longer used, and __func__ is
universally available now anyway.
- Combines the first two string literal arguments of PROFILER_LABEL and
PROFILER_LABEL_DYNAMIC into a single argument. There was no good reason for
them to be separate, and it forced a '::' in the label, which isn't always
appropriate. Also, the meaning of the "name_space" argument was interpreted
in an interesting variety of ways.
- Adds an "AUTO_" prefix to PROFILER_LABEL and PROFILER_LABEL_DYNAMIC, to make
it clearer they construct RAII objects rather than just being function calls.
(I myself have screwed up the scoping because of this in the past.)
- Fills in the 'js::ProfileEntry::Category::' qualifier within the macro, so
the caller doesn't need to. This makes a *lot* more of the uses fit onto a
single line.
The patch also makes the following changes to the macro uses (beyond those
required by the changes described above).
- Fixes a bunch of labels that had gotten out of sync with the name of the
class and/or function that encloses them.
- Removes a useless PROFILER_LABEL use within a trivial scope in
EventStateManager::DispatchMouseOrPointerEvent(). It clearly wasn't serving
any useful purpose. It also serves as extra evidence that the AUTO_ prefix is
a good idea.
- Tweaks DecodePool::SyncRunIf{Preferred,Possible} so that the labelling is
done within them, instead of at their callsites, because that's a more
standard way of doing things.
--HG--
extra : rebase_source : 318d1bc6fc1425a94aacbf489dd46e4f83211de4
2017-06-22 10:08:53 +03:00
|
|
|
AUTO_PROFILER_LABEL_DYNAMIC("ContentChild::RecvAsyncMessage", EVENTS,
|
|
|
|
messageNameCStr.get());
|
2017-03-30 00:43:21 +03:00
|
|
|
|
2017-01-17 22:00:38 +03:00
|
|
|
CrossProcessCpowHolder cpows(this, aCpows);
|
2016-01-05 12:59:30 +03:00
|
|
|
RefPtr<nsFrameMessageManager> cpm =
|
|
|
|
nsFrameMessageManager::GetChildProcessManager();
|
|
|
|
if (cpm) {
|
|
|
|
StructuredCloneData data;
|
|
|
|
ipc::UnpackClonedMessageDataForChild(aData, data);
|
|
|
|
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
|
|
|
|
nullptr, aMsg, false, &data, &cpows, aPrincipal,
|
|
|
|
nullptr);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-08-31 22:58:35 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-09-21 08:16:37 +04:00
|
|
|
ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs =
|
|
|
|
do_GetService("@mozilla.org/geolocation/service;1");
|
|
|
|
if (!gs) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
|
|
|
|
gs->Update(position);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-09-21 08:16:37 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2014-10-23 22:31:00 +04:00
|
|
|
ContentChild::RecvGeolocationError(const uint16_t& errorCode)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs =
|
|
|
|
do_GetService("@mozilla.org/geolocation/service;1");
|
|
|
|
if (!gs) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
gs->NotifyError(errorCode);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-10-23 22:31:00 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-01-16 22:58:52 +03:00
|
|
|
ContentChild::RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries)
|
2014-10-03 18:52:37 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
mAvailableDictionaries = aDictionaries;
|
|
|
|
mozInlineSpellChecker::UpdateCanEnableInlineSpellChecking();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-10-03 18:52:37 +04:00
|
|
|
}
|
|
|
|
|
Bug 1348042 - Refactor LocaleService to operate in server-client mode. r=Ehsan,qdot
LocaleService serves two main functions. It is a central place for all code in the
engine to learn about locales, but it also does the language negotiation and selection.
The former is relevant in all processes, but the latter should only be performed
by the "main" process. In case of current Desktop Firefox, the parent process
is the one performing all the language negotiation, and content processes should
operate in the "client" mode.
In Fennec, there's a Java app on top of Gecko which should work as a "server"
and then all processes, including parent process of Gecko is merely a "client" for that.
This refactor finalizes this duality making it easily configurable to define in
which mode a given LocaleService operates.
The server-client model allows all clients to stay in sync with the server,
but operate transparently for all callers just returning the right values.
In order to initialize LocaleService in the client mode in child process with the
right locales I'm adding the list of app locales to the XPCOMInitData,
and then fire LocaleService::SetAppLocales in the child process initialization.
In order to keep the list up to date, I'm adding intl:app-locales-changed to
the list of observed topics, and when triggered, I send the updated list
to the child process, which updates LocaleService::SetAppLocales with the new
list.
MozReview-Commit-ID: K9X6berF3IO
--HG--
extra : rebase_source : ca5e502d064023fddfd63fe6fe5eccefce8dee52
2017-03-26 08:09:45 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvUpdateAppLocales(nsTArray<nsCString>&& aAppLocales)
|
|
|
|
{
|
|
|
|
LocaleService::GetInstance()->AssignAppLocales(aAppLocales);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvUpdateRequestedLocales(nsTArray<nsCString>&& aRequestedLocales)
|
|
|
|
{
|
|
|
|
LocaleService::GetInstance()->AssignRequestedLocales(aRequestedLocales);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-10-09 22:07:38 +04:00
|
|
|
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|
|
|
{
|
|
|
|
#if MOZ_PERMISSIONS
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
|
|
|
services::GetPermissionManager();
|
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
|
|
|
MOZ_ASSERT(permissionManager,
|
|
|
|
"We have no permissionManager in the Content process !");
|
|
|
|
|
2016-06-17 09:18:00 +03:00
|
|
|
// note we do not need to force mUserContextId to the default here because
|
|
|
|
// the permission manager does that internally.
|
2016-01-05 12:59:30 +03:00
|
|
|
nsAutoCString originNoSuffix;
|
2017-01-12 19:38:48 +03:00
|
|
|
OriginAttributes attrs;
|
2016-08-15 13:21:53 +03:00
|
|
|
bool success = attrs.PopulateFromOrigin(permission.origin, originNoSuffix);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(success, IPC_FAIL_NO_REASON(this));
|
2016-01-05 12:59:30 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
2016-01-05 12:59:30 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal = mozilla::BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
|
|
|
|
|
|
|
// child processes don't care about modification time.
|
|
|
|
int64_t modificationTime = 0;
|
|
|
|
|
|
|
|
permissionManager->AddInternal(principal,
|
|
|
|
nsCString(permission.type),
|
|
|
|
permission.capability,
|
|
|
|
0,
|
|
|
|
permission.expireType,
|
|
|
|
permission.expireTime,
|
|
|
|
modificationTime,
|
|
|
|
nsPermissionManager::eNotify,
|
|
|
|
nsPermissionManager::eNoDBOperation);
|
2010-10-09 22:07:38 +04:00
|
|
|
#endif
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-10-09 22:07:38 +04:00
|
|
|
}
|
2011-06-20 09:36:17 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2010-12-12 01:36:08 +03:00
|
|
|
ContentChild::RecvFlushMemory(const nsString& reason)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
os->NotifyObservers(nullptr, "memory-pressure", reason.get());
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2010-12-12 01:36:08 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-06-07 02:35:51 +03:00
|
|
|
ContentChild::RecvActivateA11y(const uint32_t& aMainChromeTid,
|
|
|
|
const uint32_t& aMsaaID)
|
2011-07-21 08:37:32 +04:00
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
2016-10-20 21:34:16 +03:00
|
|
|
#ifdef XP_WIN
|
2017-06-07 02:35:51 +03:00
|
|
|
MOZ_ASSERT(aMainChromeTid != 0);
|
|
|
|
mMainChromeTid = aMainChromeTid;
|
|
|
|
|
2016-10-20 21:34:16 +03:00
|
|
|
MOZ_ASSERT(aMsaaID != 0);
|
|
|
|
mMsaaID = aMsaaID;
|
|
|
|
#endif // XP_WIN
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
// Start accessibility in content process if it's running in chrome
|
|
|
|
// process.
|
2016-08-29 18:06:48 +03:00
|
|
|
GetOrCreateAccService(nsAccessibilityService::eMainProcess);
|
2016-10-20 21:34:16 +03:00
|
|
|
#endif // ACCESSIBILITY
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-08-29 18:06:48 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-08-29 18:06:48 +03:00
|
|
|
ContentChild::RecvShutdownA11y()
|
|
|
|
{
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Try to shutdown accessibility in content process if it's shutting down in
|
|
|
|
// chrome process.
|
|
|
|
MaybeShutdownAccService(nsAccessibilityService::eMainProcess);
|
2011-07-21 08:37:32 +04:00
|
|
|
#endif
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-07-21 08:37:32 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2011-09-13 21:53:51 +04:00
|
|
|
ContentChild::RecvGarbageCollect()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// Rebroadcast the "child-gc-request" so that workers will GC.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nullptr, "child-gc-request", nullptr);
|
|
|
|
}
|
|
|
|
nsJSContext::GarbageCollectNow(JS::gcreason::DOM_IPC);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-09-13 21:53:51 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2011-09-13 21:53:51 +04:00
|
|
|
ContentChild::RecvCycleCollect()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
// Rebroadcast the "child-cc-request" so that workers will CC.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nullptr, "child-cc-request", nullptr);
|
|
|
|
}
|
|
|
|
nsJSContext::CycleCollectNow();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2011-09-13 21:53:51 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-04-22 20:41:59 +04:00
|
|
|
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
|
2014-09-24 10:14:55 +04:00
|
|
|
const nsCString& name, const nsCString& UAName,
|
|
|
|
const nsCString& ID, const nsCString& vendor)
|
2011-10-05 00:31:00 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
mAppInfo.version.Assign(version);
|
|
|
|
mAppInfo.buildID.Assign(buildID);
|
|
|
|
mAppInfo.name.Assign(name);
|
|
|
|
mAppInfo.UAName.Assign(UAName);
|
|
|
|
mAppInfo.ID.Assign(ID);
|
|
|
|
mAppInfo.vendor.Assign(vendor);
|
2013-11-29 13:28:54 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-14 17:49:38 +03:00
|
|
|
}
|
|
|
|
|
2016-11-24 18:08:31 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvRemoteType(const nsString& aRemoteType)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(DOMStringIsNull(mRemoteType));
|
|
|
|
|
|
|
|
mRemoteType.Assign(aRemoteType);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsAString&
|
|
|
|
ContentChild::GetRemoteType() const
|
|
|
|
{
|
|
|
|
return mRemoteType;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-07-13 11:34:24 +03:00
|
|
|
ContentChild::RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig)
|
|
|
|
{
|
|
|
|
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
2017-01-13 01:00:36 +03:00
|
|
|
if (!swm) {
|
|
|
|
// browser shutdown began
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
2016-07-13 11:34:24 +03:00
|
|
|
swm->LoadRegistrations(aConfig.serviceWorkerRegistrations());
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-13 11:34:24 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-07-17 17:50:50 +03:00
|
|
|
ContentChild::RecvInitBlobURLs(nsTArray<BlobURLRegistrationData>&& aRegistrations)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aRegistrations.Length(); ++i) {
|
|
|
|
BlobURLRegistrationData& registration = aRegistrations[i];
|
2017-04-24 13:16:49 +03:00
|
|
|
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(registration.blob());
|
2016-07-17 17:50:50 +03:00
|
|
|
MOZ_ASSERT(blobImpl);
|
|
|
|
|
2016-07-21 15:31:43 +03:00
|
|
|
nsHostObjectProtocolHandler::AddDataEntry(registration.url(),
|
|
|
|
registration.principal(),
|
|
|
|
blobImpl);
|
2016-07-17 17:50:50 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-17 17:50:50 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2012-04-20 04:13:20 +04:00
|
|
|
ContentChild::RecvLastPrivateDocShellDestroyed()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2012-04-20 04:13:20 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-04-26 04:53:26 +04:00
|
|
|
ContentChild::RecvNotifyProcessPriorityChanged(
|
2016-01-05 12:59:30 +03:00
|
|
|
const hal::ProcessPriority& aPriority)
|
2013-04-26 04:53:26 +04:00
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(os, IPC_OK());
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
|
|
|
props->SetPropertyAsInt32(NS_LITERAL_STRING("priority"),
|
|
|
|
static_cast<int32_t>(aPriority));
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
os->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
|
|
|
|
"ipc:process-priority-changed", nullptr);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-04-26 04:53:26 +04:00
|
|
|
ContentChild::RecvMinimizeMemoryUsage()
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
|
|
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mgr, IPC_OK());
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2016-08-24 08:23:45 +03:00
|
|
|
Unused << mgr->MinimizeMemoryUsage(/* callback = */ nullptr);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-04-26 04:53:26 +04:00
|
|
|
}
|
|
|
|
|
2013-12-13 20:28:46 +04:00
|
|
|
void
|
|
|
|
ContentChild::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT(aObserver, "null idle observer");
|
|
|
|
// Make sure aObserver isn't released while we wait for the parent
|
|
|
|
aObserver->AddRef();
|
|
|
|
SendAddIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
|
|
|
mIdleObservers.PutEntry(aObserver);
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT(aObserver, "null idle observer");
|
|
|
|
SendRemoveIdleObserver(reinterpret_cast<uint64_t>(aObserver), aIdleTimeInS);
|
|
|
|
aObserver->Release();
|
|
|
|
mIdleObservers.RemoveEntry(aObserver);
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-12-13 20:28:46 +04:00
|
|
|
ContentChild::RecvNotifyIdleObserver(const uint64_t& aObserver,
|
|
|
|
const nsCString& aTopic,
|
|
|
|
const nsString& aTimeStr)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsIObserver* observer = reinterpret_cast<nsIObserver*>(aObserver);
|
|
|
|
if (mIdleObservers.Contains(observer)) {
|
|
|
|
observer->Observe(nullptr, aTopic.get(), aTimeStr.get());
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Received notification for an idle observer that was removed.");
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-08-27 21:10:39 +04:00
|
|
|
ContentChild::RecvLoadAndRegisterSheet(const URIParams& aURI, const uint32_t& aType)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
|
|
if (!uri) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2013-08-27 21:10:39 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
|
|
|
if (sheetService) {
|
|
|
|
sheetService->LoadAndRegisterSheet(uri, aType);
|
|
|
|
}
|
2013-08-27 21:10:39 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-08-27 21:10:39 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2013-08-27 21:10:39 +04:00
|
|
|
ContentChild::RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
|
|
|
if (!uri) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2013-08-27 21:10:39 +04:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
|
|
|
if (sheetService) {
|
|
|
|
sheetService->UnregisterSheet(uri, aType);
|
|
|
|
}
|
2013-08-27 21:10:39 +04:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2013-08-27 21:10:39 +04:00
|
|
|
}
|
|
|
|
|
2014-11-13 03:31:00 +03:00
|
|
|
POfflineCacheUpdateChild*
|
|
|
|
ContentChild::AllocPOfflineCacheUpdateChild(const URIParams& manifestURI,
|
|
|
|
const URIParams& documentURI,
|
2015-10-02 19:10:02 +03:00
|
|
|
const PrincipalInfo& aLoadingPrincipalInfo,
|
2016-01-18 22:20:08 +03:00
|
|
|
const bool& stickDocument)
|
2014-11-13 03:31:00 +03:00
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("unused");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2014-11-13 03:31:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPOfflineCacheUpdateChild(POfflineCacheUpdateChild* actor)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
OfflineCacheUpdateChild* offlineCacheUpdate =
|
|
|
|
static_cast<OfflineCacheUpdateChild*>(actor);
|
|
|
|
NS_RELEASE(offlineCacheUpdate);
|
|
|
|
return true;
|
2014-11-13 03:31:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-01-05 12:59:30 +03:00
|
|
|
ContentChild::RecvDomainSetChanged(const uint32_t& aSetType,
|
|
|
|
const uint32_t& aChangeType,
|
2015-03-24 17:29:16 +03:00
|
|
|
const OptionalURIParams& aDomain)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (aChangeType == ACTIVATE_POLICY) {
|
|
|
|
if (mPolicy) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
|
|
|
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
|
|
|
MOZ_ASSERT(ssm);
|
|
|
|
ssm->ActivateDomainPolicyInternal(getter_AddRefs(mPolicy));
|
2016-11-15 06:26:00 +03:00
|
|
|
if (!mPolicy) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
return IPC_OK();
|
2017-02-09 12:31:03 +03:00
|
|
|
}
|
|
|
|
if (!mPolicy) {
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("If the domain policy is not active yet,"
|
|
|
|
" the first message should be ACTIVATE_POLICY");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(mPolicy, IPC_FAIL_NO_REASON(this));
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (aChangeType == DEACTIVATE_POLICY) {
|
|
|
|
mPolicy->Deactivate();
|
|
|
|
mPolicy = nullptr;
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIDomainSet> set;
|
|
|
|
switch(aSetType) {
|
|
|
|
case BLACKLIST:
|
|
|
|
mPolicy->GetBlacklist(getter_AddRefs(set));
|
|
|
|
break;
|
|
|
|
case SUPER_BLACKLIST:
|
|
|
|
mPolicy->GetSuperBlacklist(getter_AddRefs(set));
|
|
|
|
break;
|
|
|
|
case WHITELIST:
|
|
|
|
mPolicy->GetWhitelist(getter_AddRefs(set));
|
|
|
|
break;
|
|
|
|
case SUPER_WHITELIST:
|
|
|
|
mPolicy->GetSuperWhitelist(getter_AddRefs(set));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unexpected setType");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
MOZ_ASSERT(set);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri = DeserializeURI(aDomain);
|
|
|
|
|
|
|
|
switch(aChangeType) {
|
|
|
|
case ADD_DOMAIN:
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(uri, IPC_FAIL_NO_REASON(this));
|
2016-01-05 12:59:30 +03:00
|
|
|
set->Add(uri);
|
|
|
|
break;
|
|
|
|
case REMOVE_DOMAIN:
|
2016-11-15 06:26:00 +03:00
|
|
|
NS_ENSURE_TRUE(uri, IPC_FAIL_NO_REASON(this));
|
2016-01-05 12:59:30 +03:00
|
|
|
set->Remove(uri);
|
|
|
|
break;
|
|
|
|
case CLEAR_DOMAINS:
|
|
|
|
set->Clear();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unexpected changeType");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-03-24 17:29:16 +03:00
|
|
|
}
|
|
|
|
|
2016-06-02 15:52:17 +03:00
|
|
|
void
|
|
|
|
ContentChild::StartForceKillTimer()
|
|
|
|
{
|
|
|
|
if (mForceKillTimer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t timeoutSecs = Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
|
|
|
|
if (timeoutSecs > 0) {
|
|
|
|
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
MOZ_ASSERT(mForceKillTimer);
|
2017-06-12 22:34:10 +03:00
|
|
|
mForceKillTimer->InitWithNamedFuncCallback(
|
|
|
|
ContentChild::ForceKillTimerCallback,
|
2016-06-02 15:52:17 +03:00
|
|
|
this,
|
|
|
|
timeoutSecs * 1000,
|
2017-06-12 22:34:10 +03:00
|
|
|
nsITimer::TYPE_ONE_SHOT,
|
|
|
|
"dom::ContentChild::StartForceKillTimer");
|
2016-06-02 15:52:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
ContentChild::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
|
|
|
|
{
|
|
|
|
ProcessChild::QuickExit();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-01-10 21:18:59 +03:00
|
|
|
ContentChild::RecvShutdown()
|
|
|
|
{
|
2016-06-04 03:22:08 +03:00
|
|
|
// If we receive the shutdown message from within a nested event loop, we want
|
|
|
|
// to wait for that event loop to finish. Otherwise we could prematurely
|
|
|
|
// terminate an "unload" or "pagehide" event handler (which might be doing a
|
|
|
|
// sync XHR, for example).
|
2016-09-08 12:23:57 +03:00
|
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
|
|
|
|
NS_LITERAL_CSTRING("RecvShutdown"));
|
|
|
|
#endif
|
2017-07-20 02:08:46 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
RefPtr<nsThread> mainThread = nsThreadManager::get().GetCurrentThread();
|
|
|
|
// Note that we only have to check the recursion count for the current
|
|
|
|
// cooperative thread. Since the Shutdown message is not labeled with a
|
|
|
|
// SchedulerGroup, there can be no other cooperative threads doing work while
|
|
|
|
// we're running.
|
|
|
|
if (mainThread && mainThread->RecursionDepth() > 1) {
|
|
|
|
// We're in a nested event loop. Let's delay for an arbitrary period of
|
|
|
|
// time (100ms) in the hopes that the event loop will have finished by
|
|
|
|
// then.
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
|
|
|
NewRunnableMethod(
|
|
|
|
"dom::ContentChild::RecvShutdown", this, &ContentChild::RecvShutdown),
|
|
|
|
100);
|
|
|
|
return IPC_OK();
|
2016-06-04 03:22:08 +03:00
|
|
|
}
|
|
|
|
|
2016-09-03 02:23:00 +03:00
|
|
|
mShuttingDown = true;
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
if (mPolicy) {
|
|
|
|
mPolicy->Deactivate();
|
|
|
|
mPolicy = nullptr;
|
|
|
|
}
|
2015-03-24 17:29:16 +03:00
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
os->NotifyObservers(static_cast<nsIContentChild*>(this),
|
|
|
|
"content-child-shutdown", nullptr);
|
|
|
|
}
|
2015-01-10 21:39:33 +03:00
|
|
|
|
2016-03-13 16:25:23 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
mozilla::widget::StopAudioSession();
|
|
|
|
#endif
|
|
|
|
|
2016-01-05 12:59:30 +03:00
|
|
|
GetIPCChannel()->SetAbortOnError(false);
|
2015-02-13 22:10:56 +03:00
|
|
|
|
2017-01-24 06:15:12 +03:00
|
|
|
#ifdef MOZ_GECKO_PROFILER
|
2017-05-30 22:06:14 +03:00
|
|
|
if (mProfilerController) {
|
|
|
|
nsCString shutdownProfile = mProfilerController->GrabShutdownProfileAndShutdown();
|
|
|
|
mProfilerController = nullptr;
|
|
|
|
// Send the shutdown profile to the parent process through our own
|
|
|
|
// message channel, which we know will survive for long enough.
|
|
|
|
Unused << SendShutdownProfile(shutdownProfile);
|
2016-01-05 12:59:30 +03:00
|
|
|
}
|
2015-08-18 21:57:35 +03:00
|
|
|
#endif
|
|
|
|
|
2016-06-02 15:52:17 +03:00
|
|
|
// Start a timer that will insure we quickly exit after a reasonable
|
|
|
|
// period of time. Prevents shutdown hangs after our connection to the
|
|
|
|
// parent closes.
|
|
|
|
StartForceKillTimer();
|
|
|
|
|
2016-09-08 12:23:57 +03:00
|
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
|
|
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"),
|
|
|
|
NS_LITERAL_CSTRING("SendFinishShutdown"));
|
|
|
|
#endif
|
2016-01-05 12:59:30 +03:00
|
|
|
// Ignore errors here. If this fails, the parent will kill us after a
|
|
|
|
// timeout.
|
|
|
|
Unused << SendFinishShutdown();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-01-10 21:18:59 +03:00
|
|
|
}
|
|
|
|
|
2014-11-04 04:58:00 +03:00
|
|
|
PBrowserOrId
|
|
|
|
ContentChild::GetBrowserOrId(TabChild* aTabChild)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
if (!aTabChild ||
|
|
|
|
this == aTabChild->Manager()) {
|
|
|
|
return PBrowserOrId(aTabChild);
|
|
|
|
}
|
2017-02-09 12:31:03 +03:00
|
|
|
return PBrowserOrId(aTabChild->GetTabId());
|
2014-11-04 04:58:00 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-07 16:17:27 +03:00
|
|
|
ContentChild::RecvUpdateWindow(const uintptr_t& aChildId)
|
|
|
|
{
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
NS_ASSERTION(aChildId, "Expected child hwnd value for remote plugin instance.");
|
|
|
|
mozilla::plugins::PluginInstanceParent* parentInstance =
|
2016-01-05 12:59:30 +03:00
|
|
|
mozilla::plugins::PluginInstanceParent::LookupPluginInstanceByID(aChildId);
|
2015-04-07 16:17:27 +03:00
|
|
|
if (parentInstance) {
|
2016-01-05 12:59:30 +03:00
|
|
|
// sync! update call to the plugin instance that forces the
|
|
|
|
// plugin to paint its child window.
|
|
|
|
parentInstance->CallUpdateWindow();
|
2015-04-07 16:17:27 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-04-07 16:17:27 +03:00
|
|
|
#else
|
2016-01-08 23:40:26 +03:00
|
|
|
MOZ_ASSERT(false, "ContentChild::RecvUpdateWindow calls unexpected on this platform.");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-04-07 16:17:27 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-14 04:08:00 +03:00
|
|
|
PContentPermissionRequestChild*
|
|
|
|
ContentChild::AllocPContentPermissionRequestChild(const InfallibleTArray<PermissionRequest>& aRequests,
|
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("unused");
|
2016-01-05 12:59:30 +03:00
|
|
|
return nullptr;
|
2015-04-14 04:08:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPContentPermissionRequestChild(PContentPermissionRequestChild* actor)
|
|
|
|
{
|
2016-01-05 12:59:30 +03:00
|
|
|
nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild(actor);
|
|
|
|
auto child = static_cast<RemotePermissionRequest*>(actor);
|
|
|
|
child->IPDLRelease();
|
|
|
|
return true;
|
2015-04-14 04:08:00 +03:00
|
|
|
}
|
|
|
|
|
2015-09-21 15:54:00 +03:00
|
|
|
PWebBrowserPersistDocumentChild*
|
|
|
|
ContentChild::AllocPWebBrowserPersistDocumentChild(PBrowserChild* aBrowser,
|
|
|
|
const uint64_t& aOuterWindowID)
|
|
|
|
{
|
|
|
|
return new WebBrowserPersistDocumentChild();
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-09-21 15:54:00 +03:00
|
|
|
ContentChild::RecvPWebBrowserPersistDocumentConstructor(PWebBrowserPersistDocumentChild *aActor,
|
|
|
|
PBrowserChild* aBrowser,
|
|
|
|
const uint64_t& aOuterWindowID)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!aBrowser)) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2015-09-21 15:54:00 +03:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDocument> rootDoc =
|
|
|
|
static_cast<TabChild*>(aBrowser)->GetDocument();
|
|
|
|
nsCOMPtr<nsIDocument> foundDoc;
|
|
|
|
if (aOuterWindowID) {
|
|
|
|
foundDoc = nsContentUtils::GetSubdocumentWithOuterWindowId(rootDoc, aOuterWindowID);
|
|
|
|
} else {
|
|
|
|
foundDoc = rootDoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!foundDoc) {
|
|
|
|
aActor->SendInitFailure(NS_ERROR_NO_CONTENT);
|
|
|
|
} else {
|
|
|
|
static_cast<WebBrowserPersistDocumentChild*>(aActor)->Start(foundDoc);
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-09-21 15:54:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPWebBrowserPersistDocumentChild(PWebBrowserPersistDocumentChild* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-03-13 16:25:23 +03:00
|
|
|
ContentChild::RecvSetAudioSessionData(const nsID& aId,
|
|
|
|
const nsString& aDisplayName,
|
|
|
|
const nsString& aIconPath)
|
|
|
|
{
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
if (NS_FAILED(mozilla::widget::RecvAudioSessionData(aId, aDisplayName,
|
|
|
|
aIconPath))) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-03-13 16:25:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore failures here; we can't really do anything about them
|
|
|
|
mozilla::widget::StartAudioSession();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-03-13 16:25:23 +03:00
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Not Reached!");
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_FAIL_NO_REASON(this);
|
2016-03-13 16:25:23 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-28 22:53:46 +03:00
|
|
|
// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
|
|
|
|
// can't include ContentChild.h since it includes windows.h.
|
|
|
|
|
|
|
|
static uint64_t gNextWindowID = 0;
|
|
|
|
|
|
|
|
// We use only 53 bits for the window ID so that it can be converted to and from
|
|
|
|
// a JS value without loss of precision. The upper bits of the window ID hold the
|
|
|
|
// process ID. The lower bits identify the window.
|
|
|
|
static const uint64_t kWindowIDTotalBits = 53;
|
|
|
|
static const uint64_t kWindowIDProcessBits = 22;
|
|
|
|
static const uint64_t kWindowIDWindowBits = kWindowIDTotalBits - kWindowIDProcessBits;
|
|
|
|
|
|
|
|
// Try to return a window ID that is unique across processes and that will never
|
|
|
|
// be recycled.
|
|
|
|
uint64_t
|
|
|
|
NextWindowID()
|
|
|
|
{
|
|
|
|
uint64_t processID = 0;
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2015-01-28 22:53:46 +03:00
|
|
|
ContentChild* cc = ContentChild::GetSingleton();
|
|
|
|
processID = cc->GetID();
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(processID < (uint64_t(1) << kWindowIDProcessBits));
|
|
|
|
uint64_t processBits = processID & ((uint64_t(1) << kWindowIDProcessBits) - 1);
|
|
|
|
|
|
|
|
// Make sure no actual window ends up with mWindowID == 0.
|
|
|
|
uint64_t windowID = ++gNextWindowID;
|
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(windowID < (uint64_t(1) << kWindowIDWindowBits));
|
|
|
|
uint64_t windowBits = windowID & ((uint64_t(1) << kWindowIDWindowBits) - 1);
|
|
|
|
|
|
|
|
return (processBits << kWindowIDWindowBits) | windowBits;
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-04-08 21:48:11 +03:00
|
|
|
ContentChild::RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
|
|
|
|
const uint32_t& aAction)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService) {
|
|
|
|
dragService->StartDragSession();
|
|
|
|
nsCOMPtr<nsIDragSession> session;
|
|
|
|
dragService->GetCurrentSession(getter_AddRefs(session));
|
|
|
|
if (session) {
|
|
|
|
session->SetDragAction(aAction);
|
2016-06-21 20:07:17 +03:00
|
|
|
// Check if we are receiving any file objects. If we are we will want
|
|
|
|
// to hide any of the other objects coming in from content.
|
|
|
|
bool hasFiles = false;
|
|
|
|
for (uint32_t i = 0; i < aTransfers.Length() && !hasFiles; ++i) {
|
|
|
|
auto& items = aTransfers[i].items();
|
|
|
|
for (uint32_t j = 0; j < items.Length() && !hasFiles; ++j) {
|
2017-04-24 13:16:50 +03:00
|
|
|
if (items[j].data().type() == IPCDataTransferData::TIPCBlob) {
|
2016-06-21 20:07:17 +03:00
|
|
|
hasFiles = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the entries from the IPC to the new DataTransfer
|
2015-04-08 21:48:11 +03:00
|
|
|
nsCOMPtr<DataTransfer> dataTransfer =
|
2015-09-02 09:08:01 +03:00
|
|
|
new DataTransfer(nullptr, eDragStart, false, -1);
|
2015-04-08 21:48:11 +03:00
|
|
|
for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
|
|
|
|
auto& items = aTransfers[i].items();
|
|
|
|
for (uint32_t j = 0; j < items.Length(); ++j) {
|
|
|
|
const IPCDataTransferItem& item = items[j];
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsVariantCC> variant = new nsVariantCC();
|
2015-04-08 21:48:11 +03:00
|
|
|
if (item.data().type() == IPCDataTransferData::TnsString) {
|
|
|
|
const nsString& data = item.data().get_nsString();
|
|
|
|
variant->SetAsAString(data);
|
2016-06-15 19:57:46 +03:00
|
|
|
} else if (item.data().type() == IPCDataTransferData::TShmem) {
|
|
|
|
Shmem data = item.data().get_Shmem();
|
|
|
|
variant->SetAsACString(nsDependentCString(data.get<char>(), data.Size<char>()));
|
|
|
|
Unused << DeallocShmem(data);
|
2017-04-24 13:16:50 +03:00
|
|
|
} else if (item.data().type() == IPCDataTransferData::TIPCBlob) {
|
|
|
|
RefPtr<BlobImpl> blobImpl =
|
|
|
|
IPCBlobUtils::Deserialize(item.data().get_IPCBlob());
|
2015-05-27 02:07:54 +03:00
|
|
|
variant->SetAsISupports(blobImpl);
|
2015-05-12 18:51:08 +03:00
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
2016-06-21 20:07:17 +03:00
|
|
|
// We should hide this data from content if we have a file, and we aren't a file.
|
2017-04-24 13:16:50 +03:00
|
|
|
bool hidden = hasFiles && item.data().type() != IPCDataTransferData::TIPCBlob;
|
2016-04-21 21:11:14 +03:00
|
|
|
dataTransfer->SetDataWithPrincipalFromOtherProcess(
|
|
|
|
NS_ConvertUTF8toUTF16(item.flavor()), variant, i,
|
2016-06-21 20:07:17 +03:00
|
|
|
nsContentUtils::GetSystemPrincipal(), hidden);
|
2015-05-12 18:51:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
session->SetDataTransfer(dataTransfer);
|
|
|
|
}
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-12 18:51:08 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2015-05-12 18:51:08 +03:00
|
|
|
ContentChild::RecvEndDragSession(const bool& aDoneDrag,
|
2016-05-19 00:17:34 +03:00
|
|
|
const bool& aUserCancelled,
|
2017-02-17 06:29:42 +03:00
|
|
|
const LayoutDeviceIntPoint& aDragEndPoint,
|
|
|
|
const uint32_t& aKeyModifiers)
|
2015-05-12 18:51:08 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService) {
|
|
|
|
if (aUserCancelled) {
|
|
|
|
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
|
|
|
if (dragSession) {
|
|
|
|
dragSession->UserCancelled();
|
|
|
|
}
|
|
|
|
}
|
2016-05-19 00:17:34 +03:00
|
|
|
static_cast<nsBaseDragService*>(dragService.get())->SetDragEndPoint(aDragEndPoint);
|
2017-02-17 06:29:42 +03:00
|
|
|
dragService->EndDragSession(aDoneDrag, aKeyModifiers);
|
2015-05-12 18:51:08 +03:00
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-05-12 18:51:08 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-01-14 08:19:51 +03:00
|
|
|
ContentChild::RecvPush(const nsCString& aScope,
|
2016-03-28 21:50:39 +03:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const nsString& aMessageId)
|
2016-01-14 08:19:51 +03:00
|
|
|
{
|
2016-05-20 05:01:34 +03:00
|
|
|
PushMessageDispatcher dispatcher(aScope, aPrincipal, aMessageId, Nothing());
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObserversAndWorkers()));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-14 08:19:51 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-01-14 08:19:51 +03:00
|
|
|
ContentChild::RecvPushWithData(const nsCString& aScope,
|
|
|
|
const IPC::Principal& aPrincipal,
|
2016-03-28 21:50:39 +03:00
|
|
|
const nsString& aMessageId,
|
2016-01-14 08:19:51 +03:00
|
|
|
InfallibleTArray<uint8_t>&& aData)
|
|
|
|
{
|
2016-05-20 05:01:34 +03:00
|
|
|
PushMessageDispatcher dispatcher(aScope, aPrincipal, aMessageId, Some(aData));
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObserversAndWorkers()));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-14 08:19:51 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-01-14 08:19:51 +03:00
|
|
|
ContentChild::RecvPushSubscriptionChange(const nsCString& aScope,
|
|
|
|
const IPC::Principal& aPrincipal)
|
|
|
|
{
|
2016-05-20 05:01:34 +03:00
|
|
|
PushSubscriptionChangeDispatcher dispatcher(aScope, aPrincipal);
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObserversAndWorkers()));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-01-14 08:19:51 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-05-20 05:01:34 +03:00
|
|
|
ContentChild::RecvPushError(const nsCString& aScope, const IPC::Principal& aPrincipal,
|
|
|
|
const nsString& aMessage, const uint32_t& aFlags)
|
2016-03-28 23:33:20 +03:00
|
|
|
{
|
2016-05-20 05:01:34 +03:00
|
|
|
PushErrorDispatcher dispatcher(aScope, aPrincipal, aMessage, aFlags);
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObserversAndWorkers()));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-03-28 23:33:20 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-05-15 02:54:51 +03:00
|
|
|
ContentChild::RecvNotifyPushSubscriptionModifiedObservers(const nsCString& aScope,
|
|
|
|
const IPC::Principal& aPrincipal)
|
|
|
|
{
|
|
|
|
PushSubscriptionModifiedDispatcher dispatcher(aScope, aPrincipal);
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(dispatcher.NotifyObservers()));
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-05-15 02:54:51 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2017-04-24 13:16:49 +03:00
|
|
|
ContentChild::RecvBlobURLRegistration(const nsCString& aURI,
|
|
|
|
const IPCBlob& aBlob,
|
2016-07-17 17:50:50 +03:00
|
|
|
const IPC::Principal& aPrincipal)
|
|
|
|
{
|
2017-04-24 13:16:49 +03:00
|
|
|
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(aBlob);
|
2016-07-17 17:50:50 +03:00
|
|
|
MOZ_ASSERT(blobImpl);
|
|
|
|
|
2016-07-21 15:31:43 +03:00
|
|
|
nsHostObjectProtocolHandler::AddDataEntry(aURI, aPrincipal, blobImpl);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-17 17:50:50 +03:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-07-17 17:50:50 +03:00
|
|
|
ContentChild::RecvBlobURLUnregistration(const nsCString& aURI)
|
|
|
|
{
|
2017-03-21 14:58:41 +03:00
|
|
|
nsHostObjectProtocolHandler::RemoveDataEntry(aURI,
|
|
|
|
/* aBroadcastToOtherProcesses = */ false);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-17 17:50:50 +03:00
|
|
|
}
|
|
|
|
|
2017-02-20 06:16:48 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvDispatchLocalStorageChange(const nsString& aDocumentURI,
|
|
|
|
const nsString& aKey,
|
|
|
|
const nsString& aOldValue,
|
|
|
|
const nsString& aNewValue,
|
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const bool& aIsPrivate)
|
|
|
|
{
|
2017-05-17 08:01:14 +03:00
|
|
|
LocalStorage::DispatchStorageEvent(aDocumentURI, aKey, aOldValue, aNewValue,
|
|
|
|
aPrincipal, aIsPrivate, nullptr, true);
|
2017-02-20 06:16:48 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-10-27 21:40:50 +03:00
|
|
|
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
|
|
|
bool
|
|
|
|
ContentChild::SendGetA11yContentId()
|
|
|
|
{
|
|
|
|
return PContentChild::SendGetA11yContentId(&mMsaaID);
|
|
|
|
}
|
|
|
|
#endif // defined(XP_WIN) && defined(ACCESSIBILITY)
|
2016-07-17 17:50:50 +03:00
|
|
|
|
2016-07-14 10:04:21 +03:00
|
|
|
void
|
|
|
|
ContentChild::CreateGetFilesRequest(const nsAString& aDirectoryPath,
|
|
|
|
bool aRecursiveFlag,
|
|
|
|
nsID& aUUID,
|
|
|
|
GetFilesHelperChild* aChild)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aChild);
|
|
|
|
MOZ_ASSERT(!mGetFilesPendingRequests.GetWeak(aUUID));
|
|
|
|
|
|
|
|
Unused << SendGetFilesRequest(aUUID, nsString(aDirectoryPath),
|
|
|
|
aRecursiveFlag);
|
|
|
|
mGetFilesPendingRequests.Put(aUUID, aChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::DeleteGetFilesRequest(nsID& aUUID, GetFilesHelperChild* aChild)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aChild);
|
|
|
|
MOZ_ASSERT(mGetFilesPendingRequests.GetWeak(aUUID));
|
|
|
|
|
|
|
|
Unused << SendDeleteGetFilesRequest(aUUID);
|
|
|
|
mGetFilesPendingRequests.Remove(aUUID);
|
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult
|
2016-07-14 10:04:21 +03:00
|
|
|
ContentChild::RecvGetFilesResponse(const nsID& aUUID,
|
|
|
|
const GetFilesResponseResult& aResult)
|
|
|
|
{
|
|
|
|
GetFilesHelperChild* child = mGetFilesPendingRequests.GetWeak(aUUID);
|
|
|
|
// This object can already been deleted in case DeleteGetFilesRequest has
|
|
|
|
// been called when the response was sending by the parent.
|
|
|
|
if (!child) {
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-14 10:04:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aResult.type() == GetFilesResponseResult::TGetFilesResponseFailure) {
|
|
|
|
child->Finished(aResult.get_GetFilesResponseFailure().errorCode());
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aResult.type() == GetFilesResponseResult::TGetFilesResponseSuccess);
|
|
|
|
|
2017-04-24 13:16:49 +03:00
|
|
|
const nsTArray<IPCBlob>& ipcBlobs =
|
|
|
|
aResult.get_GetFilesResponseSuccess().blobs();
|
2016-07-14 10:04:21 +03:00
|
|
|
|
|
|
|
bool succeeded = true;
|
2017-04-24 13:16:49 +03:00
|
|
|
for (uint32_t i = 0; succeeded && i < ipcBlobs.Length(); ++i) {
|
|
|
|
RefPtr<BlobImpl> impl = IPCBlobUtils::Deserialize(ipcBlobs[i]);
|
2016-07-14 10:04:21 +03:00
|
|
|
succeeded = child->AppendBlobImpl(impl);
|
|
|
|
}
|
|
|
|
|
|
|
|
child->Finished(succeeded ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
mGetFilesPendingRequests.Remove(aUUID);
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2016-07-14 10:04:21 +03:00
|
|
|
}
|
|
|
|
|
2016-10-04 11:31:27 +03:00
|
|
|
/* static */ void
|
|
|
|
ContentChild::FatalErrorIfNotUsingGPUProcess(const char* const aProtocolName,
|
|
|
|
const char* const aErrorMsg,
|
|
|
|
base::ProcessId aOtherPid)
|
|
|
|
{
|
|
|
|
// If we're communicating with the same process or the UI process then we
|
|
|
|
// want to crash normally. Otherwise we want to just warn as the other end
|
|
|
|
// must be the GPU process and it crashing shouldn't be fatal for us.
|
|
|
|
if (aOtherPid == base::GetCurrentProcId() ||
|
|
|
|
(GetSingleton() && GetSingleton()->OtherPid() == aOtherPid)) {
|
|
|
|
mozilla::ipc::FatalError(aProtocolName, aErrorMsg, false);
|
|
|
|
} else {
|
|
|
|
nsAutoCString formattedMessage("IPDL error [");
|
|
|
|
formattedMessage.AppendASCII(aProtocolName);
|
2016-11-14 12:45:55 +03:00
|
|
|
formattedMessage.AppendLiteral(R"(]: ")");
|
2016-10-04 11:31:27 +03:00
|
|
|
formattedMessage.AppendASCII(aErrorMsg);
|
2016-11-14 12:45:55 +03:00
|
|
|
formattedMessage.AppendLiteral(R"(".)");
|
2016-10-04 11:31:27 +03:00
|
|
|
NS_WARNING(formattedMessage.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-19 00:54:57 +03:00
|
|
|
PURLClassifierChild*
|
|
|
|
ContentChild::AllocPURLClassifierChild(const Principal& aPrincipal,
|
|
|
|
const bool& aUseTrackingProtection,
|
|
|
|
bool* aSuccess)
|
|
|
|
{
|
|
|
|
*aSuccess = true;
|
|
|
|
return new URLClassifierChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPURLClassifierChild(PURLClassifierChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-07 09:15:16 +03:00
|
|
|
PURLClassifierLocalChild*
|
|
|
|
ContentChild::AllocPURLClassifierLocalChild(const URIParams& aUri,
|
|
|
|
const nsCString& aTables)
|
|
|
|
{
|
|
|
|
return new URLClassifierLocalChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-04 21:13:52 +03:00
|
|
|
// The IPC code will call this method asking us to assign an event target to new
|
|
|
|
// actors created by the ContentParent.
|
|
|
|
already_AddRefed<nsIEventTarget>
|
|
|
|
ContentChild::GetConstructedEventTarget(const Message& aMsg)
|
|
|
|
{
|
|
|
|
// Currently we only set targets for PBrowser.
|
|
|
|
if (aMsg.type() != PContent::Msg_PBrowserConstructor__ID) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-05-02 12:57:51 +03:00
|
|
|
return nsIContentChild::GetConstructedEventTarget(aMsg);
|
2016-11-04 21:13:52 +03:00
|
|
|
}
|
|
|
|
|
2017-02-08 12:19:01 +03:00
|
|
|
void
|
|
|
|
ContentChild::FileCreationRequest(nsID& aUUID, FileCreatorHelper* aHelper,
|
|
|
|
const nsAString& aFullPath,
|
|
|
|
const nsAString& aType,
|
|
|
|
const nsAString& aName,
|
|
|
|
const Optional<int64_t>& aLastModified,
|
2017-03-03 11:42:54 +03:00
|
|
|
bool aExistenceCheck,
|
2017-02-08 12:19:01 +03:00
|
|
|
bool aIsFromNsIFile)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aHelper);
|
|
|
|
|
|
|
|
bool lastModifiedPassed = false;
|
|
|
|
int64_t lastModified = 0;
|
|
|
|
if (aLastModified.WasPassed()) {
|
|
|
|
lastModifiedPassed = true;
|
|
|
|
lastModified = aLastModified.Value();
|
|
|
|
}
|
|
|
|
|
|
|
|
Unused << SendFileCreationRequest(aUUID, nsString(aFullPath), nsString(aType),
|
|
|
|
nsString(aName), lastModifiedPassed,
|
2017-03-03 11:42:54 +03:00
|
|
|
lastModified, aExistenceCheck,
|
|
|
|
aIsFromNsIFile);
|
2017-02-08 12:19:01 +03:00
|
|
|
mFileCreationPending.Put(aUUID, aHelper);
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvFileCreationResponse(const nsID& aUUID,
|
|
|
|
const FileCreationResult& aResult)
|
|
|
|
{
|
|
|
|
FileCreatorHelper* helper = mFileCreationPending.GetWeak(aUUID);
|
|
|
|
if (!helper) {
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aResult.type() == FileCreationResult::TFileCreationErrorResult) {
|
|
|
|
helper->ResponseReceived(nullptr,
|
|
|
|
aResult.get_FileCreationErrorResult().errorCode());
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aResult.type() == FileCreationResult::TFileCreationSuccessResult);
|
|
|
|
|
2017-04-24 13:16:50 +03:00
|
|
|
RefPtr<BlobImpl> impl =
|
|
|
|
IPCBlobUtils::Deserialize(aResult.get_FileCreationSuccessResult().blob());
|
2017-02-08 12:19:01 +03:00
|
|
|
helper->ResponseReceived(impl, NS_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
mFileCreationPending.Remove(aUUID);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-01-21 07:11:35 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvActivate(PBrowserChild* aTab)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvDeactivate(PBrowserChild* aTab)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvDeactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvParentActivated(PBrowserChild* aTab, const bool& aActivated)
|
|
|
|
{
|
|
|
|
TabChild* tab = static_cast<TabChild*>(aTab);
|
|
|
|
return tab->RecvParentActivated(aActivated);
|
|
|
|
}
|
|
|
|
|
2017-03-14 02:06:04 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvProvideAnonymousTemporaryFile(const uint64_t& aID,
|
|
|
|
const FileDescOrError& aFDOrError)
|
|
|
|
{
|
|
|
|
nsAutoPtr<AnonymousTemporaryFileCallback> callback;
|
2017-07-05 03:01:45 +03:00
|
|
|
mPendingAnonymousTemporaryFiles.Remove(aID, &callback);
|
2017-03-14 02:06:04 +03:00
|
|
|
MOZ_ASSERT(callback);
|
|
|
|
|
|
|
|
PRFileDesc* prfile = nullptr;
|
|
|
|
if (aFDOrError.type() == FileDescOrError::Tnsresult) {
|
|
|
|
DebugOnly<nsresult> rv = aFDOrError.get_nsresult();
|
|
|
|
MOZ_ASSERT(NS_FAILED(rv));
|
|
|
|
} else {
|
|
|
|
auto rawFD = aFDOrError.get_FileDescriptor().ClonePlatformHandle();
|
|
|
|
prfile = PR_ImportFile(PROsfd(rawFD.release()));
|
|
|
|
}
|
|
|
|
(*callback)(prfile);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-04-27 19:44:57 +03:00
|
|
|
ContentChild::AsyncOpenAnonymousTemporaryFile(const AnonymousTemporaryFileCallback& aCallback)
|
2017-03-14 02:06:04 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
static uint64_t id = 0;
|
|
|
|
auto newID = id++;
|
|
|
|
if (!SendRequestAnonymousTemporaryFile(newID)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember the association with the callback.
|
|
|
|
MOZ_ASSERT(!mPendingAnonymousTemporaryFiles.Get(newID));
|
|
|
|
mPendingAnonymousTemporaryFiles.LookupOrAdd(newID, aCallback);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-03 00:53:33 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvSetPermissionsWithKey(const nsCString& aPermissionKey,
|
|
|
|
nsTArray<IPC::Permission>&& aPerms)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManager =
|
|
|
|
services::GetPermissionManager();
|
|
|
|
permissionManager->SetPermissionsWithKey(aPermissionKey, aPerms);
|
2017-03-09 14:30:26 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-03-03 00:53:33 +03:00
|
|
|
|
2017-03-09 14:30:26 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvRefreshScreens(nsTArray<ScreenDetails>&& aScreens)
|
|
|
|
{
|
|
|
|
ScreenManager& screenManager = ScreenManager::GetSingleton();
|
|
|
|
screenManager.Refresh(Move(aScreens));
|
2017-03-03 00:53:33 +03:00
|
|
|
return IPC_OK();
|
|
|
|
}
|
2017-03-14 02:06:04 +03:00
|
|
|
|
2017-05-02 12:57:51 +03:00
|
|
|
already_AddRefed<nsIEventTarget>
|
|
|
|
ContentChild::GetEventTargetFor(TabChild* aTabChild)
|
|
|
|
{
|
|
|
|
return IToplevelProtocol::GetActorEventTarget(aTabChild);
|
|
|
|
}
|
|
|
|
|
2017-06-06 20:39:46 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvSetPluginList(const uint32_t& aPluginEpoch,
|
|
|
|
nsTArray<plugins::PluginTag>&& aPluginTags,
|
|
|
|
nsTArray<plugins::FakePluginTag>&& aFakePluginTags)
|
|
|
|
{
|
|
|
|
RefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
|
|
|
host->SetPluginsInContent(aPluginEpoch, aPluginTags, aFakePluginTags);
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2017-06-14 11:50:44 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvShareCodeCoverageMutex(const CrossProcessMutexHandle& aHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_CODE_COVERAGE
|
|
|
|
CodeCoverageHandler::Init(aHandle);
|
|
|
|
return IPC_OK();
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Shouldn't receive this message in non-code coverage builds!");
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-07-14 11:57:22 +03:00
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvDumpCodeCoverageCounters()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_CODE_COVERAGE
|
|
|
|
CodeCoverageHandler::DumpCounters(0);
|
|
|
|
return IPC_OK();
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Shouldn't receive this message in non-code coverage builds!");
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::ipc::IPCResult
|
|
|
|
ContentChild::RecvResetCodeCoverageCounters()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_CODE_COVERAGE
|
|
|
|
CodeCoverageHandler::ResetCounters(0);
|
|
|
|
return IPC_OK();
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Shouldn't receive this message in non-code coverage builds!");
|
|
|
|
return IPC_FAIL_NO_REASON(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-06-15 00:28:01 +03:00
|
|
|
already_AddRefed<nsIEventTarget>
|
|
|
|
ContentChild::GetSpecificMessageEventTarget(const Message& aMsg)
|
|
|
|
{
|
2017-07-05 08:32:54 +03:00
|
|
|
if (aMsg.type() == PJavaScript::Msg_DropTemporaryStrongReferences__ID
|
|
|
|
|| aMsg.type() == PJavaScript::Msg_DropObject__ID) {
|
2017-06-15 00:28:01 +03:00
|
|
|
return do_AddRef(SystemGroup::EventTargetFor(TaskCategory::Other));
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-05-12 18:51:08 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|