2009-08-18 23:05:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et 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-09-10 02:00:14 +04:00
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "base/basictypes.h"
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
#include "ContentParent.h"
|
2015-10-30 02:30:57 +03:00
|
|
|
#include "TabParent.h"
|
2012-08-02 10:02:29 +04:00
|
|
|
|
2012-07-18 03:59:44 +04:00
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
|
2014-04-04 00:19:00 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-03-21 16:50:07 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
|
2011-07-13 10:52:31 +04:00
|
|
|
#include "chrome/common/process_watcher.h"
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
#include <set>
|
|
|
|
|
2015-10-08 00:38:08 +03:00
|
|
|
#include "mozilla/a11y/PDocAccessible.h"
|
2012-12-22 15:53:38 +04:00
|
|
|
#include "AppProcessChecker.h"
|
2012-12-06 07:01:58 +04:00
|
|
|
#include "AudioChannelService.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "BlobParent.h"
|
2010-11-24 17:15:03 +03:00
|
|
|
#include "CrashReporterParent.h"
|
2015-02-10 13:49:03 +03:00
|
|
|
#include "GMPServiceParent.h"
|
2015-08-26 02:42:21 +03:00
|
|
|
#include "HandlerServiceParent.h"
|
2012-11-09 13:55:54 +04:00
|
|
|
#include "IHistory.h"
|
2015-04-17 04:27:13 +03:00
|
|
|
#include "imgIContainer.h"
|
2012-08-09 06:58:06 +04:00
|
|
|
#include "mozIApplication.h"
|
2012-08-16 05:46:03 +04:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2015-11-17 09:04:09 +03:00
|
|
|
#include "mozilla/CSSStyleSheet.h"
|
2015-10-30 22:30:00 +03:00
|
|
|
#include "mozilla/DataStorage.h"
|
2015-09-22 22:09:42 +03:00
|
|
|
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
|
2014-11-13 03:31:00 +03:00
|
|
|
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
|
2014-06-03 18:36:46 +04:00
|
|
|
#include "mozilla/dom/DataStoreService.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "mozilla/dom/DataTransfer.h"
|
2014-09-29 18:46:00 +04:00
|
|
|
#include "mozilla/dom/DOMStorageIPC.h"
|
|
|
|
#include "mozilla/dom/Element.h"
|
2014-10-08 20:15:23 +04:00
|
|
|
#include "mozilla/dom/File.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/dom/ExternalHelperAppParent.h"
|
2014-09-29 18:46:00 +04:00
|
|
|
#include "mozilla/dom/FileSystemRequestParent.h"
|
|
|
|
#include "mozilla/dom/GeolocationBinding.h"
|
2015-09-01 09:06:57 +03:00
|
|
|
#ifdef MOZ_EME
|
2015-09-01 08:31:48 +03:00
|
|
|
#include "mozilla/dom/MediaKeySystemAccess.h"
|
2015-09-01 09:06:57 +03:00
|
|
|
#endif
|
2015-10-23 00:10:14 +03:00
|
|
|
#include "mozilla/dom/Notification.h"
|
2015-07-31 10:25:27 +03:00
|
|
|
#include "mozilla/dom/NuwaParent.h"
|
2014-06-11 09:44:13 +04:00
|
|
|
#include "mozilla/dom/PContentBridgeParent.h"
|
2015-04-14 04:08:00 +03:00
|
|
|
#include "mozilla/dom/PContentPermissionRequestParent.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "mozilla/dom/PCycleCollectWithLogsParent.h"
|
2014-09-29 18:46:00 +04:00
|
|
|
#include "mozilla/dom/PFMRadioParent.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/dom/PMemoryReportRequestParent.h"
|
2015-04-24 02:41:00 +03:00
|
|
|
#include "mozilla/dom/ServiceWorkerRegistrar.h"
|
2012-09-13 20:37:14 +04:00
|
|
|
#include "mozilla/dom/bluetooth/PBluetoothParent.h"
|
2014-08-18 13:06:11 +04:00
|
|
|
#include "mozilla/dom/cellbroadcast/CellBroadcastParent.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
|
2015-01-07 11:58:35 +03:00
|
|
|
#include "mozilla/dom/icc/IccParent.h"
|
2015-09-09 14:15:14 +03:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
2014-09-21 11:24:42 +04:00
|
|
|
#include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
|
|
|
|
#include "mozilla/dom/mobilemessage/SmsParent.h"
|
2014-09-29 18:46:00 +04:00
|
|
|
#include "mozilla/dom/power/PowerManagerService.h"
|
2015-03-26 06:16:21 +03:00
|
|
|
#include "mozilla/dom/PresentationParent.h"
|
|
|
|
#include "mozilla/dom/PPresentationParent.h"
|
2015-11-22 12:43:55 +03:00
|
|
|
#include "mozilla/dom/quota/QuotaManagerService.h"
|
2013-09-07 10:19:53 +04:00
|
|
|
#include "mozilla/dom/telephony/TelephonyParent.h"
|
2014-03-10 16:36:12 +04:00
|
|
|
#include "mozilla/dom/time/DateCacheCleaner.h"
|
2014-09-26 09:00:24 +04:00
|
|
|
#include "mozilla/dom/voicemail/VoicemailParent.h"
|
2014-10-28 18:59:08 +03:00
|
|
|
#include "mozilla/embedding/printingui/PrintingParent.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/hal_sandbox/PHalParent.h"
|
2013-11-27 11:59:41 +04:00
|
|
|
#include "mozilla/ipc/BackgroundChild.h"
|
|
|
|
#include "mozilla/ipc/BackgroundParent.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ipc/FileDescriptorSetParent.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "mozilla/ipc/FileDescriptorUtils.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "mozilla/ipc/PFileDescriptorSetParent.h"
|
2009-08-12 22:31:48 +04:00
|
|
|
#include "mozilla/ipc/TestShellParent.h"
|
2013-08-16 21:59:31 +04:00
|
|
|
#include "mozilla/ipc/InputStreamUtils.h"
|
2015-01-27 00:32:18 +03:00
|
|
|
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2012-08-29 16:24:48 +04:00
|
|
|
#include "mozilla/layers/ImageBridgeParent.h"
|
2014-05-01 05:52:00 +04:00
|
|
|
#include "mozilla/layers/SharedBufferManagerParent.h"
|
2015-04-22 17:58:15 +03:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2015-06-18 18:46:36 +03:00
|
|
|
#include "mozilla/media/MediaParent.h"
|
2015-07-31 10:25:27 +03:00
|
|
|
#include "mozilla/Move.h"
|
2009-08-18 23:05:15 +04:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
2014-10-29 18:05:36 +03:00
|
|
|
#include "mozilla/plugins/PluginBridge.h"
|
2012-08-16 05:46:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2015-01-17 05:34:47 +03:00
|
|
|
#include "mozilla/ProcessHangMonitor.h"
|
|
|
|
#include "mozilla/ProcessHangMonitorIPC.h"
|
2015-06-14 03:55:33 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2015-06-11 00:58:30 +03:00
|
|
|
#include "mozilla/ProfileGatherer.h"
|
2015-06-14 03:55:33 +03:00
|
|
|
#endif
|
2012-08-16 05:46:03 +04:00
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
2014-12-12 22:13:28 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2015-09-21 15:54:00 +03:00
|
|
|
#include "mozilla/WebBrowserPersistDocumentParent.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "mozilla/unused.h"
|
2014-06-24 21:11:36 +04:00
|
|
|
#include "nsAnonymousTemporaryFile.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsAppRunner.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "nsAutoPtr.h"
|
2013-08-16 21:59:31 +04:00
|
|
|
#include "nsCDefaultURIFixup.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsCExternalHandlerService.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2010-03-11 08:33:00 +03:00
|
|
|
#include "nsChromeRegistryChrome.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsConsoleMessage.h"
|
2012-11-09 21:52:09 +04:00
|
|
|
#include "nsConsoleService.h"
|
2014-11-13 03:31:00 +03:00
|
|
|
#include "nsContentUtils.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsDebugImpl.h"
|
2010-08-31 22:58:35 +04:00
|
|
|
#include "nsFrameMessageManager.h"
|
2014-10-30 23:39:00 +03:00
|
|
|
#include "nsGeolocationSettings.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsHashPropertyBag.h"
|
2010-09-15 20:44:57 +04:00
|
|
|
#include "nsIAlertsService.h"
|
2013-04-26 04:53:26 +04:00
|
|
|
#include "nsIAppsService.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIClipboard.h"
|
2015-04-14 04:08:00 +03:00
|
|
|
#include "nsContentPermissionHelper.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "nsICycleCollectorListener.h"
|
2015-09-22 00:14:25 +03:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#include "nsIDocument.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIDOMGeoGeolocation.h"
|
2014-10-23 22:31:00 +04:00
|
|
|
#include "nsIDOMGeoPositionError.h"
|
2015-04-08 21:48:11 +03:00
|
|
|
#include "nsIDragService.h"
|
2014-08-01 22:02:55 +04:00
|
|
|
#include "mozilla/dom/WakeLock.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIExternalProtocolService.h"
|
2014-11-27 01:28:28 +03:00
|
|
|
#include "nsIFormProcessor.h"
|
2014-01-11 05:09:20 +04:00
|
|
|
#include "nsIGfxInfo.h"
|
2013-12-13 20:28:46 +04:00
|
|
|
#include "nsIIdleService.h"
|
2015-09-22 00:14:25 +03:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2014-05-13 21:13:00 +04:00
|
|
|
#include "nsIMemoryInfoDumper.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIMemoryReporter.h"
|
2013-02-15 00:41:30 +04:00
|
|
|
#include "nsIMozBrowserFrame.h"
|
2013-01-10 22:16:40 +04:00
|
|
|
#include "nsIMutable.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIPresShell.h"
|
2010-09-24 05:39:32 +04:00
|
|
|
#include "nsIScriptError.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2014-07-22 16:17:45 +04:00
|
|
|
#include "nsISiteSecurityService.h"
|
2014-10-03 18:52:37 +04:00
|
|
|
#include "nsISpellChecker.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsISupportsPrimitives.h"
|
2015-02-11 13:18:32 +03:00
|
|
|
#include "nsISystemMessagesInternal.h"
|
2015-01-07 08:42:23 +03:00
|
|
|
#include "nsITimer.h"
|
2013-08-16 21:59:31 +04:00
|
|
|
#include "nsIURIFixup.h"
|
2015-10-30 02:30:57 +03:00
|
|
|
#include "nsIWindowMediator.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIXULWindow.h"
|
|
|
|
#include "nsIDOMChromeWindow.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsIWindowWatcher.h"
|
2015-10-30 02:30:57 +03:00
|
|
|
#include "nsPIWindowWatcher.h"
|
|
|
|
#include "nsWindowWatcher.h"
|
2013-12-13 02:13:20 +04:00
|
|
|
#include "nsIXULRuntime.h"
|
2015-04-16 22:38:12 +03:00
|
|
|
#include "gfxDrawable.h"
|
|
|
|
#include "ImageOps.h"
|
2015-09-09 22:14:27 +03:00
|
|
|
#include "mozilla/dom/nsMixedContentBlocker.h"
|
2014-07-03 02:59:02 +04:00
|
|
|
#include "nsMemoryInfoDumper.h"
|
2013-10-23 09:26:24 +04:00
|
|
|
#include "nsMemoryReporterManager.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-08-27 21:10:39 +04:00
|
|
|
#include "nsStyleSheetService.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsToolkitCompsCID.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
2013-04-26 04:53:26 +04:00
|
|
|
#include "PreallocatedProcessManager.h"
|
|
|
|
#include "ProcessPriorityManager.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "SandboxHal.h"
|
2014-07-14 21:22:26 +04:00
|
|
|
#include "ScreenManagerParent.h"
|
2015-04-16 22:38:12 +03:00
|
|
|
#include "SourceSurfaceRawData.h"
|
2012-07-18 03:59:44 +04:00
|
|
|
#include "TabParent.h"
|
2012-08-23 23:33:46 +04:00
|
|
|
#include "URIUtils.h"
|
2013-05-07 08:10:31 +04:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
|
|
|
#include "nsIDocShell.h"
|
2015-04-29 11:57:24 +03:00
|
|
|
#include "nsDocShell.h"
|
2015-10-30 02:30:57 +03:00
|
|
|
#include "nsOpenURIInFrameParams.h"
|
2013-10-19 00:57:55 +04:00
|
|
|
#include "mozilla/net/NeckoMessageUtils.h"
|
2014-02-27 06:52:54 +04:00
|
|
|
#include "gfxPrefs.h"
|
2014-06-24 21:11:36 +04:00
|
|
|
#include "prio.h"
|
|
|
|
#include "private/pprio.h"
|
2014-10-29 21:11:00 +03:00
|
|
|
#include "ContentProcessManager.h"
|
2015-09-10 23:50:58 +03:00
|
|
|
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
2015-04-22 22:55:23 +03:00
|
|
|
#include "mozilla/psm/PSMContentListener.h"
|
2015-05-01 18:07:19 +03:00
|
|
|
#include "nsPluginHost.h"
|
|
|
|
#include "nsPluginTags.h"
|
|
|
|
#include "nsIBlocklistService.h"
|
2011-02-15 01:34:46 +03:00
|
|
|
|
2015-04-11 01:18:05 +03:00
|
|
|
#include "nsIBidiKeyboard.h"
|
|
|
|
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
|
|
|
#include "signaling/src/peerconnection/WebrtcGlobalParent.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-24 01:30:40 +04:00
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
#include "nsSystemInfo.h"
|
2010-10-09 22:07:38 +04:00
|
|
|
#endif
|
|
|
|
|
2014-05-21 09:49:36 +04:00
|
|
|
#if defined(XP_LINUX)
|
|
|
|
#include "mozilla/Hal.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-24 01:30:40 +04:00
|
|
|
#ifdef ANDROID
|
|
|
|
# include "gfxAndroidPlatform.h"
|
2010-11-24 16:58:21 +03:00
|
|
|
#endif
|
|
|
|
|
2012-07-18 03:59:44 +04:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
# include "nsPermissionManager.h"
|
|
|
|
#endif
|
2011-02-16 21:43:23 +03:00
|
|
|
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-18 03:59:44 +04:00
|
|
|
# include "AndroidBridge.h"
|
2011-01-13 07:04:42 +03:00
|
|
|
#endif
|
|
|
|
|
2012-08-04 03:48:58 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
#include "nsIVolume.h"
|
2014-09-15 22:51:25 +04:00
|
|
|
#include "nsVolumeService.h"
|
2012-08-04 03:48:58 +04:00
|
|
|
#include "nsIVolumeService.h"
|
2013-11-25 03:50:03 +04:00
|
|
|
#include "SpeakerManagerService.h"
|
2012-12-15 04:01:34 +04:00
|
|
|
using namespace mozilla::system;
|
2012-08-04 03:48:58 +04:00
|
|
|
#endif
|
|
|
|
|
2015-11-05 00:46:10 +03:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#endif
|
|
|
|
|
2012-09-13 20:37:14 +04:00
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
#include "BluetoothParent.h"
|
|
|
|
#include "BluetoothService.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-02 02:24:27 +04:00
|
|
|
#include "mozilla/RemoteSpellCheckEngineParent.h"
|
|
|
|
|
2013-09-04 02:28:06 +04:00
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
#include "mozilla/dom/FMRadioParent.h"
|
|
|
|
#endif
|
|
|
|
|
2013-02-28 00:31:19 +04:00
|
|
|
#include "Crypto.h"
|
|
|
|
|
2013-04-04 02:13:17 +04:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
#include "mozilla/dom/SpeechSynthesisParent.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
#ifdef ENABLE_TESTS
|
2014-04-01 06:55:36 +04:00
|
|
|
#include "BackgroundChildImpl.h"
|
2013-11-27 11:59:41 +04:00
|
|
|
#include "mozilla/ipc/PBackgroundChild.h"
|
|
|
|
#include "nsIIPCBackgroundChildCreateCallback.h"
|
|
|
|
#endif
|
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
|
2014-08-15 22:56:28 +04:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX)
|
2014-11-25 02:22:13 +03:00
|
|
|
#include "mozilla/SandboxInfo.h"
|
2015-10-08 08:13:09 +03:00
|
|
|
#include "mozilla/SandboxBroker.h"
|
|
|
|
#include "mozilla/SandboxBrokerPolicyFactory.h"
|
2014-08-15 22:56:28 +04:00
|
|
|
#endif
|
|
|
|
|
2014-09-11 17:50:55 +04:00
|
|
|
#ifdef MOZ_TOOLKIT_SEARCH
|
|
|
|
#include "nsIBrowserSearchService.h"
|
|
|
|
#endif
|
|
|
|
|
2014-11-18 20:50:25 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
#include "nsIProfiler.h"
|
|
|
|
#include "nsIProfileSaveEvent.h"
|
|
|
|
#endif
|
|
|
|
|
2015-04-24 01:05:29 +03:00
|
|
|
#ifdef MOZ_GAMEPAD
|
|
|
|
#include "mozilla/dom/GamepadMonitoring.h"
|
|
|
|
#endif
|
|
|
|
|
2011-03-01 08:36:43 +03:00
|
|
|
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
|
|
|
|
2012-12-20 11:41:08 +04:00
|
|
|
using base::ChildPrivileges;
|
2011-01-20 09:14:12 +03:00
|
|
|
using base::KillProcess;
|
2015-06-14 03:55:33 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2015-06-11 00:58:30 +03:00
|
|
|
using mozilla::ProfileGatherer;
|
2015-06-14 03:55:33 +03:00
|
|
|
#endif
|
2014-11-24 23:05:45 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
using namespace CrashReporter;
|
|
|
|
#endif
|
2012-09-13 20:37:14 +04:00
|
|
|
using namespace mozilla::dom::bluetooth;
|
2014-08-18 13:06:11 +04:00
|
|
|
using namespace mozilla::dom::cellbroadcast;
|
2012-06-20 03:14:39 +04:00
|
|
|
using namespace mozilla::dom::devicestorage;
|
2015-01-07 11:58:35 +03:00
|
|
|
using namespace mozilla::dom::icc;
|
2012-07-14 15:24:20 +04:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2014-08-01 22:02:55 +04:00
|
|
|
using namespace mozilla::dom::power;
|
2014-09-21 11:24:42 +04:00
|
|
|
using namespace mozilla::dom::mobileconnection;
|
2013-03-01 12:38:47 +04:00
|
|
|
using namespace mozilla::dom::mobilemessage;
|
2013-09-07 10:19:53 +04:00
|
|
|
using namespace mozilla::dom::telephony;
|
2014-09-26 09:00:24 +04:00
|
|
|
using namespace mozilla::dom::voicemail;
|
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;
|
2013-01-27 01:14:01 +04:00
|
|
|
using namespace mozilla::hal;
|
2012-07-18 03:59:44 +04:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
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;
|
2014-07-14 21:22:26 +04:00
|
|
|
using namespace mozilla::widget;
|
2009-09-03 04:18:27 +04:00
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
#ifdef ENABLE_TESTS
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class BackgroundTester final : public nsIIPCBackgroundChildCreateCallback,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIObserver
|
2013-11-27 11:59:41 +04:00
|
|
|
{
|
|
|
|
static uint32_t sCallbackCount;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~BackgroundTester()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ActorCreated(PBackgroundChild* aActor) override
|
2013-11-27 11:59:41 +04:00
|
|
|
{
|
|
|
|
MOZ_RELEASE_ASSERT(aActor,
|
|
|
|
"Failed to create a PBackgroundChild actor!");
|
|
|
|
|
|
|
|
NS_NAMED_LITERAL_CSTRING(testStr, "0123456789");
|
|
|
|
|
|
|
|
PBackgroundTestChild* testActor =
|
|
|
|
aActor->SendPBackgroundTestConstructor(testStr);
|
|
|
|
MOZ_RELEASE_ASSERT(testActor);
|
|
|
|
|
|
|
|
if (!sCallbackCount) {
|
|
|
|
PBackgroundChild* existingBackgroundChild =
|
|
|
|
BackgroundChild::GetForCurrentThread();
|
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(existingBackgroundChild);
|
|
|
|
MOZ_RELEASE_ASSERT(existingBackgroundChild == aActor);
|
|
|
|
|
|
|
|
bool ok =
|
|
|
|
existingBackgroundChild->
|
|
|
|
SendPBackgroundTestConstructor(testStr);
|
|
|
|
MOZ_RELEASE_ASSERT(ok);
|
|
|
|
|
|
|
|
// Callback 3.
|
|
|
|
ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
|
|
|
MOZ_RELEASE_ASSERT(ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
sCallbackCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
ActorFailed() override
|
2013-11-27 11:59:41 +04:00
|
|
|
{
|
|
|
|
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
|
2015-03-21 19:28:04 +03:00
|
|
|
override
|
2013-11-27 11:59:41 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
MOZ_RELEASE_ASSERT(observerService);
|
|
|
|
|
|
|
|
nsresult rv = observerService->RemoveObserver(this, aTopic);
|
|
|
|
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
if (!strcmp(aTopic, "profile-after-change")) {
|
|
|
|
if (mozilla::Preferences::GetBool("pbackground.testing", false)) {
|
|
|
|
rv = observerService->AddObserver(this, "xpcom-shutdown",
|
|
|
|
false);
|
|
|
|
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
// Callback 1.
|
|
|
|
bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
|
|
|
MOZ_RELEASE_ASSERT(ok);
|
|
|
|
|
2014-04-01 06:55:36 +04:00
|
|
|
BackgroundChildImpl::ThreadLocal* threadLocal =
|
|
|
|
BackgroundChildImpl::GetThreadLocalForCurrentThread();
|
|
|
|
MOZ_RELEASE_ASSERT(threadLocal);
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
// Callback 2.
|
|
|
|
ok = BackgroundChild::GetOrCreateForCurrentThread(this);
|
|
|
|
MOZ_RELEASE_ASSERT(ok);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp(aTopic, "xpcom-shutdown")) {
|
|
|
|
MOZ_RELEASE_ASSERT(sCallbackCount == 3);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_CRASH("Unknown observer topic!");
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t BackgroundTester::sCallbackCount = 0;
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(BackgroundTester, nsIIPCBackgroundChildCreateCallback,
|
|
|
|
nsIObserver)
|
2013-11-27 11:59:41 +04:00
|
|
|
|
|
|
|
#endif // ENABLE_TESTS
|
|
|
|
|
|
|
|
void
|
|
|
|
MaybeTestPBackground()
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_TESTS
|
|
|
|
// This test relies on running the event loop and XPCShell does not always
|
|
|
|
// do so. Bail out here if we detect that we're running in XPCShell.
|
|
|
|
if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is called too early at startup to test preferences directly. We have
|
|
|
|
// to install an observer to be notified when preferences are available.
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
MOZ_RELEASE_ASSERT(observerService);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserver> observer = new BackgroundTester();
|
|
|
|
nsresult rv = observerService->AddObserver(observer, "profile-after-change",
|
|
|
|
false);
|
|
|
|
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-11 13:47:11 +04:00
|
|
|
// XXX Workaround for bug 986973 to maintain the existing broken semantics
|
|
|
|
template<>
|
|
|
|
struct nsIConsoleService::COMTypeInfo<nsConsoleService, void> {
|
2014-06-02 16:08:24 +04:00
|
|
|
static const nsIID kIID;
|
2014-05-11 13:47:11 +04:00
|
|
|
};
|
|
|
|
const nsIID nsIConsoleService::COMTypeInfo<nsConsoleService, void>::kIID = NS_ICONSOLESERVICE_IID;
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-08-22 09:41:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2014-09-30 18:12:11 +04:00
|
|
|
int32_t ContentParent::sNuwaPid = 0;
|
2014-08-22 09:41:34 +04:00
|
|
|
bool ContentParent::sNuwaReady = false;
|
|
|
|
#endif
|
|
|
|
|
2010-05-11 21:22:34 +04:00
|
|
|
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
2015-05-02 00:14:39 +03:00
|
|
|
#define NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC "ipc:network:set-connectivity"
|
2010-05-11 16:44:12 +04:00
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
class MemoryReportRequestParent : public PMemoryReportRequestParent
|
|
|
|
{
|
|
|
|
public:
|
2015-04-27 22:44:00 +03:00
|
|
|
explicit MemoryReportRequestParent(uint32_t aGeneration);
|
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
virtual ~MemoryReportRequestParent();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-05-02 22:44:13 +04:00
|
|
|
|
2015-04-27 22:45:00 +03:00
|
|
|
virtual bool RecvReport(const MemoryReport& aReport) override;
|
|
|
|
virtual bool Recv__delete__() override;
|
2015-01-16 22:58:52 +03:00
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
private:
|
2015-04-27 22:44:00 +03:00
|
|
|
const uint32_t mGeneration;
|
2015-05-06 21:51:00 +03:00
|
|
|
// Non-null if we haven't yet called EndProcessReport() on it.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsMemoryReporterManager> mReporterManager;
|
2015-04-27 22:44:00 +03:00
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
ContentParent* Owner()
|
|
|
|
{
|
|
|
|
return static_cast<ContentParent*>(Manager());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-04-27 22:44:00 +03:00
|
|
|
MemoryReportRequestParent::MemoryReportRequestParent(uint32_t aGeneration)
|
|
|
|
: mGeneration(aGeneration)
|
2011-02-16 21:43:23 +03:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryReportRequestParent);
|
2015-04-27 22:45:00 +03:00
|
|
|
mReporterManager = nsMemoryReporterManager::GetOrCreate();
|
|
|
|
NS_WARN_IF(!mReporterManager);
|
2011-02-16 21:43:23 +03:00
|
|
|
}
|
|
|
|
|
2015-04-27 22:45:00 +03:00
|
|
|
bool
|
|
|
|
MemoryReportRequestParent::RecvReport(const MemoryReport& aReport)
|
2014-05-02 22:44:13 +04:00
|
|
|
{
|
2015-04-27 22:45:00 +03:00
|
|
|
if (mReporterManager) {
|
|
|
|
mReporterManager->HandleChildReport(mGeneration, aReport);
|
|
|
|
}
|
|
|
|
return true;
|
2014-05-02 22:44:13 +04:00
|
|
|
}
|
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
bool
|
2015-04-27 22:45:00 +03:00
|
|
|
MemoryReportRequestParent::Recv__delete__()
|
2011-02-16 21:43:23 +03:00
|
|
|
{
|
2015-04-27 22:45:00 +03:00
|
|
|
// Notifying the reporter manager is done in ActorDestroy, because
|
|
|
|
// it needs to happen even if the child process exits mid-report.
|
|
|
|
// (The reporter manager will time out eventually, but let's avoid
|
|
|
|
// that if possible.)
|
2011-02-16 21:43:23 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-27 22:45:00 +03:00
|
|
|
void
|
|
|
|
MemoryReportRequestParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
if (mReporterManager) {
|
2015-05-06 21:51:00 +03:00
|
|
|
mReporterManager->EndProcessReport(mGeneration, aWhy == Deletion);
|
2015-04-27 22:45:00 +03:00
|
|
|
mReporterManager = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
MemoryReportRequestParent::~MemoryReportRequestParent()
|
|
|
|
{
|
2015-04-27 22:45:00 +03:00
|
|
|
MOZ_ASSERT(!mReporterManager);
|
2011-02-16 21:43:23 +03:00
|
|
|
MOZ_COUNT_DTOR(MemoryReportRequestParent);
|
|
|
|
}
|
|
|
|
|
2014-05-13 21:13:00 +04:00
|
|
|
// IPC receiver for remote GC/CC logging.
|
2015-03-21 19:28:04 +03:00
|
|
|
class CycleCollectWithLogsParent final : public PCycleCollectWithLogsParent
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CycleCollectWithLogsParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CycleCollectWithLogsParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool AllocAndSendConstructor(ContentParent* aManager,
|
|
|
|
bool aDumpAllTraces,
|
|
|
|
nsICycleCollectorLogSink* aSink,
|
|
|
|
nsIDumpGCAndCCLogsCallback* aCallback)
|
|
|
|
{
|
|
|
|
CycleCollectWithLogsParent *actor;
|
|
|
|
FILE* gcLog;
|
|
|
|
FILE* ccLog;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
actor = new CycleCollectWithLogsParent(aSink, aCallback);
|
|
|
|
rv = actor->mSink->Open(&gcLog, &ccLog);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
delete actor;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aManager->
|
|
|
|
SendPCycleCollectWithLogsConstructor(actor,
|
|
|
|
aDumpAllTraces,
|
|
|
|
FILEToFileDescriptor(gcLog),
|
|
|
|
FILEToFileDescriptor(ccLog));
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RecvCloseGCLog() override
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << mSink->CloseGCLog();
|
2014-05-13 21:13:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool RecvCloseCCLog() override
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << mSink->CloseCCLog();
|
2014-05-13 21:13:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool Recv__delete__() override
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
|
|
|
// Report completion to mCallback only on successful
|
|
|
|
// completion of the protocol.
|
|
|
|
nsCOMPtr<nsIFile> gcLog, ccLog;
|
|
|
|
mSink->GetGcLog(getter_AddRefs(gcLog));
|
|
|
|
mSink->GetCcLog(getter_AddRefs(ccLog));
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << mCallback->OnDump(gcLog, ccLog, /* parent = */ false);
|
2014-05-13 21:13:00 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActorDestroy(ActorDestroyReason aReason) override
|
2014-05-13 21:13:00 +04:00
|
|
|
{
|
|
|
|
// If the actor is unexpectedly destroyed, we deliberately
|
|
|
|
// don't call Close[GC]CLog on the sink, because the logs may
|
|
|
|
// be incomplete. See also the nsCycleCollectorLogSinkToFile
|
|
|
|
// implementaiton of those methods, and its destructor.
|
|
|
|
}
|
|
|
|
|
|
|
|
CycleCollectWithLogsParent(nsICycleCollectorLogSink *aSink,
|
|
|
|
nsIDumpGCAndCCLogsCallback *aCallback)
|
|
|
|
: mSink(aSink), mCallback(aCallback)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CycleCollectWithLogsParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsICycleCollectorLogSink> mSink;
|
|
|
|
nsCOMPtr<nsIDumpGCAndCCLogsCallback> mCallback;
|
|
|
|
};
|
|
|
|
|
2013-11-06 07:58:20 +04:00
|
|
|
// A memory reporter for ContentParent objects themselves.
|
2015-03-21 19:28:04 +03:00
|
|
|
class ContentParentsMemoryReporter final : public nsIMemoryReporter
|
2013-07-18 01:31:10 +04:00
|
|
|
{
|
2014-06-23 23:56:07 +04:00
|
|
|
~ContentParentsMemoryReporter() {}
|
2013-07-18 01:31:10 +04:00
|
|
|
public:
|
2013-12-08 09:39:47 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
2013-11-06 07:58:20 +04:00
|
|
|
};
|
2013-12-08 09:39:47 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ContentParentsMemoryReporter, nsIMemoryReporter)
|
2013-07-18 01:31:10 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2013-11-06 07:58:20 +04:00
|
|
|
ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
2014-05-21 10:06:54 +04:00
|
|
|
nsISupports* aClosure,
|
|
|
|
bool aAnonymize)
|
2013-07-18 01:31:10 +04:00
|
|
|
{
|
|
|
|
nsAutoTArray<ContentParent*, 16> cps;
|
|
|
|
ContentParent::GetAllEvenIfDead(cps);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < cps.Length(); i++) {
|
|
|
|
ContentParent* cp = cps[i];
|
2013-09-28 05:42:08 +04:00
|
|
|
MessageChannel* channel = cp->GetIPCChannel();
|
2013-07-18 01:31:10 +04:00
|
|
|
|
|
|
|
nsString friendlyName;
|
2014-05-21 10:06:54 +04:00
|
|
|
cp->FriendlyName(friendlyName, aAnonymize);
|
2013-07-18 01:31:10 +04:00
|
|
|
|
|
|
|
cp->AddRef();
|
|
|
|
nsrefcnt refcnt = cp->Release();
|
|
|
|
|
|
|
|
const char* channelStr = "no channel";
|
|
|
|
uint32_t numQueuedMessages = 0;
|
|
|
|
if (channel) {
|
|
|
|
if (channel->Unsound_IsClosed()) {
|
|
|
|
channelStr = "closed channel";
|
|
|
|
} else {
|
|
|
|
channelStr = "open channel";
|
|
|
|
}
|
|
|
|
numQueuedMessages = channel->Unsound_NumQueuedMessages();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintfCString path("queued-ipc-messages/content-parent"
|
|
|
|
"(%s, pid=%d, %s, 0x%p, refcnt=%d)",
|
|
|
|
NS_ConvertUTF16toUTF8(friendlyName).get(),
|
2014-06-11 09:44:03 +04:00
|
|
|
cp->Pid(), channelStr,
|
|
|
|
static_cast<nsIContentParent*>(cp), refcnt);
|
2013-07-18 01:31:10 +04:00
|
|
|
|
|
|
|
NS_NAMED_LITERAL_CSTRING(desc,
|
|
|
|
"The number of unset IPC messages held in this ContentParent's "
|
|
|
|
"channel. A large value here might indicate that we're leaking "
|
|
|
|
"messages. Similarly, a ContentParent object for a process that's no "
|
|
|
|
"longer running could indicate that we're leaking ContentParents.");
|
|
|
|
|
|
|
|
nsresult rv = cb->Callback(/* process */ EmptyCString(),
|
|
|
|
path,
|
2013-12-11 23:59:39 +04:00
|
|
|
KIND_OTHER,
|
|
|
|
UNITS_COUNT,
|
2013-07-18 01:31:10 +04:00
|
|
|
numQueuedMessages,
|
|
|
|
desc,
|
|
|
|
aClosure);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
|
|
|
|
nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
|
|
|
|
nsTArray<ContentParent*>* ContentParent::sPrivateContent;
|
2013-07-18 01:31:10 +04:00
|
|
|
StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
|
2015-10-08 08:13:09 +03:00
|
|
|
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
UniquePtr<SandboxBrokerPolicyFactory> ContentParent::sSandboxBrokerPolicyFactory;
|
|
|
|
#endif
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2014-05-09 15:30:42 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// The pref updates sent to the Nuwa process.
|
|
|
|
static nsTArray<PrefSetting>* sNuwaPrefUpdates;
|
|
|
|
#endif
|
|
|
|
|
2012-12-28 13:45:16 +04:00
|
|
|
// This is true when subprocess launching is enabled. This is the
|
|
|
|
// case between StartUp() and ShutDown() or JoinAllSubprocesses().
|
|
|
|
static bool sCanLaunchSubprocesses;
|
|
|
|
|
2015-04-10 18:56:49 +03:00
|
|
|
// Set to true if the DISABLE_UNSAFE_CPOW_WARNINGS environment variable is
|
|
|
|
// set.
|
|
|
|
static bool sDisableUnsafeCPOWWarnings = false;
|
|
|
|
|
2011-09-30 11:00:48 +04:00
|
|
|
// The first content child has ID 1, so the chrome process can have ID 0.
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint64_t gContentChildID = 1;
|
2011-09-30 11:00:48 +04:00
|
|
|
|
2012-08-16 05:46:03 +04:00
|
|
|
// We want the prelaunched process to know that it's for apps, but not
|
|
|
|
// actually for any app in particular. Use a magic manifest URL.
|
|
|
|
// Can't be a static constant.
|
|
|
|
#define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
|
|
|
|
|
2014-02-13 10:55:28 +04:00
|
|
|
static const char* sObserverTopics[] = {
|
|
|
|
"xpcom-shutdown",
|
2015-01-10 21:42:10 +03:00
|
|
|
"profile-before-change",
|
2014-02-13 10:55:28 +04:00
|
|
|
NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC,
|
2015-05-02 00:14:39 +03:00
|
|
|
NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC,
|
2014-02-13 10:55:28 +04:00
|
|
|
"memory-pressure",
|
|
|
|
"child-gc-request",
|
|
|
|
"child-cc-request",
|
|
|
|
"child-mmu-request",
|
|
|
|
"last-pb-context-exited",
|
|
|
|
"file-watcher-update",
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
NS_VOLUME_STATE_CHANGED,
|
2015-05-04 09:11:00 +03:00
|
|
|
NS_VOLUME_REMOVED,
|
2014-02-13 10:55:28 +04:00
|
|
|
"phone-state-changed",
|
|
|
|
#endif
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
"a11y-init-or-shutdown",
|
|
|
|
#endif
|
2014-08-29 04:20:27 +04:00
|
|
|
"app-theme-changed",
|
2014-11-18 20:50:25 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
"profiler-started",
|
|
|
|
"profiler-stopped",
|
2015-07-15 19:39:39 +03:00
|
|
|
"profiler-paused",
|
|
|
|
"profiler-resumed",
|
2015-06-11 00:58:30 +03:00
|
|
|
"profiler-subprocess-gather",
|
2014-11-18 20:50:25 +03:00
|
|
|
"profiler-subprocess",
|
|
|
|
#endif
|
2015-10-29 11:56:12 +03:00
|
|
|
"gmp-changed",
|
2014-02-13 10:55:28 +04:00
|
|
|
};
|
|
|
|
|
2015-08-14 10:41:54 +03:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Contains the observer topics that can be sent to the Nuwa process after it
|
|
|
|
// becomes ready. The ContentParent instance will unregister sObserverTopics
|
|
|
|
// if not listed in sNuwaSafeObserverTopics.
|
|
|
|
static const char* sNuwaSafeObserverTopics[] = {
|
|
|
|
"xpcom-shutdown",
|
|
|
|
"profile-before-change",
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
"phone-state-changed",
|
|
|
|
#endif
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
"a11y-init-or-shutdown",
|
|
|
|
#endif
|
|
|
|
"nsPref:Changed"
|
|
|
|
};
|
|
|
|
#endif
|
2013-11-22 07:25:34 +04:00
|
|
|
/* static */ already_AddRefed<ContentParent>
|
2013-06-03 14:14:40 +04:00
|
|
|
ContentParent::RunNuwaProcess()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> nuwaProcess =
|
2013-06-03 14:14:40 +04:00
|
|
|
new ContentParent(/* aApp = */ nullptr,
|
2014-06-11 09:44:13 +04:00
|
|
|
/* aOpener = */ nullptr,
|
2013-06-03 14:14:40 +04:00
|
|
|
/* aIsForBrowser = */ false,
|
|
|
|
/* aIsForPreallocated = */ true,
|
|
|
|
/* aIsNuwaProcess = */ true);
|
2015-05-11 10:24:40 +03:00
|
|
|
|
|
|
|
if (!nuwaProcess->LaunchSubprocess(PROCESS_PRIORITY_BACKGROUND)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
nuwaProcess->Init();
|
2014-08-22 09:41:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2014-09-30 18:12:11 +04:00
|
|
|
sNuwaPid = nuwaProcess->Pid();
|
2014-08-22 09:41:34 +04:00
|
|
|
sNuwaReady = false;
|
|
|
|
#endif
|
2013-11-22 07:25:34 +04:00
|
|
|
return nuwaProcess.forget();
|
2013-06-03 14:14:40 +04:00
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
// PreallocateAppProcess is called by the PreallocatedProcessManager.
|
|
|
|
// ContentParent then takes this process back within
|
2014-08-13 10:18:00 +04:00
|
|
|
// GetNewOrPreallocatedAppProcess.
|
2013-04-26 04:53:26 +04:00
|
|
|
/*static*/ already_AddRefed<ContentParent>
|
2012-08-16 05:46:03 +04:00
|
|
|
ContentParent::PreallocateAppProcess()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> process =
|
2013-04-26 04:53:26 +04:00
|
|
|
new ContentParent(/* app = */ nullptr,
|
2014-06-11 09:44:13 +04:00
|
|
|
/* aOpener = */ nullptr,
|
2013-04-26 04:53:26 +04:00
|
|
|
/* isForBrowserElement = */ false,
|
2015-05-11 10:24:40 +03:00
|
|
|
/* isForPreallocated = */ true);
|
|
|
|
|
|
|
|
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
process->Init();
|
|
|
|
return process.forget();
|
2012-08-16 05:46:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ already_AddRefed<ContentParent>
|
2014-08-13 10:18:00 +04:00
|
|
|
ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
|
|
|
|
ProcessPriority aInitialPriority,
|
|
|
|
ContentParent* aOpener,
|
|
|
|
/*out*/ bool* aTookPreAllocated)
|
2012-08-16 05:46:03 +04:00
|
|
|
{
|
2014-08-13 10:18:00 +04:00
|
|
|
MOZ_ASSERT(aApp);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
|
2014-08-13 10:18:00 +04:00
|
|
|
|
|
|
|
if (process) {
|
|
|
|
if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
|
|
|
|
// Kill the process just in case it's not actually dead; we don't want
|
|
|
|
// to "leak" this process!
|
2015-02-03 20:09:27 +03:00
|
|
|
process->KillHard("GetNewOrPreallocatedAppProcess");
|
2014-08-13 10:18:00 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsAutoString manifestURL;
|
|
|
|
if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
|
|
|
|
NS_ERROR("Failed to get manifest URL");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-09-09 12:57:53 +04:00
|
|
|
process->TransformPreallocatedIntoApp(aOpener,
|
|
|
|
manifestURL);
|
2015-01-28 08:52:46 +03:00
|
|
|
process->ForwardKnownInfo();
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
if (aTookPreAllocated) {
|
|
|
|
*aTookPreAllocated = true;
|
|
|
|
}
|
|
|
|
return process.forget();
|
|
|
|
}
|
2013-02-08 18:32:23 +04:00
|
|
|
}
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
// XXXkhuey Nuwa wants the frame loader to try again later, but the
|
|
|
|
// frame loader is really not set up to do that ...
|
|
|
|
NS_WARNING("Unable to use pre-allocated app process");
|
|
|
|
process = new ContentParent(aApp,
|
|
|
|
/* aOpener = */ aOpener,
|
|
|
|
/* isForBrowserElement = */ false,
|
2015-05-11 10:24:40 +03:00
|
|
|
/* isForPreallocated = */ false);
|
|
|
|
|
|
|
|
if (!process->LaunchSubprocess(aInitialPriority)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
process->Init();
|
2015-01-28 08:52:46 +03:00
|
|
|
process->ForwardKnownInfo();
|
2014-08-13 10:18:00 +04:00
|
|
|
|
|
|
|
if (aTookPreAllocated) {
|
|
|
|
*aTookPreAllocated = false;
|
2013-02-08 18:32:23 +04:00
|
|
|
}
|
|
|
|
|
2012-08-16 05:46:03 +04:00
|
|
|
return process.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::StartUp()
|
|
|
|
{
|
2014-06-18 21:22:05 +04:00
|
|
|
// We could launch sub processes from content process
|
|
|
|
// FIXME Bug 1023701 - Stop using ContentParent static methods in
|
|
|
|
// child process
|
|
|
|
sCanLaunchSubprocesses = true;
|
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (!XRE_IsParentProcess()) {
|
2014-06-18 21:22:05 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-15 22:56:28 +04:00
|
|
|
#if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
|
|
|
|
// Require sandboxing on B2G >= KitKat. This condition must stay
|
|
|
|
// in sync with ContentChild::RecvSetProcessSandbox.
|
2014-11-25 02:22:13 +03:00
|
|
|
if (!SandboxInfo::Get().CanSandboxContent()) {
|
2014-08-15 22:56:28 +04:00
|
|
|
// MOZ_CRASH strings are only for debug builds; make sure the
|
|
|
|
// message is clear on non-debug builds as well:
|
|
|
|
printf_stderr("Sandboxing support is required on this platform. "
|
|
|
|
"Recompile kernel with CONFIG_SECCOMP_FILTER=y\n");
|
|
|
|
MOZ_CRASH("Sandboxing support is required on this platform.");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-11-07 09:35:30 +04:00
|
|
|
// Note: This reporter measures all ContentParents.
|
|
|
|
RegisterStrongMemoryReporter(new ContentParentsMemoryReporter());
|
2013-07-18 01:31:10 +04:00
|
|
|
|
2014-03-10 16:36:12 +04:00
|
|
|
mozilla::dom::time::InitializeDateCacheCleaner();
|
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
BlobParent::Startup(BlobParent::FriendKey());
|
|
|
|
|
2014-06-18 21:22:05 +04:00
|
|
|
BackgroundChild::Startup();
|
2013-11-27 11:59:41 +04:00
|
|
|
|
2014-06-18 21:22:05 +04:00
|
|
|
// Try to preallocate a process that we can transform into an app later.
|
|
|
|
PreallocatedProcessManager::AllocateAfterDelay();
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2014-06-18 21:22:05 +04:00
|
|
|
// Test the PBackground infrastructure on ENABLE_TESTS builds when a special
|
|
|
|
// testing preference is set.
|
|
|
|
MaybeTestPBackground();
|
2015-04-10 18:56:49 +03:00
|
|
|
|
|
|
|
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
|
2015-10-08 08:13:09 +03:00
|
|
|
|
|
|
|
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
sSandboxBrokerPolicyFactory = MakeUnique<SandboxBrokerPolicyFactory>();
|
|
|
|
#endif
|
2012-08-16 05:46:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::ShutDown()
|
|
|
|
{
|
|
|
|
// No-op for now. We rely on normal process shutdown and
|
|
|
|
// ClearOnShutdown() to clean up our state.
|
2012-12-28 13:45:16 +04:00
|
|
|
sCanLaunchSubprocesses = false;
|
2015-10-08 08:13:09 +03:00
|
|
|
|
|
|
|
#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
|
|
|
|
sSandboxBrokerPolicyFactory = nullptr;
|
|
|
|
#endif
|
2012-12-28 13:45:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
|
|
|
|
Monitor* aMonitor, bool* aDone)
|
|
|
|
{
|
|
|
|
const nsTArray<ContentParent*>& processes = *aProcesses;
|
|
|
|
for (uint32_t i = 0; i < processes.Length(); ++i) {
|
|
|
|
if (GeckoChildProcessHost* process = processes[i]->mSubprocess) {
|
|
|
|
process->Join();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(*aMonitor);
|
|
|
|
*aDone = true;
|
|
|
|
lock.Notify();
|
|
|
|
}
|
|
|
|
// Don't touch any arguments to this function from now on.
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::JoinAllSubprocesses()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsAutoTArray<ContentParent*, 8> processes;
|
|
|
|
GetAll(processes);
|
|
|
|
if (processes.IsEmpty()) {
|
|
|
|
printf_stderr("There are no live subprocesses.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf_stderr("Subprocesses are still alive. Doing emergency join.\n");
|
|
|
|
|
|
|
|
bool done = false;
|
|
|
|
Monitor monitor("mozilla.dom.ContentParent.JoinAllSubprocesses");
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(
|
|
|
|
&ContentParent::JoinProcessesIOThread,
|
|
|
|
&processes, &monitor, &done));
|
|
|
|
{
|
|
|
|
MonitorAutoLock lock(monitor);
|
|
|
|
while (!done) {
|
|
|
|
lock.Wait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sCanLaunchSubprocesses = false;
|
2012-08-16 05:46:03 +04:00
|
|
|
}
|
|
|
|
|
2013-04-03 03:52:51 +04:00
|
|
|
/*static*/ already_AddRefed<ContentParent>
|
2014-08-13 10:18:00 +04:00
|
|
|
ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
|
|
|
ProcessPriority aPriority,
|
|
|
|
ContentParent* aOpener)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2013-04-26 04:53:26 +04:00
|
|
|
if (!sNonAppContentParents)
|
|
|
|
sNonAppContentParents = new nsTArray<ContentParent*>();
|
2011-08-02 23:35:42 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
|
2011-08-02 23:35:42 +04:00
|
|
|
if (maxContentProcesses < 1)
|
|
|
|
maxContentProcesses = 1;
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
if (sNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
|
2014-06-11 09:44:13 +04:00
|
|
|
uint32_t startIdx = rand() % sNonAppContentParents->Length();
|
|
|
|
uint32_t currIdx = startIdx;
|
|
|
|
do {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> p = (*sNonAppContentParents)[currIdx];
|
2014-06-11 09:44:13 +04:00
|
|
|
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
|
|
|
|
if (p->mOpener == aOpener) {
|
|
|
|
return p.forget();
|
|
|
|
}
|
|
|
|
currIdx = (currIdx + 1) % sNonAppContentParents->Length();
|
|
|
|
} while (currIdx != startIdx);
|
2011-03-26 23:16:45 +03:00
|
|
|
}
|
2012-08-09 06:58:06 +04:00
|
|
|
|
2014-02-13 14:42:41 +04:00
|
|
|
// Try to take and transform the preallocated process into browser.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
|
2014-02-13 14:42:41 +04:00
|
|
|
if (p) {
|
2014-09-09 12:57:53 +04:00
|
|
|
p->TransformPreallocatedIntoBrowser(aOpener);
|
2014-02-13 14:42:41 +04:00
|
|
|
} else {
|
|
|
|
// Failed in using the preallocated process: fork from the chrome process.
|
|
|
|
p = new ContentParent(/* app = */ nullptr,
|
2014-06-11 09:44:13 +04:00
|
|
|
aOpener,
|
2014-02-13 14:42:41 +04:00
|
|
|
aForBrowserElement,
|
2015-05-11 10:24:40 +03:00
|
|
|
/* isForPreallocated = */ false);
|
|
|
|
|
|
|
|
if (!p->LaunchSubprocess(aPriority)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-04-30 10:00:00 +04:00
|
|
|
p->Init();
|
2014-02-13 14:42:41 +04:00
|
|
|
}
|
2015-01-28 08:52:46 +03:00
|
|
|
p->ForwardKnownInfo();
|
2014-02-13 14:42:41 +04:00
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
sNonAppContentParents->AppendElement(p);
|
2013-04-03 03:52:51 +04:00
|
|
|
return p.forget();
|
2011-08-02 23:35:42 +04:00
|
|
|
}
|
2010-12-26 23:03:52 +03:00
|
|
|
|
2013-02-15 00:41:30 +04:00
|
|
|
/*static*/ ProcessPriority
|
2013-07-24 03:39:17 +04:00
|
|
|
ContentParent::GetInitialProcessPriority(Element* aFrameElement)
|
2013-02-15 00:41:30 +04:00
|
|
|
{
|
|
|
|
// Frames with mozapptype == critical which are expecting a system message
|
2013-09-24 12:10:20 +04:00
|
|
|
// get FOREGROUND_HIGH priority.
|
2013-02-15 00:41:30 +04:00
|
|
|
|
|
|
|
if (!aFrameElement) {
|
|
|
|
return PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
}
|
|
|
|
|
2013-09-24 12:10:20 +04:00
|
|
|
if (aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
|
2014-05-30 17:29:43 +04:00
|
|
|
NS_LITERAL_STRING("inputmethod"), eCaseMatters)) {
|
2013-09-24 12:10:20 +04:00
|
|
|
return PROCESS_PRIORITY_FOREGROUND_KEYBOARD;
|
|
|
|
} else if (!aFrameElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::mozapptype,
|
|
|
|
NS_LITERAL_STRING("critical"), eCaseMatters)) {
|
2013-02-15 00:41:30 +04:00
|
|
|
return PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMozBrowserFrame> browserFrame =
|
|
|
|
do_QueryInterface(aFrameElement);
|
|
|
|
if (!browserFrame) {
|
|
|
|
return PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return browserFrame->GetIsExpectingSystemMessage() ?
|
|
|
|
PROCESS_PRIORITY_FOREGROUND_HIGH :
|
|
|
|
PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
}
|
|
|
|
|
2015-04-07 16:17:27 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
extern const wchar_t* kPluginWidgetContentParentProperty;
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
|
|
|
|
{
|
|
|
|
if (!aWidget || aWidget->Destroyed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Fire off an async request to the plugin to paint its window
|
|
|
|
HWND hwnd = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW);
|
|
|
|
NS_ASSERTION(hwnd, "Expected valid hwnd value.");
|
|
|
|
ContentParent* cp = reinterpret_cast<ContentParent*>(
|
|
|
|
::GetPropW(hwnd, kPluginWidgetContentParentProperty));
|
|
|
|
if (cp && !cp->IsDestroyed()) {
|
|
|
|
cp->SendUpdateWindow((uintptr_t)hwnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // defined(XP_WIN)
|
|
|
|
|
2013-11-19 15:03:30 +04:00
|
|
|
bool
|
|
|
|
ContentParent::PreallocatedProcessReady()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
return PreallocatedProcessManager::PreallocatedProcessReady();
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
|
|
|
|
const hal::ProcessPriority& aPriority,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aOpenerTabId,
|
|
|
|
ContentParentId* aCpId,
|
2014-06-11 09:44:13 +04:00
|
|
|
bool* aIsForApp,
|
2014-10-29 21:11:00 +03:00
|
|
|
bool* aIsForBrowser,
|
|
|
|
TabId* aTabId)
|
2014-06-11 09:44:13 +04:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if (!CanOpenBrowser(aContext)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> cp;
|
2014-08-13 10:18:00 +04:00
|
|
|
MaybeInvalidTabContext tc(aContext);
|
|
|
|
if (!tc.IsValid()) {
|
|
|
|
NS_ERROR(nsPrintfCString("Received an invalid TabContext from "
|
|
|
|
"the child process. (%s)",
|
|
|
|
tc.GetInvalidReason()).get());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
|
|
|
|
if (ownApp) {
|
|
|
|
cp = GetNewOrPreallocatedAppProcess(ownApp,
|
|
|
|
aPriority,
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
|
|
|
|
aPriority,
|
|
|
|
this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cp) {
|
2014-10-29 21:11:00 +03:00
|
|
|
*aCpId = 0;
|
2014-09-09 12:57:51 +04:00
|
|
|
*aIsForApp = false;
|
|
|
|
*aIsForBrowser = false;
|
|
|
|
return true;
|
2014-08-13 10:18:00 +04:00
|
|
|
}
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
*aCpId = cp->ChildID();
|
2014-06-11 09:44:13 +04:00
|
|
|
*aIsForApp = cp->IsForApp();
|
|
|
|
*aIsForBrowser = cp->IsForBrowser();
|
2014-10-29 21:11:00 +03:00
|
|
|
|
|
|
|
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
|
|
|
|
cpm->AddContentProcess(cp, this->ChildID());
|
|
|
|
|
|
|
|
if (cpm->AddGrandchildProcess(this->ChildID(), cp->ChildID())) {
|
|
|
|
// Pre-allocate a TabId here to save one time IPC call at app startup.
|
|
|
|
*aTabId = AllocateTabId(aOpenerTabId,
|
|
|
|
aContext,
|
|
|
|
cp->ChildID());
|
|
|
|
return (*aTabId != 0);
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
|
|
|
|
return false;
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-12-19 04:35:48 +03:00
|
|
|
ContentParent::RecvBridgeToChildProcess(const ContentParentId& aCpId)
|
2014-10-24 10:29:00 +04:00
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
|
|
|
|
ContentParent* cp = cpm->GetContentProcessById(aCpId);
|
|
|
|
|
|
|
|
if (cp) {
|
|
|
|
ContentParentId parentId;
|
|
|
|
if (cpm->GetParentProcessId(cp->ChildID(), &parentId) &&
|
|
|
|
parentId == this->ChildID()) {
|
2015-07-10 03:07:49 +03:00
|
|
|
return NS_SUCCEEDED(PContentBridge::Bridge(this, cp));
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// You can't bridge to a process you didn't open!
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard("BridgeToChildProcess");
|
2014-10-29 21:11:00 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsIDocShell* GetOpenerDocShellHelper(Element* aFrameElement)
|
|
|
|
{
|
|
|
|
// Propagate the private-browsing status of the element's parent
|
|
|
|
// docshell to the remote docshell, via the chrome flags.
|
|
|
|
nsCOMPtr<Element> frameElement = do_QueryInterface(aFrameElement);
|
|
|
|
MOZ_ASSERT(frameElement);
|
|
|
|
nsPIDOMWindow* win = frameElement->OwnerDoc()->GetWindow();
|
|
|
|
if (!win) {
|
|
|
|
NS_WARNING("Remote frame has no window");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
nsIDocShell* docShell = win->GetDocShell();
|
|
|
|
if (!docShell) {
|
|
|
|
NS_WARNING("Remote frame has no docshell");
|
|
|
|
return nullptr;
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
|
|
|
|
return docShell;
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
|
2015-02-10 13:49:03 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvCreateGMPService()
|
|
|
|
{
|
|
|
|
return PGMPService::Open(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvGetGMPPluginVersionForAPI(const nsCString& aAPI,
|
|
|
|
nsTArray<nsCString>&& aTags,
|
|
|
|
bool* aHasVersion,
|
|
|
|
nsCString* aVersion)
|
|
|
|
{
|
|
|
|
return GMPServiceParent::RecvGetGMPPluginVersionForAPI(aAPI, Move(aTags),
|
|
|
|
aHasVersion,
|
|
|
|
aVersion);
|
|
|
|
}
|
|
|
|
|
2015-09-01 08:31:48 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvIsGMPPresentOnDisk(const nsString& aKeySystem,
|
|
|
|
const nsCString& aVersion,
|
|
|
|
bool* aIsPresent,
|
|
|
|
nsCString* aMessage)
|
|
|
|
{
|
2015-09-01 09:06:57 +03:00
|
|
|
#ifdef MOZ_EME
|
2015-09-01 08:31:48 +03:00
|
|
|
*aIsPresent = MediaKeySystemAccess::IsGMPPresentOnDisk(aKeySystem,
|
|
|
|
aVersion,
|
|
|
|
*aMessage);
|
2015-09-01 09:06:57 +03:00
|
|
|
#else
|
|
|
|
*aIsPresent = false;
|
|
|
|
#endif
|
2015-09-01 08:31:48 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-29 18:05:36 +03:00
|
|
|
bool
|
2015-03-17 20:42:34 +03:00
|
|
|
ContentParent::RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv, uint32_t* aRunID)
|
2014-10-29 18:05:36 +03:00
|
|
|
{
|
2015-01-30 19:37:03 +03:00
|
|
|
*aRv = NS_OK;
|
2015-03-17 20:42:34 +03:00
|
|
|
return mozilla::plugins::SetupBridge(aPluginId, this, false, aRv, aRunID);
|
2014-10-29 18:05:36 +03:00
|
|
|
}
|
|
|
|
|
2015-11-05 00:46:10 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvUngrabPointer(const uint32_t& aTime)
|
|
|
|
{
|
|
|
|
#if !defined(MOZ_WIDGET_GTK)
|
|
|
|
NS_RUNTIMEABORT("This message only makes sense on GTK platforms");
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
gdk_pointer_ungrab(aTime);
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-17 00:03:27 +03:00
|
|
|
bool
|
2015-01-30 19:37:03 +03:00
|
|
|
ContentParent::RecvConnectPluginBridge(const uint32_t& aPluginId, nsresult* aRv)
|
2015-01-17 00:03:27 +03:00
|
|
|
{
|
2015-01-30 19:37:03 +03:00
|
|
|
*aRv = NS_OK;
|
2015-03-17 20:42:34 +03:00
|
|
|
// We don't need to get the run ID for the plugin, since we already got it
|
|
|
|
// in the first call to SetupBridge in RecvLoadPlugin, so we pass in a dummy
|
|
|
|
// pointer and just throw it away.
|
|
|
|
uint32_t dummy = 0;
|
|
|
|
return mozilla::plugins::SetupBridge(aPluginId, this, true, aRv, &dummy);
|
2015-01-17 00:03:27 +03:00
|
|
|
}
|
|
|
|
|
2015-05-01 18:07:19 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetBlocklistState(const uint32_t& aPluginId,
|
|
|
|
uint32_t* aState)
|
|
|
|
{
|
|
|
|
*aState = nsIBlocklistService::STATE_BLOCKED;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2015-05-01 18:07:19 +03:00
|
|
|
if (!pluginHost) {
|
2015-07-24 21:52:20 +03:00
|
|
|
NS_WARNING("Plugin host not found");
|
2015-05-01 18:07:19 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsPluginTag* tag = pluginHost->PluginWithId(aPluginId);
|
|
|
|
|
|
|
|
if (!tag) {
|
2015-07-24 21:52:20 +03:00
|
|
|
// Default state is blocked anyway
|
|
|
|
NS_WARNING("Plugin tag not found. This should never happen, but to avoid a crash we're forcibly blocking it");
|
|
|
|
return true;
|
2015-05-01 18:07:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_SUCCEEDED(tag->GetBlocklistState(aState));
|
|
|
|
}
|
|
|
|
|
2014-10-29 18:05:36 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
|
2015-11-11 07:35:00 +03:00
|
|
|
nsresult* aRv,
|
2014-10-29 18:05:36 +03:00
|
|
|
nsTArray<PluginTag>* aPlugins,
|
|
|
|
uint32_t* aNewPluginEpoch)
|
|
|
|
{
|
2015-11-11 07:35:00 +03:00
|
|
|
*aRv = mozilla::plugins::FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch);
|
|
|
|
return true;
|
2014-10-29 18:05:36 +03:00
|
|
|
}
|
|
|
|
|
2012-08-09 06:58:06 +04:00
|
|
|
/*static*/ TabParent*
|
2013-02-15 00:41:30 +04:00
|
|
|
ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
2014-06-20 21:55:40 +04:00
|
|
|
Element* aFrameElement,
|
|
|
|
ContentParent* aOpenerContentParent)
|
2012-07-14 01:10:20 +04:00
|
|
|
{
|
2012-12-28 13:45:16 +04:00
|
|
|
if (!sCanLaunchSubprocesses) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-16 21:07:50 +03:00
|
|
|
if (TabParent* parent = TabParent::GetNextTabParent()) {
|
|
|
|
parent->SetOwnerElement(aFrameElement);
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2014-05-30 17:29:43 +04:00
|
|
|
ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
|
2015-07-04 04:29:00 +03:00
|
|
|
bool isInContentProcess = !XRE_IsParentProcess();
|
2014-10-29 21:11:00 +03:00
|
|
|
TabId tabId;
|
|
|
|
|
|
|
|
nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement);
|
|
|
|
TabId openerTabId;
|
|
|
|
if (docShell) {
|
|
|
|
openerTabId = TabParent::GetTabIdFrom(docShell);
|
|
|
|
}
|
2014-05-30 17:29:43 +04:00
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tp;
|
|
|
|
RefPtr<nsIContentParent> constructorSender;
|
2014-08-13 10:18:00 +04:00
|
|
|
if (isInContentProcess) {
|
2014-06-11 09:44:13 +04:00
|
|
|
MOZ_ASSERT(aContext.IsBrowserElement());
|
2014-10-29 21:11:00 +03:00
|
|
|
constructorSender = CreateContentBridgeParent(aContext,
|
|
|
|
initialPriority,
|
|
|
|
openerTabId,
|
|
|
|
&tabId);
|
2014-06-20 21:55:40 +04:00
|
|
|
} else {
|
2014-10-29 21:11:00 +03:00
|
|
|
if (aOpenerContentParent) {
|
|
|
|
constructorSender = aOpenerContentParent;
|
|
|
|
} else {
|
|
|
|
constructorSender =
|
|
|
|
GetNewOrUsedBrowserProcess(aContext.IsBrowserElement(),
|
|
|
|
initialPriority);
|
2015-05-11 10:24:40 +03:00
|
|
|
if (!constructorSender) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
|
|
|
tabId = AllocateTabId(openerTabId,
|
|
|
|
aContext.AsIPCTabContext(),
|
|
|
|
constructorSender->ChildID());
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
|
|
|
if (constructorSender) {
|
2015-09-22 00:14:25 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
if (!treeOwner) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
|
|
|
|
if (!wbc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-05-07 08:10:31 +04:00
|
|
|
uint32_t chromeFlags = 0;
|
2015-09-22 00:14:25 +03:00
|
|
|
wbc->GetChromeFlags(&chromeFlags);
|
2013-05-07 08:10:31 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
|
|
|
if (loadContext && loadContext->UsePrivateBrowsing()) {
|
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
|
|
|
|
}
|
|
|
|
bool affectLifetime;
|
|
|
|
docShell->GetAffectPrivateSessionLifetime(&affectLifetime);
|
|
|
|
if (affectLifetime) {
|
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
|
|
|
|
}
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
if (tabId == 0) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aContext, chromeFlags));
|
2014-11-16 21:23:22 +03:00
|
|
|
tp->SetInitedByParent();
|
2014-01-11 05:10:57 +04:00
|
|
|
tp->SetOwnerElement(aFrameElement);
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
PBrowserParent* browser = constructorSender->SendPBrowserConstructor(
|
2014-03-15 23:00:15 +04:00
|
|
|
// DeallocPBrowserParent() releases this ref.
|
|
|
|
tp.forget().take(),
|
2014-10-29 21:11:00 +03:00
|
|
|
tabId,
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
aContext.AsIPCTabContext(),
|
2014-06-04 01:15:27 +04:00
|
|
|
chromeFlags,
|
2014-06-11 09:44:13 +04:00
|
|
|
constructorSender->ChildID(),
|
|
|
|
constructorSender->IsForApp(),
|
|
|
|
constructorSender->IsForBrowser());
|
2015-02-06 00:47:32 +03:00
|
|
|
return TabParent::GetFrom(browser);
|
2012-08-09 06:58:06 +04:00
|
|
|
}
|
|
|
|
return nullptr;
|
2012-07-14 01:10:20 +04:00
|
|
|
}
|
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
// If we got here, we have an app and we're not a browser element. ownApp
|
|
|
|
// shouldn't be null, because we otherwise would have gone into the
|
|
|
|
// !HasOwnApp() branch above.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsIContentParent> parent;
|
2014-08-13 10:18:00 +04:00
|
|
|
bool reused = false;
|
|
|
|
bool tookPreallocated = false;
|
|
|
|
nsAutoString manifestURL;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
if (isInContentProcess) {
|
2014-10-29 21:11:00 +03:00
|
|
|
parent = CreateContentBridgeParent(aContext,
|
|
|
|
initialPriority,
|
|
|
|
openerTabId,
|
|
|
|
&tabId);
|
2012-07-14 01:10:20 +04:00
|
|
|
}
|
2014-08-13 10:18:00 +04:00
|
|
|
else {
|
|
|
|
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
|
2012-07-14 01:10:20 +04:00
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
if (!sAppContentParents) {
|
|
|
|
sAppContentParents =
|
|
|
|
new nsDataHashtable<nsStringHashKey, ContentParent*>();
|
|
|
|
}
|
2012-08-09 06:58:06 +04:00
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
// Each app gets its own ContentParent instance unless it shares it with
|
|
|
|
// a parent app.
|
|
|
|
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
|
|
|
|
NS_ERROR("Failed to get manifest URL");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
|
2014-08-13 10:18:00 +04:00
|
|
|
|
|
|
|
if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
|
|
|
|
nsAutoString parentAppManifestURL;
|
|
|
|
aFrameElement->GetAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::parentapp, parentAppManifestURL);
|
|
|
|
nsAdoptingString systemAppManifestURL =
|
|
|
|
Preferences::GetString("b2g.system_manifest_url");
|
|
|
|
nsCOMPtr<nsIAppsService> appsService =
|
|
|
|
do_GetService(APPS_SERVICE_CONTRACTID);
|
|
|
|
if (!parentAppManifestURL.IsEmpty() &&
|
|
|
|
!parentAppManifestURL.Equals(systemAppManifestURL) &&
|
|
|
|
appsService) {
|
|
|
|
nsCOMPtr<mozIApplication> parentApp;
|
|
|
|
nsCOMPtr<mozIApplication> app;
|
|
|
|
appsService->GetAppByManifestURL(parentAppManifestURL,
|
|
|
|
getter_AddRefs(parentApp));
|
|
|
|
appsService->GetAppByManifestURL(manifestURL,
|
|
|
|
getter_AddRefs(app));
|
|
|
|
|
|
|
|
// Only let certified apps re-use the same process.
|
|
|
|
unsigned short parentAppStatus = 0;
|
|
|
|
unsigned short appStatus = 0;
|
|
|
|
if (app &&
|
|
|
|
NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
|
|
|
|
appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
|
|
|
|
parentApp &&
|
|
|
|
NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
|
|
|
|
parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
|
|
|
|
// Check if we can re-use the process of the parent app.
|
|
|
|
p = sAppContentParents->Get(parentAppManifestURL);
|
|
|
|
}
|
2014-03-26 08:56:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
if (p) {
|
|
|
|
// Check that the process is still alive and set its priority.
|
|
|
|
// Hopefully the process won't die after this point, if this call
|
|
|
|
// succeeds.
|
|
|
|
if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
|
|
|
|
p = nullptr;
|
|
|
|
}
|
2013-02-15 00:41:30 +04:00
|
|
|
}
|
2013-02-15 00:41:30 +04:00
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
reused = !!p;
|
|
|
|
if (!p) {
|
|
|
|
p = GetNewOrPreallocatedAppProcess(ownApp,
|
|
|
|
initialPriority,
|
|
|
|
nullptr,
|
|
|
|
&tookPreallocated);
|
|
|
|
MOZ_ASSERT(p);
|
|
|
|
sAppContentParents->Put(manifestURL, p);
|
2012-08-16 05:46:03 +04:00
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
tabId = AllocateTabId(openerTabId,
|
|
|
|
aContext.AsIPCTabContext(),
|
|
|
|
p->ChildID());
|
2014-08-13 10:18:00 +04:00
|
|
|
parent = static_cast<nsIContentParent*>(p);
|
|
|
|
}
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
if (!parent || (tabId == 0)) {
|
2014-08-13 10:18:00 +04:00
|
|
|
return nullptr;
|
2012-07-14 01:10:20 +04:00
|
|
|
}
|
|
|
|
|
2014-01-11 05:10:57 +04:00
|
|
|
uint32_t chromeFlags = 0;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
|
2014-11-16 21:23:22 +03:00
|
|
|
tp->SetInitedByParent();
|
2013-02-15 00:41:30 +04:00
|
|
|
tp->SetOwnerElement(aFrameElement);
|
2014-08-13 10:18:00 +04:00
|
|
|
PBrowserParent* browser = parent->SendPBrowserConstructor(
|
2014-03-15 23:00:15 +04:00
|
|
|
// DeallocPBrowserParent() releases this ref.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent>(tp).forget().take(),
|
2014-10-29 21:11:00 +03:00
|
|
|
tabId,
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
aContext.AsIPCTabContext(),
|
2014-06-04 01:15:27 +04:00
|
|
|
chromeFlags,
|
2014-08-13 10:18:00 +04:00
|
|
|
parent->ChildID(),
|
|
|
|
parent->IsForApp(),
|
|
|
|
parent->IsForBrowser());
|
|
|
|
|
|
|
|
if (isInContentProcess) {
|
|
|
|
// Just return directly without the following check in content process.
|
2015-02-06 00:47:32 +03:00
|
|
|
return TabParent::GetFrom(browser);
|
2014-08-13 10:18:00 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 02:56:22 +04:00
|
|
|
if (!browser) {
|
|
|
|
// We failed to actually start the PBrowser. This can happen if the
|
|
|
|
// other process has already died.
|
|
|
|
if (!reused) {
|
|
|
|
// Don't leave a broken ContentParent in the hashtable.
|
2015-02-03 20:09:27 +03:00
|
|
|
parent->AsContentParent()->KillHard("CreateBrowserOrApp");
|
2014-07-09 02:56:22 +04:00
|
|
|
sAppContentParents->Remove(manifestURL);
|
2014-08-13 10:18:00 +04:00
|
|
|
parent = nullptr;
|
2014-07-09 02:56:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we took the preallocated process and it was already dead, try
|
|
|
|
// again with a non-preallocated process. We can be sure this won't
|
|
|
|
// loop forever, because the next time through there will be no
|
|
|
|
// preallocated process to take.
|
|
|
|
if (tookPreallocated) {
|
|
|
|
return ContentParent::CreateBrowserOrApp(aContext,
|
|
|
|
aFrameElement,
|
|
|
|
aOpenerContentParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise just give up.
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-02-15 00:41:30 +04:00
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
parent->AsContentParent()->MaybeTakeCPUWakeLock(aFrameElement);
|
2013-02-15 00:41:30 +04:00
|
|
|
|
2015-02-06 00:47:32 +03:00
|
|
|
return TabParent::GetFrom(browser);
|
2012-07-14 01:10:20 +04:00
|
|
|
}
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
/*static*/ ContentBridgeParent*
|
|
|
|
ContentParent::CreateContentBridgeParent(const TabContext& aContext,
|
2014-10-29 21:11:00 +03:00
|
|
|
const hal::ProcessPriority& aPriority,
|
|
|
|
const TabId& aOpenerTabId,
|
|
|
|
/*out*/ TabId* aTabId)
|
2014-08-13 10:18:00 +04:00
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
MOZ_ASSERT(aTabId);
|
|
|
|
|
2014-08-13 10:18:00 +04:00
|
|
|
ContentChild* child = ContentChild::GetSingleton();
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentParentId cpId;
|
2014-08-13 10:18:00 +04:00
|
|
|
bool isForApp;
|
|
|
|
bool isForBrowser;
|
|
|
|
if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
|
|
|
|
aPriority,
|
2014-10-29 21:11:00 +03:00
|
|
|
aOpenerTabId,
|
|
|
|
&cpId,
|
2014-08-13 10:18:00 +04:00
|
|
|
&isForApp,
|
2014-10-29 21:11:00 +03:00
|
|
|
&isForBrowser,
|
|
|
|
aTabId)) {
|
2014-08-13 10:18:00 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
if (cpId == 0) {
|
2014-09-09 12:57:51 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2014-12-19 04:35:48 +03:00
|
|
|
if (!child->SendBridgeToChildProcess(cpId)) {
|
2014-08-13 10:18:00 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
ContentBridgeParent* parent = child->GetLastBridge();
|
2014-10-29 21:11:00 +03:00
|
|
|
parent->SetChildID(cpId);
|
2014-08-13 10:18:00 +04:00
|
|
|
parent->SetIsForApp(isForApp);
|
|
|
|
parent->SetIsForBrowser(isForBrowser);
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2011-08-02 23:35:42 +04:00
|
|
|
void
|
|
|
|
ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
|
|
|
|
{
|
2012-07-14 01:10:20 +04:00
|
|
|
aArray.Clear();
|
|
|
|
|
2013-07-18 01:31:10 +04:00
|
|
|
if (!sContentParents) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-18 01:31:10 +04:00
|
|
|
for (ContentParent* cp = sContentParents->getFirst(); cp;
|
2013-06-03 14:14:40 +04:00
|
|
|
cp = cp->LinkedListElement<ContentParent>::getNext()) {
|
2013-07-18 01:31:10 +04:00
|
|
|
if (cp->mIsAlive) {
|
|
|
|
aArray.AppendElement(cp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::GetAllEvenIfDead(nsTArray<ContentParent*>& aArray)
|
|
|
|
{
|
|
|
|
aArray.Clear();
|
|
|
|
|
|
|
|
if (!sContentParents) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-18 01:31:10 +04:00
|
|
|
for (ContentParent* cp = sContentParents->getFirst(); cp;
|
2013-06-03 14:14:40 +04:00
|
|
|
cp = cp->LinkedListElement<ContentParent>::getNext()) {
|
2013-04-26 04:53:26 +04:00
|
|
|
aArray.AppendElement(cp);
|
2012-10-03 05:19:11 +04:00
|
|
|
}
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2010-12-26 23:03:52 +03:00
|
|
|
void
|
|
|
|
ContentParent::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
2014-02-13 10:55:28 +04:00
|
|
|
size_t length = ArrayLength(sObserverTopics);
|
|
|
|
for (size_t i = 0; i < length; ++i) {
|
|
|
|
obs->AddObserver(this, sObserverTopics[i], false);
|
|
|
|
}
|
2010-12-26 23:03:52 +03:00
|
|
|
}
|
2012-04-04 08:09:20 +04:00
|
|
|
Preferences::AddStrongObserver(this, "");
|
2010-12-26 23:03:52 +03:00
|
|
|
if (obs) {
|
2015-08-28 10:18:00 +03:00
|
|
|
nsAutoString cpId;
|
|
|
|
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
|
|
|
|
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
|
2010-12-26 23:03:52 +03:00
|
|
|
}
|
2011-07-21 08:37:32 +04:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// If accessibility is running in chrome process then start it in content
|
|
|
|
// process.
|
|
|
|
if (nsIPresShell::IsAccessibilityActive()) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendActivateA11y();
|
2011-07-21 08:37:32 +04:00
|
|
|
}
|
|
|
|
#endif
|
2015-08-11 21:26:27 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
|
|
|
|
bool profilerActive = false;
|
|
|
|
DebugOnly<nsresult> rv = profiler->IsActive(&profilerActive);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
if (profilerActive) {
|
|
|
|
nsCOMPtr<nsIProfilerStartParams> currentProfilerParams;
|
|
|
|
rv = profiler->GetStartParams(getter_AddRefs(currentProfilerParams));
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
StartProfiler(currentProfilerParams);
|
|
|
|
}
|
|
|
|
#endif
|
2010-12-26 23:03:52 +03:00
|
|
|
}
|
|
|
|
|
2015-01-28 08:52:46 +03:00
|
|
|
void
|
|
|
|
ContentParent::ForwardKnownInfo()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mMetamorphosed);
|
|
|
|
if (!mMetamorphosed) {
|
|
|
|
return;
|
|
|
|
}
|
2015-01-28 08:54:10 +03:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
InfallibleTArray<VolumeInfo> volumeInfo;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton();
|
2015-11-25 23:50:00 +03:00
|
|
|
if (vs) {
|
2015-01-28 08:54:10 +03:00
|
|
|
vs->GetVolumesForIPC(&volumeInfo);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendVolumes(volumeInfo);
|
2015-01-28 08:54:10 +03:00
|
|
|
}
|
|
|
|
#endif /* MOZ_WIDGET_GONK */
|
2015-02-11 13:18:32 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsISystemMessagesInternal> systemMessenger =
|
|
|
|
do_GetService("@mozilla.org/system-message-internal;1");
|
|
|
|
if (systemMessenger && !mIsForBrowser) {
|
|
|
|
nsCOMPtr<nsIURI> manifestURI;
|
|
|
|
nsresult rv = NS_NewURI(getter_AddRefs(manifestURI), mAppManifestURL);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
systemMessenger->RefreshCache(mMessageManager, manifestURI);
|
|
|
|
}
|
|
|
|
}
|
2015-01-28 08:52:46 +03:00
|
|
|
}
|
|
|
|
|
2014-08-01 22:02:55 +04:00
|
|
|
namespace {
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class SystemMessageHandledListener final
|
2014-08-01 22:02:55 +04:00
|
|
|
: public nsITimerCallback
|
|
|
|
, public LinkedListElement<SystemMessageHandledListener>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
SystemMessageHandledListener() {}
|
|
|
|
|
|
|
|
static void OnSystemMessageHandled()
|
|
|
|
{
|
|
|
|
if (!sListeners) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemMessageHandledListener* listener = sListeners->popFirst();
|
|
|
|
if (!listener) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Careful: ShutDown() may delete |this|.
|
|
|
|
listener->ShutDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Init(WakeLock* aWakeLock)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mWakeLock);
|
|
|
|
MOZ_ASSERT(!mTimer);
|
|
|
|
|
|
|
|
// mTimer keeps a strong reference to |this|. When this object's
|
|
|
|
// destructor runs, it will remove itself from the LinkedList.
|
|
|
|
|
|
|
|
if (!sListeners) {
|
|
|
|
sListeners = new LinkedList<SystemMessageHandledListener>();
|
|
|
|
ClearOnShutdown(&sListeners);
|
|
|
|
}
|
|
|
|
sListeners->insertBack(this);
|
|
|
|
|
|
|
|
mWakeLock = aWakeLock;
|
|
|
|
|
|
|
|
mTimer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
|
|
|
|
uint32_t timeoutSec =
|
|
|
|
Preferences::GetInt("dom.ipc.systemMessageCPULockTimeoutSec", 30);
|
|
|
|
mTimer->InitWithCallback(this, timeoutSec * 1000,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Notify(nsITimer* aTimer) override
|
2014-08-01 22:02:55 +04:00
|
|
|
{
|
|
|
|
// Careful: ShutDown() may delete |this|.
|
|
|
|
ShutDown();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
~SystemMessageHandledListener() {}
|
|
|
|
|
|
|
|
static StaticAutoPtr<LinkedList<SystemMessageHandledListener> > sListeners;
|
|
|
|
|
|
|
|
void ShutDown()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SystemMessageHandledListener> kungFuDeathGrip = this;
|
2014-08-01 22:02:55 +04:00
|
|
|
|
|
|
|
ErrorResult rv;
|
|
|
|
mWakeLock->Unlock(rv);
|
|
|
|
|
|
|
|
if (mTimer) {
|
|
|
|
mTimer->Cancel();
|
|
|
|
mTimer = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<WakeLock> mWakeLock;
|
2014-08-01 22:02:55 +04:00
|
|
|
nsCOMPtr<nsITimer> mTimer;
|
|
|
|
};
|
|
|
|
|
|
|
|
StaticAutoPtr<LinkedList<SystemMessageHandledListener> >
|
|
|
|
SystemMessageHandledListener::sListeners;
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(SystemMessageHandledListener,
|
|
|
|
nsITimerCallback)
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2014-08-01 22:02:55 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::MaybeTakeCPUWakeLock(Element* aFrameElement)
|
|
|
|
{
|
|
|
|
// Take the CPU wake lock on behalf of this processs if it's expecting a
|
|
|
|
// system message. We'll release the CPU lock once the message is
|
|
|
|
// delivered, or after some period of time, which ever comes first.
|
|
|
|
|
|
|
|
nsCOMPtr<nsIMozBrowserFrame> browserFrame =
|
|
|
|
do_QueryInterface(aFrameElement);
|
|
|
|
if (!browserFrame ||
|
|
|
|
!browserFrame->GetIsExpectingSystemMessage()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PowerManagerService> pms = PowerManagerService::GetInstance();
|
|
|
|
RefPtr<WakeLock> lock =
|
2014-08-01 22:02:55 +04:00
|
|
|
pms->NewWakeLockOnBehalfOfProcess(NS_LITERAL_STRING("cpu"), this);
|
|
|
|
|
|
|
|
// This object's Init() function keeps it alive.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SystemMessageHandledListener> listener =
|
2014-08-01 22:02:55 +04:00
|
|
|
new SystemMessageHandledListener();
|
|
|
|
listener->Init(lock);
|
|
|
|
}
|
|
|
|
|
2013-02-08 18:32:23 +04:00
|
|
|
bool
|
2013-02-15 00:41:30 +04:00
|
|
|
ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
|
2012-08-16 05:46:03 +04:00
|
|
|
{
|
2013-04-26 04:53:26 +04:00
|
|
|
ProcessPriorityManager::SetProcessPriority(this, aPriority);
|
2013-02-08 18:32:23 +04:00
|
|
|
|
2013-02-15 00:41:30 +04:00
|
|
|
// Now that we've set this process's priority, check whether the process is
|
|
|
|
// still alive. Hopefully we've set the priority to FOREGROUND*, so the
|
|
|
|
// process won't unexpectedly crash after this point!
|
2013-02-15 00:41:29 +04:00
|
|
|
//
|
2014-03-21 16:50:07 +04:00
|
|
|
// Bug 943174: use waitid() with WNOWAIT so that, if the process
|
|
|
|
// did exit, we won't consume its zombie and confuse the
|
|
|
|
// GeckoChildProcessHost dtor. Also, if the process isn't a
|
|
|
|
// direct child because of Nuwa this will fail with ECHILD, and we
|
|
|
|
// need to assume the child is alive in that case rather than
|
|
|
|
// assuming it's dead (as is otherwise a reasonable fallback).
|
2014-04-04 00:19:00 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-03-21 16:50:07 +04:00
|
|
|
siginfo_t info;
|
|
|
|
info.si_pid = 0;
|
|
|
|
if (waitid(P_PID, Pid(), &info, WNOWAIT | WNOHANG | WEXITED) == 0
|
|
|
|
&& info.si_pid != 0) {
|
2013-02-15 00:41:29 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-15 00:41:30 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
// Helper for ContentParent::TransformPreallocatedIntoApp.
|
|
|
|
static void
|
|
|
|
TryGetNameFromManifestURL(const nsAString& aManifestURL,
|
|
|
|
nsAString& aName)
|
|
|
|
{
|
|
|
|
aName.Truncate();
|
|
|
|
if (aManifestURL.IsEmpty() ||
|
|
|
|
aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE_VOID(appsService);
|
|
|
|
|
2013-10-09 02:52:26 +04:00
|
|
|
nsCOMPtr<mozIApplication> app;
|
|
|
|
appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
|
2013-04-26 04:53:26 +04:00
|
|
|
|
|
|
|
if (!app) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
app->GetName(aName);
|
|
|
|
}
|
|
|
|
|
2014-03-13 02:48:15 +04:00
|
|
|
void
|
2014-09-09 12:57:53 +04:00
|
|
|
ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
|
|
|
|
const nsAString& aAppManifestURL)
|
2013-02-15 00:41:30 +04:00
|
|
|
{
|
2013-04-26 04:53:26 +04:00
|
|
|
MOZ_ASSERT(IsPreallocated());
|
2015-01-28 08:52:46 +03:00
|
|
|
mMetamorphosed = true;
|
2014-09-09 12:57:53 +04:00
|
|
|
mOpener = aOpener;
|
2013-04-26 04:53:26 +04:00
|
|
|
mAppManifestURL = aAppManifestURL;
|
|
|
|
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
|
2012-08-16 05:46:03 +04:00
|
|
|
}
|
|
|
|
|
2014-02-13 14:42:41 +04:00
|
|
|
void
|
2014-09-09 12:57:53 +04:00
|
|
|
ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
|
2014-02-13 14:42:41 +04:00
|
|
|
{
|
|
|
|
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
|
2015-01-28 08:52:46 +03:00
|
|
|
mMetamorphosed = true;
|
2014-09-09 12:57:53 +04:00
|
|
|
mOpener = aOpener;
|
2014-02-13 14:42:41 +04:00
|
|
|
mAppManifestURL.Truncate();
|
|
|
|
mIsForBrowser = true;
|
|
|
|
}
|
|
|
|
|
2012-08-16 05:46:03 +04:00
|
|
|
void
|
2015-01-10 21:18:59 +03:00
|
|
|
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
|
2015-01-07 10:33:50 +03:00
|
|
|
{
|
2015-01-10 21:46:46 +03:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (aMethod == SEND_SHUTDOWN_MESSAGE && IsNuwaProcess()) {
|
|
|
|
// We shouldn't send shutdown messages to frozen Nuwa processes,
|
|
|
|
// so just close the channel.
|
|
|
|
aMethod = CLOSE_CHANNEL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-10 21:18:59 +03:00
|
|
|
// Shutting down by sending a shutdown message works differently than the
|
|
|
|
// other methods. We first call Shutdown() in the child. After the child is
|
|
|
|
// ready, it calls FinishShutdown() on us. Then we close the channel.
|
|
|
|
if (aMethod == SEND_SHUTDOWN_MESSAGE) {
|
2015-01-10 21:42:10 +03:00
|
|
|
if (mIPCOpen && !mShutdownPending && SendShutdown()) {
|
2015-01-10 21:18:59 +03:00
|
|
|
mShutdownPending = true;
|
2015-01-10 21:45:58 +03:00
|
|
|
// Start the force-kill timer if we haven't already.
|
|
|
|
StartForceKillTimer();
|
2015-01-10 21:18:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If call was not successful, the channel must have been broken
|
|
|
|
// somehow, and we will clean up the error in ActorDestroy.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-22 12:43:55 +03:00
|
|
|
using mozilla::dom::quota::QuotaManagerService;
|
2014-09-27 03:21:57 +04:00
|
|
|
|
2015-11-22 12:43:55 +03:00
|
|
|
if (QuotaManagerService* quotaManagerService = QuotaManagerService::Get()) {
|
|
|
|
quotaManagerService->AbortOperationsForProcess(mChildID);
|
2013-08-07 22:08:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// If Close() fails with an error, we'll end up back in this function, but
|
2015-01-10 21:18:59 +03:00
|
|
|
// with aMethod = CLOSE_CHANNEL_WITH_ERROR. It's important that we call
|
2013-08-07 22:08:52 +04:00
|
|
|
// CloseWithError() in this case; see bug 895204.
|
|
|
|
|
2015-01-10 21:18:59 +03:00
|
|
|
if (aMethod == CLOSE_CHANNEL && !mCalledClose) {
|
2013-08-07 22:08:52 +04:00
|
|
|
// Close() can only be called once: It kicks off the destruction
|
|
|
|
// sequence.
|
|
|
|
mCalledClose = true;
|
|
|
|
Close();
|
2014-10-22 10:50:10 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Kill Nuwa process forcibly to break its IPC channels and finalize
|
|
|
|
// corresponding parents.
|
|
|
|
if (IsNuwaProcess()) {
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard("ShutDownProcess");
|
2014-10-22 10:50:10 +04:00
|
|
|
}
|
|
|
|
#endif
|
2013-08-07 22:08:52 +04:00
|
|
|
}
|
|
|
|
|
2015-01-10 21:18:59 +03:00
|
|
|
if (aMethod == CLOSE_CHANNEL_WITH_ERROR && !mCalledCloseWithError) {
|
2013-09-28 05:42:08 +04:00
|
|
|
MessageChannel* channel = GetIPCChannel();
|
2013-08-07 22:08:52 +04:00
|
|
|
if (channel) {
|
|
|
|
mCalledCloseWithError = true;
|
|
|
|
channel->CloseWithError();
|
|
|
|
}
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
2012-10-05 23:09:33 +04:00
|
|
|
|
2015-10-07 21:30:33 +03:00
|
|
|
const ManagedContainer<POfflineCacheUpdateParent>& ocuParents =
|
2014-11-13 03:31:00 +03:00
|
|
|
ManagedPOfflineCacheUpdateParent();
|
2015-10-07 21:30:33 +03:00
|
|
|
for (auto iter = ocuParents.ConstIter(); !iter.Done(); iter.Next()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> ocuParent =
|
2015-10-07 21:30:33 +03:00
|
|
|
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(iter.Get()->GetKey());
|
2014-11-13 03:31:00 +03:00
|
|
|
ocuParent->StopSendingMessagesToChild();
|
|
|
|
}
|
|
|
|
|
2013-08-07 22:08:52 +04:00
|
|
|
// NB: must MarkAsDead() here so that this isn't accidentally
|
|
|
|
// returned from Get*() while in the midst of shutdown.
|
|
|
|
MarkAsDead();
|
|
|
|
|
|
|
|
// A ContentParent object might not get freed until after XPCOM shutdown has
|
|
|
|
// shut down the cycle collector. But by then it's too late to release any
|
|
|
|
// CC'ed objects, so we need to null them out here, while we still can. See
|
|
|
|
// bug 899761.
|
2014-05-31 01:03:05 +04:00
|
|
|
ShutDownMessageManager();
|
|
|
|
}
|
|
|
|
|
2015-01-10 21:18:59 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvFinishShutdown()
|
|
|
|
{
|
|
|
|
// At this point, we already called ShutDownProcess once with
|
|
|
|
// SEND_SHUTDOWN_MESSAGE. To actually close the channel, we call
|
|
|
|
// ShutDownProcess again with CLOSE_CHANNEL.
|
|
|
|
MOZ_ASSERT(mShutdownPending);
|
|
|
|
ShutDownProcess(CLOSE_CHANNEL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-31 01:03:05 +04:00
|
|
|
void
|
|
|
|
ContentParent::ShutDownMessageManager()
|
|
|
|
{
|
|
|
|
if (!mMessageManager) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mMessageManager->ReceiveMessage(
|
2015-04-16 18:17:54 +03:00
|
|
|
static_cast<nsIContentFrameMessageManager*>(mMessageManager.get()), nullptr,
|
2014-05-31 01:03:05 +04:00
|
|
|
CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
|
|
|
|
nullptr, nullptr, nullptr, nullptr);
|
|
|
|
|
|
|
|
mMessageManager->Disconnect();
|
|
|
|
mMessageManager = nullptr;
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::MarkAsDead()
|
|
|
|
{
|
|
|
|
if (!mAppManifestURL.IsEmpty()) {
|
2013-04-26 04:53:26 +04:00
|
|
|
if (sAppContentParents) {
|
|
|
|
sAppContentParents->Remove(mAppManifestURL);
|
|
|
|
if (!sAppContentParents->Count()) {
|
|
|
|
delete sAppContentParents;
|
2013-10-28 18:04:12 +04:00
|
|
|
sAppContentParents = nullptr;
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
}
|
2013-04-26 04:53:26 +04:00
|
|
|
} else if (sNonAppContentParents) {
|
|
|
|
sNonAppContentParents->RemoveElement(this);
|
|
|
|
if (!sNonAppContentParents->Length()) {
|
|
|
|
delete sNonAppContentParents;
|
2013-10-28 18:04:12 +04:00
|
|
|
sNonAppContentParents = nullptr;
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
if (sPrivateContent) {
|
|
|
|
sPrivateContent->RemoveElement(this);
|
|
|
|
if (!sPrivateContent->Length()) {
|
|
|
|
delete sPrivateContent;
|
2013-10-28 18:04:12 +04:00
|
|
|
sPrivateContent = nullptr;
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mIsAlive = false;
|
|
|
|
}
|
|
|
|
|
2013-06-03 14:14:40 +04:00
|
|
|
void
|
|
|
|
ContentParent::OnChannelError()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> content(this);
|
2013-06-03 14:14:40 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2013-12-11 13:48:28 +04:00
|
|
|
// Handle app or Nuwa process exit before normal channel error handling.
|
2013-11-22 07:25:34 +04:00
|
|
|
PreallocatedProcessManager::MaybeForgetSpare(this);
|
2013-06-03 14:14:40 +04:00
|
|
|
#endif
|
2013-12-11 13:48:28 +04:00
|
|
|
PContentParent::OnChannelError();
|
2013-06-03 14:14:40 +04:00
|
|
|
}
|
|
|
|
|
2010-11-24 16:58:21 +03:00
|
|
|
void
|
2012-09-17 12:37:20 +04:00
|
|
|
ContentParent::OnChannelConnected(int32_t pid)
|
2010-11-24 16:58:21 +03:00
|
|
|
{
|
2015-04-01 11:40:35 +03:00
|
|
|
SetOtherProcessId(pid);
|
2011-02-15 01:34:46 +03:00
|
|
|
|
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
2015-04-01 11:40:35 +03:00
|
|
|
// Check nice preference
|
|
|
|
int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
|
|
|
|
|
|
|
|
// Environment variable overrides preference
|
|
|
|
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
|
|
|
|
if (relativeNicenessStr) {
|
|
|
|
nice = atoi(relativeNicenessStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make the GUI thread have higher priority on single-cpu devices */
|
|
|
|
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
|
|
|
|
if (infoService) {
|
|
|
|
int32_t cpus;
|
|
|
|
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
cpus = 1;
|
2011-02-15 01:34:46 +03:00
|
|
|
}
|
2015-04-01 11:40:35 +03:00
|
|
|
if (nice != 0 && cpus == 1) {
|
|
|
|
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
2011-02-15 01:34:46 +03:00
|
|
|
}
|
2010-11-24 16:58:21 +03:00
|
|
|
}
|
2015-04-01 11:40:35 +03:00
|
|
|
#endif
|
2010-11-24 16:58:21 +03:00
|
|
|
}
|
|
|
|
|
2011-07-13 10:52:31 +04:00
|
|
|
void
|
2015-02-03 20:09:27 +03:00
|
|
|
ContentParent::ProcessingError(Result aCode, const char* aReason)
|
2011-07-13 10:52:31 +04:00
|
|
|
{
|
2015-02-03 20:09:27 +03:00
|
|
|
if (MsgDropped == aCode) {
|
2011-07-13 10:52:31 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-09-06 02:18:48 +04:00
|
|
|
// Other errors are big deals.
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard(aReason);
|
2011-07-13 10:52:31 +04:00
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:39 +04:00
|
|
|
typedef std::pair<ContentParent*, std::set<uint64_t> > IDPair;
|
2014-06-14 11:24:59 +04:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
std::map<ContentParent*, std::set<uint64_t> >&
|
|
|
|
NestedBrowserLayerIds()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
static std::map<ContentParent*, std::set<uint64_t> > sNestedBrowserIds;
|
|
|
|
return sNestedBrowserIds;
|
|
|
|
}
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2014-06-11 09:44:39 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvAllocateLayerTreeId(uint64_t* aId)
|
|
|
|
{
|
|
|
|
*aId = CompositorParent::AllocateLayerTreeId();
|
|
|
|
|
2014-06-14 11:24:59 +04:00
|
|
|
auto iter = NestedBrowserLayerIds().find(this);
|
|
|
|
if (iter == NestedBrowserLayerIds().end()) {
|
2014-06-11 09:44:39 +04:00
|
|
|
std::set<uint64_t> ids;
|
|
|
|
ids.insert(*aId);
|
2014-06-14 11:24:59 +04:00
|
|
|
NestedBrowserLayerIds().insert(IDPair(this, ids));
|
2014-06-11 09:44:39 +04:00
|
|
|
} else {
|
|
|
|
iter->second.insert(*aId);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvDeallocateLayerTreeId(const uint64_t& aId)
|
|
|
|
{
|
2014-06-14 11:24:59 +04:00
|
|
|
auto iter = NestedBrowserLayerIds().find(this);
|
|
|
|
if (iter != NestedBrowserLayerIds().end() &&
|
2014-06-11 09:44:39 +04:00
|
|
|
iter->second.find(aId) != iter->second.end()) {
|
|
|
|
CompositorParent::DeallocateLayerTreeId(aId);
|
|
|
|
} else {
|
|
|
|
// You can't deallocate layer tree ids that you didn't allocate
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard("DeallocateLayerTreeId");
|
2014-06-11 09:44:39 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-24 16:58:21 +03:00
|
|
|
namespace {
|
2011-08-31 08:11:25 +04:00
|
|
|
|
2010-11-24 16:58:21 +03:00
|
|
|
void
|
|
|
|
DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
|
|
|
{
|
|
|
|
XRE_GetIOMessageLoop()
|
|
|
|
->PostTask(FROM_HERE,
|
|
|
|
new DeleteTask<GeckoChildProcessHost>(aSubprocess));
|
|
|
|
}
|
2011-08-31 08:11:25 +04:00
|
|
|
|
|
|
|
// This runnable only exists to delegate ownership of the
|
|
|
|
// ContentParent to this runnable, until it's deleted by the event
|
|
|
|
// system.
|
|
|
|
struct DelayedDeleteContentParentTask : public nsRunnable
|
|
|
|
{
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { }
|
2011-08-31 08:11:25 +04:00
|
|
|
|
|
|
|
// No-op
|
|
|
|
NS_IMETHODIMP Run() { return NS_OK; }
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> mObj;
|
2011-08-31 08:11:25 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2010-11-24 16:58:21 +03:00
|
|
|
|
2010-02-02 04:53:52 +03:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::ActorDestroy(ActorDestroyReason why)
|
2010-02-02 04:53:52 +03:00
|
|
|
{
|
2015-01-07 08:42:23 +03:00
|
|
|
if (mForceKillTimer) {
|
|
|
|
mForceKillTimer->Cancel();
|
|
|
|
mForceKillTimer = nullptr;
|
2015-01-07 08:40:56 +03:00
|
|
|
}
|
|
|
|
|
2015-01-10 21:42:10 +03:00
|
|
|
// Signal shutdown completion regardless of error state, so we can
|
|
|
|
// finish waiting in the xpcom-shutdown/profile-before-change observer.
|
2015-01-10 21:39:33 +03:00
|
|
|
mIPCOpen = false;
|
2015-01-10 21:18:59 +03:00
|
|
|
|
2015-01-17 05:34:47 +03:00
|
|
|
if (mHangMonitorActor) {
|
|
|
|
ProcessHangMonitor::RemoveProcess(mHangMonitorActor);
|
|
|
|
mHangMonitorActor = nullptr;
|
|
|
|
}
|
|
|
|
|
2015-01-10 21:18:59 +03:00
|
|
|
if (why == NormalShutdown && !mCalledClose) {
|
|
|
|
// If we shut down normally but haven't called Close, assume somebody
|
|
|
|
// else called Close on us. In that case, we still need to call
|
|
|
|
// ShutDownProcess below to perform other necessary clean up.
|
|
|
|
mCalledClose = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we always clean up.
|
|
|
|
ShutDownProcess(why == NormalShutdown ? CLOSE_CHANNEL
|
|
|
|
: CLOSE_CHANNEL_WITH_ERROR);
|
2014-05-31 01:03:05 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> kungFuDeathGrip(this);
|
2010-12-26 23:03:52 +03:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2010-12-26 22:27:50 +03:00
|
|
|
if (obs) {
|
2014-02-13 10:55:28 +04:00
|
|
|
size_t length = ArrayLength(sObserverTopics);
|
|
|
|
for (size_t i = 0; i < length; ++i) {
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this),
|
|
|
|
sObserverTopics[i]);
|
|
|
|
}
|
2010-12-26 22:27:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// remove the global remote preferences observers
|
2012-04-04 08:09:20 +04:00
|
|
|
Preferences::RemoveObserver(this, "");
|
2010-12-26 22:27:50 +03:00
|
|
|
|
2014-05-09 15:30:42 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Remove the pref update requests.
|
|
|
|
if (IsNuwaProcess() && sNuwaPrefUpdates) {
|
|
|
|
delete sNuwaPrefUpdates;
|
|
|
|
sNuwaPrefUpdates = nullptr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-12-26 22:27:50 +03:00
|
|
|
RecvRemoveGeolocationListener();
|
|
|
|
|
2012-11-09 21:52:09 +04:00
|
|
|
mConsoleService = nullptr;
|
|
|
|
|
2010-10-08 23:12:40 +04:00
|
|
|
if (obs) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
2010-11-24 16:58:21 +03:00
|
|
|
|
2012-11-17 19:05:18 +04:00
|
|
|
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
|
|
|
|
|
2010-11-24 16:58:21 +03:00
|
|
|
if (AbnormalShutdown == why) {
|
2014-12-12 22:13:28 +03:00
|
|
|
Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT,
|
|
|
|
NS_LITERAL_CSTRING("content"), 1);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
|
2010-11-24 16:58:21 +03:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-01-04 03:39:25 +04:00
|
|
|
// There's a window in which child processes can crash
|
|
|
|
// after IPC is established, but before a crash reporter
|
|
|
|
// is created.
|
2015-10-08 03:15:56 +03:00
|
|
|
if (PCrashReporterParent* p = LoneManagedOrNull(ManagedPCrashReporterParent())) {
|
2013-01-04 03:39:25 +04:00
|
|
|
CrashReporterParent* crashReporter =
|
2015-10-08 03:15:56 +03:00
|
|
|
static_cast<CrashReporterParent*>(p);
|
2010-11-24 16:58:21 +03:00
|
|
|
|
2013-01-07 18:42:32 +04:00
|
|
|
// If we're an app process, always stomp the latest URI
|
|
|
|
// loaded in the child process with our manifest URL. We
|
|
|
|
// would rather associate the crashes with apps than
|
|
|
|
// random child windows loaded in them.
|
|
|
|
//
|
|
|
|
// XXX would be nice if we could get both ...
|
|
|
|
if (!mAppManifestURL.IsEmpty()) {
|
|
|
|
crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("URL"),
|
|
|
|
NS_ConvertUTF16toUTF8(mAppManifestURL));
|
|
|
|
}
|
|
|
|
|
2015-06-11 20:25:45 +03:00
|
|
|
// if mCreatedPairedMinidumps is true, we've already generated
|
|
|
|
// parent/child dumps for dekstop crashes.
|
|
|
|
if (!mCreatedPairedMinidumps) {
|
2014-11-24 23:05:45 +03:00
|
|
|
crashReporter->GenerateCrashReport(this, nullptr);
|
|
|
|
}
|
2012-12-26 03:06:27 +04:00
|
|
|
|
2013-01-04 03:39:25 +04:00
|
|
|
nsAutoString dumpID(crashReporter->ChildDumpID());
|
|
|
|
props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
|
|
|
|
}
|
2010-11-24 16:58:21 +03:00
|
|
|
#endif
|
|
|
|
}
|
2015-08-28 10:18:00 +03:00
|
|
|
nsAutoString cpId;
|
|
|
|
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
|
|
|
|
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
|
2010-10-08 23:12:40 +04:00
|
|
|
}
|
2010-11-24 16:58:21 +03:00
|
|
|
|
2015-05-27 11:05:04 +03:00
|
|
|
// Remove any and all idle listeners.
|
|
|
|
nsCOMPtr<nsIIdleService> idleService =
|
|
|
|
do_GetService("@mozilla.org/widget/idleservice;1");
|
|
|
|
MOZ_ASSERT(idleService);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ParentIdleListener> listener;
|
2015-05-27 11:05:04 +03:00
|
|
|
for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
|
|
|
|
listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
|
|
|
|
idleService->RemoveIdleObserver(listener, listener->mTime);
|
|
|
|
}
|
2013-12-13 20:28:46 +04:00
|
|
|
mIdleListeners.Clear();
|
|
|
|
|
2010-11-24 16:58:21 +03:00
|
|
|
MessageLoop::current()->
|
|
|
|
PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
|
2013-10-28 18:04:12 +04:00
|
|
|
mSubprocess = nullptr;
|
2011-08-31 08:11:25 +04:00
|
|
|
|
|
|
|
// IPDL rules require actors to live on past ActorDestroy, but it
|
|
|
|
// may be that the kungFuDeathGrip above is the last reference to
|
|
|
|
// |this|. If so, when we go out of scope here, we're deleted and
|
|
|
|
// all hell breaks loose.
|
|
|
|
//
|
|
|
|
// This runnable ensures that a reference to |this| lives on at
|
|
|
|
// least until after the current task finishes running.
|
|
|
|
NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
|
2014-06-11 09:44:13 +04:00
|
|
|
|
2015-08-28 10:18:00 +03:00
|
|
|
// Release the appId's reference count of any processes
|
|
|
|
// created by this ContentParent and the frame opened by this ContentParent
|
|
|
|
// if this ContentParent crashes.
|
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
2014-10-29 21:11:00 +03:00
|
|
|
nsTArray<ContentParentId> childIDArray =
|
|
|
|
cpm->GetAllChildProcessById(this->ChildID());
|
2015-08-28 10:18:00 +03:00
|
|
|
if (why == AbnormalShutdown) {
|
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
|
|
|
if(permMgr) {
|
|
|
|
// Release the appId's reference count of its child-processes
|
|
|
|
for (uint32_t i = 0; i < childIDArray.Length(); i++) {
|
|
|
|
nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(childIDArray[i]);
|
|
|
|
for (uint32_t j = 0 ; j < tabCtxs.Length() ; j++) {
|
|
|
|
if (tabCtxs[j].OwnOrContainingAppId() != nsIScriptSecurityManager::NO_APP_ID) {
|
|
|
|
permMgr->ReleaseAppId(tabCtxs[j].OwnOrContainingAppId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Release the appId's reference count belong to itself
|
|
|
|
nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(mChildID);
|
|
|
|
for (uint32_t i = 0; i < tabCtxs.Length() ; i++) {
|
|
|
|
if (tabCtxs[i].OwnOrContainingAppId()!= nsIScriptSecurityManager::NO_APP_ID) {
|
|
|
|
permMgr->ReleaseAppId(tabCtxs[i].OwnOrContainingAppId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy any processes created by this ContentParent
|
2014-10-29 21:11:00 +03:00
|
|
|
for(uint32_t i = 0; i < childIDArray.Length(); i++) {
|
|
|
|
ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
|
2015-06-10 20:08:00 +03:00
|
|
|
SEND_SHUTDOWN_MESSAGE));
|
2014-06-11 09:44:13 +04:00
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
cpm->RemoveContentProcess(this->ChildID());
|
2015-08-12 06:22:20 +03:00
|
|
|
|
|
|
|
if (mDriverCrashGuard) {
|
|
|
|
mDriverCrashGuard->NotifyCrashed();
|
|
|
|
}
|
2010-02-02 04:53:52 +03:00
|
|
|
}
|
|
|
|
|
2012-07-17 22:27:27 +04:00
|
|
|
void
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentParent::NotifyTabDestroying(const TabId& aTabId,
|
|
|
|
const ContentParentId& aCpId)
|
2013-01-10 17:22:14 +04:00
|
|
|
{
|
2015-08-28 10:18:00 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2013-01-10 17:22:14 +04:00
|
|
|
// There can be more than one PBrowser for a given app process
|
|
|
|
// because of popup windows. PBrowsers can also destroy
|
|
|
|
// concurrently. When all the PBrowsers are destroying, kick off
|
|
|
|
// another task to ensure the child process *really* shuts down,
|
|
|
|
// even if the PBrowsers themselves never finish destroying.
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
ContentParent* cp = cpm->GetContentProcessById(aCpId);
|
|
|
|
if (!cp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++cp->mNumDestroyingTabs;
|
|
|
|
nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(aCpId);
|
|
|
|
if (static_cast<size_t>(cp->mNumDestroyingTabs) != tabIds.Length()) {
|
2013-01-10 17:22:14 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're dying now, so prevent this content process from being
|
|
|
|
// recycled during its shutdown procedure.
|
2015-08-28 10:18:00 +03:00
|
|
|
cp->MarkAsDead();
|
|
|
|
cp->StartForceKillTimer();
|
|
|
|
} else {
|
|
|
|
ContentChild::GetSingleton()->SendNotifyTabDestroying(aTabId, aCpId);
|
|
|
|
}
|
2015-01-10 21:45:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::StartForceKillTimer()
|
|
|
|
{
|
|
|
|
if (mForceKillTimer || !mIPCOpen) {
|
|
|
|
return;
|
|
|
|
}
|
2013-01-10 17:22:14 +04:00
|
|
|
|
2015-09-09 03:12:27 +03:00
|
|
|
int32_t timeoutSecs = Preferences::GetInt("dom.ipc.tabs.shutdownTimeoutSecs", 5);
|
2013-01-10 17:22:14 +04:00
|
|
|
if (timeoutSecs > 0) {
|
2015-01-07 08:42:23 +03:00
|
|
|
mForceKillTimer = do_CreateInstance("@mozilla.org/timer;1");
|
|
|
|
MOZ_ASSERT(mForceKillTimer);
|
|
|
|
mForceKillTimer->InitWithFuncCallback(ContentParent::ForceKillTimerCallback,
|
|
|
|
this,
|
|
|
|
timeoutSecs * 1000,
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
2013-01-10 17:22:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentParent::NotifyTabDestroyed(const TabId& aTabId,
|
2013-01-10 17:22:14 +04:00
|
|
|
bool aNotifiedDestroying)
|
2012-07-17 22:27:27 +04:00
|
|
|
{
|
2013-01-10 17:22:14 +04:00
|
|
|
if (aNotifiedDestroying) {
|
|
|
|
--mNumDestroyingTabs;
|
|
|
|
}
|
|
|
|
|
2015-04-14 04:08:00 +03:00
|
|
|
nsTArray<PContentPermissionRequestParent*> parentArray =
|
2015-08-28 10:18:00 +03:00
|
|
|
nsContentPermissionUtils::GetContentPermissionRequestParentById(aTabId);
|
2015-04-14 04:08:00 +03:00
|
|
|
|
|
|
|
// Need to close undeleted ContentPermissionRequestParents before tab is closed.
|
|
|
|
for (auto& permissionRequestParent : parentArray) {
|
2015-11-09 03:55:08 +03:00
|
|
|
Unused << PContentPermissionRequestParent::Send__delete__(permissionRequestParent);
|
2015-04-14 04:08:00 +03:00
|
|
|
}
|
|
|
|
|
2012-07-17 22:27:27 +04:00
|
|
|
// There can be more than one PBrowser for a given app process
|
|
|
|
// because of popup windows. When the last one closes, shut
|
|
|
|
// us down.
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID());
|
|
|
|
if (tabIds.Length() == 1) {
|
2015-01-10 21:18:59 +03:00
|
|
|
// In the case of normal shutdown, send a shutdown message to child to
|
|
|
|
// allow it to perform shutdown tasks.
|
2012-07-17 22:27:27 +04:00
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
2013-07-15 16:55:13 +04:00
|
|
|
NewRunnableMethod(this, &ContentParent::ShutDownProcess,
|
2015-01-10 21:18:59 +03:00
|
|
|
SEND_SHUTDOWN_MESSAGE));
|
2012-07-17 22:27:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 00:32:18 +03:00
|
|
|
jsipc::CPOWManager*
|
2013-07-03 11:24:32 +04:00
|
|
|
ContentParent::GetCPOWManager()
|
|
|
|
{
|
2015-10-08 03:15:56 +03:00
|
|
|
if (PJavaScriptParent* p = LoneManagedOrNull(ManagedPJavaScriptParent())) {
|
|
|
|
return CPOWManagerFor(p);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
2014-05-09 02:43:53 +04:00
|
|
|
return nullptr;
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2009-08-12 22:31:48 +04:00
|
|
|
TestShellParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::CreateTestShell()
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2009-09-10 02:00:14 +04:00
|
|
|
return static_cast<TestShellParent*>(SendPTestShellConstructor());
|
2009-08-12 22:31:48 +04:00
|
|
|
}
|
|
|
|
|
2009-11-11 11:34:08 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::DestroyTestShell(TestShellParent* aTestShell)
|
2009-11-11 11:34:08 +03:00
|
|
|
{
|
2009-12-03 11:16:14 +03:00
|
|
|
return PTestShellParent::Send__delete__(aTestShell);
|
2009-11-11 11:34:08 +03:00
|
|
|
}
|
|
|
|
|
2011-06-24 03:31:58 +04:00
|
|
|
TestShellParent*
|
|
|
|
ContentParent::GetTestShellSingleton()
|
|
|
|
{
|
2015-10-08 03:15:56 +03:00
|
|
|
PTestShellParent* p = LoneManagedOrNull(ManagedPTestShellParent());
|
|
|
|
return static_cast<TestShellParent*>(p);
|
2011-06-24 03:31:58 +04:00
|
|
|
}
|
|
|
|
|
2013-06-03 14:14:40 +04:00
|
|
|
void
|
|
|
|
ContentParent::InitializeMembers()
|
|
|
|
{
|
|
|
|
mSubprocess = nullptr;
|
|
|
|
mChildID = gContentChildID++;
|
|
|
|
mGeolocationWatchID = -1;
|
|
|
|
mNumDestroyingTabs = 0;
|
|
|
|
mIsAlive = true;
|
2015-01-28 08:52:46 +03:00
|
|
|
mMetamorphosed = false;
|
2013-06-03 14:14:40 +04:00
|
|
|
mSendPermissionUpdates = false;
|
2014-06-03 18:36:46 +04:00
|
|
|
mSendDataStoreInfos = false;
|
2013-06-03 14:14:40 +04:00
|
|
|
mCalledClose = false;
|
|
|
|
mCalledCloseWithError = false;
|
|
|
|
mCalledKillHard = false;
|
2014-12-18 21:52:00 +03:00
|
|
|
mCreatedPairedMinidumps = false;
|
2015-01-10 21:18:59 +03:00
|
|
|
mShutdownPending = false;
|
2015-01-10 21:39:33 +03:00
|
|
|
mIPCOpen = true;
|
2015-01-17 05:34:47 +03:00
|
|
|
mHangMonitorActor = nullptr;
|
2013-06-03 14:14:40 +04:00
|
|
|
}
|
|
|
|
|
2015-05-11 10:24:40 +03:00
|
|
|
bool
|
|
|
|
ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PRIORITY_FOREGROUND */)
|
|
|
|
{
|
|
|
|
std::vector<std::string> extraArgs;
|
|
|
|
if (mIsNuwaProcess) {
|
|
|
|
extraArgs.push_back("-nuwa");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSubprocess->LaunchAndWaitForProcessHandle(extraArgs)) {
|
|
|
|
MarkAsDead();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Open(mSubprocess->GetChannel(),
|
|
|
|
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
|
|
|
|
|
|
|
InitInternal(aInitialPriority,
|
|
|
|
true, /* Setup off-main thread compositing */
|
|
|
|
true /* Send registered chrome */);
|
|
|
|
|
|
|
|
ContentProcessManager::GetSingleton()->AddContentProcess(this);
|
|
|
|
|
|
|
|
ProcessHangMonitor::AddProcess(this);
|
|
|
|
|
|
|
|
// Set a reply timeout for CPOWs.
|
|
|
|
SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 0));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
ContentParent::ContentParent(mozIApplication* aApp,
|
2014-06-11 09:44:13 +04:00
|
|
|
ContentParent* aOpener,
|
2012-08-29 16:24:48 +04:00
|
|
|
bool aIsForBrowser,
|
2013-04-26 04:53:26 +04:00
|
|
|
bool aIsForPreallocated,
|
2013-06-03 14:14:40 +04:00
|
|
|
bool aIsNuwaProcess /* = false */)
|
2014-06-11 09:44:03 +04:00
|
|
|
: nsIContentParent()
|
2014-06-11 09:44:13 +04:00
|
|
|
, mOpener(aOpener)
|
2014-06-11 09:44:03 +04:00
|
|
|
, mIsForBrowser(aIsForBrowser)
|
2014-01-14 22:35:08 +04:00
|
|
|
, mIsNuwaProcess(aIsNuwaProcess)
|
2015-04-24 01:05:29 +03:00
|
|
|
, mHasGamepadListener(false)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2013-06-03 14:14:40 +04:00
|
|
|
InitializeMembers(); // Perform common initialization.
|
|
|
|
|
2014-01-15 09:17:34 +04:00
|
|
|
// No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
|
|
|
|
// true.
|
|
|
|
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
|
|
|
|
|
|
|
|
// Only the preallocated process uses Nuwa.
|
|
|
|
MOZ_ASSERT_IF(aIsNuwaProcess, aIsForPreallocated);
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2015-01-28 08:52:46 +03:00
|
|
|
if (!aIsNuwaProcess && !aIsForPreallocated) {
|
|
|
|
mMetamorphosed = true;
|
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
// Insert ourselves into the global linked list of ContentParent objects.
|
2013-07-18 01:31:10 +04:00
|
|
|
if (!sContentParents) {
|
|
|
|
sContentParents = new LinkedList<ContentParent>();
|
|
|
|
}
|
2013-06-03 14:14:40 +04:00
|
|
|
if (!aIsNuwaProcess) {
|
|
|
|
sContentParents->insertBack(this);
|
|
|
|
}
|
2013-04-26 04:53:26 +04:00
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
if (aApp) {
|
|
|
|
aApp->GetManifestURL(mAppManifestURL);
|
|
|
|
aApp->GetName(mAppName);
|
|
|
|
} else if (aIsForPreallocated) {
|
|
|
|
mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
|
|
|
|
}
|
|
|
|
|
2012-04-10 23:57:20 +04:00
|
|
|
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
|
|
|
|
// PID along with the warning.
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Parent");
|
|
|
|
|
2014-11-15 04:22:44 +03:00
|
|
|
#if defined(XP_WIN) && !defined(MOZ_B2G)
|
|
|
|
// Request Windows message deferral behavior on our side of the PContent
|
|
|
|
// channel. Generally only applies to the situation where we get caught in
|
|
|
|
// a deadlock with the plugin process when sending CPOWs.
|
|
|
|
GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
|
|
|
|
#endif
|
|
|
|
|
2009-09-03 04:18:27 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2014-03-13 02:48:15 +04:00
|
|
|
ChildPrivileges privs = aIsNuwaProcess
|
|
|
|
? base::PRIVILEGES_INHERIT
|
|
|
|
: base::PRIVILEGES_DEFAULT;
|
|
|
|
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, privs);
|
2012-07-18 03:59:44 +04:00
|
|
|
|
2013-06-03 14:14:40 +04:00
|
|
|
IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2013-06-03 14:14:40 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2013-11-29 13:28:54 +04:00
|
|
|
static const mozilla::ipc::FileDescriptor*
|
2013-06-03 14:14:40 +04:00
|
|
|
FindFdProtocolFdMapping(const nsTArray<ProtocolFdMapping>& aFds,
|
|
|
|
ProtocolId aProtoId)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < aFds.Length(); i++) {
|
|
|
|
if (aFds[i].protocolId() == aProtoId) {
|
|
|
|
return &aFds[i].fd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor is used for new content process cloned from a template.
|
|
|
|
*
|
|
|
|
* For Nuwa.
|
|
|
|
*/
|
|
|
|
ContentParent::ContentParent(ContentParent* aTemplate,
|
|
|
|
const nsAString& aAppManifestURL,
|
|
|
|
base::ProcessHandle aPid,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<ProtocolFdMapping>&& aFds)
|
2014-03-13 02:48:15 +04:00
|
|
|
: mAppManifestURL(aAppManifestURL)
|
2013-06-03 14:14:40 +04:00
|
|
|
, mIsForBrowser(false)
|
2014-01-14 22:35:08 +04:00
|
|
|
, mIsNuwaProcess(false)
|
2013-06-03 14:14:40 +04:00
|
|
|
{
|
|
|
|
InitializeMembers(); // Perform common initialization.
|
|
|
|
|
|
|
|
sContentParents->insertBack(this);
|
|
|
|
|
|
|
|
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
|
|
|
|
// PID along with the warning.
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Parent");
|
|
|
|
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
|
|
|
|
const FileDescriptor* fd = FindFdProtocolFdMapping(aFds, GetProtocolId());
|
|
|
|
|
|
|
|
NS_ASSERTION(fd != nullptr, "IPC Channel for PContent is necessary!");
|
|
|
|
mSubprocess = new GeckoExistingProcessHost(GeckoProcessType_Content,
|
|
|
|
aPid,
|
2014-03-13 02:48:15 +04:00
|
|
|
*fd);
|
2013-06-03 14:14:40 +04:00
|
|
|
|
|
|
|
mSubprocess->LaunchAndWaitForProcessHandle();
|
|
|
|
|
|
|
|
// Clone actors routed by aTemplate for this instance.
|
|
|
|
IToplevelProtocol::SetTransport(mSubprocess->GetChannel());
|
|
|
|
ProtocolCloneContext cloneContext;
|
|
|
|
cloneContext.SetContentParent(this);
|
|
|
|
CloneManagees(aTemplate, &cloneContext);
|
|
|
|
CloneOpenedToplevels(aTemplate, aFds, aPid, &cloneContext);
|
|
|
|
|
|
|
|
Open(mSubprocess->GetChannel(),
|
2015-04-01 11:40:35 +03:00
|
|
|
base::GetProcId(mSubprocess->GetChildProcessHandle()));
|
2013-06-03 14:14:40 +04:00
|
|
|
|
|
|
|
// Set the subprocess's priority (bg if we're a preallocated process, fg
|
|
|
|
// otherwise). We do this first because we're likely /lowering/ its CPU and
|
|
|
|
// memory priority, which it has inherited from this process.
|
|
|
|
ProcessPriority priority;
|
|
|
|
if (IsPreallocated()) {
|
2014-03-13 11:24:42 +04:00
|
|
|
priority = PROCESS_PRIORITY_PREALLOC;
|
2013-06-03 14:14:40 +04:00
|
|
|
} else {
|
|
|
|
priority = PROCESS_PRIORITY_FOREGROUND;
|
|
|
|
}
|
|
|
|
|
2013-11-29 13:28:54 +04:00
|
|
|
InitInternal(priority,
|
|
|
|
false, /* Setup Off-main thread compositing */
|
|
|
|
false /* Send registered chrome */);
|
2014-10-29 21:11:00 +03:00
|
|
|
|
|
|
|
ContentProcessManager::GetSingleton()->AddContentProcess(this);
|
2013-06-03 14:14:40 +04:00
|
|
|
}
|
|
|
|
#endif // MOZ_NUWA_PROCESS
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::~ContentParent()
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2015-01-07 08:42:23 +03:00
|
|
|
if (mForceKillTimer) {
|
|
|
|
mForceKillTimer->Cancel();
|
2013-01-10 17:22:14 +04:00
|
|
|
}
|
|
|
|
|
2009-09-03 04:18:27 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-07-14 01:10:20 +04:00
|
|
|
|
|
|
|
// We should be removed from all these lists in ActorDestroy.
|
2013-04-26 04:53:26 +04:00
|
|
|
MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
|
2012-07-14 01:10:20 +04:00
|
|
|
if (mAppManifestURL.IsEmpty()) {
|
2013-04-26 04:53:26 +04:00
|
|
|
MOZ_ASSERT(!sNonAppContentParents ||
|
|
|
|
!sNonAppContentParents->Contains(this));
|
2012-07-14 01:10:20 +04:00
|
|
|
} else {
|
2013-04-26 04:53:26 +04:00
|
|
|
// In general, we expect sAppContentParents->Get(mAppManifestURL) to be
|
2013-10-28 18:04:12 +04:00
|
|
|
// nullptr. But it could be that we created another ContentParent for
|
|
|
|
// this app after we did this->ActorDestroy(), so the right check is
|
|
|
|
// that sAppContentParents->Get(mAppManifestURL) != this.
|
2013-04-26 04:53:26 +04:00
|
|
|
MOZ_ASSERT(!sAppContentParents ||
|
|
|
|
sAppContentParents->Get(mAppManifestURL) != this);
|
2012-07-14 01:10:20 +04:00
|
|
|
}
|
2014-08-22 09:41:34 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
sNuwaReady = false;
|
2014-09-30 18:12:11 +04:00
|
|
|
sNuwaPid = 0;
|
2014-08-22 09:41:34 +04:00
|
|
|
}
|
|
|
|
#endif
|
2010-04-12 04:24:45 +04:00
|
|
|
}
|
|
|
|
|
2013-11-29 13:28:54 +04:00
|
|
|
void
|
|
|
|
ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
|
|
|
bool aSetupOffMainThreadCompositing,
|
|
|
|
bool aSendRegisteredChrome)
|
|
|
|
{
|
2015-04-20 22:50:34 +03:00
|
|
|
if (aSendRegisteredChrome) {
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryChrome* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
|
|
|
chromeRegistry->SendRegisteredChrome(this);
|
|
|
|
}
|
|
|
|
|
2015-05-14 17:49:38 +03:00
|
|
|
if (gAppData) {
|
|
|
|
nsCString version(gAppData->version);
|
|
|
|
nsCString buildID(gAppData->buildID);
|
|
|
|
nsCString name(gAppData->name);
|
|
|
|
nsCString UAName(gAppData->UAName);
|
|
|
|
nsCString ID(gAppData->ID);
|
|
|
|
nsCString vendor(gAppData->vendor);
|
|
|
|
|
|
|
|
// Sending all information to content process.
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendAppInfo(version, buildID, name, UAName, ID, vendor);
|
2015-05-14 17:49:38 +03:00
|
|
|
}
|
|
|
|
|
2015-10-09 16:22:00 +03:00
|
|
|
// Initialize the message manager (and load delayed scripts) now that we
|
|
|
|
// have established communications with the child.
|
|
|
|
mMessageManager->InitWithCallback(this);
|
|
|
|
|
|
|
|
// Set the subprocess's priority. We do this early on because we're likely
|
|
|
|
// /lowering/ the process's CPU and memory priority, which it has inherited
|
|
|
|
// from this process.
|
|
|
|
//
|
|
|
|
// This call can cause us to send IPC messages to the child process, so it
|
|
|
|
// must come after the Open() call above.
|
|
|
|
ProcessPriorityManager::SetProcessPriority(this, aInitialPriority);
|
|
|
|
|
2013-11-29 13:28:54 +04:00
|
|
|
if (aSetupOffMainThreadCompositing) {
|
|
|
|
// NB: internally, this will send an IPC message to the child
|
|
|
|
// process to get it to create the CompositorChild. This
|
|
|
|
// message goes through the regular IPC queue for this
|
|
|
|
// channel, so delivery will happen-before any other messages
|
|
|
|
// we send. The CompositorChild must be created before any
|
|
|
|
// PBrowsers are created, because they rely on the Compositor
|
|
|
|
// already being around. (Creation is async, so can't happen
|
|
|
|
// on demand.)
|
|
|
|
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
|
|
|
|
if (useOffMainThreadCompositing) {
|
|
|
|
DebugOnly<bool> opened = PCompositor::Open(this);
|
|
|
|
MOZ_ASSERT(opened);
|
|
|
|
|
2014-06-17 11:41:00 +04:00
|
|
|
opened = PImageBridge::Open(this);
|
|
|
|
MOZ_ASSERT(opened);
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
2014-05-01 05:52:00 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-07-08 17:46:17 +04:00
|
|
|
DebugOnly<bool> opened = PSharedBufferManager::Open(this);
|
|
|
|
MOZ_ASSERT(opened);
|
2014-05-01 05:52:00 +04:00
|
|
|
#endif
|
2014-07-08 17:46:17 +04:00
|
|
|
}
|
2013-11-29 13:28:54 +04:00
|
|
|
|
|
|
|
if (gAppData) {
|
|
|
|
// Sending all information to content process.
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendAppInit();
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
|
|
|
if (sheetService) {
|
|
|
|
// This looks like a lot of work, but in a normal browser session we just
|
|
|
|
// send two loads.
|
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : *sheetService->AgentStyleSheets()) {
|
2013-11-29 13:28:54 +04:00
|
|
|
URIParams uri;
|
2015-11-17 09:04:09 +03:00
|
|
|
SerializeURI(sheet->GetSheetURI(), uri);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AGENT_SHEET);
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : *sheetService->UserStyleSheets()) {
|
2013-11-29 13:28:54 +04:00
|
|
|
URIParams uri;
|
2015-11-17 09:04:09 +03:00
|
|
|
SerializeURI(sheet->GetSheetURI(), uri);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::USER_SHEET);
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
|
|
|
|
2015-11-17 09:04:09 +03:00
|
|
|
for (CSSStyleSheet* sheet : *sheetService->AuthorStyleSheets()) {
|
2013-11-29 13:28:54 +04:00
|
|
|
URIParams uri;
|
2015-11-17 09:04:09 +03:00
|
|
|
SerializeURI(sheet->GetSheetURI(), uri);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendLoadAndRegisterSheet(uri, nsIStyleSheetService::AUTHOR_SHEET);
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_CONTENT_SANDBOX
|
2014-03-13 02:48:15 +04:00
|
|
|
bool shouldSandbox = true;
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
shouldSandbox = false;
|
|
|
|
}
|
|
|
|
#endif
|
2015-10-08 08:13:09 +03:00
|
|
|
MaybeFileDesc brokerFd = void_t();
|
|
|
|
#ifdef XP_LINUX
|
|
|
|
if (shouldSandbox) {
|
|
|
|
MOZ_ASSERT(!mSandboxBroker);
|
|
|
|
UniquePtr<SandboxBroker::Policy> policy =
|
|
|
|
sSandboxBrokerPolicyFactory->GetContentPolicy(Pid());
|
|
|
|
if (policy) {
|
|
|
|
brokerFd = FileDescriptor();
|
|
|
|
mSandboxBroker = SandboxBroker::Create(Move(policy), Pid(),
|
|
|
|
brokerFd);
|
|
|
|
if (!mSandboxBroker) {
|
|
|
|
KillHard("SandboxBroker::Create failed");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(static_cast<const FileDescriptor&>(brokerFd).IsValid());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) {
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard("SandboxInitFailed");
|
2013-11-29 13:28:54 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-04-12 04:24:45 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::IsAlive()
|
2010-04-12 04:24:45 +04:00
|
|
|
{
|
|
|
|
return mIsAlive;
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
|
|
|
|
2012-07-17 22:27:27 +04:00
|
|
|
bool
|
|
|
|
ContentParent::IsForApp()
|
|
|
|
{
|
|
|
|
return !mAppManifestURL.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2014-01-14 22:35:08 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
bool
|
2015-05-19 09:31:25 +03:00
|
|
|
ContentParent::IsNuwaProcess()
|
2014-01-14 22:35:08 +04:00
|
|
|
{
|
|
|
|
return mIsNuwaProcess;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-18 01:31:10 +04:00
|
|
|
int32_t
|
|
|
|
ContentParent::Pid()
|
|
|
|
{
|
|
|
|
if (!mSubprocess || !mSubprocess->GetChildProcessHandle()) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return base::GetProcId(mSubprocess->GetChildProcessHandle());
|
|
|
|
}
|
|
|
|
|
2010-05-26 04:13:47 +04:00
|
|
|
bool
|
2012-08-23 00:00:21 +04:00
|
|
|
ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefSetting>* aPrefs)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
2012-08-23 00:00:21 +04:00
|
|
|
Preferences::GetPreferences(aPrefs);
|
2010-05-28 22:09:15 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-13 07:04:42 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvReadFontList(InfallibleTArray<FontListEntry>* retValue)
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
2015-05-13 08:11:25 +03:00
|
|
|
gfxAndroidPlatform::GetPlatform()->GetSystemFontList(retValue);
|
2011-01-13 07:04:42 +03:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-30 22:30:00 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvReadDataStorageArray(const nsString& aFilename,
|
|
|
|
InfallibleTArray<DataStorageItem>* aValues)
|
|
|
|
{
|
|
|
|
RefPtr<DataStorage> storage = DataStorage::Get(aFilename);
|
|
|
|
storage->GetAll(aValues);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 22:07:38 +04:00
|
|
|
bool
|
2010-11-09 05:49:00 +03:00
|
|
|
ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
|
2010-07-15 18:04:25 +04:00
|
|
|
{
|
2010-10-09 22:07:38 +04:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
2011-08-30 21:45:09 +04:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
2014-04-29 21:27:26 +04:00
|
|
|
services::GetPermissionManager();
|
2011-08-30 21:45:09 +04:00
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(permissionManager,
|
|
|
|
"We have no permissionManager in the Chrome process !");
|
2010-10-09 22:07:38 +04:00
|
|
|
|
2010-10-21 22:36:39 +04:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
2011-09-18 23:02:27 +04:00
|
|
|
DebugOnly<nsresult> rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Could not get enumerator!");
|
2010-10-09 22:07:38 +04:00
|
|
|
while(1) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasMore;
|
2010-10-09 22:07:38 +04:00
|
|
|
enumerator->HasMoreElements(&hasMore);
|
|
|
|
if (!hasMore)
|
|
|
|
break;
|
2010-10-21 22:36:39 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> supp;
|
|
|
|
enumerator->GetNext(getter_AddRefs(supp));
|
2010-10-09 22:07:38 +04:00
|
|
|
nsCOMPtr<nsIPermission> perm = do_QueryInterface(supp);
|
|
|
|
|
2015-06-10 19:48:22 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
perm->GetPrincipal(getter_AddRefs(principal));
|
|
|
|
nsCString origin;
|
|
|
|
if (principal) {
|
|
|
|
principal->GetOrigin(origin);
|
|
|
|
}
|
2010-10-09 22:07:38 +04:00
|
|
|
nsCString type;
|
|
|
|
perm->GetType(type);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t capability;
|
2010-10-09 22:07:38 +04:00
|
|
|
perm->GetCapability(&capability);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t expireType;
|
2010-10-09 22:07:38 +04:00
|
|
|
perm->GetExpireType(&expireType);
|
2012-08-22 19:56:38 +04:00
|
|
|
int64_t expireTime;
|
2010-10-09 22:07:38 +04:00
|
|
|
perm->GetExpireTime(&expireTime);
|
|
|
|
|
2015-06-10 19:48:22 +03:00
|
|
|
aPermissions->AppendElement(IPC::Permission(origin, type,
|
2012-08-23 22:38:01 +04:00
|
|
|
capability, expireType,
|
|
|
|
expireTime));
|
2010-07-15 18:04:25 +04:00
|
|
|
}
|
2010-10-09 22:07:38 +04:00
|
|
|
|
|
|
|
// Ask for future changes
|
2011-08-02 23:35:42 +04:00
|
|
|
mSendPermissionUpdates = true;
|
2010-10-09 22:07:38 +04:00
|
|
|
#endif
|
|
|
|
|
2011-04-30 03:46:20 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-01 08:36:43 +03:00
|
|
|
bool
|
2015-04-16 22:38:12 +03:00
|
|
|
ContentParent::RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
|
|
|
|
const bool& aIsPrivateData,
|
|
|
|
const int32_t& aWhichClipboard)
|
2011-03-01 08:36:43 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
2015-04-10 20:14:33 +03:00
|
|
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
trans->Init(nullptr);
|
2015-04-10 19:51:06 +03:00
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
const nsTArray<IPCDataTransferItem>& items = aDataTransfer.items();
|
|
|
|
for (uint32_t j = 0; j < items.Length(); ++j) {
|
|
|
|
const IPCDataTransferItem& item = items[j];
|
2015-04-10 19:51:06 +03:00
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
trans->AddDataFlavor(item.flavor().get());
|
2015-04-10 19:51:06 +03:00
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
if (item.data().type() == IPCDataTransferData::TnsString) {
|
|
|
|
nsCOMPtr<nsISupportsString> dataWrapper =
|
|
|
|
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
nsString text = item.data().get_nsString();
|
|
|
|
rv = dataWrapper->SetData(text);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
rv = trans->SetTransferData(item.flavor().get(), dataWrapper,
|
|
|
|
text.Length() * sizeof(char16_t));
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
} else if (item.data().type() == IPCDataTransferData::TnsCString) {
|
2015-07-08 08:06:00 +03:00
|
|
|
if (item.flavor().EqualsLiteral(kNativeImageMime) ||
|
|
|
|
item.flavor().EqualsLiteral(kJPEGImageMime) ||
|
2015-06-24 21:19:11 +03:00
|
|
|
item.flavor().EqualsLiteral(kJPGImageMime) ||
|
|
|
|
item.flavor().EqualsLiteral(kPNGImageMime) ||
|
|
|
|
item.flavor().EqualsLiteral(kGIFImageMime)) {
|
|
|
|
const IPCDataTransferImage& imageDetails = item.imageDetails();
|
2015-09-23 21:49:05 +03:00
|
|
|
const gfx::IntSize size(imageDetails.width(), imageDetails.height());
|
2015-06-24 21:19:11 +03:00
|
|
|
if (!size.width || !size.height) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString text = item.data().get_nsCString();
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DataSourceSurface> image =
|
2015-06-24 21:19:11 +03:00
|
|
|
new mozilla::gfx::SourceSurfaceRawData();
|
|
|
|
mozilla::gfx::SourceSurfaceRawData* raw =
|
|
|
|
static_cast<mozilla::gfx::SourceSurfaceRawData*>(image.get());
|
|
|
|
raw->InitWrappingData(
|
|
|
|
reinterpret_cast<uint8_t*>(const_cast<nsCString&>(text).BeginWriting()),
|
|
|
|
size, imageDetails.stride(),
|
|
|
|
static_cast<mozilla::gfx::SurfaceFormat>(imageDetails.format()), false);
|
|
|
|
raw->GuaranteePersistance();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxDrawable> drawable = new gfxSurfaceDrawable(image, size);
|
2015-06-24 21:19:11 +03:00
|
|
|
nsCOMPtr<imgIContainer> imageContainer(image::ImageOps::CreateFromDrawable(drawable));
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsInterfacePointer>
|
|
|
|
imgPtr(do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv));
|
|
|
|
|
|
|
|
rv = imgPtr->SetData(imageContainer);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
trans->SetTransferData(item.flavor().get(), imgPtr, sizeof(nsISupports*));
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsISupportsCString> dataWrapper =
|
|
|
|
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
2015-04-10 19:51:06 +03:00
|
|
|
|
2015-06-24 21:19:11 +03:00
|
|
|
const nsCString& text = item.data().get_nsCString();
|
|
|
|
rv = dataWrapper->SetData(text);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
2015-04-16 22:38:12 +03:00
|
|
|
|
2015-06-24 21:19:11 +03:00
|
|
|
rv = trans->SetTransferData(item.flavor().get(), dataWrapper,
|
|
|
|
text.Length());
|
2015-04-16 22:38:12 +03:00
|
|
|
|
2015-06-24 21:19:11 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
}
|
2015-04-16 22:38:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trans->SetIsPrivateData(aIsPrivateData);
|
|
|
|
|
|
|
|
clipboard->SetData(trans, nullptr, aWhichClipboard);
|
2011-03-01 08:36:43 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-04-16 22:38:12 +03:00
|
|
|
ContentParent::RecvGetClipboard(nsTArray<nsCString>&& aTypes,
|
|
|
|
const int32_t& aWhichClipboard,
|
|
|
|
IPCDataTransfer* aDataTransfer)
|
2011-03-01 08:36:43 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
2012-07-30 18:20:58 +04:00
|
|
|
trans->Init(nullptr);
|
2014-02-10 04:13:10 +04:00
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
for (uint32_t t = 0; t < aTypes.Length(); t++) {
|
|
|
|
trans->AddDataFlavor(aTypes[t].get());
|
|
|
|
}
|
2011-03-01 08:36:43 +03:00
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
clipboard->GetData(trans, aWhichClipboard);
|
|
|
|
nsContentUtils::TransferableToIPCTransferable(trans, aDataTransfer,
|
2015-10-28 00:41:58 +03:00
|
|
|
true, nullptr, this);
|
2011-03-01 08:36:43 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-04-16 22:38:12 +03:00
|
|
|
ContentParent::RecvEmptyClipboard(const int32_t& aWhichClipboard)
|
2011-03-01 08:36:43 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
clipboard->EmptyClipboard(aWhichClipboard);
|
2011-03-01 08:36:43 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-04-16 22:38:12 +03:00
|
|
|
ContentParent::RecvClipboardHasType(nsTArray<nsCString>&& aTypes,
|
|
|
|
const int32_t& aWhichClipboard,
|
|
|
|
bool* aHasType)
|
2011-03-01 08:36:43 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
2015-04-16 22:38:12 +03:00
|
|
|
const char** typesChrs = new const char *[aTypes.Length()];
|
|
|
|
for (uint32_t t = 0; t < aTypes.Length(); t++) {
|
|
|
|
typesChrs[t] = aTypes[t].get();
|
|
|
|
}
|
|
|
|
|
|
|
|
clipboard->HasDataMatchingFlavors(typesChrs, aTypes.Length(),
|
|
|
|
aWhichClipboard, aHasType);
|
|
|
|
|
|
|
|
delete [] typesChrs;
|
2011-03-01 08:36:43 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-30 22:04:41 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
ContentParent::RecvGetSystemColors(const uint32_t& colorsCount, InfallibleTArray<uint32_t>* colors)
|
2011-03-30 22:04:41 +04:00
|
|
|
{
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
|
|
|
if (AndroidBridge::Bridge() == nullptr) {
|
2011-07-28 04:34:47 +04:00
|
|
|
// Do not fail - the colors won't be right, but it's not critical
|
|
|
|
return true;
|
|
|
|
}
|
2011-03-30 22:04:41 +04:00
|
|
|
|
|
|
|
colors->AppendElements(colorsCount);
|
|
|
|
|
|
|
|
// The array elements correspond to the members of AndroidSystemColors structure,
|
|
|
|
// so just pass the pointer to the elements buffer
|
|
|
|
AndroidBridge::Bridge()->GetSystemColors((AndroidSystemColors*)colors->Elements());
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-14 01:02:13 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
ContentParent::RecvGetIconForExtension(const nsCString& aFileExt, const uint32_t& aIconSize, InfallibleTArray<uint8_t>* bits)
|
2011-06-14 01:02:13 +04:00
|
|
|
{
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
|
|
|
if (AndroidBridge::Bridge() == nullptr) {
|
2011-07-28 04:34:47 +04:00
|
|
|
// Do not fail - just no icon will be shown
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-14 01:02:13 +04:00
|
|
|
|
|
|
|
bits->AppendElements(aIconSize * aIconSize * 4);
|
|
|
|
|
|
|
|
AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, bits->Elements());
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-27 05:14:52 +04:00
|
|
|
bool
|
2011-09-29 10:19:26 +04:00
|
|
|
ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
|
2011-07-27 05:14:52 +04:00
|
|
|
{
|
|
|
|
// default behavior is to show the last password character
|
2011-10-17 18:59:28 +04:00
|
|
|
*showPassword = true;
|
2011-11-11 04:17:46 +04:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
2013-11-12 22:41:01 +04:00
|
|
|
|
2015-01-10 03:33:57 +03:00
|
|
|
*showPassword = mozilla::widget::GeckoAppShell::GetShowPasswordSetting();
|
2011-07-27 05:14:52 +04:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-09 08:46:19 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvFirstIdle()
|
|
|
|
{
|
2013-06-03 14:14:40 +04:00
|
|
|
// When the ContentChild goes idle, it sends us a FirstIdle message
|
|
|
|
// which we use as a good time to prelaunch another process. If we
|
|
|
|
// prelaunch any sooner than this, then we'll be competing with the
|
2012-10-09 08:46:19 +04:00
|
|
|
// child process and slowing it down.
|
2013-05-10 00:27:06 +04:00
|
|
|
PreallocatedProcessManager::AllocateAfterDelay();
|
2012-10-09 08:46:19 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-11 03:55:59 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
|
|
|
|
const bool& aHidden)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
2015-07-11 03:55:59 +03:00
|
|
|
MOZ_ASSERT(service);
|
|
|
|
service->SetDefaultVolumeControlChannelInternal(aChannel,
|
|
|
|
aHidden, mChildID);
|
2015-07-10 19:38:46 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-10 19:38:46 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAudioChannelServiceStatus(
|
|
|
|
const bool& aTelephonyChannel,
|
|
|
|
const bool& aContentOrNormalChannel,
|
|
|
|
const bool& aAnyChannel)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
2015-07-10 19:38:46 +03:00
|
|
|
MOZ_ASSERT(service);
|
|
|
|
|
|
|
|
service->ChildStatusReceived(mChildID, aTelephonyChannel,
|
|
|
|
aContentOrNormalChannel, aAnyChannel);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-03 18:36:46 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvDataStoreGetStores(
|
|
|
|
const nsString& aName,
|
2014-07-17 07:53:23 +04:00
|
|
|
const nsString& aOwner,
|
2014-06-03 18:36:46 +04:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
InfallibleTArray<DataStoreSetting>* aValue)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataStoreService> service = DataStoreService::GetOrCreate();
|
2014-06-03 18:36:46 +04:00
|
|
|
if (NS_WARN_IF(!service)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-17 07:53:23 +04:00
|
|
|
nsresult rv = service->GetDataStoresFromIPC(aName, aOwner, aPrincipal, aValue);
|
2014-06-03 18:36:46 +04:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSendDataStoreInfos = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-31 10:25:27 +03:00
|
|
|
void
|
|
|
|
ContentParent::ForkNewProcess(bool aBlocking)
|
2013-06-03 14:14:40 +04:00
|
|
|
{
|
2013-11-22 07:25:34 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2015-07-31 10:25:27 +03:00
|
|
|
uint32_t pid;
|
|
|
|
auto fds = MakeUnique<nsTArray<ProtocolFdMapping>>();
|
|
|
|
|
|
|
|
MOZ_ASSERT(IsNuwaProcess() && mNuwaParent);
|
|
|
|
|
|
|
|
if (mNuwaParent->ForkNewProcess(pid, mozilla::Move(fds), aBlocking)) {
|
|
|
|
OnNewProcessCreated(pid, mozilla::Move(fds));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NS_ERROR("ContentParent::ForkNewProcess() not implemented!");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-08-14 10:41:54 +03:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Keep only observer topics listed in sNuwaSafeObserverTopics and unregister
|
|
|
|
// all the other registered topics.
|
|
|
|
static void
|
|
|
|
KeepNuwaSafeObserverTopics(ContentParent* aNuwaContentParent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aNuwaContentParent && aNuwaContentParent->IsNuwaProcess());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (!obs) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t topicLength = ArrayLength(sObserverTopics);
|
|
|
|
for (size_t i = 0; i < topicLength; ++i) {
|
|
|
|
bool nuwaSafe = false;
|
|
|
|
size_t safeTopicLength = ArrayLength(sNuwaSafeObserverTopics);
|
|
|
|
|
|
|
|
for (size_t j = 0; j < safeTopicLength; j++) {
|
|
|
|
if (!nsCRT::strcmp(sObserverTopics[i],
|
|
|
|
sNuwaSafeObserverTopics[j])) {
|
|
|
|
// In the whitelist: don't need to unregister.
|
|
|
|
nuwaSafe = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!nuwaSafe) {
|
|
|
|
obs->RemoveObserver(aNuwaContentParent, sObserverTopics[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-07-31 10:25:27 +03:00
|
|
|
void
|
|
|
|
ContentParent::OnNuwaReady()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
// Protection from unauthorized IPC message is done in PNuwa protocol.
|
|
|
|
// Just assert that this actor is really for the Nuwa process.
|
|
|
|
MOZ_ASSERT(IsNuwaProcess());
|
2014-04-13 22:18:02 +04:00
|
|
|
|
2014-08-22 09:41:34 +04:00
|
|
|
sNuwaReady = true;
|
2015-08-14 10:41:54 +03:00
|
|
|
KeepNuwaSafeObserverTopics(this);
|
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
PreallocatedProcessManager::OnNuwaReady();
|
2015-07-31 10:25:27 +03:00
|
|
|
return;
|
2013-11-22 07:25:34 +04:00
|
|
|
#else
|
2015-07-31 10:25:27 +03:00
|
|
|
NS_ERROR("ContentParent::OnNuwaReady() not implemented!");
|
|
|
|
return;
|
2013-11-22 07:25:34 +04:00
|
|
|
#endif
|
2013-06-03 14:14:40 +04:00
|
|
|
}
|
|
|
|
|
2015-07-31 10:25:27 +03:00
|
|
|
void
|
|
|
|
ContentParent::OnNewProcessCreated(uint32_t aPid,
|
|
|
|
UniquePtr<nsTArray<ProtocolFdMapping>>&& aFds)
|
2013-06-03 14:14:40 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2015-07-31 10:25:27 +03:00
|
|
|
// Protection from unauthorized IPC message is done in PNuwa protocol.
|
|
|
|
// Just assert that this actor is really for the Nuwa process.
|
|
|
|
MOZ_ASSERT(IsNuwaProcess());
|
2014-04-13 22:18:02 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ContentParent> content;
|
2013-06-03 14:14:40 +04:00
|
|
|
content = new ContentParent(this,
|
|
|
|
MAGIC_PREALLOCATED_APP_MANIFEST_URL,
|
|
|
|
aPid,
|
2015-07-31 10:25:27 +03:00
|
|
|
Move(*aFds.get()));
|
2013-06-03 14:14:40 +04:00
|
|
|
content->Init();
|
2014-05-09 15:30:42 +04:00
|
|
|
|
|
|
|
size_t numNuwaPrefUpdates = sNuwaPrefUpdates ?
|
|
|
|
sNuwaPrefUpdates->Length() : 0;
|
|
|
|
// Resend pref updates to the forked child.
|
2014-11-27 02:13:49 +03:00
|
|
|
for (size_t i = 0; i < numNuwaPrefUpdates; i++) {
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i));
|
2014-05-09 15:30:42 +04:00
|
|
|
}
|
2014-08-22 09:41:34 +04:00
|
|
|
|
|
|
|
// Update offline settings.
|
2015-04-11 01:18:05 +03:00
|
|
|
bool isOffline, isLangRTL;
|
2015-05-02 00:14:39 +03:00
|
|
|
bool isConnected;
|
2014-10-03 18:52:37 +04:00
|
|
|
InfallibleTArray<nsString> unusedDictionaries;
|
2014-10-22 13:50:00 +04:00
|
|
|
ClipboardCapabilities clipboardCaps;
|
2015-03-24 17:29:16 +03:00
|
|
|
DomainPolicyClone domainPolicy;
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData initialData;
|
2015-04-22 17:58:15 +03:00
|
|
|
|
2015-05-02 00:14:39 +03:00
|
|
|
RecvGetXPCOMProcessAttributes(&isOffline, &isConnected,
|
|
|
|
&isLangRTL, &unusedDictionaries,
|
2015-06-17 18:49:50 +03:00
|
|
|
&clipboardCaps, &domainPolicy, &initialData);
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << content->SendSetOffline(isOffline);
|
|
|
|
mozilla::Unused << content->SendSetConnectivity(isConnected);
|
2014-10-22 13:50:00 +04:00
|
|
|
MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() &&
|
|
|
|
!clipboardCaps.supportsFindClipboard(),
|
|
|
|
"Unexpected values");
|
2014-08-22 09:41:34 +04:00
|
|
|
|
2013-11-22 07:25:34 +04:00
|
|
|
PreallocatedProcessManager::PublishSpareProcess(content);
|
2015-07-31 10:25:27 +03:00
|
|
|
return;
|
2013-06-03 14:14:40 +04:00
|
|
|
#else
|
2015-07-31 10:25:27 +03:00
|
|
|
NS_ERROR("ContentParent::OnNewProcessCreated() not implemented!");
|
|
|
|
return;
|
2013-06-03 14:14:40 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-20 04:22:25 +04:00
|
|
|
// We want ContentParent to show up in CC logs for debugging purposes, but we
|
|
|
|
// don't actually cycle collect it.
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_0(ContentParent)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(ContentParent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(ContentParent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ContentParent)
|
2014-06-11 09:44:03 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIContentParent)
|
2014-03-20 04:22:25 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionCallback)
|
2014-10-23 22:31:00 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionErrorCallback)
|
2014-03-20 04:22:25 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_END
|
2009-09-03 04:18:27 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aData)
|
2009-09-03 04:18:27 +04:00
|
|
|
{
|
2015-01-10 21:42:10 +03:00
|
|
|
if (mSubprocess && (!strcmp(aTopic, "profile-before-change") ||
|
|
|
|
!strcmp(aTopic, "xpcom-shutdown"))) {
|
|
|
|
// Okay to call ShutDownProcess multiple times.
|
|
|
|
ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
|
2015-01-10 21:39:33 +03:00
|
|
|
|
|
|
|
// Wait for shutdown to complete, so that we receive any shutdown
|
|
|
|
// data (e.g. telemetry) from the child before we quit.
|
|
|
|
// This loop terminate prematurely based on mForceKillTimer.
|
2015-04-17 20:59:56 +03:00
|
|
|
while (mIPCOpen && !mCalledKillHard) {
|
2015-01-10 21:39:33 +03:00
|
|
|
NS_ProcessNextEvent(nullptr, true);
|
2015-01-10 21:18:59 +03:00
|
|
|
}
|
2010-11-24 16:58:21 +03:00
|
|
|
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
2010-05-11 16:44:12 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
if (!mIsAlive || !mSubprocess)
|
|
|
|
return NS_OK;
|
|
|
|
|
2015-08-14 10:41:54 +03:00
|
|
|
// The Nuwa process unregisters the topics after it becomes ready except for
|
|
|
|
// the ones listed in sNuwaSafeObserverTopics. If the topic needs to be
|
|
|
|
// observed by the Nuwa process, either for:
|
|
|
|
// 1. The topic is safe for the Nuwa process, either:
|
|
|
|
// 1.1 The state can safely happen (only run on the main thread) in the Nuwa
|
|
|
|
// process (e.g. "a11y-init-or-shutdown"), or
|
|
|
|
// 1.2 The topic doesn't send an IPC message (e.g. "xpcom-shutdown").
|
|
|
|
// 2. The topic needs special handling (e.g. nsPref:Changed),
|
|
|
|
// add the topic to sNuwaSafeObserverTopics and then handle it if necessary.
|
|
|
|
|
2010-12-12 01:36:08 +03:00
|
|
|
// listening for memory pressure event
|
2012-11-08 05:07:57 +04:00
|
|
|
if (!strcmp(aTopic, "memory-pressure") &&
|
2013-04-26 05:36:53 +04:00
|
|
|
!StringEndsWith(nsDependentString(aData),
|
|
|
|
NS_LITERAL_STRING("-no-forward"))) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendFlushMemory(nsDependentString(aData));
|
2010-12-12 01:36:08 +03:00
|
|
|
}
|
2010-05-26 04:13:47 +04:00
|
|
|
// listening for remotePrefs...
|
2010-12-12 01:36:08 +03:00
|
|
|
else if (!strcmp(aTopic, "nsPref:changed")) {
|
2010-05-26 04:13:47 +04:00
|
|
|
// We know prefs are ASCII here.
|
|
|
|
NS_LossyConvertUTF16toASCII strData(aData);
|
2010-10-20 00:35:08 +04:00
|
|
|
|
2012-08-23 00:00:21 +04:00
|
|
|
PrefSetting pref(strData, null_t(), null_t());
|
|
|
|
Preferences::GetPreference(&pref);
|
2014-05-09 15:30:42 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
2015-08-14 10:41:54 +03:00
|
|
|
if (IsReadyNuwaProcess()) {
|
2014-05-09 15:30:42 +04:00
|
|
|
// Don't send the pref update to the Nuwa process. Save the update
|
|
|
|
// to send to the forked child.
|
|
|
|
if (!sNuwaPrefUpdates) {
|
|
|
|
sNuwaPrefUpdates = new nsTArray<PrefSetting>();
|
|
|
|
}
|
|
|
|
sNuwaPrefUpdates->AppendElement(pref);
|
|
|
|
} else if (!SendPreferenceUpdate(pref)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
#else
|
2012-08-23 00:00:21 +04:00
|
|
|
if (!SendPreferenceUpdate(pref)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2011-01-06 07:54:47 +03:00
|
|
|
}
|
2014-05-09 15:30:42 +04:00
|
|
|
#endif
|
2010-05-26 04:13:47 +04:00
|
|
|
}
|
2010-07-19 22:33:33 +04:00
|
|
|
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
|
2015-08-14 10:41:54 +03:00
|
|
|
NS_ConvertUTF16toUTF8 dataStr(aData);
|
|
|
|
const char *offline = dataStr.get();
|
|
|
|
if (!SendSetOffline(!strcmp(offline, "true") ? true : false)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2015-05-02 00:14:39 +03:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC)) {
|
2015-08-14 10:41:54 +03:00
|
|
|
if (!SendSetConnectivity(NS_LITERAL_STRING("true").Equals(aData))) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2015-05-02 00:14:39 +03:00
|
|
|
}
|
2010-05-11 16:44:12 +04:00
|
|
|
}
|
2010-09-15 20:44:57 +04:00
|
|
|
// listening for alert notifications
|
|
|
|
else if (!strcmp(aTopic, "alertfinished") ||
|
2013-03-18 17:24:53 +04:00
|
|
|
!strcmp(aTopic, "alertclickcallback") ||
|
2015-10-23 00:10:14 +03:00
|
|
|
!strcmp(aTopic, "alertshow") ||
|
2015-10-23 00:20:51 +03:00
|
|
|
!strcmp(aTopic, "alertdisablecallback") ||
|
|
|
|
!strcmp(aTopic, "alertsettingscallback")) {
|
2010-09-15 20:44:57 +04:00
|
|
|
if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
|
|
|
|
nsDependentString(aData)))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2011-09-13 21:53:51 +04:00
|
|
|
else if (!strcmp(aTopic, "child-gc-request")){
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendGarbageCollect();
|
2011-09-13 21:53:51 +04:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "child-cc-request")){
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendCycleCollect();
|
2011-02-16 21:43:23 +03:00
|
|
|
}
|
2013-12-03 08:07:02 +04:00
|
|
|
else if (!strcmp(aTopic, "child-mmu-request")){
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendMinimizeMemoryUsage();
|
2013-12-03 08:07:02 +04:00
|
|
|
}
|
2012-04-20 04:13:20 +04:00
|
|
|
else if (!strcmp(aTopic, "last-pb-context-exited")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendLastPrivateDocShellDestroyed();
|
2012-04-20 04:13:20 +04:00
|
|
|
}
|
2012-08-18 06:43:00 +04:00
|
|
|
else if (!strcmp(aTopic, "file-watcher-update")) {
|
|
|
|
nsCString creason;
|
|
|
|
CopyUTF16toUTF8(aData, creason);
|
2012-08-31 02:17:37 +04:00
|
|
|
DeviceStorageFile* file = static_cast<DeviceStorageFile*>(aSubject);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendFilePathUpdate(file->mStorageType, file->mStorageName, file->mPath, creason);
|
2012-08-18 06:43:00 +04:00
|
|
|
}
|
2012-08-04 03:48:58 +04:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
else if(!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) {
|
|
|
|
nsCOMPtr<nsIVolume> vol = do_QueryInterface(aSubject);
|
|
|
|
if (!vol) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString volName;
|
|
|
|
nsString mountPoint;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t state;
|
2012-12-15 04:01:34 +04:00
|
|
|
int32_t mountGeneration;
|
2013-08-23 03:12:25 +04:00
|
|
|
bool isMediaPresent;
|
|
|
|
bool isSharing;
|
2013-12-03 13:32:56 +04:00
|
|
|
bool isFormatting;
|
2014-05-14 02:48:04 +04:00
|
|
|
bool isFake;
|
2014-09-22 07:42:33 +04:00
|
|
|
bool isUnmounting;
|
2014-12-22 05:33:33 +03:00
|
|
|
bool isRemovable;
|
|
|
|
bool isHotSwappable;
|
2012-08-04 03:48:58 +04:00
|
|
|
|
|
|
|
vol->GetName(volName);
|
|
|
|
vol->GetMountPoint(mountPoint);
|
|
|
|
vol->GetState(&state);
|
2012-12-15 04:01:34 +04:00
|
|
|
vol->GetMountGeneration(&mountGeneration);
|
2013-08-23 03:12:25 +04:00
|
|
|
vol->GetIsMediaPresent(&isMediaPresent);
|
|
|
|
vol->GetIsSharing(&isSharing);
|
2013-12-03 13:32:56 +04:00
|
|
|
vol->GetIsFormatting(&isFormatting);
|
2014-05-14 02:48:04 +04:00
|
|
|
vol->GetIsFake(&isFake);
|
2014-09-22 07:42:33 +04:00
|
|
|
vol->GetIsUnmounting(&isUnmounting);
|
2014-12-22 05:33:33 +03:00
|
|
|
vol->GetIsRemovable(&isRemovable);
|
|
|
|
vol->GetIsHotSwappable(&isHotSwappable);
|
2012-08-04 03:48:58 +04:00
|
|
|
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendFileSystemUpdate(volName, mountPoint, state,
|
2015-08-14 10:41:54 +03:00
|
|
|
mountGeneration, isMediaPresent,
|
|
|
|
isSharing, isFormatting, isFake,
|
|
|
|
isUnmounting, isRemovable, isHotSwappable);
|
2013-09-13 12:51:45 +04:00
|
|
|
} else if (!strcmp(aTopic, "phone-state-changed")) {
|
|
|
|
nsString state(aData);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyPhoneStateChange(state);
|
2012-08-04 03:48:58 +04:00
|
|
|
}
|
2015-05-04 09:11:00 +03:00
|
|
|
else if(!strcmp(aTopic, NS_VOLUME_REMOVED)) {
|
2015-08-14 10:41:54 +03:00
|
|
|
nsString volName(aData);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendVolumeRemoved(volName);
|
2015-05-04 09:11:00 +03:00
|
|
|
}
|
2012-08-04 03:48:58 +04:00
|
|
|
#endif
|
2011-07-21 08:37:32 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// Make sure accessibility is running in content process when accessibility
|
|
|
|
// gets initiated in chrome process.
|
|
|
|
else if (aData && (*aData == '1') &&
|
|
|
|
!strcmp(aTopic, "a11y-init-or-shutdown")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendActivateA11y();
|
2011-07-21 08:37:32 +04:00
|
|
|
}
|
|
|
|
#endif
|
2014-08-29 04:20:27 +04:00
|
|
|
else if (!strcmp(aTopic, "app-theme-changed")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendOnAppThemeChanged();
|
2014-08-29 04:20:27 +04:00
|
|
|
}
|
2014-11-18 20:50:25 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
|
|
|
else if (!strcmp(aTopic, "profiler-started")) {
|
|
|
|
nsCOMPtr<nsIProfilerStartParams> params(do_QueryInterface(aSubject));
|
2015-08-11 21:26:27 +03:00
|
|
|
StartProfiler(params);
|
2014-11-18 20:50:25 +03:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "profiler-stopped")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendStopProfiler();
|
2014-11-18 20:50:25 +03:00
|
|
|
}
|
2015-07-15 19:39:39 +03:00
|
|
|
else if (!strcmp(aTopic, "profiler-paused")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendPauseProfiler(true);
|
2015-07-15 19:39:39 +03:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "profiler-resumed")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendPauseProfiler(false);
|
2015-07-15 19:39:39 +03:00
|
|
|
}
|
2015-06-11 00:58:30 +03:00
|
|
|
else if (!strcmp(aTopic, "profiler-subprocess-gather")) {
|
|
|
|
mGatherer = static_cast<ProfileGatherer*>(aSubject);
|
|
|
|
mGatherer->WillGatherOOPProfile();
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendGatherProfile();
|
2015-06-11 00:58:30 +03:00
|
|
|
}
|
2014-11-18 20:50:25 +03:00
|
|
|
else if (!strcmp(aTopic, "profiler-subprocess")) {
|
|
|
|
nsCOMPtr<nsIProfileSaveEvent> pse = do_QueryInterface(aSubject);
|
|
|
|
if (pse) {
|
2015-06-11 00:58:30 +03:00
|
|
|
if (!mProfile.IsEmpty()) {
|
|
|
|
pse->AddSubProfile(mProfile.get());
|
|
|
|
mProfile.Truncate();
|
2014-11-18 20:50:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-10-29 11:56:12 +03:00
|
|
|
else if (!strcmp(aTopic, "gmp-changed")) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendNotifyGMPsChanged();
|
2015-10-29 11:56:12 +03:00
|
|
|
}
|
2009-09-03 04:18:27 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-10 13:49:03 +03:00
|
|
|
PGMPServiceParent*
|
|
|
|
ContentParent::AllocPGMPServiceParent(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return GMPServiceParent::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-09-26 08:19:09 +04:00
|
|
|
PCompositorParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPCompositorParent(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
2012-07-18 03:59:45 +04:00
|
|
|
{
|
|
|
|
return CompositorParent::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-09-26 08:19:09 +04:00
|
|
|
PImageBridgeParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPImageBridgeParent(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
2012-08-29 16:24:48 +04:00
|
|
|
{
|
|
|
|
return ImageBridgeParent::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2013-11-27 11:59:41 +04:00
|
|
|
PBackgroundParent*
|
|
|
|
ContentParent::AllocPBackgroundParent(Transport* aTransport,
|
|
|
|
ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return BackgroundParent::Alloc(this, aTransport, aOtherProcess);
|
2014-05-01 05:52:00 +04:00
|
|
|
}
|
|
|
|
|
2015-01-17 05:34:47 +03:00
|
|
|
PProcessHangMonitorParent*
|
|
|
|
ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
|
|
|
|
ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
mHangMonitorActor = CreateHangMonitorParent(this, aTransport, aOtherProcess);
|
|
|
|
return mHangMonitorActor;
|
|
|
|
}
|
|
|
|
|
2014-05-01 05:52:00 +04:00
|
|
|
PSharedBufferManagerParent*
|
|
|
|
ContentParent::AllocPSharedBufferManagerParent(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return SharedBufferManagerParent::Create(aTransport, aOtherProcess);
|
2013-11-27 11:59:41 +04:00
|
|
|
}
|
|
|
|
|
2012-09-05 04:36:16 +04:00
|
|
|
bool
|
2014-10-24 04:28:00 +04:00
|
|
|
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
|
2012-09-05 04:36:16 +04:00
|
|
|
bool* aIsForApp, bool* aIsForBrowser)
|
|
|
|
{
|
2014-10-24 04:28:00 +04:00
|
|
|
*aCpId = mChildID;
|
2012-09-05 04:36:16 +04:00
|
|
|
*aIsForApp = IsForApp();
|
|
|
|
*aIsForBrowser = mIsForBrowser;
|
2012-11-09 01:09:39 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-03 18:52:37 +04:00
|
|
|
ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
|
2015-05-02 00:14:39 +03:00
|
|
|
bool* aIsConnected,
|
2015-04-11 01:18:05 +03:00
|
|
|
bool* aIsLangRTL,
|
2014-10-22 13:50:00 +04:00
|
|
|
InfallibleTArray<nsString>* dictionaries,
|
2015-03-24 17:29:16 +03:00
|
|
|
ClipboardCapabilities* clipboardCaps,
|
2015-05-01 04:20:51 +03:00
|
|
|
DomainPolicyClone* domainPolicy,
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData* aInitialData)
|
2012-11-09 01:09:39 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIOService> io(do_GetIOService());
|
2014-10-03 18:52:37 +04:00
|
|
|
MOZ_ASSERT(io, "No IO service?");
|
2012-11-09 01:09:39 +04:00
|
|
|
DebugOnly<nsresult> rv = io->GetOffline(aIsOffline);
|
2014-10-03 18:52:37 +04:00
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting offline?");
|
|
|
|
|
2015-05-02 00:14:39 +03:00
|
|
|
rv = io->GetConnectivity(aIsConnected);
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed getting connectivity?");
|
|
|
|
|
2015-04-11 01:18:05 +03:00
|
|
|
nsIBidiKeyboard* bidi = nsContentUtils::GetBidiKeyboard();
|
|
|
|
|
|
|
|
*aIsLangRTL = false;
|
|
|
|
if (bidi) {
|
|
|
|
bidi->IsLangRTL(aIsLangRTL);
|
|
|
|
}
|
|
|
|
|
2014-10-03 18:52:37 +04:00
|
|
|
nsCOMPtr<nsISpellChecker> spellChecker(do_GetService(NS_SPELLCHECKER_CONTRACTID));
|
|
|
|
MOZ_ASSERT(spellChecker, "No spell checker?");
|
|
|
|
|
|
|
|
spellChecker->GetDictionaryList(dictionaries);
|
2012-11-09 01:09:39 +04:00
|
|
|
|
2014-10-22 13:50:00 +04:00
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
|
|
|
|
MOZ_ASSERT(clipboard, "No clipboard?");
|
|
|
|
|
|
|
|
rv = clipboard->SupportsSelectionClipboard(&clipboardCaps->supportsSelectionClipboard());
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
|
|
|
rv = clipboard->SupportsFindClipboard(&clipboardCaps->supportsFindClipboard());
|
|
|
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
|
|
|
|
2015-03-24 17:29:16 +03:00
|
|
|
// Let's copy the domain policy from the parent to the child (if it's active).
|
|
|
|
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
|
|
|
|
NS_ENSURE_TRUE(ssm, false);
|
|
|
|
ssm->CloneDomainPolicy(domainPolicy);
|
|
|
|
|
2015-05-01 04:20:51 +03:00
|
|
|
if (nsFrameMessageManager* mm = nsFrameMessageManager::sParentProcessManager) {
|
|
|
|
AutoJSAPI jsapi;
|
|
|
|
if (NS_WARN_IF(!jsapi.Init(xpc::PrivilegedJunkScope()))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
JS::RootedValue init(jsapi.cx());
|
|
|
|
nsresult result = mm->GetInitialProcessData(jsapi.cx(), &init);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-09 10:10:32 +03:00
|
|
|
ErrorResult rv;
|
|
|
|
aInitialData->Write(jsapi.cx(), init, rv);
|
|
|
|
if (NS_WARN_IF(rv.Failed())) {
|
2015-05-01 04:20:51 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-05 04:36:16 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-03 11:24:32 +04:00
|
|
|
mozilla::jsipc::PJavaScriptParent *
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPJavaScriptParent()
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2015-10-07 21:30:33 +03:00
|
|
|
MOZ_ASSERT(ManagedPJavaScriptParent().IsEmpty());
|
2014-06-11 09:44:03 +04:00
|
|
|
return nsIContentParent::AllocPJavaScriptParent();
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPJavaScriptParent(PJavaScriptParent *parent)
|
2013-07-03 11:24:32 +04:00
|
|
|
{
|
2014-06-11 09:44:03 +04:00
|
|
|
return nsIContentParent::DeallocPJavaScriptParent(parent);
|
2013-07-03 11:24:32 +04:00
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
PBrowserParent*
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentParent::AllocPBrowserParent(const TabId& aTabId,
|
|
|
|
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& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2014-10-29 21:11:00 +03:00
|
|
|
return nsIContentParent::AllocPBrowserParent(aTabId,
|
|
|
|
aContext,
|
2014-06-11 09:44:03 +04:00
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpId,
|
2014-06-11 09:44:03 +04:00
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPBrowserParent(PBrowserParent* frame)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2014-06-11 09:44:03 +04:00
|
|
|
return nsIContentParent::DeallocPBrowserParent(frame);
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2012-06-20 03:14:39 +04:00
|
|
|
PDeviceStorageRequestParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPDeviceStorageRequestParent(const DeviceStorageParams& aParams)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DeviceStorageRequestParent> result = new DeviceStorageRequestParent(aParams);
|
2014-05-28 07:04:23 +04:00
|
|
|
if (!result->EnsureRequiredPermissions(this)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->Dispatch();
|
|
|
|
return result.forget().take();
|
2012-06-20 03:14:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPDeviceStorageRequestParent(PDeviceStorageRequestParent* doomed)
|
2012-06-20 03:14:39 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
DeviceStorageRequestParent *parent = static_cast<DeviceStorageRequestParent*>(doomed);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
return true;
|
2012-06-20 03:14:39 +04:00
|
|
|
}
|
|
|
|
|
2014-03-05 07:25:40 +04:00
|
|
|
PFileSystemRequestParent*
|
|
|
|
ContentParent::AllocPFileSystemRequestParent(const FileSystemParams& aParams)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FileSystemRequestParent> result = new FileSystemRequestParent();
|
2014-05-28 07:04:23 +04:00
|
|
|
if (!result->Dispatch(this, aParams)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return result.forget().take();
|
2014-03-05 07:25:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPFileSystemRequestParent(PFileSystemRequestParent* doomed)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
FileSystemRequestParent* parent = static_cast<FileSystemRequestParent*>(doomed);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
return true;
|
2014-03-05 07:25:40 +04:00
|
|
|
}
|
|
|
|
|
2012-08-02 10:02:29 +04:00
|
|
|
PBlobParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPBlobParent(const BlobConstructorParams& aParams)
|
2012-08-02 10:02:29 +04:00
|
|
|
{
|
2014-06-11 09:44:03 +04:00
|
|
|
return nsIContentParent::AllocPBlobParent(aParams);
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPBlobParent(PBlobParent* aActor)
|
2012-08-02 10:02:29 +04:00
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
return nsIContentParent::DeallocPBlobParent(aActor);
|
2012-08-02 10:02:29 +04:00
|
|
|
}
|
|
|
|
|
2015-11-28 13:48:28 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvPBlobConstructor(PBlobParent* aActor,
|
|
|
|
const BlobConstructorParams& aParams)
|
|
|
|
{
|
|
|
|
const ParentBlobConstructorParams& params = aParams.get_ParentBlobConstructorParams();
|
|
|
|
if (params.blobParams().type() == AnyBlobConstructorParams::TKnownBlobConstructorParams) {
|
|
|
|
return aActor->SendCreatedFromKnownBlob();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-02 02:24:27 +04:00
|
|
|
mozilla::PRemoteSpellcheckEngineParent *
|
|
|
|
ContentParent::AllocPRemoteSpellcheckEngineParent()
|
|
|
|
{
|
|
|
|
mozilla::RemoteSpellcheckEngineParent *parent = new mozilla::RemoteSpellcheckEngineParent();
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPRemoteSpellcheckEngineParent(PRemoteSpellcheckEngineParent *parent)
|
|
|
|
{
|
|
|
|
delete parent;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-07 08:42:23 +03:00
|
|
|
/* static */ void
|
|
|
|
ContentParent::ForceKillTimerCallback(nsITimer* aTimer, void* aClosure)
|
|
|
|
{
|
2015-09-09 03:12:27 +03:00
|
|
|
#ifdef ENABLE_TESTS
|
|
|
|
// We don't want to time out the content process during XPCShell tests. This
|
|
|
|
// is the easiest way to ensure that.
|
|
|
|
if (PR_GetEnv("XPCSHELL_TEST_PROFILE_DIR")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-07 08:42:23 +03:00
|
|
|
auto self = static_cast<ContentParent*>(aClosure);
|
2015-02-03 20:09:27 +03:00
|
|
|
self->KillHard("ShutDownKill");
|
2015-01-07 08:42:23 +03:00
|
|
|
}
|
|
|
|
|
2012-09-06 02:18:48 +04:00
|
|
|
void
|
2015-02-03 20:09:27 +03:00
|
|
|
ContentParent::KillHard(const char* aReason)
|
2012-09-06 02:18:48 +04:00
|
|
|
{
|
2013-08-17 04:44:17 +04:00
|
|
|
// On Windows, calling KillHard multiple times causes problems - the
|
|
|
|
// process handle becomes invalid on the first call, causing a second call
|
|
|
|
// to crash our process - more details in bug 890840.
|
|
|
|
if (mCalledKillHard) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mCalledKillHard = true;
|
2015-01-07 08:42:23 +03:00
|
|
|
mForceKillTimer = nullptr;
|
2014-11-24 23:05:45 +03:00
|
|
|
|
2014-12-18 21:52:00 +03:00
|
|
|
#if defined(MOZ_CRASHREPORTER) && !defined(MOZ_B2G)
|
2015-06-11 20:25:45 +03:00
|
|
|
// We're about to kill the child process associated with this content.
|
|
|
|
// Something has gone wrong to get us here, so we generate a minidump
|
|
|
|
// of the parent and child for submission to the crash server.
|
2015-10-08 03:15:56 +03:00
|
|
|
if (PCrashReporterParent* p = LoneManagedOrNull(ManagedPCrashReporterParent())) {
|
2014-11-24 23:05:45 +03:00
|
|
|
CrashReporterParent* crashReporter =
|
2015-10-08 03:15:56 +03:00
|
|
|
static_cast<CrashReporterParent*>(p);
|
2015-06-11 20:25:45 +03:00
|
|
|
// GeneratePairedMinidump creates two minidumps for us - the main
|
|
|
|
// one is for the content process we're about to kill, and the other
|
|
|
|
// one is for the main browser process. That second one is the extra
|
|
|
|
// minidump tagging along, so we have to tell the crash reporter that
|
|
|
|
// it exists and is being appended.
|
|
|
|
nsAutoCString additionalDumps("browser");
|
|
|
|
crashReporter->AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("additional_minidumps"),
|
|
|
|
additionalDumps);
|
|
|
|
if (IsKillHardAnnotationSet()) {
|
|
|
|
crashReporter->AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("kill_hard"),
|
|
|
|
GetKillHardAnnotation());
|
2014-11-24 23:05:45 +03:00
|
|
|
}
|
2015-06-11 20:25:45 +03:00
|
|
|
nsDependentCString reason(aReason);
|
|
|
|
crashReporter->AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("ipc_channel_error"),
|
|
|
|
reason);
|
|
|
|
|
|
|
|
// Generate the report and insert into the queue for submittal.
|
|
|
|
mCreatedPairedMinidumps = crashReporter->GenerateCompleteMinidump(this);
|
2014-11-24 23:05:45 +03:00
|
|
|
}
|
|
|
|
#endif
|
2015-04-01 11:40:35 +03:00
|
|
|
ProcessHandle otherProcessHandle;
|
|
|
|
if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) {
|
|
|
|
NS_ERROR("Failed to open child process when attempting kill.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!KillProcess(otherProcessHandle, base::PROCESS_END_KILLED_BY_USER,
|
|
|
|
false)) {
|
2012-09-06 02:18:48 +04:00
|
|
|
NS_WARNING("failed to kill subprocess!");
|
|
|
|
}
|
2015-04-01 11:40:35 +03:00
|
|
|
|
2014-10-22 10:50:10 +04:00
|
|
|
if (mSubprocess) {
|
|
|
|
mSubprocess->SetAlreadyDead();
|
|
|
|
}
|
2015-04-01 11:40:35 +03:00
|
|
|
|
|
|
|
// EnsureProcessTerminated has responsibilty for closing otherProcessHandle.
|
2012-09-06 02:18:48 +04:00
|
|
|
XRE_GetIOMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ProcessWatcher::EnsureProcessTerminated,
|
2015-04-01 11:40:35 +03:00
|
|
|
otherProcessHandle, /*force=*/true));
|
2012-09-06 02:18:48 +04:00
|
|
|
}
|
|
|
|
|
2013-04-26 04:53:26 +04:00
|
|
|
bool
|
|
|
|
ContentParent::IsPreallocated()
|
|
|
|
{
|
|
|
|
return mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-05-21 10:06:54 +04:00
|
|
|
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
|
2013-04-26 04:53:26 +04:00
|
|
|
{
|
|
|
|
aName.Truncate();
|
2014-02-03 22:58:11 +04:00
|
|
|
#ifdef MOZ_NUWA_PROCESS
|
|
|
|
if (IsNuwaProcess()) {
|
|
|
|
aName.AssignLiteral("(Nuwa)");
|
|
|
|
} else
|
|
|
|
#endif
|
2013-04-26 04:53:26 +04:00
|
|
|
if (IsPreallocated()) {
|
|
|
|
aName.AssignLiteral("(Preallocated)");
|
|
|
|
} else if (mIsForBrowser) {
|
|
|
|
aName.AssignLiteral("Browser");
|
2014-05-21 10:06:54 +04:00
|
|
|
} else if (aAnonymize) {
|
|
|
|
aName.AssignLiteral("<anonymized-name>");
|
2013-04-26 04:53:26 +04:00
|
|
|
} else if (!mAppName.IsEmpty()) {
|
|
|
|
aName = mAppName;
|
|
|
|
} else if (!mAppManifestURL.IsEmpty()) {
|
|
|
|
aName.AssignLiteral("Unknown app: ");
|
|
|
|
aName.Append(mAppManifestURL);
|
|
|
|
} else {
|
|
|
|
aName.AssignLiteral("???");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-24 17:15:03 +03:00
|
|
|
PCrashReporterParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPCrashReporterParent(const NativeThreadId& tid,
|
|
|
|
const uint32_t& processType)
|
2010-11-24 17:15:03 +03:00
|
|
|
{
|
2011-06-08 23:56:31 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2014-05-28 07:04:23 +04:00
|
|
|
return new CrashReporterParent();
|
2011-06-08 23:56:31 +04:00
|
|
|
#else
|
2014-05-28 07:04:23 +04:00
|
|
|
return nullptr;
|
2011-06-08 23:56:31 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPCrashReporterConstructor(PCrashReporterParent* actor,
|
|
|
|
const NativeThreadId& tid,
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t& processType)
|
2011-06-08 23:56:31 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
static_cast<CrashReporterParent*>(actor)->SetChildData(tid, processType);
|
|
|
|
return true;
|
2010-11-24 17:15:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPCrashReporterParent(PCrashReporterParent* crashreporter)
|
2010-11-24 17:15:03 +03:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
2010-11-24 17:15:03 +03:00
|
|
|
}
|
|
|
|
|
2013-01-27 01:14:01 +04:00
|
|
|
hal_sandbox::PHalParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPHalParent()
|
2011-10-06 02:15:45 +04:00
|
|
|
{
|
2013-01-27 01:14:01 +04:00
|
|
|
return hal_sandbox::CreateHalParent();
|
2011-10-06 02:15:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPHalParent(hal_sandbox::PHalParent* aHal)
|
2011-10-06 02:15:45 +04:00
|
|
|
{
|
|
|
|
delete aHal;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-22 22:09:42 +03:00
|
|
|
devtools::PHeapSnapshotTempFileHelperParent*
|
|
|
|
ContentParent::AllocPHeapSnapshotTempFileHelperParent()
|
|
|
|
{
|
|
|
|
return devtools::HeapSnapshotTempFileHelperParent::Create();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPHeapSnapshotTempFileHelperParent(
|
|
|
|
devtools::PHeapSnapshotTempFileHelperParent* aHeapSnapshotHelper)
|
|
|
|
{
|
|
|
|
delete aHeapSnapshotHelper;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-01-07 11:58:35 +03:00
|
|
|
PIccParent*
|
|
|
|
ContentParent::AllocPIccParent(const uint32_t& aServiceId)
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "mobileconnection")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
IccParent* parent = new IccParent(aServiceId);
|
|
|
|
// We release this ref in DeallocPIccParent().
|
|
|
|
parent->AddRef();
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPIccParent(PIccParent* aActor)
|
|
|
|
{
|
|
|
|
// IccParent is refcounted, must not be freed manually.
|
|
|
|
static_cast<IccParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-16 21:43:23 +03:00
|
|
|
PMemoryReportRequestParent*
|
2014-05-21 10:06:54 +04:00
|
|
|
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
|
|
|
|
const bool &aAnonymize,
|
|
|
|
const bool &aMinimizeMemoryUsage,
|
2014-09-18 19:59:00 +04:00
|
|
|
const MaybeFileDesc &aDMDFile)
|
2011-02-16 21:43:23 +03:00
|
|
|
{
|
2015-04-27 22:44:00 +03:00
|
|
|
MemoryReportRequestParent* parent =
|
|
|
|
new MemoryReportRequestParent(aGeneration);
|
2014-05-28 07:04:23 +04:00
|
|
|
return parent;
|
2011-02-16 21:43:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor)
|
2011-02-16 21:43:23 +03:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
delete actor;
|
|
|
|
return true;
|
2011-02-16 21:43:23 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 21:13:00 +04:00
|
|
|
PCycleCollectWithLogsParent*
|
|
|
|
ContentParent::AllocPCycleCollectWithLogsParent(const bool& aDumpAllTraces,
|
|
|
|
const FileDescriptor& aGCLog,
|
|
|
|
const FileDescriptor& aCCLog)
|
|
|
|
{
|
|
|
|
MOZ_CRASH("Don't call this; use ContentParent::CycleCollectWithLogs");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPCycleCollectWithLogsParent(PCycleCollectWithLogsParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::CycleCollectWithLogs(bool aDumpAllTraces,
|
|
|
|
nsICycleCollectorLogSink* aSink,
|
|
|
|
nsIDumpGCAndCCLogsCallback* aCallback)
|
|
|
|
{
|
|
|
|
return CycleCollectWithLogsParent::AllocAndSendConstructor(this,
|
|
|
|
aDumpAllTraces,
|
|
|
|
aSink,
|
|
|
|
aCallback);
|
|
|
|
}
|
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
PTestShellParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPTestShellParent()
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
return new TestShellParent();
|
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
|
|
|
ContentParent::DeallocPTestShellParent(PTestShellParent* shell)
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
delete shell;
|
|
|
|
return true;
|
2009-08-12 22:31:48 +04:00
|
|
|
}
|
2013-07-08 19:48:39 +04:00
|
|
|
|
2014-07-01 14:28:18 +04:00
|
|
|
PMobileConnectionParent*
|
|
|
|
ContentParent::AllocPMobileConnectionParent(const uint32_t& aClientId)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_RIL
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<MobileConnectionParent> parent = new MobileConnectionParent(aClientId);
|
2014-07-01 14:28:18 +04:00
|
|
|
// We release this ref in DeallocPMobileConnectionParent().
|
|
|
|
parent->AddRef();
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("No support for mobileconnection on this platform!");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPMobileConnectionParent(PMobileConnectionParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_RIL
|
|
|
|
// MobileConnectionParent is refcounted, must not be freed manually.
|
|
|
|
static_cast<MobileConnectionParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("No support for mobileconnection on this platform!");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
PNeckoParent*
|
|
|
|
ContentParent::AllocPNeckoParent()
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
|
|
|
return new NeckoParent();
|
|
|
|
}
|
|
|
|
|
2013-07-08 19:48:39 +04:00
|
|
|
bool
|
|
|
|
ContentParent::DeallocPNeckoParent(PNeckoParent* necko)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2014-10-28 18:59:08 +03:00
|
|
|
PPrintingParent*
|
|
|
|
ContentParent::AllocPPrintingParent()
|
|
|
|
{
|
2014-11-22 14:15:00 +03:00
|
|
|
#ifdef NS_PRINTING
|
2014-10-28 18:59:08 +03:00
|
|
|
return new PrintingParent();
|
2014-11-22 14:15:00 +03:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2014-10-28 18:59:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPPrintingConstructor(PPrintingParent* aActor)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPPrintingParent(PPrintingParent* printing)
|
|
|
|
{
|
|
|
|
delete printing;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-14 21:22:26 +04:00
|
|
|
PScreenManagerParent*
|
|
|
|
ContentParent::AllocPScreenManagerParent(uint32_t* aNumberOfScreens,
|
|
|
|
float* aSystemDefaultScale,
|
|
|
|
bool* aSuccess)
|
|
|
|
{
|
|
|
|
return new ScreenManagerParent(aNumberOfScreens, aSystemDefaultScale, aSuccess);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPScreenManagerParent(PScreenManagerParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-22 22:55:23 +03:00
|
|
|
PPSMContentDownloaderParent*
|
|
|
|
ContentParent::AllocPPSMContentDownloaderParent(const uint32_t& aCertType)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PSMContentDownloaderParent> downloader =
|
2015-04-22 22:55:23 +03:00
|
|
|
new PSMContentDownloaderParent(aCertType);
|
|
|
|
return downloader.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPPSMContentDownloaderParent(PPSMContentDownloaderParent* aListener)
|
|
|
|
{
|
|
|
|
auto* listener = static_cast<PSMContentDownloaderParent*>(aListener);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PSMContentDownloaderParent> downloader = dont_AddRef(listener);
|
2015-04-22 22:55:23 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-16 02:55:08 +04:00
|
|
|
PExternalHelperAppParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPExternalHelperAppParent(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,
|
2013-09-12 23:24:10 +04:00
|
|
|
const OptionalURIParams& aReferrer,
|
|
|
|
PBrowserParent* aBrowser)
|
2010-09-16 02:55:08 +04:00
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
|
|
|
|
parent->AddRef();
|
2014-08-18 13:06:11 +04:00
|
|
|
parent->Init(this,
|
|
|
|
aMimeContentType,
|
2014-02-14 02:43:58 +04:00
|
|
|
aContentDisposition,
|
|
|
|
aContentDispositionHint,
|
|
|
|
aContentDispositionFilename,
|
2014-08-18 13:06:11 +04:00
|
|
|
aForceSave,
|
|
|
|
aReferrer,
|
2014-02-14 02:43:58 +04:00
|
|
|
aBrowser);
|
2010-09-16 02:55:08 +04:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPExternalHelperAppParent(PExternalHelperAppParent* aService)
|
2010-09-16 02:55:08 +04:00
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = static_cast<ExternalHelperAppParent *>(aService);
|
|
|
|
parent->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-26 02:42:21 +03:00
|
|
|
PHandlerServiceParent*
|
|
|
|
ContentParent::AllocPHandlerServiceParent()
|
|
|
|
{
|
|
|
|
HandlerServiceParent* actor = new HandlerServiceParent();
|
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPHandlerServiceParent(PHandlerServiceParent* aHandlerServiceParent)
|
|
|
|
{
|
|
|
|
static_cast<HandlerServiceParent*>(aHandlerServiceParent)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-18 13:06:11 +04:00
|
|
|
PCellBroadcastParent*
|
|
|
|
ContentParent::AllocPCellBroadcastParent()
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "cellbroadcast")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CellBroadcastParent* actor = new CellBroadcastParent();
|
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPCellBroadcastParent(PCellBroadcastParent* aActor)
|
|
|
|
{
|
|
|
|
static_cast<CellBroadcastParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPCellBroadcastConstructor(PCellBroadcastParent* aActor)
|
|
|
|
{
|
|
|
|
return static_cast<CellBroadcastParent*>(aActor)->Init();
|
|
|
|
}
|
|
|
|
|
2011-11-21 02:40:53 +04:00
|
|
|
PSmsParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPSmsParent()
|
2011-11-21 02:40:53 +04:00
|
|
|
{
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "sms")) {
|
2012-08-16 23:34:53 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-11-07 01:29:30 +04:00
|
|
|
|
|
|
|
SmsParent* parent = new SmsParent();
|
|
|
|
parent->AddRef();
|
|
|
|
return parent;
|
2011-11-21 02:40:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPSmsParent(PSmsParent* aSms)
|
2011-11-21 02:40:53 +04:00
|
|
|
{
|
2012-11-07 01:29:30 +04:00
|
|
|
static_cast<SmsParent*>(aSms)->Release();
|
2011-11-21 02:40:53 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-09-07 10:19:53 +04:00
|
|
|
PTelephonyParent*
|
|
|
|
ContentParent::AllocPTelephonyParent()
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "telephony")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TelephonyParent* actor = new TelephonyParent();
|
|
|
|
NS_ADDREF(actor);
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPTelephonyParent(PTelephonyParent* aActor)
|
|
|
|
{
|
|
|
|
static_cast<TelephonyParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-26 09:00:24 +04:00
|
|
|
PVoicemailParent*
|
|
|
|
ContentParent::AllocPVoicemailParent()
|
|
|
|
{
|
|
|
|
if (!AssertAppProcessPermission(this, "voicemail")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
VoicemailParent* actor = new VoicemailParent();
|
|
|
|
actor->AddRef();
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPVoicemailConstructor(PVoicemailParent* aActor)
|
|
|
|
{
|
|
|
|
return static_cast<VoicemailParent*>(aActor)->Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPVoicemailParent(PVoicemailParent* aActor)
|
|
|
|
{
|
|
|
|
static_cast<VoicemailParent*>(aActor)->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-18 18:46:36 +03:00
|
|
|
media::PMediaParent*
|
|
|
|
ContentParent::AllocPMediaParent()
|
|
|
|
{
|
|
|
|
return media::AllocPMediaParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPMediaParent(media::PMediaParent *aActor)
|
|
|
|
{
|
|
|
|
return media::DeallocPMediaParent(aActor);
|
|
|
|
}
|
|
|
|
|
2010-11-19 04:15:23 +03:00
|
|
|
PStorageParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPStorageParent()
|
2010-11-19 04:15:23 +03:00
|
|
|
{
|
2013-04-15 16:38:48 +04:00
|
|
|
return new DOMStorageDBParent();
|
2010-11-19 04:15:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPStorageParent(PStorageParent* aActor)
|
2010-11-19 04:15:23 +03:00
|
|
|
{
|
2013-04-15 16:38:48 +04:00
|
|
|
DOMStorageDBParent* child = static_cast<DOMStorageDBParent*>(aActor);
|
|
|
|
child->ReleaseIPDLReference();
|
2010-11-19 04:15:23 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-13 20:37:14 +04:00
|
|
|
PBluetoothParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPBluetoothParent()
|
2012-09-13 20:37:14 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
2012-09-25 22:52:30 +04:00
|
|
|
if (!AssertAppProcessPermission(this, "bluetooth")) {
|
2012-09-13 20:37:14 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return new mozilla::dom::bluetooth::BluetoothParent();
|
|
|
|
#else
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("No support for bluetooth on this platform!");
|
2012-09-13 20:37:14 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPBluetoothParent(PBluetoothParent* aActor)
|
2012-09-13 20:37:14 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("No support for bluetooth on this platform!");
|
2012-09-13 20:37:14 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPBluetoothConstructor(PBluetoothParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<BluetoothService> btService = BluetoothService::Get();
|
2012-09-13 20:37:14 +04:00
|
|
|
NS_ENSURE_TRUE(btService, false);
|
|
|
|
|
|
|
|
return static_cast<BluetoothParent*>(aActor)->InitWithService(btService);
|
|
|
|
#else
|
2013-06-29 05:38:30 +04:00
|
|
|
MOZ_CRASH("No support for bluetooth on this platform!");
|
2012-09-13 20:37:14 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-09-04 02:28:06 +04:00
|
|
|
PFMRadioParent*
|
|
|
|
ContentParent::AllocPFMRadioParent()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
if (!AssertAppProcessPermission(this, "fmradio")) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return new FMRadioParent();
|
|
|
|
#else
|
|
|
|
NS_WARNING("No support for FMRadio on this platform!");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPFMRadioParent(PFMRadioParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_FM
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_WARNING("No support for FMRadio on this platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-03-26 06:16:21 +03:00
|
|
|
PPresentationParent*
|
|
|
|
ContentParent::AllocPPresentationParent()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PresentationParent> actor = new PresentationParent();
|
2015-03-26 06:16:21 +03:00
|
|
|
return actor.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPPresentationParent(PPresentationParent* aActor)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PresentationParent> actor =
|
2015-03-26 06:16:21 +03:00
|
|
|
dont_AddRef(static_cast<PresentationParent*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPPresentationConstructor(PPresentationParent* aActor)
|
|
|
|
{
|
|
|
|
return static_cast<PresentationParent*>(aActor)->Init();
|
|
|
|
}
|
|
|
|
|
2013-04-04 02:13:17 +04:00
|
|
|
PSpeechSynthesisParent*
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::AllocPSpeechSynthesisParent()
|
2013-04-04 02:13:17 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
return new mozilla::dom::SpeechSynthesisParent();
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 19:48:39 +04:00
|
|
|
ContentParent::DeallocPSpeechSynthesisParent(PSpeechSynthesisParent* aActor)
|
2013-04-04 02:13:17 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPSpeechSynthesisConstructor(PSpeechSynthesisParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WEBSPEECH
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-11-25 03:50:03 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvSpeakerManagerGetSpeakerStatus(bool* aValue)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-05-28 07:04:23 +04:00
|
|
|
*aValue = false;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SpeakerManagerService> service =
|
2014-08-20 06:25:55 +04:00
|
|
|
SpeakerManagerService::GetOrCreateSpeakerManagerService();
|
|
|
|
MOZ_ASSERT(service);
|
|
|
|
|
|
|
|
*aValue = service->GetSpeakerStatus();
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2013-11-25 03:50:03 +04:00
|
|
|
#endif
|
2014-05-28 07:04:23 +04:00
|
|
|
return false;
|
2013-11-25 03:50:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvSpeakerManagerForceSpeaker(const bool& aEnable)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SpeakerManagerService> service =
|
2014-08-20 06:25:55 +04:00
|
|
|
SpeakerManagerService::GetOrCreateSpeakerManagerService();
|
|
|
|
MOZ_ASSERT(service);
|
|
|
|
service->ForceSpeaker(aEnable, mChildID);
|
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2013-11-25 03:50:03 +04:00
|
|
|
#endif
|
2014-05-28 07:04:23 +04:00
|
|
|
return false;
|
2013-11-25 03:50:03 +04:00
|
|
|
}
|
|
|
|
|
2010-07-02 19:50:41 +04:00
|
|
|
bool
|
2012-08-23 23:33:46 +04:00
|
|
|
ContentParent::RecvStartVisitedQuery(const URIParams& aURI)
|
2010-07-02 19:50:41 +04:00
|
|
|
{
|
2012-08-23 23:33:46 +04:00
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
|
|
|
if (!newURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-05 21:07:46 +04:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 23:33:46 +04:00
|
|
|
history->RegisterVisitedCallback(newURI, nullptr);
|
2010-08-05 21:07:46 +04:00
|
|
|
}
|
2010-07-02 19:50:41 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 19:50:24 +04:00
|
|
|
|
|
|
|
bool
|
2012-08-23 23:33:46 +04:00
|
|
|
ContentParent::RecvVisitURI(const URIParams& uri,
|
|
|
|
const OptionalURIParams& referrer,
|
|
|
|
const uint32_t& flags)
|
2010-07-02 19:50:24 +04:00
|
|
|
{
|
2012-08-23 23:33:46 +04:00
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> ourReferrer = DeserializeURI(referrer);
|
2010-08-05 21:07:46 +04:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 23:33:46 +04:00
|
|
|
history->VisitURI(ourURI, ourReferrer, flags);
|
2010-08-05 21:07:46 +04:00
|
|
|
}
|
2010-07-02 19:50:24 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 19:53:42 +04:00
|
|
|
|
|
|
|
bool
|
2012-08-23 23:33:46 +04:00
|
|
|
ContentParent::RecvSetURITitle(const URIParams& uri,
|
|
|
|
const nsString& title)
|
2010-07-02 19:53:42 +04:00
|
|
|
{
|
2012-08-23 23:33:46 +04:00
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-05 21:07:46 +04:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 23:33:46 +04:00
|
|
|
history->SetURITitle(ourURI, title);
|
2010-08-05 21:07:46 +04:00
|
|
|
}
|
2010-07-02 19:53:42 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-28 00:31:19 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetRandomValues(const uint32_t& length,
|
|
|
|
InfallibleTArray<uint8_t>* randomValues)
|
|
|
|
{
|
|
|
|
uint8_t* buf = Crypto::GetRandomValues(length);
|
2013-09-17 20:54:34 +04:00
|
|
|
if (!buf) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-28 00:31:19 +04:00
|
|
|
|
|
|
|
randomValues->SetCapacity(length);
|
|
|
|
randomValues->SetLength(length);
|
|
|
|
|
|
|
|
memcpy(randomValues->Elements(), buf, length);
|
|
|
|
|
2015-04-01 08:29:55 +03:00
|
|
|
free(buf);
|
2013-02-28 00:31:19 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-21 09:49:36 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetSystemMemory(const uint64_t& aGetterId)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
uint32_t memoryTotal = 0;
|
2014-05-21 09:49:36 +04:00
|
|
|
|
|
|
|
#if defined(XP_LINUX)
|
2014-05-28 07:04:23 +04:00
|
|
|
memoryTotal = mozilla::hal::GetTotalSystemMemoryLevel();
|
2014-05-21 09:49:36 +04:00
|
|
|
#endif
|
|
|
|
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendSystemMemoryAvailable(aGetterId, memoryTotal);
|
2014-05-21 09:49:36 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2014-05-21 09:49:36 +04:00
|
|
|
}
|
|
|
|
|
2015-04-22 17:58:15 +03:00
|
|
|
bool
|
2015-07-11 00:11:59 +03:00
|
|
|
ContentParent::RecvGetLookAndFeelCache(nsTArray<LookAndFeelInt>* aLookAndFeelIntCache)
|
2015-04-22 17:58:15 +03:00
|
|
|
{
|
2015-07-11 00:11:59 +03:00
|
|
|
*aLookAndFeelIntCache = LookAndFeel::GetIntCache();
|
2015-04-22 17:58:15 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-22 16:17:45 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvIsSecureURI(const uint32_t& type,
|
|
|
|
const URIParams& uri,
|
|
|
|
const uint32_t& flags,
|
|
|
|
bool* isSecureURI)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsISiteSecurityService> sss(do_GetService(NS_SSSERVICE_CONTRACTID));
|
|
|
|
if (!sss) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsresult rv = sss->IsSecureURI(type, ourURI, flags, isSecureURI);
|
|
|
|
return NS_SUCCEEDED(rv);
|
|
|
|
}
|
2014-05-21 09:49:36 +04:00
|
|
|
|
2015-09-09 22:14:27 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAccumulateMixedContentHSTS(const URIParams& aURI, const bool& aActive)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(aURI);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsMixedContentBlocker::AccumulateMixedContentHSTS(ourURI, aActive);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-10 21:14:45 +04:00
|
|
|
bool
|
2012-08-23 23:33:46 +04:00
|
|
|
ContentParent::RecvLoadURIExternal(const URIParams& uri)
|
2010-08-10 21:14:45 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIExternalProtocolService> extProtService(do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
|
2012-08-23 23:33:46 +04:00
|
|
|
if (!extProtService) {
|
2010-08-10 21:14:45 +04:00
|
|
|
return true;
|
2012-08-23 23:33:46 +04:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
extProtService->LoadURI(ourURI, nullptr);
|
2010-08-10 21:14:45 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-23 00:20:51 +03:00
|
|
|
bool
|
|
|
|
ContentParent::HasNotificationPermission(const IPC::Principal& aPrincipal)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_CHILD_PERMISSIONS
|
|
|
|
uint32_t permission = mozilla::CheckPermission(this, aPrincipal,
|
|
|
|
"desktop-notification");
|
|
|
|
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif /* MOZ_CHILD_PERMISSIONS */
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-15 20:44:57 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
2011-09-29 10:19:26 +04:00
|
|
|
const nsString& aText, const bool& aTextClickable,
|
2013-03-18 17:24:53 +04:00
|
|
|
const nsString& aCookie, const nsString& aName,
|
2013-11-12 03:56:21 +04:00
|
|
|
const nsString& aBidi, const nsString& aLang,
|
2014-08-21 04:56:12 +04:00
|
|
|
const nsString& aData,
|
2014-11-28 22:08:29 +03:00
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const bool& aInPrivateBrowsing)
|
2010-09-15 20:44:57 +04:00
|
|
|
{
|
2015-10-23 00:20:51 +03:00
|
|
|
if (!HasNotificationPermission(aPrincipal)) {
|
2013-11-12 03:56:21 +04:00
|
|
|
return true;
|
2012-12-20 23:06:42 +04:00
|
|
|
}
|
2013-11-12 03:56:21 +04:00
|
|
|
|
2010-09-15 20:44:57 +04:00
|
|
|
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID));
|
|
|
|
if (sysAlerts) {
|
|
|
|
sysAlerts->ShowAlertNotification(aImageUrl, aTitle, aText, aTextClickable,
|
2014-08-21 04:56:12 +04:00
|
|
|
aCookie, this, aName, aBidi, aLang,
|
2014-11-28 22:08:29 +03:00
|
|
|
aData, aPrincipal, aInPrivateBrowsing);
|
2013-03-18 17:24:53 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-11-12 03:56:21 +04:00
|
|
|
ContentParent::RecvCloseAlert(const nsString& aName,
|
|
|
|
const IPC::Principal& aPrincipal)
|
2013-03-18 17:24:53 +04:00
|
|
|
{
|
2015-10-23 00:20:51 +03:00
|
|
|
if (!HasNotificationPermission(aPrincipal)) {
|
2013-11-12 03:56:21 +04:00
|
|
|
return true;
|
2013-03-18 17:24:53 +04:00
|
|
|
}
|
2013-11-12 03:56:21 +04:00
|
|
|
|
2013-03-18 17:24:53 +04:00
|
|
|
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID));
|
|
|
|
if (sysAlerts) {
|
2013-11-12 03:56:21 +04:00
|
|
|
sysAlerts->CloseAlert(aName, aPrincipal);
|
2010-09-15 20:44:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-31 22:58:35 +04:00
|
|
|
|
2015-10-23 00:10:14 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvDisableNotifications(const IPC::Principal& aPrincipal)
|
|
|
|
{
|
2015-10-23 00:20:51 +03:00
|
|
|
if (HasNotificationPermission(aPrincipal)) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << Notification::RemovePermission(aPrincipal);
|
2015-10-23 00:10:14 +03:00
|
|
|
}
|
2015-10-23 00:20:51 +03:00
|
|
|
return true;
|
|
|
|
}
|
2015-10-23 00:10:14 +03:00
|
|
|
|
2015-10-23 00:20:51 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvOpenNotificationSettings(const IPC::Principal& aPrincipal)
|
|
|
|
{
|
|
|
|
if (HasNotificationPermission(aPrincipal)) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << Notification::OpenSettings(aPrincipal);
|
2015-10-23 00:20:51 +03:00
|
|
|
}
|
2015-10-23 00:10:14 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-31 22:58:35 +04:00
|
|
|
bool
|
2012-08-02 10:02:29 +04:00
|
|
|
ContentParent::RecvSyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
const IPC::Principal& aPrincipal,
|
2015-09-10 23:50:58 +03:00
|
|
|
nsTArray<StructuredCloneData>* aRetvals)
|
2010-08-31 22:58:35 +04:00
|
|
|
{
|
2015-01-16 22:58:52 +03:00
|
|
|
return nsIContentParent::RecvSyncMessage(aMsg, aData, Move(aCpows),
|
|
|
|
aPrincipal, aRetvals);
|
2010-08-31 22:58:35 +04:00
|
|
|
}
|
|
|
|
|
2013-10-01 20:15:06 +04:00
|
|
|
bool
|
2014-10-08 08:32:45 +04:00
|
|
|
ContentParent::RecvRpcMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2014-10-08 08:32:45 +04:00
|
|
|
const IPC::Principal& aPrincipal,
|
2015-09-10 23:50:58 +03:00
|
|
|
nsTArray<StructuredCloneData>* aRetvals)
|
2014-10-08 08:32:45 +04:00
|
|
|
{
|
2015-01-16 22:58:52 +03:00
|
|
|
return nsIContentParent::RecvRpcMessage(aMsg, aData, Move(aCpows), aPrincipal,
|
2014-10-08 08:32:45 +04:00
|
|
|
aRetvals);
|
2013-10-01 20:15:06 +04:00
|
|
|
}
|
|
|
|
|
2010-08-31 22:58:35 +04:00
|
|
|
bool
|
2012-08-02 10:02:29 +04:00
|
|
|
ContentParent::RecvAsyncMessage(const nsString& aMsg,
|
2013-07-11 02:05:39 +04:00
|
|
|
const ClonedMessageData& aData,
|
2015-01-16 22:58:52 +03:00
|
|
|
InfallibleTArray<CpowEntry>&& aCpows,
|
2013-11-06 21:21:15 +04:00
|
|
|
const IPC::Principal& aPrincipal)
|
2010-08-31 22:58:35 +04:00
|
|
|
{
|
2015-01-16 22:58:52 +03:00
|
|
|
return nsIContentParent::RecvAsyncMessage(aMsg, aData, Move(aCpows),
|
|
|
|
aPrincipal);
|
2010-08-31 22:58:35 +04:00
|
|
|
}
|
2010-09-21 08:16:37 +04:00
|
|
|
|
2013-01-09 19:03:28 +04:00
|
|
|
bool
|
2013-04-18 18:13:23 +04:00
|
|
|
ContentParent::RecvFilePathUpdateNotify(const nsString& aType,
|
2013-05-11 13:10:18 +04:00
|
|
|
const nsString& aStorageName,
|
2013-04-18 18:13:23 +04:00
|
|
|
const nsString& aFilePath,
|
|
|
|
const nsCString& aReason)
|
2013-01-09 19:03:28 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DeviceStorageFile> dsf = new DeviceStorageFile(aType,
|
2013-05-11 13:10:18 +04:00
|
|
|
aStorageName,
|
|
|
|
aFilePath);
|
2013-01-09 19:03:28 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (!obs) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-05-11 13:10:18 +04:00
|
|
|
obs->NotifyObservers(dsf, "file-watcher-update",
|
|
|
|
NS_ConvertASCIItoUTF16(aReason).get());
|
2013-01-09 19:03:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-26 21:27:31 +04:00
|
|
|
static int32_t
|
2014-10-23 22:31:00 +04:00
|
|
|
AddGeolocationListener(nsIDOMGeoPositionCallback* watcher, nsIDOMGeoPositionErrorCallback* errorCallBack, bool highAccuracy)
|
2013-02-26 21:27:31 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return -1;
|
|
|
|
}
|
2013-02-26 21:27:31 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
PositionOptions* options = new PositionOptions();
|
|
|
|
options->mTimeout = 0;
|
|
|
|
options->mMaximumAge = 0;
|
|
|
|
options->mEnableHighAccuracy = highAccuracy;
|
|
|
|
int32_t retval = 1;
|
2014-10-23 22:31:00 +04:00
|
|
|
geo->WatchPosition(watcher, errorCallBack, options, &retval);
|
2014-05-28 07:04:23 +04:00
|
|
|
return retval;
|
2013-02-26 21:27:31 +04:00
|
|
|
}
|
|
|
|
|
2010-09-21 08:16:37 +04:00
|
|
|
bool
|
2013-02-26 21:27:31 +04:00
|
|
|
ContentParent::RecvAddGeolocationListener(const IPC::Principal& aPrincipal,
|
|
|
|
const bool& aHighAccuracy)
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
2013-08-22 23:52:07 +04:00
|
|
|
#ifdef MOZ_CHILD_PERMISSIONS
|
2014-06-14 00:40:46 +04:00
|
|
|
if (!ContentParent::IgnoreIPCPrincipal()) {
|
2014-05-28 07:04:23 +04:00
|
|
|
uint32_t permission = mozilla::CheckPermission(this, aPrincipal,
|
|
|
|
"geolocation");
|
|
|
|
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-03 01:21:37 +04:00
|
|
|
}
|
2013-11-27 08:28:16 +04:00
|
|
|
#endif /* MOZ_CHILD_PERMISSIONS */
|
2013-01-03 01:21:37 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
// To ensure no geolocation updates are skipped, we always force the
|
|
|
|
// creation of a new listener.
|
|
|
|
RecvRemoveGeolocationListener();
|
2014-10-23 22:31:00 +04:00
|
|
|
mGeolocationWatchID = AddGeolocationListener(this, this, aHighAccuracy);
|
2014-10-30 23:39:00 +03:00
|
|
|
|
|
|
|
// let the the settings cache know the origin of the new listener
|
|
|
|
nsAutoCString origin;
|
|
|
|
// hint to the compiler to use the conversion operator to nsIPrincipal*
|
|
|
|
nsCOMPtr<nsIPrincipal> principal = static_cast<nsIPrincipal*>(aPrincipal);
|
|
|
|
if (!principal) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-13 01:08:20 +03:00
|
|
|
principal->GetOrigin(origin);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsGeolocationSettings> gs = nsGeolocationSettings::GetGeolocationSettings();
|
2014-10-30 23:39:00 +03:00
|
|
|
if (gs) {
|
|
|
|
gs->PutWatchOrigin(mGeolocationWatchID, origin);
|
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2010-09-21 08:16:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-05 20:43:13 +03:00
|
|
|
ContentParent::RecvRemoveGeolocationListener()
|
2010-09-21 08:16:37 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
if (mGeolocationWatchID != -1) {
|
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
geo->ClearWatch(mGeolocationWatchID);
|
2014-10-30 23:39:00 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsGeolocationSettings> gs = nsGeolocationSettings::GetGeolocationSettings();
|
2014-10-30 23:39:00 +03:00
|
|
|
if (gs) {
|
|
|
|
gs->RemoveWatchOrigin(mGeolocationWatchID);
|
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
mGeolocationWatchID = -1;
|
2012-12-04 04:03:16 +04:00
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2010-09-21 08:16:37 +04:00
|
|
|
}
|
|
|
|
|
2012-12-31 20:36:46 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvSetGeolocationHigherAccuracy(const bool& aEnable)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
// This should never be called without a listener already present,
|
|
|
|
// so this check allows us to forgo securing privileges.
|
|
|
|
if (mGeolocationWatchID != -1) {
|
2014-10-30 23:39:00 +03:00
|
|
|
nsCString origin;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsGeolocationSettings> gs = nsGeolocationSettings::GetGeolocationSettings();
|
2014-10-30 23:39:00 +03:00
|
|
|
// get the origin stored for the curent watch ID
|
|
|
|
if (gs) {
|
|
|
|
gs->GetWatchOrigin(mGeolocationWatchID, origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove and recreate a new, high-accuracy listener
|
2014-05-28 07:04:23 +04:00
|
|
|
RecvRemoveGeolocationListener();
|
2014-10-23 22:31:00 +04:00
|
|
|
mGeolocationWatchID = AddGeolocationListener(this, this, aEnable);
|
2014-10-30 23:39:00 +03:00
|
|
|
|
|
|
|
// map the new watch ID to the origin
|
|
|
|
if (gs) {
|
|
|
|
gs->PutWatchOrigin(mGeolocationWatchID, origin);
|
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
}
|
|
|
|
return true;
|
2012-12-31 20:36:46 +04:00
|
|
|
}
|
|
|
|
|
2010-09-21 08:16:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentParent::HandleEvent(nsIDOMGeoPosition* postion)
|
|
|
|
{
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendGeolocationUpdate(GeoPosition(postion));
|
2014-05-28 07:04:23 +04:00
|
|
|
return NS_OK;
|
2010-09-21 08:16:37 +04:00
|
|
|
}
|
|
|
|
|
2014-10-23 22:31:00 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentParent::HandleEvent(nsIDOMGeoPositionError* postionError)
|
|
|
|
{
|
|
|
|
int16_t errorCode;
|
|
|
|
nsresult rv;
|
|
|
|
rv = postionError->GetCode(&errorCode);
|
|
|
|
NS_ENSURE_SUCCESS(rv,rv);
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << SendGeolocationError(errorCode);
|
2014-10-23 22:31:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-09 21:52:09 +04:00
|
|
|
nsConsoleService *
|
|
|
|
ContentParent::GetConsoleService()
|
|
|
|
{
|
|
|
|
if (mConsoleService) {
|
|
|
|
return mConsoleService.get();
|
|
|
|
}
|
|
|
|
|
2015-07-31 16:49:27 +03:00
|
|
|
// XXXkhuey everything about this is terrible.
|
2012-11-09 21:52:09 +04:00
|
|
|
// Get the ConsoleService by CID rather than ContractID, so that we
|
|
|
|
// can cast the returned pointer to an nsConsoleService (rather than
|
|
|
|
// just an nsIConsoleService). This allows us to call the non-idl function
|
|
|
|
// nsConsoleService::LogMessageWithMode.
|
|
|
|
NS_DEFINE_CID(consoleServiceCID, NS_CONSOLESERVICE_CID);
|
2015-07-31 16:49:27 +03:00
|
|
|
nsCOMPtr<nsIConsoleService> consoleService(do_GetService(consoleServiceCID));
|
|
|
|
mConsoleService = static_cast<nsConsoleService*>(consoleService.get());
|
2012-11-09 21:52:09 +04:00
|
|
|
return mConsoleService.get();
|
|
|
|
}
|
|
|
|
|
2010-09-24 05:39:32 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvConsoleMessage(const nsString& aMessage)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsConsoleService> consoleService = GetConsoleService();
|
2014-05-28 07:04:23 +04:00
|
|
|
if (!consoleService) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsConsoleMessage> msg(new nsConsoleMessage(aMessage.get()));
|
2014-05-28 07:04:23 +04:00
|
|
|
consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
|
2010-09-24 05:39:32 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvScriptError(const nsString& aMessage,
|
|
|
|
const nsString& aSourceName,
|
|
|
|
const nsString& aSourceLine,
|
2012-08-22 19:56:38 +04:00
|
|
|
const uint32_t& aLineNumber,
|
|
|
|
const uint32_t& aColNumber,
|
|
|
|
const uint32_t& aFlags,
|
2010-09-24 05:39:32 +04:00
|
|
|
const nsCString& aCategory)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsConsoleService> consoleService = GetConsoleService();
|
2014-05-28 07:04:23 +04:00
|
|
|
if (!consoleService) {
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
nsCOMPtr<nsIScriptError> msg(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
|
|
|
nsresult rv = msg->Init(aMessage, aSourceName, aSourceLine,
|
|
|
|
aLineNumber, aColNumber, aFlags, aCategory.get());
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return true;
|
2010-09-24 05:39:32 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
|
|
|
|
return true;
|
2010-09-24 05:39:32 +04:00
|
|
|
}
|
|
|
|
|
2012-04-20 04:13:20 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvPrivateDocShellsExist(const bool& aExist)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
if (!sPrivateContent)
|
|
|
|
sPrivateContent = new nsTArray<ContentParent*>();
|
|
|
|
if (aExist) {
|
|
|
|
sPrivateContent->AppendElement(this);
|
|
|
|
} else {
|
|
|
|
sPrivateContent->RemoveElement(this);
|
2015-06-12 04:53:31 +03:00
|
|
|
|
|
|
|
// Only fire the notification if we have private and non-private
|
|
|
|
// windows: if privatebrowsing.autostart is true, all windows are
|
|
|
|
// private.
|
|
|
|
if (!sPrivateContent->Length() &&
|
|
|
|
!Preferences::GetBool("browser.privatebrowsing.autostart")) {
|
2014-05-28 07:04:23 +04:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
|
|
|
delete sPrivateContent;
|
|
|
|
sPrivateContent = nullptr;
|
|
|
|
}
|
2012-04-20 04:13:20 +04:00
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2012-04-20 04:13:20 +04:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:13:02 +03:00
|
|
|
bool
|
|
|
|
ContentParent::DoLoadMessageManagerScript(const nsAString& aURL,
|
|
|
|
bool aRunInGlobalScope)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!aRunInGlobalScope);
|
|
|
|
return SendLoadProcessScript(nsString(aURL));
|
|
|
|
}
|
|
|
|
|
2015-10-07 13:42:43 +03:00
|
|
|
nsresult
|
2013-07-11 02:05:39 +04:00
|
|
|
ContentParent::DoSendAsyncMessage(JSContext* aCx,
|
|
|
|
const nsAString& aMessage,
|
2015-09-10 23:50:58 +03:00
|
|
|
StructuredCloneData& aHelper,
|
2013-11-06 21:21:15 +04:00
|
|
|
JS::Handle<JSObject *> aCpows,
|
|
|
|
nsIPrincipal* aPrincipal)
|
2012-09-28 09:43:12 +04:00
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
ClonedMessageData data;
|
2015-09-02 19:20:30 +03:00
|
|
|
if (!BuildClonedMessageDataForParent(this, aHelper, data)) {
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
2014-05-28 07:04:23 +04:00
|
|
|
}
|
|
|
|
InfallibleTArray<CpowEntry> cpows;
|
2015-04-28 03:05:05 +03:00
|
|
|
jsipc::CPOWManager* mgr = GetCPOWManager();
|
|
|
|
if (aCpows && (!mgr || !mgr->Wrap(aCx, aCpows, &cpows))) {
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-05-28 07:04:23 +04:00
|
|
|
}
|
2015-08-14 10:41:54 +03:00
|
|
|
if (IsReadyNuwaProcess()) {
|
2014-09-30 18:13:52 +04:00
|
|
|
// Nuwa won't receive frame messages after it is frozen.
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (!SendAsyncMessage(nsString(aMessage), data, cpows, Principal(aPrincipal))) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2014-09-30 18:13:52 +04:00
|
|
|
}
|
2015-10-07 13:42:43 +03:00
|
|
|
return NS_OK;
|
2012-09-28 09:43:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::CheckPermission(const nsAString& aPermission)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
return AssertAppProcessPermission(this, NS_ConvertUTF16toUTF8(aPermission).get());
|
2012-09-28 09:43:12 +04:00
|
|
|
}
|
|
|
|
|
2012-12-22 16:00:10 +04:00
|
|
|
bool
|
|
|
|
ContentParent::CheckManifestURL(const nsAString& aManifestURL)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
return AssertAppProcessManifestURL(this, NS_ConvertUTF16toUTF8(aManifestURL).get());
|
2012-12-22 16:00:10 +04:00
|
|
|
}
|
2012-09-28 09:43:12 +04:00
|
|
|
|
2013-01-14 14:08:55 +04:00
|
|
|
bool
|
|
|
|
ContentParent::CheckAppHasPermission(const nsAString& aPermission)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
return AssertAppHasPermission(this, NS_ConvertUTF16toUTF8(aPermission).get());
|
2013-01-14 14:08:55 +04:00
|
|
|
}
|
|
|
|
|
2013-06-29 14:52:16 +04:00
|
|
|
bool
|
|
|
|
ContentParent::CheckAppHasStatus(unsigned short aStatus)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
return AssertAppHasStatus(this, aStatus);
|
2013-06-29 14:52:16 +04:00
|
|
|
}
|
|
|
|
|
2014-08-12 16:59:47 +04:00
|
|
|
bool
|
|
|
|
ContentParent::KillChild()
|
|
|
|
{
|
2015-02-03 20:09:27 +03:00
|
|
|
KillHard("KillChild");
|
2014-08-12 16:59:47 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:03 +04:00
|
|
|
PBlobParent*
|
|
|
|
ContentParent::SendPBlobConstructor(PBlobParent* aActor,
|
|
|
|
const BlobConstructorParams& aParams)
|
|
|
|
{
|
|
|
|
return PContentParent::SendPBlobConstructor(aActor, aParams);
|
|
|
|
}
|
|
|
|
|
2013-02-15 00:41:30 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvSystemMessageHandled()
|
|
|
|
{
|
|
|
|
SystemMessageHandledListener::OnSystemMessageHandled();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-11 09:44:13 +04:00
|
|
|
PBrowserParent*
|
|
|
|
ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
const TabId& aTabId,
|
2014-06-11 09:44:13 +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:13 +04:00
|
|
|
const bool& aIsForApp,
|
|
|
|
const bool& aIsForBrowser)
|
|
|
|
{
|
|
|
|
return PContentParent::SendPBrowserConstructor(aActor,
|
2014-10-29 21:11:00 +03:00
|
|
|
aTabId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aContext,
|
|
|
|
aChromeFlags,
|
2014-10-24 04:28:00 +04:00
|
|
|
aCpId,
|
2014-06-11 09:44:13 +04:00
|
|
|
aIsForApp,
|
|
|
|
aIsForBrowser);
|
|
|
|
}
|
|
|
|
|
2013-07-09 10:37:47 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvCreateFakeVolume(const nsString& fsName, const nsString& mountPoint)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-05-28 07:04:23 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv);
|
|
|
|
if (vs) {
|
|
|
|
vs->CreateFakeVolume(fsName, mountPoint);
|
|
|
|
}
|
|
|
|
return true;
|
2013-07-09 10:37:47 +04:00
|
|
|
#else
|
2014-05-28 07:04:23 +04:00
|
|
|
NS_WARNING("ContentParent::RecvCreateFakeVolume shouldn't be called when MOZ_WIDGET_GONK is not defined");
|
|
|
|
return false;
|
2013-07-09 10:37:47 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvSetFakeVolumeState(const nsString& fsName, const int32_t& fsState)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-05-28 07:04:23 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv);
|
|
|
|
if (vs) {
|
|
|
|
vs->SetFakeVolumeState(fsName, fsState);
|
|
|
|
}
|
|
|
|
return true;
|
2013-07-09 10:37:47 +04:00
|
|
|
#else
|
2014-05-28 07:04:23 +04:00
|
|
|
NS_WARNING("ContentParent::RecvSetFakeVolumeState shouldn't be called when MOZ_WIDGET_GONK is not defined");
|
|
|
|
return false;
|
2013-07-09 10:37:47 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-05-04 09:11:00 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvRemoveFakeVolume(const nsString& fsName)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv);
|
|
|
|
if (vs) {
|
|
|
|
vs->RemoveFakeVolume(fsName);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_WARNING("ContentParent::RecvRemoveFakeVolume shouldn't be called when MOZ_WIDGET_GONK is not defined");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-16 21:59:31 +04:00
|
|
|
bool
|
2014-09-11 17:50:55 +04:00
|
|
|
ContentParent::RecvKeywordToURI(const nsCString& aKeyword,
|
|
|
|
nsString* aProviderName,
|
|
|
|
OptionalInputStreamParams* aPostData,
|
2013-08-16 21:59:31 +04:00
|
|
|
OptionalURIParams* aURI)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
|
|
|
|
if (!fixup) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-16 21:59:31 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
nsCOMPtr<nsIInputStream> postData;
|
2014-09-11 17:50:55 +04:00
|
|
|
nsCOMPtr<nsIURIFixupInfo> info;
|
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
if (NS_FAILED(fixup->KeywordToURI(aKeyword, getter_AddRefs(postData),
|
2014-09-11 17:50:55 +04:00
|
|
|
getter_AddRefs(info)))) {
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
|
|
|
}
|
2014-09-11 17:50:55 +04:00
|
|
|
info->GetKeywordProviderName(*aProviderName);
|
2013-08-16 21:59:31 +04:00
|
|
|
|
2014-05-28 07:04:23 +04:00
|
|
|
nsTArray<mozilla::ipc::FileDescriptor> fds;
|
|
|
|
SerializeInputStream(postData, *aPostData, fds);
|
|
|
|
MOZ_ASSERT(fds.IsEmpty());
|
2014-03-25 22:37:13 +04:00
|
|
|
|
2014-09-11 17:50:55 +04:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
info->GetPreferredURI(getter_AddRefs(uri));
|
2014-05-28 07:04:23 +04:00
|
|
|
SerializeURI(uri, *aURI);
|
|
|
|
return true;
|
2013-08-16 21:59:31 +04:00
|
|
|
}
|
|
|
|
|
2014-09-11 17:50:55 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvNotifyKeywordSearchLoading(const nsString &aProvider,
|
|
|
|
const nsString &aKeyword) {
|
|
|
|
#ifdef MOZ_TOOLKIT_SEARCH
|
|
|
|
nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1");
|
|
|
|
if (searchSvc) {
|
|
|
|
nsCOMPtr<nsISearchEngine> searchEngine;
|
|
|
|
searchSvc->GetEngineByName(aProvider, getter_AddRefs(searchEngine));
|
|
|
|
if (searchEngine) {
|
|
|
|
nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService();
|
|
|
|
if (obsSvc) {
|
|
|
|
// Note that "keyword-search" refers to a search via the url
|
|
|
|
// bar, not a bookmarks keyword search.
|
|
|
|
obsSvc->NotifyObservers(searchEngine, "keyword-search", aKeyword.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-29 11:57:24 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvCopyFavicon(const URIParams& aOldURI,
|
|
|
|
const URIParams& aNewURI,
|
2015-11-25 00:31:57 +03:00
|
|
|
const IPC::Principal& aLoadingPrincipal,
|
2015-04-29 11:57:24 +03:00
|
|
|
const bool& aInPrivateBrowsing)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> oldURI = DeserializeURI(aOldURI);
|
|
|
|
if (!oldURI) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aNewURI);
|
|
|
|
if (!newURI) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-25 00:31:57 +03:00
|
|
|
nsDocShell::CopyFavicon(oldURI, newURI, aLoadingPrincipal, aInPrivateBrowsing);
|
2015-04-29 11:57:24 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-27 08:56:57 +04:00
|
|
|
bool
|
|
|
|
ContentParent::ShouldContinueFromReplyTimeout()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ProcessHangMonitor> monitor = ProcessHangMonitor::Get();
|
2015-01-17 05:34:47 +03:00
|
|
|
return !monitor || !monitor->ShouldTimeOutCPOWs();
|
2013-08-27 08:56:57 +04:00
|
|
|
}
|
|
|
|
|
2013-11-24 13:06:27 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus,
|
|
|
|
const nsString& aPageURL,
|
|
|
|
const bool& aIsAudio,
|
|
|
|
const bool& aIsVideo)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
// recording-device-ipc-events needs to gather more information from content process
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
2013-11-24 13:06:27 +04:00
|
|
|
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), ChildID());
|
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), IsForApp());
|
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
|
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
|
|
|
|
|
|
|
|
nsString requestURL = IsForApp() ? AppManifestURL() : aPageURL;
|
|
|
|
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
|
|
|
|
|
|
|
|
obs->NotifyObservers((nsIPropertyBag2*) props,
|
|
|
|
"recording-device-ipc-events",
|
|
|
|
aRecordingStatus.get());
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Could not get the Observer service for ContentParent::RecvRecordingDeviceEvents.");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-11 05:09:20 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetGraphicsFeatureStatus(const int32_t& aFeature,
|
|
|
|
int32_t* aStatus,
|
|
|
|
bool* aSuccess)
|
|
|
|
{
|
2015-07-08 23:51:09 +03:00
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
2014-01-11 05:09:20 +04:00
|
|
|
if (!gfxInfo) {
|
|
|
|
*aSuccess = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aSuccess = NS_SUCCEEDED(gfxInfo->GetFeatureStatus(aFeature, aStatus));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-13 20:28:46 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAddIdleObserver(const uint64_t& aObserver, const uint32_t& aIdleTimeInS)
|
|
|
|
{
|
2014-05-28 07:04:23 +04:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIIdleService> idleService =
|
2015-05-27 11:05:04 +03:00
|
|
|
do_GetService("@mozilla.org/widget/idleservice;1", &rv);
|
2014-05-28 07:04:23 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2013-12-13 20:28:46 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ParentIdleListener> listener =
|
2015-05-27 11:05:04 +03:00
|
|
|
new ParentIdleListener(this, aObserver, aIdleTimeInS);
|
|
|
|
rv = idleService->AddIdleObserver(listener, aIdleTimeInS);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
mIdleListeners.AppendElement(listener);
|
2014-05-28 07:04:23 +04:00
|
|
|
return true;
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvRemoveIdleObserver(const uint64_t& aObserver, const uint32_t& aIdleTimeInS)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ParentIdleListener> listener;
|
2015-05-27 11:05:04 +03:00
|
|
|
for (int32_t i = mIdleListeners.Length() - 1; i >= 0; --i) {
|
|
|
|
listener = static_cast<ParentIdleListener*>(mIdleListeners[i].get());
|
|
|
|
if (listener->mObserver == aObserver &&
|
|
|
|
listener->mTime == aIdleTimeInS) {
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIIdleService> idleService =
|
|
|
|
do_GetService("@mozilla.org/widget/idleservice;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
idleService->RemoveIdleObserver(listener, aIdleTimeInS);
|
|
|
|
mIdleListeners.RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
2014-05-28 07:04:23 +04:00
|
|
|
}
|
|
|
|
return true;
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 20:37:26 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvBackUpXResources(const FileDescriptor& aXSocketFd)
|
|
|
|
{
|
|
|
|
#ifndef MOZ_X11
|
|
|
|
NS_RUNTIMEABORT("This message only makes sense on X11 platforms");
|
|
|
|
#else
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(0 > mChildXSocketFdDup.get(),
|
|
|
|
"Already backed up X resources??");
|
2014-02-05 20:37:26 +04:00
|
|
|
mChildXSocketFdDup.forget();
|
|
|
|
if (aXSocketFd.IsValid()) {
|
2014-05-28 07:04:23 +04:00
|
|
|
mChildXSocketFdDup.reset(aXSocketFd.PlatformHandle());
|
2014-02-05 20:37:26 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-24 21:11:36 +04:00
|
|
|
bool
|
2015-03-10 12:32:00 +03:00
|
|
|
ContentParent::RecvOpenAnonymousTemporaryFile(FileDescOrError *aFD)
|
2014-06-24 21:11:36 +04:00
|
|
|
{
|
|
|
|
PRFileDesc *prfd;
|
|
|
|
nsresult rv = NS_OpenAnonymousTemporaryFile(&prfd);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2015-03-10 12:32:00 +03:00
|
|
|
// Returning false will kill the child process; instead
|
|
|
|
// propagate the error and let the child handle it.
|
|
|
|
*aFD = rv;
|
|
|
|
return true;
|
2014-06-24 21:11:36 +04:00
|
|
|
}
|
2014-07-28 21:17:51 +04:00
|
|
|
*aFD = FileDescriptor(FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(prfd)));
|
2014-06-24 21:11:36 +04:00
|
|
|
// The FileDescriptor object owns a duplicate of the file handle; we
|
|
|
|
// must close the original (and clean up the NSPR descriptor).
|
|
|
|
PR_Close(prfd);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-27 01:28:28 +03:00
|
|
|
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
|
|
|
|
|
|
|
|
bool
|
2014-12-19 20:07:04 +03:00
|
|
|
ContentParent::RecvKeygenProcessValue(const nsString& oldValue,
|
|
|
|
const nsString& challenge,
|
|
|
|
const nsString& keytype,
|
|
|
|
const nsString& keyparams,
|
|
|
|
nsString* newValue)
|
2014-11-27 01:28:28 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFormProcessor> formProcessor =
|
|
|
|
do_GetService(kFormProcessorCID);
|
|
|
|
if (!formProcessor) {
|
|
|
|
newValue->Truncate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
formProcessor->ProcessValueIPC(oldValue, challenge, keytype, keyparams,
|
|
|
|
*newValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-12-19 20:07:04 +03:00
|
|
|
ContentParent::RecvKeygenProvideContent(nsString* aAttribute,
|
|
|
|
nsTArray<nsString>* aContent)
|
2014-11-27 01:28:28 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFormProcessor> formProcessor =
|
|
|
|
do_GetService(kFormProcessorCID);
|
|
|
|
if (!formProcessor) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
formProcessor->ProvideContent(NS_LITERAL_STRING("SELECT"), *aContent,
|
|
|
|
*aAttribute);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-25 22:37:13 +04:00
|
|
|
PFileDescriptorSetParent*
|
2014-03-25 22:37:28 +04:00
|
|
|
ContentParent::AllocPFileDescriptorSetParent(const FileDescriptor& aFD)
|
2014-03-25 22:37:13 +04:00
|
|
|
{
|
2014-03-25 22:37:28 +04:00
|
|
|
return new FileDescriptorSetParent(aFD);
|
2014-03-25 22:37:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPFileDescriptorSetParent(PFileDescriptorSetParent* aActor)
|
|
|
|
{
|
2014-03-25 22:37:28 +04:00
|
|
|
delete static_cast<FileDescriptorSetParent*>(aActor);
|
2014-03-25 22:37:13 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-30 15:59:27 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvFlushPendingFileDeletions()
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<IndexedDatabaseManager> mgr = IndexedDatabaseManager::Get();
|
2015-06-30 15:59:27 +03:00
|
|
|
if (NS_WARN_IF(!mgr)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!mgr->IsMainProcess())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = mgr->FlushPendingFileDeletions();
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-14 00:40:46 +04:00
|
|
|
bool
|
|
|
|
ContentParent::IgnoreIPCPrincipal()
|
|
|
|
{
|
|
|
|
static bool sDidAddVarCache = false;
|
|
|
|
static bool sIgnoreIPCPrincipal = false;
|
|
|
|
if (!sDidAddVarCache) {
|
|
|
|
sDidAddVarCache = true;
|
|
|
|
Preferences::AddBoolVarCache(&sIgnoreIPCPrincipal,
|
|
|
|
"dom.testing.ignore_ipc_principal", false);
|
|
|
|
}
|
|
|
|
return sIgnoreIPCPrincipal;
|
|
|
|
}
|
|
|
|
|
2014-10-03 18:52:37 +04:00
|
|
|
void
|
|
|
|
ContentParent::NotifyUpdatedDictionaries()
|
|
|
|
{
|
|
|
|
nsAutoTArray<ContentParent*, 8> processes;
|
|
|
|
GetAll(processes);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISpellChecker> spellChecker(do_GetService(NS_SPELLCHECKER_CONTRACTID));
|
|
|
|
MOZ_ASSERT(spellChecker, "No spell checker?");
|
|
|
|
|
|
|
|
InfallibleTArray<nsString> dictionaries;
|
|
|
|
spellChecker->GetDictionaryList(&dictionaries);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < processes.Length(); ++i) {
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << processes[i]->SendUpdateDictionaryList(dictionaries);
|
2014-10-03 18:52:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
/*static*/ TabId
|
|
|
|
ContentParent::AllocateTabId(const TabId& aOpenerTabId,
|
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const ContentParentId& aCpId)
|
|
|
|
{
|
|
|
|
TabId tabId;
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
2014-10-29 21:11:00 +03:00
|
|
|
tabId = cpm->AllocateTabId(aOpenerTabId, aContext, aCpId);
|
2015-08-28 10:18:00 +03:00
|
|
|
// Add appId's reference count in oop case
|
|
|
|
if (tabId) {
|
|
|
|
PermissionManagerAddref(aCpId, tabId);
|
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ContentChild::GetSingleton()->SendAllocateTabId(aOpenerTabId,
|
|
|
|
aContext,
|
|
|
|
aCpId,
|
|
|
|
&tabId);
|
|
|
|
}
|
|
|
|
return tabId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::DeallocateTabId(const TabId& aTabId,
|
2015-08-28 10:18:00 +03:00
|
|
|
const ContentParentId& aCpId,
|
|
|
|
bool aMarkedDestroying)
|
2014-10-29 21:11:00 +03:00
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2015-08-28 10:18:00 +03:00
|
|
|
// Release appId's reference count in oop case
|
|
|
|
if (aTabId) {
|
|
|
|
PermissionManagerRelease(aCpId, aTabId);
|
|
|
|
}
|
|
|
|
|
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
ContentParent* cp = cpm->GetContentProcessById(aCpId);
|
|
|
|
|
|
|
|
cp->NotifyTabDestroyed(aTabId, aMarkedDestroying);
|
|
|
|
|
2014-10-29 21:11:00 +03:00
|
|
|
ContentProcessManager::GetSingleton()->DeallocateTabId(aCpId,
|
|
|
|
aTabId);
|
|
|
|
}
|
|
|
|
else {
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentChild::GetSingleton()->SendDeallocateTabId(aTabId,
|
|
|
|
aCpId,
|
|
|
|
aMarkedDestroying);
|
2014-10-29 21:11:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvAllocateTabId(const TabId& aOpenerTabId,
|
|
|
|
const IPCTabContext& aContext,
|
|
|
|
const ContentParentId& aCpId,
|
|
|
|
TabId* aTabId)
|
|
|
|
{
|
|
|
|
*aTabId = AllocateTabId(aOpenerTabId, aContext, aCpId);
|
|
|
|
if (!(*aTabId)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-08-28 10:18:00 +03:00
|
|
|
ContentParent::RecvDeallocateTabId(const TabId& aTabId,
|
|
|
|
const ContentParentId& aCpId,
|
|
|
|
const bool& aMarkedDestroying)
|
|
|
|
{
|
|
|
|
DeallocateTabId(aTabId, aCpId, aMarkedDestroying);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvNotifyTabDestroying(const TabId& aTabId,
|
|
|
|
const ContentParentId& aCpId)
|
2014-10-29 21:11:00 +03:00
|
|
|
{
|
2015-08-28 10:18:00 +03:00
|
|
|
NotifyTabDestroying(aTabId, aCpId);
|
2014-10-29 21:11:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTArray<TabContext>
|
|
|
|
ContentParent::GetManagedTabContext()
|
|
|
|
{
|
|
|
|
return Move(ContentProcessManager::GetSingleton()->
|
|
|
|
GetTabContextByContentProcess(this->ChildID()));
|
|
|
|
}
|
|
|
|
|
2014-11-13 03:31:00 +03:00
|
|
|
mozilla::docshell::POfflineCacheUpdateParent*
|
|
|
|
ContentParent::AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
|
|
|
|
const URIParams& aDocumentURI,
|
2015-10-02 19:10:02 +03:00
|
|
|
const PrincipalInfo& aLoadingPrincipalInfo,
|
2014-11-13 03:31:00 +03:00
|
|
|
const bool& aStickDocument,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
|
|
|
TabContext tabContext;
|
|
|
|
if (!ContentProcessManager::GetSingleton()->
|
|
|
|
GetTabContextByProcessAndTabId(this->ChildID(), aTabId, &tabContext)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
2014-11-13 03:31:00 +03:00
|
|
|
new mozilla::docshell::OfflineCacheUpdateParent(
|
2015-11-03 13:53:41 +03:00
|
|
|
tabContext.OriginAttributesRef());
|
2014-11-13 03:31:00 +03:00
|
|
|
// Use this reference as the IPDL reference.
|
|
|
|
return update.forget().take();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
|
|
|
|
const URIParams& aManifestURI,
|
|
|
|
const URIParams& aDocumentURI,
|
2015-10-02 19:10:02 +03:00
|
|
|
const PrincipalInfo& aLoadingPrincipal,
|
2014-11-13 03:31:00 +03:00
|
|
|
const bool& aStickDocument,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aActor);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
2014-11-13 03:31:00 +03:00
|
|
|
static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(aActor);
|
|
|
|
|
2015-10-02 19:10:02 +03:00
|
|
|
nsresult rv = update->Schedule(aManifestURI, aDocumentURI, aLoadingPrincipal, aStickDocument);
|
2014-11-13 03:31:00 +03:00
|
|
|
if (NS_FAILED(rv) && IsAlive()) {
|
|
|
|
// Inform the child of failure.
|
2015-11-02 08:53:26 +03:00
|
|
|
Unused << update->SendFinish(false, false);
|
2014-11-13 03:31:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPOfflineCacheUpdateParent(POfflineCacheUpdateParent* aActor)
|
|
|
|
{
|
|
|
|
// Reclaim the IPDL reference.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
|
2014-11-13 03:31:00 +03:00
|
|
|
dont_AddRef(static_cast<mozilla::docshell::OfflineCacheUpdateParent*>(aActor));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-22 01:29:18 +03:00
|
|
|
PWebrtcGlobalParent *
|
|
|
|
ContentParent::AllocPWebrtcGlobalParent()
|
|
|
|
{
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2015-04-22 01:29:18 +03:00
|
|
|
return WebrtcGlobalParent::Alloc();
|
2015-05-06 19:29:33 +03:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2015-04-22 01:29:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPWebrtcGlobalParent(PWebrtcGlobalParent *aActor)
|
|
|
|
{
|
2015-05-06 19:29:33 +03:00
|
|
|
#ifdef MOZ_WEBRTC
|
2015-04-22 01:29:18 +03:00
|
|
|
WebrtcGlobalParent::Dealloc(static_cast<WebrtcGlobalParent*>(aActor));
|
|
|
|
return true;
|
2015-05-06 19:29:33 +03:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2015-04-22 01:29:18 +03:00
|
|
|
}
|
|
|
|
|
2014-11-13 03:31:00 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvSetOfflinePermission(const Principal& aPrincipal)
|
|
|
|
{
|
|
|
|
nsIPrincipal* principal = aPrincipal;
|
|
|
|
nsContentUtils::MaybeAllowOfflineAppByDefault(principal, nullptr);
|
|
|
|
return true;
|
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
|
2015-04-08 21:48:11 +03:00
|
|
|
void
|
|
|
|
ContentParent::MaybeInvokeDragSession(TabParent* aParent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDragService> dragService =
|
|
|
|
do_GetService("@mozilla.org/widget/dragservice;1");
|
|
|
|
if (dragService && dragService->MaybeAddChildProcess(this)) {
|
|
|
|
// We need to send transferable data to child process.
|
|
|
|
nsCOMPtr<nsIDragSession> session;
|
|
|
|
dragService->GetCurrentSession(getter_AddRefs(session));
|
|
|
|
if (session) {
|
|
|
|
nsTArray<IPCDataTransfer> dataTransfers;
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> domTransfer;
|
|
|
|
session->GetDataTransfer(getter_AddRefs(domTransfer));
|
|
|
|
nsCOMPtr<DataTransfer> transfer = do_QueryInterface(domTransfer);
|
|
|
|
if (!transfer) {
|
2015-09-02 09:08:01 +03:00
|
|
|
// Pass eDrop to get DataTransfer with external
|
2015-04-08 21:48:11 +03:00
|
|
|
// drag formats cached.
|
2015-09-02 09:08:01 +03:00
|
|
|
transfer = new DataTransfer(nullptr, eDrop, true, -1);
|
2015-04-08 21:48:11 +03:00
|
|
|
session->SetDataTransfer(transfer);
|
|
|
|
}
|
|
|
|
// Note, even though this fills the DataTransfer object with
|
|
|
|
// external data, the data is usually transfered over IPC lazily when
|
|
|
|
// needed.
|
|
|
|
transfer->FillAllExternalData();
|
|
|
|
nsCOMPtr<nsILoadContext> lc = aParent ?
|
|
|
|
aParent->GetLoadContext() : nullptr;
|
|
|
|
nsCOMPtr<nsISupportsArray> transferables =
|
|
|
|
transfer->GetTransferables(lc);
|
|
|
|
nsContentUtils::TransferablesToIPCTransferables(transferables,
|
|
|
|
dataTransfers,
|
2015-10-28 00:41:58 +03:00
|
|
|
false,
|
2015-04-08 21:48:11 +03:00
|
|
|
nullptr,
|
|
|
|
this);
|
|
|
|
uint32_t action;
|
|
|
|
session->GetDragAction(&action);
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << SendInvokeDragSession(dataTransfers, action);
|
2015-04-08 21:48:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvUpdateDropEffect(const uint32_t& aDragAction,
|
|
|
|
const uint32_t& aDropEffect)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
|
|
|
|
if (dragSession) {
|
|
|
|
dragSession->SetDragAction(aDragAction);
|
|
|
|
nsCOMPtr<nsIDOMDataTransfer> dt;
|
|
|
|
dragSession->GetDataTransfer(getter_AddRefs(dt));
|
|
|
|
if (dt) {
|
|
|
|
dt->SetDropEffectInt(aDropEffect);
|
|
|
|
}
|
|
|
|
dragSession->UpdateDragEffect();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-04-14 04:08:00 +03:00
|
|
|
PContentPermissionRequestParent*
|
|
|
|
ContentParent::AllocPContentPermissionRequestParent(const InfallibleTArray<PermissionRequest>& aRequests,
|
|
|
|
const IPC::Principal& aPrincipal,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TabParent> tp = cpm->GetTopLevelTabParentByProcessAndTabId(this->ChildID(),
|
2015-04-14 04:08:00 +03:00
|
|
|
aTabId);
|
|
|
|
if (!tp) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsContentPermissionUtils::CreateContentPermissionRequestParent(aRequests,
|
|
|
|
tp->GetOwnerElement(),
|
|
|
|
aPrincipal,
|
|
|
|
aTabId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestParent* actor)
|
|
|
|
{
|
|
|
|
nsContentPermissionUtils::NotifyRemoveContentPermissionRequestParent(actor);
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-21 15:54:00 +03:00
|
|
|
PWebBrowserPersistDocumentParent*
|
|
|
|
ContentParent::AllocPWebBrowserPersistDocumentParent(PBrowserParent* aBrowser,
|
|
|
|
const uint64_t& aOuterWindowID)
|
|
|
|
{
|
|
|
|
return new WebBrowserPersistDocumentParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPWebBrowserPersistDocumentParent(PWebBrowserPersistDocumentParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
static already_AddRefed<nsPIDOMWindow>
|
|
|
|
FindMostRecentOpenWindow()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator =
|
|
|
|
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
windowMediator->GetEnumerator(MOZ_UTF16("navigator:browser"),
|
|
|
|
getter_AddRefs(windowEnumerator));
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> latest;
|
|
|
|
|
|
|
|
bool hasMore = false;
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&hasMore)));
|
|
|
|
while (hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> item;
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->GetNext(getter_AddRefs(item))));
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(item);
|
|
|
|
|
|
|
|
if (window && !window->Closed()) {
|
|
|
|
latest = window;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(windowEnumerator->HasMoreElements(&hasMore)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return latest.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
|
|
|
PBrowserParent* aNewTab,
|
|
|
|
const uint32_t& aChromeFlags,
|
|
|
|
const bool& aCalledFromJS,
|
|
|
|
const bool& aPositionSpecified,
|
|
|
|
const bool& aSizeSpecified,
|
2015-10-30 21:54:52 +03:00
|
|
|
const nsCString& aURI,
|
2015-10-30 02:30:57 +03:00
|
|
|
const nsString& aName,
|
|
|
|
const nsCString& aFeatures,
|
2015-10-30 21:54:52 +03:00
|
|
|
const nsCString& aBaseURI,
|
2015-10-30 02:30:57 +03:00
|
|
|
nsresult* aResult,
|
|
|
|
bool* aWindowIsNew,
|
|
|
|
InfallibleTArray<FrameScriptInfo>* aFrameScripts,
|
|
|
|
nsCString* aURLToLoad)
|
|
|
|
{
|
|
|
|
// We always expect to open a new window here. If we don't, it's an error.
|
|
|
|
*aWindowIsNew = true;
|
|
|
|
|
|
|
|
// The content process should never be in charge of computing whether or
|
|
|
|
// not a window should be private or remote - the parent will do that.
|
|
|
|
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW));
|
|
|
|
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW));
|
|
|
|
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME));
|
|
|
|
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW));
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
TabParent* thisTabParent = nullptr;
|
|
|
|
if (aThisTab) {
|
|
|
|
thisTabParent = TabParent::GetFrom(aThisTab);
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
if (NS_WARN_IF(thisTabParent && thisTabParent->IsBrowserOrApp())) {
|
2015-10-30 02:30:57 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIWindowWatcher> pwwatch =
|
|
|
|
do_GetService(NS_WINDOWWATCHER_CONTRACTID, aResult);
|
|
|
|
|
|
|
|
if (NS_WARN_IF(NS_FAILED(*aResult))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TabParent* newTab = TabParent::GetFrom(aNewTab);
|
|
|
|
MOZ_ASSERT(newTab);
|
|
|
|
|
|
|
|
// Content has requested that we open this new content window, so
|
|
|
|
// we must have an opener.
|
|
|
|
newTab->SetHasContentOpener(true);
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
nsCOMPtr<nsIContent> frame;
|
|
|
|
if (thisTabParent) {
|
|
|
|
frame = do_QueryInterface(thisTabParent->GetOwnerElement());
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> parent;
|
|
|
|
if (frame) {
|
|
|
|
parent = frame->OwnerDoc()->GetWindow();
|
|
|
|
|
|
|
|
// If our chrome window is in the process of closing, don't try to open a
|
|
|
|
// new tab in it.
|
|
|
|
if (parent && parent->Closed()) {
|
|
|
|
parent = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
nsCOMPtr<nsIBrowserDOMWindow> browserDOMWin;
|
|
|
|
if (thisTabParent) {
|
|
|
|
browserDOMWin = thisTabParent->GetBrowserDOMWindow();
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
|
|
|
// If we haven't found a chrome window to open in, just use the most recently
|
|
|
|
// opened one.
|
|
|
|
if (!parent) {
|
|
|
|
parent = FindMostRecentOpenWindow();
|
|
|
|
if (NS_WARN_IF(!parent)) {
|
|
|
|
*aResult = NS_ERROR_FAILURE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(parent);
|
|
|
|
if (rootChromeWin) {
|
|
|
|
rootChromeWin->GetBrowserDOMWindow(getter_AddRefs(browserDOMWin));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t openLocation =
|
|
|
|
nsWindowWatcher::GetWindowOpenLocation(parent, aChromeFlags, aCalledFromJS,
|
|
|
|
aPositionSpecified, aSizeSpecified);
|
|
|
|
|
|
|
|
MOZ_ASSERT(openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB ||
|
|
|
|
openLocation == nsIBrowserDOMWindow::OPEN_NEWWINDOW);
|
|
|
|
|
|
|
|
// Opening new tabs is the easy case...
|
|
|
|
if (openLocation == nsIBrowserDOMWindow::OPEN_NEWTAB) {
|
|
|
|
if (NS_WARN_IF(!browserDOMWin)) {
|
|
|
|
*aResult = NS_ERROR_FAILURE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrivate = false;
|
2015-10-30 02:30:57 +03:00
|
|
|
if (thisTabParent) {
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext = thisTabParent->GetLoadContext();
|
|
|
|
loadContext->GetUsePrivateBrowsing(&isPrivate);
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIOpenURIInFrameParams> params = new nsOpenURIInFrameParams();
|
2015-10-30 21:54:52 +03:00
|
|
|
params->SetReferrer(NS_ConvertUTF8toUTF16(aBaseURI));
|
2015-10-30 02:30:57 +03:00
|
|
|
params->SetIsPrivate(isPrivate);
|
|
|
|
|
|
|
|
TabParent::AutoUseNewTab aunt(newTab, aWindowIsNew, aURLToLoad);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner;
|
|
|
|
browserDOMWin->OpenURIInFrame(nullptr, params,
|
|
|
|
openLocation,
|
|
|
|
nsIBrowserDOMWindow::OPEN_NEW,
|
|
|
|
getter_AddRefs(frameLoaderOwner));
|
|
|
|
if (!frameLoaderOwner) {
|
|
|
|
*aWindowIsNew = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
newTab->SwapFrameScriptsFrom(*aFrameScripts);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// WindowWatcher is going to expect a valid URI to open a window
|
|
|
|
// to. If it can't find one, it's going to attempt to figure one
|
|
|
|
// out on its own, which is problematic because it can't access
|
|
|
|
// the document for the remote browser we're opening. Luckily,
|
|
|
|
// TabChild has sent us a baseURI with which we can ensure that
|
|
|
|
// the URI we pass to WindowWatcher is valid.
|
|
|
|
nsCOMPtr<nsIURI> baseURI;
|
|
|
|
*aResult = NS_NewURI(getter_AddRefs(baseURI), aBaseURI);
|
|
|
|
|
|
|
|
if (NS_WARN_IF(NS_FAILED(*aResult))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString finalURIString;
|
|
|
|
if (!aURI.IsEmpty()) {
|
|
|
|
nsCOMPtr<nsIURI> finalURI;
|
2015-10-30 21:54:52 +03:00
|
|
|
*aResult = NS_NewURI(getter_AddRefs(finalURI), aURI.get(), baseURI);
|
2015-10-30 02:30:57 +03:00
|
|
|
|
|
|
|
if (NS_WARN_IF(NS_FAILED(*aResult))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
finalURI->GetSpec(finalURIString);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
|
|
|
|
TabParent::AutoUseNewTab aunt(newTab, aWindowIsNew, aURLToLoad);
|
|
|
|
|
2015-10-30 21:54:52 +03:00
|
|
|
// If nsWindowWatcher::OpenWindowInternal was passed a nullptr for the URI
|
|
|
|
// to open in the content process, we indicate that by sending up a voided
|
|
|
|
// nsString (since primitives are not nullable). If we detect the voided
|
|
|
|
// nsString, we know that we need to send OpenWindow2 a nullptr for the URI.
|
|
|
|
const char* uri = aURI.IsVoid() ? nullptr : finalURIString.get();
|
|
|
|
const char* name = aName.IsVoid() ? nullptr : NS_ConvertUTF16toUTF8(aName).get();
|
|
|
|
const char* features = aFeatures.IsVoid() ? nullptr : aFeatures.get();
|
|
|
|
|
|
|
|
*aResult = pwwatch->OpenWindow2(parent, uri, name, features, aCalledFromJS,
|
2015-10-30 02:30:57 +03:00
|
|
|
false, false, thisTabParent, nullptr, getter_AddRefs(window));
|
|
|
|
|
|
|
|
if (NS_WARN_IF(NS_FAILED(*aResult))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(window);
|
|
|
|
if (NS_WARN_IF(!pwindow)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> windowDocShell = pwindow->GetDocShell();
|
|
|
|
if (NS_WARN_IF(!windowDocShell)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
windowDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(treeOwner);
|
|
|
|
if (NS_WARN_IF(!xulWin)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWin;
|
|
|
|
xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin));
|
|
|
|
if (NS_WARN_IF(!xulBrowserWin)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsITabParent> newRemoteTab;
|
|
|
|
*aResult = xulBrowserWin->ForceInitialBrowserRemote(getter_AddRefs(newRemoteTab));
|
|
|
|
|
|
|
|
if (NS_WARN_IF(NS_FAILED(*aResult))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab);
|
|
|
|
|
|
|
|
newTab->SwapFrameScriptsFrom(*aFrameScripts);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-28 10:18:00 +03:00
|
|
|
/* static */ bool
|
|
|
|
ContentParent::PermissionManagerAddref(const ContentParentId& aCpId,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess(),
|
|
|
|
"Call PermissionManagerAddref in content process!");
|
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
uint32_t appId = cpm->GetAppIdByProcessAndTabId(aCpId, aTabId);
|
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
|
|
|
if (appId != nsIScriptSecurityManager::NO_APP_ID && permMgr) {
|
|
|
|
permMgr->AddrefAppId(appId);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool
|
|
|
|
ContentParent::PermissionManagerRelease(const ContentParentId& aCpId,
|
|
|
|
const TabId& aTabId)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess(),
|
|
|
|
"Call PermissionManagerRelease in content process!");
|
|
|
|
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
|
|
|
uint32_t appId = cpm->GetAppIdByProcessAndTabId(aCpId, aTabId);
|
|
|
|
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
|
|
|
if (appId != nsIScriptSecurityManager::NO_APP_ID && permMgr) {
|
|
|
|
permMgr->ReleaseAppId(appId);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-24 02:41:00 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration* aConfig)
|
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
2015-04-24 02:41:00 +03:00
|
|
|
|
|
|
|
return GetBrowserConfiguration(aURI, *aConfig);;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ bool
|
|
|
|
ContentParent::GetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration& aConfig)
|
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
|
2015-04-24 02:41:00 +03:00
|
|
|
MOZ_ASSERT(swr);
|
|
|
|
|
|
|
|
swr->GetRegistrations(aConfig.serviceWorkerRegistrations());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ContentChild::GetSingleton()->SendGetBrowserConfiguration(aURI, &aConfig);
|
|
|
|
}
|
|
|
|
|
2015-04-24 01:05:29 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGamepadListenerAdded()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_GAMEPAD
|
|
|
|
if (mHasGamepadListener) {
|
|
|
|
NS_WARNING("Gamepad listener already started, cannot start again!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mHasGamepadListener = true;
|
|
|
|
StartGamepadMonitoring();
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvGamepadListenerRemoved()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_GAMEPAD
|
|
|
|
if (!mHasGamepadListener) {
|
|
|
|
NS_WARNING("Gamepad listener already stopped, cannot stop again!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mHasGamepadListener = false;
|
|
|
|
MaybeStopGamepadMonitoring();
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-11 00:58:30 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvProfile(const nsCString& aProfile)
|
|
|
|
{
|
2015-06-14 03:55:33 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2015-06-11 00:58:30 +03:00
|
|
|
if (NS_WARN_IF(!mGatherer)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
mProfile = aProfile;
|
|
|
|
mGatherer->GatheredOOPProfile();
|
|
|
|
mGatherer = nullptr;
|
2015-06-14 03:55:33 +03:00
|
|
|
#endif
|
2015-06-11 00:58:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-02 23:59:33 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetGraphicsDeviceInitData(DeviceInitData* aOut)
|
|
|
|
{
|
|
|
|
gfxPlatform::GetPlatform()->GetDeviceInitData(aOut);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-12 06:22:20 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvBeginDriverCrashGuard(const uint32_t& aGuardType, bool* aOutCrashed)
|
|
|
|
{
|
|
|
|
// Only one driver crash guard should be active at a time, per-process.
|
|
|
|
MOZ_ASSERT(!mDriverCrashGuard);
|
|
|
|
|
|
|
|
UniquePtr<gfx::DriverCrashGuard> guard;
|
|
|
|
switch (gfx::CrashGuardType(aGuardType)) {
|
|
|
|
case gfx::CrashGuardType::D3D11Layers:
|
|
|
|
guard = MakeUnique<gfx::D3D11LayersCrashGuard>(this);
|
|
|
|
break;
|
2015-08-12 06:22:20 +03:00
|
|
|
case gfx::CrashGuardType::D3D9Video:
|
|
|
|
guard = MakeUnique<gfx::D3D9VideoCrashGuard>(this);
|
|
|
|
break;
|
2015-08-15 08:14:00 +03:00
|
|
|
case gfx::CrashGuardType::GLContext:
|
|
|
|
guard = MakeUnique<gfx::GLContextCrashGuard>(this);
|
|
|
|
break;
|
2015-08-12 06:22:20 +03:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unknown crash guard type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (guard->Crashed()) {
|
|
|
|
*aOutCrashed = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aOutCrashed = false;
|
|
|
|
mDriverCrashGuard = Move(guard);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvEndDriverCrashGuard(const uint32_t& aGuardType)
|
|
|
|
{
|
|
|
|
mDriverCrashGuard = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:01:07 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetDeviceStorageLocation(const nsString& aType,
|
|
|
|
nsString* aPath) {
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
mozilla::AndroidBridge::GetExternalPublicDirectory(aType, *aPath);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-11-04 22:08:14 +03:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetAndroidSystemInfo(AndroidSystemInfo* aInfo)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
nsSystemInfo::GetAndroidSystemInfo(aInfo);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
MOZ_CRASH("wrong platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-08-11 21:26:27 +03:00
|
|
|
void
|
|
|
|
ContentParent::StartProfiler(nsIProfilerStartParams* aParams)
|
|
|
|
{
|
2015-11-27 19:00:18 +03:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2015-08-11 21:26:27 +03:00
|
|
|
if (NS_WARN_IF(!aParams)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProfilerInitParams ipcParams;
|
|
|
|
|
|
|
|
ipcParams.enabled() = true;
|
|
|
|
aParams->GetEntries(&ipcParams.entries());
|
|
|
|
aParams->GetInterval(&ipcParams.interval());
|
|
|
|
ipcParams.features() = aParams->GetFeatures();
|
|
|
|
ipcParams.threadFilters() = aParams->GetThreadFilterNames();
|
|
|
|
|
|
|
|
Unused << SendStartProfiler(ipcParams);
|
2015-11-27 19:00:18 +03:00
|
|
|
#endif
|
2015-08-11 21:26:27 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
} // namespace dom
|
2013-02-15 00:41:30 +04:00
|
|
|
} // namespace mozilla
|
2013-12-13 20:28:46 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(ParentIdleListener, nsIObserver)
|
2013-12-13 20:28:46 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
ParentIdleListener::Observe(nsISupports*, const char* aTopic, const char16_t* aData) {
|
2015-11-02 08:53:26 +03:00
|
|
|
mozilla::Unused << mParent->SendNotifyIdleObserver(mObserver,
|
2014-05-28 07:04:23 +04:00
|
|
|
nsDependentCString(aTopic),
|
|
|
|
nsDependentString(aData));
|
|
|
|
return NS_OK;
|
2013-12-13 20:28:46 +04:00
|
|
|
}
|
2015-10-08 00:38:08 +03:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::HandleWindowsMessages(const Message& aMsg) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aMsg.is_sync());
|
|
|
|
|
|
|
|
// a11y messages can be triggered by windows messages, which means if we
|
|
|
|
// allow handling windows messages while we wait for the response to a sync
|
|
|
|
// a11y message we can reenter the ipc message sending code.
|
|
|
|
if (a11y::PDocAccessible::PDocAccessibleStart < aMsg.type() &&
|
|
|
|
a11y::PDocAccessible::PDocAccessibleEnd > aMsg.type()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|