2009-08-18 19:05:15 +00: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 11:12:37 +00: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-09 22:00:14 +00:00
|
|
|
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "base/basictypes.h"
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "ContentParent.h"
|
|
|
|
|
2012-07-17 23:59:44 +00:00
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
|
2011-07-13 06:52:31 +00:00
|
|
|
#include "chrome/common/process_watcher.h"
|
|
|
|
|
2012-08-16 19:34:53 +00:00
|
|
|
#include "AppProcessPermissions.h"
|
2012-12-06 03:01:58 +00:00
|
|
|
#include "AudioChannelService.h"
|
2010-11-24 14:15:03 +00:00
|
|
|
#include "CrashReporterParent.h"
|
2012-11-09 09:55:54 +00:00
|
|
|
#include "IHistory.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "IDBFactory.h"
|
|
|
|
#include "IndexedDBParent.h"
|
|
|
|
#include "IndexedDatabaseManager.h"
|
2012-08-09 02:58:06 +00:00
|
|
|
#include "mozIApplication.h"
|
2012-08-16 01:46:03 +00:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "mozilla/dom/ExternalHelperAppParent.h"
|
|
|
|
#include "mozilla/dom/PMemoryReportRequestParent.h"
|
|
|
|
#include "mozilla/dom/StorageParent.h"
|
2012-09-13 16:37:14 +00:00
|
|
|
#include "mozilla/dom/bluetooth/PBluetoothParent.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
|
2012-11-06 21:29:30 +00:00
|
|
|
#include "SmsParent.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "mozilla/hal_sandbox/PHalParent.h"
|
2009-08-12 18:31:48 +00:00
|
|
|
#include "mozilla/ipc/TestShellParent.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2012-08-29 12:24:48 +00:00
|
|
|
#include "mozilla/layers/ImageBridgeParent.h"
|
2009-08-18 19:05:15 +00:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
2012-08-16 01:46:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
|
|
|
#include "nsAppRunner.h"
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsCExternalHandlerService.h"
|
2009-09-03 00:18:27 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2010-03-11 05:33:00 +00:00
|
|
|
#include "nsChromeRegistryChrome.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsConsoleMessage.h"
|
2012-11-09 17:52:09 +00:00
|
|
|
#include "nsConsoleService.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsDebugImpl.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2012-08-03 06:25:30 +00:00
|
|
|
#include "nsDOMFile.h"
|
2010-08-10 17:14:45 +00:00
|
|
|
#include "nsExternalHelperAppService.h"
|
2010-08-31 18:58:35 +00:00
|
|
|
#include "nsFrameMessageManager.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsHashPropertyBag.h"
|
2010-09-15 16:44:57 +00:00
|
|
|
#include "nsIAlertsService.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsIClipboard.h"
|
2012-08-09 02:58:06 +00:00
|
|
|
#include "nsIDOMApplicationRegistry.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsIDOMGeoGeolocation.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsIFilePicker.h"
|
|
|
|
#include "nsIMemoryReporter.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIPresShell.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "nsIRemoteBlob.h"
|
2010-09-24 01:39:32 +00:00
|
|
|
#include "nsIScriptError.h"
|
2012-08-09 02:58:06 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIWindowWatcher.h"
|
|
|
|
#include "nsMemoryReporterManager.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
2011-06-17 02:59:00 +00:00
|
|
|
#include "nsSystemInfo.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsToolkitCompsCID.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "SandboxHal.h"
|
2012-08-02 06:02:29 +00:00
|
|
|
#include "StructuredCloneUtils.h"
|
2012-07-17 23:59:44 +00:00
|
|
|
#include "TabParent.h"
|
2012-08-23 19:33:46 +00:00
|
|
|
#include "URIUtils.h"
|
2012-12-31 16:36:46 +00:00
|
|
|
#include "nsGeolocation.h"
|
2011-02-14 22:34:46 +00:00
|
|
|
|
2012-07-17 23:59:44 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
# include "gfxAndroidPlatform.h"
|
2010-10-09 18:07:38 +00:00
|
|
|
#endif
|
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2012-07-17 23:59:44 +00:00
|
|
|
# include "nsExceptionHandler.h"
|
|
|
|
# include "nsICrashReporter.h"
|
2010-11-24 13:58:21 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-17 23:59:44 +00:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
# include "nsPermissionManager.h"
|
|
|
|
#endif
|
2011-02-16 18:43:23 +00:00
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-17 23:59:44 +00:00
|
|
|
# include "AndroidBridge.h"
|
2011-01-13 04:04:42 +00:00
|
|
|
#endif
|
|
|
|
|
2012-08-03 23:48:58 +00:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
#include "nsIVolume.h"
|
|
|
|
#include "nsIVolumeService.h"
|
|
|
|
#endif
|
|
|
|
|
2012-09-13 16:37:14 +00:00
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
#include "BluetoothParent.h"
|
|
|
|
#include "BluetoothService.h"
|
|
|
|
#endif
|
|
|
|
|
2011-03-01 05:36:43 +00:00
|
|
|
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
|
|
|
|
static const char* sClipboardTextFlavors[] = { kUnicodeMime };
|
|
|
|
|
2012-12-20 07:41:08 +00:00
|
|
|
using base::ChildPrivileges;
|
2011-01-20 06:14:12 +00:00
|
|
|
using base::KillProcess;
|
2012-09-13 16:37:14 +00:00
|
|
|
using namespace mozilla::dom::bluetooth;
|
2012-06-19 23:14:39 +00:00
|
|
|
using namespace mozilla::dom::devicestorage;
|
2011-11-20 22:40:53 +00:00
|
|
|
using namespace mozilla::dom::sms;
|
2012-07-14 11:24:20 +00:00
|
|
|
using namespace mozilla::dom::indexedDB;
|
2012-07-17 23:59:44 +00:00
|
|
|
using namespace mozilla::hal_sandbox;
|
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
using namespace mozilla::net;
|
2009-09-03 00:18:27 +00:00
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2010-05-11 17:22:34 +00:00
|
|
|
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
2010-05-11 12:44:12 +00:00
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
class MemoryReportRequestParent : public PMemoryReportRequestParent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MemoryReportRequestParent();
|
|
|
|
virtual ~MemoryReportRequestParent();
|
|
|
|
|
|
|
|
virtual bool Recv__delete__(const InfallibleTArray<MemoryReport>& report);
|
|
|
|
private:
|
|
|
|
ContentParent* Owner()
|
|
|
|
{
|
|
|
|
return static_cast<ContentParent*>(Manager());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MemoryReportRequestParent::MemoryReportRequestParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(MemoryReportRequestParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
MemoryReportRequestParent::Recv__delete__(const InfallibleTArray<MemoryReport>& report)
|
|
|
|
{
|
|
|
|
Owner()->SetChildMemoryReporters(report);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemoryReportRequestParent::~MemoryReportRequestParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(MemoryReportRequestParent);
|
|
|
|
}
|
|
|
|
|
2012-07-13 21:10:20 +00:00
|
|
|
nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::gAppContentParents;
|
|
|
|
nsTArray<ContentParent*>* ContentParent::gNonAppContentParents;
|
2012-04-20 00:13:20 +00:00
|
|
|
nsTArray<ContentParent*>* ContentParent::gPrivateContent;
|
2009-08-12 16:18:08 +00:00
|
|
|
|
2012-12-28 09:45:16 +00:00
|
|
|
// This is true when subprocess launching is enabled. This is the
|
|
|
|
// case between StartUp() and ShutDown() or JoinAllSubprocesses().
|
|
|
|
static bool sCanLaunchSubprocesses;
|
|
|
|
|
2011-09-30 07:00:48 +00:00
|
|
|
// The first content child has ID 1, so the chrome process can have ID 0.
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint64_t gContentChildID = 1;
|
2011-09-30 07:00:48 +00:00
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
// Try to keep an app process always preallocated, to get
|
|
|
|
// initialization off the critical path of app startup.
|
|
|
|
static bool sKeepAppProcessPreallocated;
|
|
|
|
static StaticRefPtr<ContentParent> sPreallocatedAppProcess;
|
|
|
|
static CancelableTask* sPreallocateAppProcessTask;
|
|
|
|
// This number is fairly arbitrary ... the intention is to put off
|
|
|
|
// launching another app process until the last one has finished
|
|
|
|
// loading its content, to reduce CPU/memory/IO contention.
|
|
|
|
static int sPreallocateDelayMs;
|
|
|
|
// 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}}")
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::PreallocateAppProcess()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!sPreallocatedAppProcess);
|
|
|
|
|
|
|
|
if (sPreallocateAppProcessTask) {
|
|
|
|
// We were called directly while a delayed task was scheduled.
|
|
|
|
sPreallocateAppProcessTask->Cancel();
|
|
|
|
sPreallocateAppProcessTask = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
sPreallocatedAppProcess =
|
2012-08-23 10:23:43 +00:00
|
|
|
new ContentParent(MAGIC_PREALLOCATED_APP_MANIFEST_URL,
|
2012-08-29 12:24:48 +00:00
|
|
|
/*isBrowserElement=*/false,
|
|
|
|
base::PRIVILEGES_DEFAULT);
|
2012-08-16 01:46:03 +00:00
|
|
|
sPreallocatedAppProcess->Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::DelayedPreallocateAppProcess()
|
|
|
|
{
|
|
|
|
sPreallocateAppProcessTask = nullptr;
|
|
|
|
if (!sPreallocatedAppProcess) {
|
|
|
|
PreallocateAppProcess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
ContentParent::ScheduleDelayedPreallocateAppProcess()
|
|
|
|
{
|
|
|
|
if (!sKeepAppProcessPreallocated || sPreallocateAppProcessTask) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sPreallocateAppProcessTask =
|
|
|
|
NewRunnableFunction(DelayedPreallocateAppProcess);
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
|
|
|
FROM_HERE, sPreallocateAppProcessTask, sPreallocateDelayMs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ already_AddRefed<ContentParent>
|
|
|
|
ContentParent::MaybeTakePreallocatedAppProcess()
|
|
|
|
{
|
|
|
|
nsRefPtr<ContentParent> process = sPreallocatedAppProcess.get();
|
|
|
|
sPreallocatedAppProcess = nullptr;
|
|
|
|
return process.forget();
|
|
|
|
}
|
|
|
|
|
2012-10-09 04:46:19 +00:00
|
|
|
/*static*/ void
|
|
|
|
ContentParent::FirstIdle(void)
|
|
|
|
{
|
|
|
|
// The parent has gone idle for the first time. This would be a good
|
|
|
|
// time to preallocate an app process.
|
|
|
|
ScheduleDelayedPreallocateAppProcess();
|
|
|
|
}
|
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
/*static*/ void
|
|
|
|
ContentParent::StartUp()
|
|
|
|
{
|
|
|
|
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sKeepAppProcessPreallocated =
|
2012-10-03 00:13:40 +00:00
|
|
|
Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false);
|
2012-08-16 01:46:03 +00:00
|
|
|
if (sKeepAppProcessPreallocated) {
|
|
|
|
ClearOnShutdown(&sPreallocatedAppProcess);
|
|
|
|
|
|
|
|
sPreallocateDelayMs = Preferences::GetUint(
|
2012-10-03 00:13:40 +00:00
|
|
|
"dom.ipc.processPrelaunch.delayMs", 1000);
|
2012-08-16 01:46:03 +00:00
|
|
|
|
|
|
|
MOZ_ASSERT(!sPreallocateAppProcessTask);
|
2012-10-09 04:46:19 +00:00
|
|
|
|
|
|
|
// Let's not slow down the main process initialization. Wait until
|
|
|
|
// the main process goes idle before we preallocate a process
|
|
|
|
MessageLoop::current()->PostIdleTask(FROM_HERE, NewRunnableFunction(FirstIdle));
|
2012-08-16 01:46:03 +00:00
|
|
|
}
|
2012-12-28 09:45:16 +00:00
|
|
|
|
|
|
|
sCanLaunchSubprocesses = true;
|
2012-08-16 01:46:03 +00: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 09:45:16 +00:00
|
|
|
sCanLaunchSubprocesses = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*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 01:46:03 +00:00
|
|
|
}
|
|
|
|
|
2012-08-09 02:58:06 +00:00
|
|
|
/*static*/ ContentParent*
|
2012-08-23 10:23:43 +00:00
|
|
|
ContentParent::GetNewOrUsed(bool aForBrowserElement)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2012-07-13 21:10:20 +00:00
|
|
|
if (!gNonAppContentParents)
|
|
|
|
gNonAppContentParents = new nsTArray<ContentParent*>();
|
2011-08-02 19:35:42 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t maxContentProcesses = Preferences::GetInt("dom.ipc.processCount", 1);
|
2011-08-02 19:35:42 +00:00
|
|
|
if (maxContentProcesses < 1)
|
|
|
|
maxContentProcesses = 1;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
if (gNonAppContentParents->Length() >= uint32_t(maxContentProcesses)) {
|
|
|
|
uint32_t idx = rand() % gNonAppContentParents->Length();
|
2012-07-13 21:10:20 +00:00
|
|
|
ContentParent* p = (*gNonAppContentParents)[idx];
|
|
|
|
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in gNonAppContentParents?");
|
2011-08-02 19:35:42 +00:00
|
|
|
return p;
|
2011-03-26 20:16:45 +00:00
|
|
|
}
|
2012-08-09 02:58:06 +00:00
|
|
|
|
2012-07-13 21:10:20 +00:00
|
|
|
nsRefPtr<ContentParent> p =
|
2012-08-23 10:23:43 +00:00
|
|
|
new ContentParent(/* appManifestURL = */ EmptyString(),
|
|
|
|
aForBrowserElement);
|
2011-08-02 19:35:42 +00:00
|
|
|
p->Init();
|
2012-07-13 21:10:20 +00:00
|
|
|
gNonAppContentParents->AppendElement(p);
|
2011-08-02 19:35:42 +00:00
|
|
|
return p;
|
|
|
|
}
|
2010-12-26 20:03:52 +00:00
|
|
|
|
2012-12-20 07:41:08 +00:00
|
|
|
namespace {
|
|
|
|
struct SpecialPermission {
|
|
|
|
const char* perm; // an app permission
|
|
|
|
ChildPrivileges privs; // the OS privilege it requires
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static ChildPrivileges
|
|
|
|
PrivilegesForApp(mozIApplication* aApp)
|
2012-08-29 12:24:48 +00:00
|
|
|
{
|
2012-12-20 07:41:08 +00:00
|
|
|
const SpecialPermission specialPermissions[] = {
|
2012-09-20 23:26:41 +00:00
|
|
|
// FIXME/bug 785592: implement a CameraBridge so we don't have
|
|
|
|
// to hack around with OS permissions
|
2012-12-20 07:41:08 +00:00
|
|
|
{ "camera", base::PRIVILEGES_INHERIT },
|
2012-09-20 23:26:41 +00:00
|
|
|
// FIXME/bug 793034: change our video architecture so that we
|
|
|
|
// can stream video from remote processes
|
2012-12-20 07:41:08 +00:00
|
|
|
{ "deprecated-hwvideo", base::PRIVILEGES_VIDEO }
|
2012-09-20 23:26:41 +00:00
|
|
|
};
|
2012-12-20 07:41:08 +00:00
|
|
|
for (size_t i = 0; i < ArrayLength(specialPermissions); ++i) {
|
|
|
|
const char* const permission = specialPermissions[i].perm;
|
|
|
|
bool hasPermission = false;
|
|
|
|
if (NS_FAILED(aApp->HasPermission(permission, &hasPermission))) {
|
2012-09-20 23:26:41 +00:00
|
|
|
NS_WARNING("Unable to check permissions. Breakage may follow.");
|
2012-12-20 07:41:08 +00:00
|
|
|
break;
|
|
|
|
} else if (hasPermission) {
|
|
|
|
return specialPermissions[i].privs;
|
2012-09-20 23:26:41 +00:00
|
|
|
}
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
2012-12-20 07:41:08 +00:00
|
|
|
return base::PRIVILEGES_DEFAULT;
|
2012-08-29 12:24:48 +00:00
|
|
|
}
|
|
|
|
|
2012-08-09 02:58:06 +00:00
|
|
|
/*static*/ TabParent*
|
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 18:32:37 +00:00
|
|
|
ContentParent::CreateBrowserOrApp(const TabContext& aContext)
|
2012-07-13 21:10:20 +00:00
|
|
|
{
|
2012-12-28 09:45:16 +00:00
|
|
|
if (!sCanLaunchSubprocesses) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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 18:32:37 +00:00
|
|
|
if (aContext.IsBrowserElement() || !aContext.HasOwnApp()) {
|
|
|
|
if (ContentParent* cp = GetNewOrUsed(aContext.IsBrowserElement())) {
|
|
|
|
nsRefPtr<TabParent> tp(new TabParent(aContext));
|
|
|
|
PBrowserParent* browser = cp->SendPBrowserConstructor(
|
|
|
|
tp.forget().get(), // DeallocPBrowserParent() releases this ref.
|
|
|
|
aContext.AsIPCTabContext(),
|
|
|
|
/* chromeFlags */ 0);
|
|
|
|
return static_cast<TabParent*>(browser);
|
2012-08-09 02:58:06 +00:00
|
|
|
}
|
|
|
|
return nullptr;
|
2012-07-13 21:10:20 +00: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 18:32:37 +00: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.
|
|
|
|
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
|
|
|
|
|
2012-07-13 21:10:20 +00:00
|
|
|
if (!gAppContentParents) {
|
|
|
|
gAppContentParents =
|
|
|
|
new nsDataHashtable<nsStringHashKey, ContentParent*>();
|
|
|
|
gAppContentParents->Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Each app gets its own ContentParent instance.
|
2012-08-09 02:58:06 +00:00
|
|
|
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 18:32:37 +00:00
|
|
|
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
|
2012-08-09 02:58:06 +00:00
|
|
|
NS_ERROR("Failed to get manifest URL");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
nsRefPtr<ContentParent> p = gAppContentParents->Get(manifestURL);
|
2012-07-13 21:10:20 +00:00
|
|
|
if (!p) {
|
2012-12-20 07:41:08 +00:00
|
|
|
ChildPrivileges privs = PrivilegesForApp(ownApp);
|
|
|
|
if (privs != base::PRIVILEGES_DEFAULT) {
|
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 18:32:37 +00:00
|
|
|
p = new ContentParent(manifestURL, /* isBrowserElement = */ false,
|
2012-12-20 07:41:08 +00:00
|
|
|
privs);
|
2012-08-16 01:46:03 +00:00
|
|
|
p->Init();
|
2012-08-29 12:24:48 +00:00
|
|
|
} else {
|
|
|
|
p = MaybeTakePreallocatedAppProcess();
|
|
|
|
if (p) {
|
|
|
|
p->SetManifestFromPreallocated(manifestURL);
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Unable to use pre-allocated app process");
|
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 18:32:37 +00:00
|
|
|
p = new ContentParent(manifestURL, /* isBrowserElement = */ false,
|
2012-08-29 12:24:48 +00:00
|
|
|
base::PRIVILEGES_DEFAULT);
|
|
|
|
p->Init();
|
|
|
|
}
|
2012-08-16 01:46:03 +00:00
|
|
|
}
|
2012-08-09 02:58:06 +00:00
|
|
|
gAppContentParents->Put(manifestURL, p);
|
2012-07-13 21:10:20 +00: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 18:32:37 +00:00
|
|
|
nsRefPtr<TabParent> tp = new TabParent(aContext);
|
|
|
|
PBrowserParent* browser = p->SendPBrowserConstructor(
|
|
|
|
tp.forget().get(), // DeallocPBrowserParent() releases this ref.
|
|
|
|
aContext.AsIPCTabContext(),
|
|
|
|
/* chromeFlags */ 0);
|
|
|
|
return static_cast<TabParent*>(browser);
|
2012-07-13 21:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
AppendToTArray(const nsAString& aKey, ContentParent* aValue, void* aArray)
|
|
|
|
{
|
|
|
|
nsTArray<ContentParent*> *array =
|
|
|
|
static_cast<nsTArray<ContentParent*>*>(aArray);
|
|
|
|
array->AppendElement(aValue);
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
2011-08-02 19:35:42 +00:00
|
|
|
void
|
|
|
|
ContentParent::GetAll(nsTArray<ContentParent*>& aArray)
|
|
|
|
{
|
2012-07-13 21:10:20 +00:00
|
|
|
aArray.Clear();
|
|
|
|
|
|
|
|
if (gNonAppContentParents) {
|
|
|
|
aArray.AppendElements(*gNonAppContentParents);
|
2011-08-02 19:35:42 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 21:10:20 +00:00
|
|
|
if (gAppContentParents) {
|
|
|
|
gAppContentParents->EnumerateRead(&AppendToTArray, &aArray);
|
|
|
|
}
|
2012-10-03 01:19:11 +00:00
|
|
|
|
|
|
|
if (sPreallocatedAppProcess) {
|
|
|
|
aArray.AppendElement(sPreallocatedAppProcess);
|
|
|
|
}
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-26 20:03:52 +00:00
|
|
|
void
|
|
|
|
ContentParent::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
|
|
|
if (obs) {
|
2011-10-17 14:59:28 +00:00
|
|
|
obs->AddObserver(this, "xpcom-shutdown", false);
|
|
|
|
obs->AddObserver(this, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, false);
|
|
|
|
obs->AddObserver(this, "child-memory-reporter-request", false);
|
|
|
|
obs->AddObserver(this, "memory-pressure", false);
|
|
|
|
obs->AddObserver(this, "child-gc-request", false);
|
|
|
|
obs->AddObserver(this, "child-cc-request", false);
|
2012-04-20 00:13:20 +00:00
|
|
|
obs->AddObserver(this, "last-pb-context-exited", false);
|
2012-08-18 02:43:00 +00:00
|
|
|
obs->AddObserver(this, "file-watcher-update", false);
|
2012-08-03 23:48:58 +00:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
obs->AddObserver(this, NS_VOLUME_STATE_CHANGED, false);
|
|
|
|
#endif
|
2011-07-21 04:37:32 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-10-17 14:59:28 +00:00
|
|
|
obs->AddObserver(this, "a11y-init-or-shutdown", false);
|
2011-07-21 04:37:32 +00:00
|
|
|
#endif
|
2010-12-26 20:03:52 +00:00
|
|
|
}
|
2012-04-04 04:09:20 +00:00
|
|
|
Preferences::AddStrongObserver(this, "");
|
2010-12-26 20:03:52 +00:00
|
|
|
nsCOMPtr<nsIThreadInternal>
|
|
|
|
threadInt(do_QueryInterface(NS_GetCurrentThread()));
|
|
|
|
if (threadInt) {
|
2011-12-02 12:33:05 +00:00
|
|
|
threadInt->AddObserver(this);
|
2010-12-26 20:03:52 +00:00
|
|
|
}
|
|
|
|
if (obs) {
|
2012-07-30 14:20:58 +00:00
|
|
|
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", nullptr);
|
2010-12-26 20:03:52 +00:00
|
|
|
}
|
2011-07-21 04:37:32 +00:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
// If accessibility is running in chrome process then start it in content
|
|
|
|
// process.
|
|
|
|
if (nsIPresShell::IsAccessibilityActive()) {
|
2011-09-18 19:02:27 +00:00
|
|
|
unused << SendActivateA11y();
|
2011-07-21 04:37:32 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-12-26 20:03:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
void
|
2012-08-16 01:46:03 +00:00
|
|
|
ContentParent::SetManifestFromPreallocated(const nsAString& aAppManifestURL)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL);
|
|
|
|
// Clients should think of mAppManifestURL as const ... we're
|
|
|
|
// bending the rules here just for the preallocation hack.
|
|
|
|
const_cast<nsString&>(mAppManifestURL) = aAppManifestURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::ShutDownProcess()
|
2012-07-17 18:27:27 +00:00
|
|
|
{
|
2012-11-27 20:43:52 +00:00
|
|
|
if (!mIsDestroyed) {
|
2012-10-05 19:09:33 +00:00
|
|
|
const InfallibleTArray<PIndexedDBParent*>& idbParents =
|
|
|
|
ManagedPIndexedDBParent();
|
|
|
|
for (uint32_t i = 0; i < idbParents.Length(); ++i) {
|
|
|
|
static_cast<IndexedDBParent*>(idbParents[i])->Disconnect();
|
2012-07-17 18:27:27 +00:00
|
|
|
}
|
2012-10-05 19:09:33 +00:00
|
|
|
|
|
|
|
// Close() can only be called once. It kicks off the
|
|
|
|
// destruction sequence.
|
|
|
|
Close();
|
2012-11-27 20:43:52 +00:00
|
|
|
mIsDestroyed = true;
|
2012-10-05 19:09:33 +00:00
|
|
|
}
|
|
|
|
// NB: must MarkAsDead() here so that this isn't accidentally
|
|
|
|
// returned from Get*() while in the midst of shutdown.
|
|
|
|
MarkAsDead();
|
2012-07-17 18:27:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::MarkAsDead()
|
|
|
|
{
|
|
|
|
if (!mAppManifestURL.IsEmpty()) {
|
|
|
|
if (gAppContentParents) {
|
|
|
|
gAppContentParents->Remove(mAppManifestURL);
|
|
|
|
if (!gAppContentParents->Count()) {
|
|
|
|
delete gAppContentParents;
|
|
|
|
gAppContentParents = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (gNonAppContentParents) {
|
|
|
|
gNonAppContentParents->RemoveElement(this);
|
|
|
|
if (!gNonAppContentParents->Length()) {
|
|
|
|
delete gNonAppContentParents;
|
|
|
|
gNonAppContentParents = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gPrivateContent) {
|
|
|
|
gPrivateContent->RemoveElement(this);
|
|
|
|
if (!gPrivateContent->Length()) {
|
|
|
|
delete gPrivateContent;
|
|
|
|
gPrivateContent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mIsAlive = false;
|
|
|
|
}
|
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
void
|
2012-09-17 08:37:20 +00:00
|
|
|
ContentParent::OnChannelConnected(int32_t pid)
|
2010-11-24 13:58:21 +00:00
|
|
|
{
|
|
|
|
ProcessHandle handle;
|
|
|
|
if (!base::OpenPrivilegedProcessHandle(pid, &handle)) {
|
|
|
|
NS_WARNING("Can't open handle to child process.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetOtherProcess(handle);
|
2011-02-14 22:34:46 +00:00
|
|
|
|
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
// Check nice preference
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nice = Preferences::GetInt("dom.ipc.content.nice", 0);
|
2011-02-14 22:34:46 +00:00
|
|
|
|
|
|
|
// Environment variable overrides preference
|
|
|
|
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
|
|
|
|
if (relativeNicenessStr) {
|
|
|
|
nice = atoi(relativeNicenessStr);
|
|
|
|
}
|
|
|
|
|
2011-06-17 13:26:17 +00:00
|
|
|
/* make the GUI thread have higher priority on single-cpu devices */
|
2011-06-17 02:59:00 +00:00
|
|
|
nsCOMPtr<nsIPropertyBag2> infoService = do_GetService(NS_SYSTEMINFO_CONTRACTID);
|
|
|
|
if (infoService) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t cpus;
|
2011-06-17 02:59:00 +00:00
|
|
|
nsresult rv = infoService->GetPropertyAsInt32(NS_LITERAL_STRING("cpucount"), &cpus);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
cpus = 1;
|
|
|
|
}
|
|
|
|
if (nice != 0 && cpus == 1) {
|
|
|
|
setpriority(PRIO_PROCESS, pid, getpriority(PRIO_PROCESS, pid) + nice);
|
|
|
|
}
|
2011-02-14 22:34:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-11-24 13:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-13 06:52:31 +00:00
|
|
|
void
|
|
|
|
ContentParent::ProcessingError(Result what)
|
|
|
|
{
|
|
|
|
if (MsgDropped == what) {
|
|
|
|
// Messages sent after crashes etc. are not a big deal.
|
|
|
|
return;
|
|
|
|
}
|
2012-09-05 22:18:48 +00:00
|
|
|
// Other errors are big deals.
|
|
|
|
KillHard();
|
2011-07-13 06:52:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
namespace {
|
2011-08-31 04:11:25 +00:00
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
void
|
|
|
|
DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
|
|
|
{
|
|
|
|
XRE_GetIOMessageLoop()
|
|
|
|
->PostTask(FROM_HERE,
|
|
|
|
new DeleteTask<GeckoChildProcessHost>(aSubprocess));
|
|
|
|
}
|
2011-08-31 04:11:25 +00: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
|
|
|
|
{
|
|
|
|
DelayedDeleteContentParentTask(ContentParent* aObj) : mObj(aObj) { }
|
|
|
|
|
|
|
|
// No-op
|
|
|
|
NS_IMETHODIMP Run() { return NS_OK; }
|
|
|
|
|
|
|
|
nsRefPtr<ContentParent> mObj;
|
|
|
|
};
|
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
}
|
|
|
|
|
2010-02-02 01:53:52 +00:00
|
|
|
void
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::ActorDestroy(ActorDestroyReason why)
|
2010-02-02 01:53:52 +00:00
|
|
|
{
|
2012-09-28 05:43:24 +00:00
|
|
|
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
|
|
|
if (ppm) {
|
|
|
|
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
|
|
|
CHILD_PROCESS_SHUTDOWN_MESSAGE, false,
|
|
|
|
nullptr, nullptr, nullptr);
|
|
|
|
}
|
2010-02-02 01:53:52 +00:00
|
|
|
nsCOMPtr<nsIThreadObserver>
|
|
|
|
kungFuDeathGrip(static_cast<nsIThreadObserver*>(this));
|
2010-12-26 20:03:52 +00:00
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2010-12-26 19:27:50 +00:00
|
|
|
if (obs) {
|
2010-02-02 01:53:52 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "xpcom-shutdown");
|
2010-12-26 19:27:50 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "memory-pressure");
|
2011-02-16 18:43:23 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-memory-reporter-request");
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC);
|
2011-09-13 17:53:51 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-gc-request");
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "child-cc-request");
|
2012-04-20 00:13:20 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "last-pb-context-exited");
|
2012-08-18 02:43:00 +00:00
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "file-watcher-update");
|
2012-08-03 23:48:58 +00:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), NS_VOLUME_STATE_CHANGED);
|
|
|
|
#endif
|
2011-07-21 04:37:32 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "a11y-init-or-shutdown");
|
|
|
|
#endif
|
2010-12-26 19:27:50 +00:00
|
|
|
}
|
|
|
|
|
2012-08-16 01:46:03 +00:00
|
|
|
if (sPreallocatedAppProcess == this) {
|
|
|
|
sPreallocatedAppProcess = nullptr;
|
|
|
|
}
|
|
|
|
|
2011-08-02 19:57:48 +00:00
|
|
|
mMessageManager->Disconnect();
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
// clear the child memory reporters
|
|
|
|
InfallibleTArray<MemoryReport> empty;
|
|
|
|
SetChildMemoryReporters(empty);
|
|
|
|
|
2010-12-26 19:27:50 +00:00
|
|
|
// remove the global remote preferences observers
|
2012-04-04 04:09:20 +00:00
|
|
|
Preferences::RemoveObserver(this, "");
|
2010-12-26 19:27:50 +00:00
|
|
|
|
|
|
|
RecvRemoveGeolocationListener();
|
|
|
|
|
2012-11-09 17:52:09 +00:00
|
|
|
mConsoleService = nullptr;
|
|
|
|
|
2010-02-02 01:53:52 +00:00
|
|
|
nsCOMPtr<nsIThreadInternal>
|
|
|
|
threadInt(do_QueryInterface(NS_GetCurrentThread()));
|
|
|
|
if (threadInt)
|
2011-12-02 12:33:05 +00:00
|
|
|
threadInt->RemoveObserver(this);
|
2010-02-02 01:53:52 +00:00
|
|
|
if (mRunToCompletionDepth)
|
|
|
|
mRunToCompletionDepth = 0;
|
2010-04-12 00:24:45 +00:00
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
MarkAsDead();
|
2010-10-08 19:12:40 +00:00
|
|
|
|
|
|
|
if (obs) {
|
2010-11-24 13:58:21 +00:00
|
|
|
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
|
|
|
props->Init();
|
|
|
|
|
2012-11-17 15:05:18 +00:00
|
|
|
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID);
|
|
|
|
|
2010-11-24 13:58:21 +00:00
|
|
|
if (AbnormalShutdown == why) {
|
2011-10-17 14:59:28 +00:00
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true);
|
2010-11-24 13:58:21 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-01-03 23:39:25 +00:00
|
|
|
// There's a window in which child processes can crash
|
|
|
|
// after IPC is established, but before a crash reporter
|
|
|
|
// is created.
|
|
|
|
if (ManagedPCrashReporterParent().Length() > 0) {
|
|
|
|
CrashReporterParent* crashReporter =
|
2011-06-08 19:56:31 +00:00
|
|
|
static_cast<CrashReporterParent*>(ManagedPCrashReporterParent()[0]);
|
2010-11-24 13:58:21 +00:00
|
|
|
|
2013-01-03 23:39:25 +00:00
|
|
|
crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("URL"),
|
|
|
|
NS_ConvertUTF16toUTF8(mAppManifestURL));
|
|
|
|
crashReporter->GenerateCrashReport(this, NULL);
|
2012-12-25 23:06:27 +00:00
|
|
|
|
2013-01-03 23:39:25 +00:00
|
|
|
nsAutoString dumpID(crashReporter->ChildDumpID());
|
|
|
|
props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID);
|
|
|
|
}
|
2010-11-24 13:58:21 +00:00
|
|
|
#endif
|
|
|
|
}
|
2012-11-17 15:05:18 +00:00
|
|
|
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", nullptr);
|
2010-10-08 19:12:40 +00:00
|
|
|
}
|
2010-11-24 13:58:21 +00:00
|
|
|
|
|
|
|
MessageLoop::current()->
|
|
|
|
PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
|
|
|
|
mSubprocess = NULL;
|
2011-08-31 04:11:25 +00: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));
|
2010-02-02 01:53:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
void
|
|
|
|
ContentParent::NotifyTabDestroyed(PBrowserParent* aTab)
|
|
|
|
{
|
|
|
|
// There can be more than one PBrowser for a given app process
|
|
|
|
// because of popup windows. When the last one closes, shut
|
|
|
|
// us down.
|
2012-11-27 20:43:52 +00:00
|
|
|
if (ManagedPBrowserParent().Length() == 1) {
|
|
|
|
// Prevent this content process from being recycled, since
|
|
|
|
// it's dying.
|
|
|
|
MarkAsDead();
|
2012-07-17 18:27:27 +00:00
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
2012-08-16 01:46:03 +00:00
|
|
|
NewRunnableMethod(this, &ContentParent::ShutDownProcess));
|
2012-07-17 18:27:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 18:31:48 +00:00
|
|
|
TestShellParent*
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::CreateTestShell()
|
2009-08-12 18:31:48 +00:00
|
|
|
{
|
2009-09-09 22:00:14 +00:00
|
|
|
return static_cast<TestShellParent*>(SendPTestShellConstructor());
|
2009-08-12 18:31:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-11 08:34:08 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::DestroyTestShell(TestShellParent* aTestShell)
|
2009-11-11 08:34:08 +00:00
|
|
|
{
|
2009-12-03 08:16:14 +00:00
|
|
|
return PTestShellParent::Send__delete__(aTestShell);
|
2009-11-11 08:34:08 +00:00
|
|
|
}
|
|
|
|
|
2011-06-23 23:31:58 +00:00
|
|
|
TestShellParent*
|
|
|
|
ContentParent::GetTestShellSingleton()
|
|
|
|
{
|
|
|
|
if (!ManagedPTestShellParent().Length())
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-06-23 23:31:58 +00:00
|
|
|
return static_cast<TestShellParent*>(ManagedPTestShellParent()[0]);
|
|
|
|
}
|
|
|
|
|
2012-08-23 10:23:43 +00:00
|
|
|
ContentParent::ContentParent(const nsAString& aAppManifestURL,
|
2012-08-29 12:24:48 +00:00
|
|
|
bool aIsForBrowser,
|
|
|
|
ChildOSPrivileges aOSPrivileges)
|
|
|
|
: mSubprocess(nullptr)
|
|
|
|
, mOSPrivileges(aOSPrivileges)
|
2012-12-28 17:57:35 +00:00
|
|
|
, mChildID(CONTENT_PARENT_UNKNOWN_CHILD_ID)
|
2012-08-29 12:24:48 +00:00
|
|
|
, mGeolocationWatchID(-1)
|
2010-02-02 01:53:52 +00:00
|
|
|
, mRunToCompletionDepth(0)
|
2010-03-29 20:29:45 +00:00
|
|
|
, mShouldCallUnblockChild(false)
|
2012-09-05 00:36:16 +00:00
|
|
|
, mAppManifestURL(aAppManifestURL)
|
2010-04-12 00:24:45 +00:00
|
|
|
, mIsAlive(true)
|
2012-11-27 20:43:52 +00:00
|
|
|
, mIsDestroyed(false)
|
2011-08-02 19:35:42 +00:00
|
|
|
, mSendPermissionUpdates(false)
|
2012-09-05 00:36:16 +00:00
|
|
|
, mIsForBrowser(aIsForBrowser)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2012-04-10 19:57:20 +00:00
|
|
|
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
|
|
|
|
// PID along with the warning.
|
|
|
|
nsDebugImpl::SetMultiprocessMode("Parent");
|
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-08-29 12:24:48 +00:00
|
|
|
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content,
|
|
|
|
aOSPrivileges);
|
2012-07-17 23:59:44 +00:00
|
|
|
|
|
|
|
bool useOffMainThreadCompositing = !!CompositorParent::CompositorLoop();
|
|
|
|
if (useOffMainThreadCompositing) {
|
2012-08-07 23:29:32 +00:00
|
|
|
// We need the subprocess's ProcessHandle to create the
|
|
|
|
// PCompositor channel below. Block just until we have that.
|
|
|
|
mSubprocess->LaunchAndWaitForProcessHandle();
|
2012-07-17 23:59:44 +00:00
|
|
|
} else {
|
|
|
|
mSubprocess->AsyncLaunch();
|
|
|
|
}
|
2009-10-27 21:52:37 +00:00
|
|
|
Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
|
2010-03-11 05:33:00 +00:00
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
// 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.)
|
|
|
|
if (useOffMainThreadCompositing) {
|
|
|
|
DebugOnly<bool> opened = PCompositor::Open(this);
|
|
|
|
MOZ_ASSERT(opened);
|
2012-08-29 12:24:48 +00:00
|
|
|
|
|
|
|
if (Preferences::GetBool("layers.async-video.enabled",false)) {
|
|
|
|
opened = PImageBridge::Open(this);
|
|
|
|
MOZ_ASSERT(opened);
|
|
|
|
}
|
2012-07-17 23:59:45 +00:00
|
|
|
}
|
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryChrome* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
|
|
|
chromeRegistry->SendRegisteredChrome(this);
|
2011-08-02 19:57:48 +00:00
|
|
|
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
|
2011-10-04 20:31:00 +00:00
|
|
|
|
|
|
|
if (gAppData) {
|
|
|
|
nsCString version(gAppData->version);
|
|
|
|
nsCString buildID(gAppData->buildID);
|
|
|
|
|
|
|
|
//Sending all information to content process
|
2012-07-17 23:59:44 +00:00
|
|
|
unused << SendAppInfo(version, buildID);
|
2011-10-04 20:31:00 +00:00
|
|
|
}
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::~ContentParent()
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2010-11-24 13:58:21 +00:00
|
|
|
if (OtherProcess())
|
|
|
|
base::CloseProcessHandle(OtherProcess());
|
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-07-13 21:10:20 +00:00
|
|
|
|
|
|
|
// We should be removed from all these lists in ActorDestroy.
|
|
|
|
MOZ_ASSERT(!gPrivateContent || !gPrivateContent->Contains(this));
|
|
|
|
if (mAppManifestURL.IsEmpty()) {
|
|
|
|
MOZ_ASSERT(!gNonAppContentParents ||
|
|
|
|
!gNonAppContentParents->Contains(this));
|
|
|
|
} else {
|
2012-10-04 04:44:50 +00:00
|
|
|
// In general, we expect gAppContentParents->Get(mAppManifestURL) to be
|
|
|
|
// NULL. But it could be that we created another ContentParent for this
|
|
|
|
// app after we did this->ActorDestroy(), so the right check is that
|
|
|
|
// gAppContentParent->Get(mAppManifestURL) != this.
|
2012-07-13 21:10:20 +00:00
|
|
|
MOZ_ASSERT(!gAppContentParents ||
|
2012-10-04 04:44:50 +00:00
|
|
|
gAppContentParents->Get(mAppManifestURL) != this);
|
2012-07-13 21:10:20 +00:00
|
|
|
}
|
2010-04-12 00:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::IsAlive()
|
2010-04-12 00:24:45 +00:00
|
|
|
{
|
|
|
|
return mIsAlive;
|
2009-09-03 00:18:27 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 18:27:27 +00:00
|
|
|
bool
|
|
|
|
ContentParent::IsForApp()
|
|
|
|
{
|
|
|
|
return !mAppManifestURL.IsEmpty();
|
|
|
|
}
|
|
|
|
|
2010-05-26 00:13:47 +00:00
|
|
|
bool
|
2012-08-22 20:00:21 +00:00
|
|
|
ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefSetting>* aPrefs)
|
2010-05-26 00:13:47 +00:00
|
|
|
{
|
2012-08-22 20:00:21 +00:00
|
|
|
Preferences::GetPreferences(aPrefs);
|
2010-05-28 18:09:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-13 04:04:42 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvReadFontList(InfallibleTArray<FontListEntry>* retValue)
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
gfxAndroidPlatform::GetPlatform()->GetFontList(retValue);
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 18:07:38 +00:00
|
|
|
bool
|
2010-11-09 02:49:00 +00:00
|
|
|
ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
|
2010-07-15 14:04:25 +00:00
|
|
|
{
|
2010-10-09 18:07:38 +00:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
2011-08-30 17:45:09 +00:00
|
|
|
nsCOMPtr<nsIPermissionManager> permissionManagerIface =
|
|
|
|
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
|
|
|
|
nsPermissionManager* permissionManager =
|
|
|
|
static_cast<nsPermissionManager*>(permissionManagerIface.get());
|
2010-10-09 18:07:38 +00:00
|
|
|
NS_ABORT_IF_FALSE(permissionManager,
|
|
|
|
"We have no permissionManager in the Chrome process !");
|
|
|
|
|
2010-10-21 18:36:39 +00:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
2011-09-18 19:02:27 +00:00
|
|
|
DebugOnly<nsresult> rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
|
2010-10-09 18:07:38 +00:00
|
|
|
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Could not get enumerator!");
|
|
|
|
while(1) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool hasMore;
|
2010-10-09 18:07:38 +00:00
|
|
|
enumerator->HasMoreElements(&hasMore);
|
|
|
|
if (!hasMore)
|
|
|
|
break;
|
2010-10-21 18:36:39 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> supp;
|
|
|
|
enumerator->GetNext(getter_AddRefs(supp));
|
2010-10-09 18:07:38 +00:00
|
|
|
nsCOMPtr<nsIPermission> perm = do_QueryInterface(supp);
|
|
|
|
|
|
|
|
nsCString host;
|
|
|
|
perm->GetHost(host);
|
2012-08-23 18:38:01 +00:00
|
|
|
uint32_t appId;
|
|
|
|
perm->GetAppId(&appId);
|
|
|
|
bool isInBrowserElement;
|
|
|
|
perm->GetIsInBrowserElement(&isInBrowserElement);
|
2010-10-09 18:07:38 +00:00
|
|
|
nsCString type;
|
|
|
|
perm->GetType(type);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t capability;
|
2010-10-09 18:07:38 +00:00
|
|
|
perm->GetCapability(&capability);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t expireType;
|
2010-10-09 18:07:38 +00:00
|
|
|
perm->GetExpireType(&expireType);
|
2012-08-22 15:56:38 +00:00
|
|
|
int64_t expireTime;
|
2010-10-09 18:07:38 +00:00
|
|
|
perm->GetExpireTime(&expireTime);
|
|
|
|
|
2012-08-23 18:38:01 +00:00
|
|
|
aPermissions->AppendElement(IPC::Permission(host, appId,
|
|
|
|
isInBrowserElement, type,
|
|
|
|
capability, expireType,
|
|
|
|
expireTime));
|
2010-07-15 14:04:25 +00:00
|
|
|
}
|
2010-10-09 18:07:38 +00:00
|
|
|
|
|
|
|
// Ask for future changes
|
2011-08-02 19:35:42 +00:00
|
|
|
mSendPermissionUpdates = true;
|
2010-10-09 18:07:38 +00:00
|
|
|
#endif
|
|
|
|
|
2011-04-29 23:46:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-01 05:36:43 +00:00
|
|
|
bool
|
2012-08-15 03:37:44 +00:00
|
|
|
ContentParent::RecvSetClipboardText(const nsString& text,
|
|
|
|
const bool& isPrivateData,
|
2012-08-22 15:56:38 +00:00
|
|
|
const int32_t& whichClipboard)
|
2011-03-01 05:36:43 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsString> dataWrapper =
|
|
|
|
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
rv = dataWrapper->SetData(text);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITransferable> trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
2012-07-30 14:20:58 +00:00
|
|
|
trans->Init(nullptr);
|
2011-03-01 05:36:43 +00:00
|
|
|
|
|
|
|
// If our data flavor has already been added, this will fail. But we don't care
|
|
|
|
trans->AddDataFlavor(kUnicodeMime);
|
2012-08-15 03:37:44 +00:00
|
|
|
trans->SetIsPrivateData(isPrivateData);
|
2011-03-01 05:36:43 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> nsisupportsDataWrapper =
|
|
|
|
do_QueryInterface(dataWrapper);
|
|
|
|
|
|
|
|
rv = trans->SetTransferData(kUnicodeMime, nsisupportsDataWrapper,
|
|
|
|
text.Length() * sizeof(PRUnichar));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
clipboard->SetData(trans, NULL, whichClipboard);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
ContentParent::RecvGetClipboardText(const int32_t& whichClipboard, nsString* text)
|
2011-03-01 05:36:43 +00: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 14:20:58 +00:00
|
|
|
trans->Init(nullptr);
|
2011-03-01 05:36:43 +00:00
|
|
|
|
|
|
|
clipboard->GetData(trans, whichClipboard);
|
|
|
|
nsCOMPtr<nsISupports> tmp;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t len;
|
2011-08-09 19:38:26 +00:00
|
|
|
rv = trans->GetTransferData(kUnicodeMime, getter_AddRefs(tmp), &len);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return false;
|
2011-03-01 05:36:43 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupportsString> supportsString = do_QueryInterface(tmp);
|
|
|
|
// No support for non-text data
|
2011-08-09 19:38:26 +00:00
|
|
|
if (!supportsString)
|
|
|
|
return false;
|
2011-03-01 05:36:43 +00:00
|
|
|
supportsString->GetData(*text);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvEmptyClipboard()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
clipboard->EmptyClipboard(nsIClipboard::kGlobalClipboard);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-09-29 06:19:26 +00:00
|
|
|
ContentParent::RecvClipboardHasText(bool* hasText)
|
2011-03-01 05:36:43 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, true);
|
|
|
|
|
|
|
|
clipboard->HasDataMatchingFlavors(sClipboardTextFlavors, 1,
|
|
|
|
nsIClipboard::kGlobalClipboard, hasText);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-30 18:04:41 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
ContentParent::RecvGetSystemColors(const uint32_t& colorsCount, InfallibleTArray<uint32_t>* colors)
|
2011-03-30 18:04:41 +00:00
|
|
|
{
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
|
|
|
if (AndroidBridge::Bridge() == nullptr) {
|
2011-07-28 00:34:47 +00:00
|
|
|
// Do not fail - the colors won't be right, but it's not critical
|
|
|
|
return true;
|
|
|
|
}
|
2011-03-30 18:04:41 +00: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-13 21:02:13 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
ContentParent::RecvGetIconForExtension(const nsCString& aFileExt, const uint32_t& aIconSize, InfallibleTArray<uint8_t>* bits)
|
2011-06-13 21:02:13 +00:00
|
|
|
{
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
|
|
|
if (AndroidBridge::Bridge() == nullptr) {
|
2011-07-28 00:34:47 +00:00
|
|
|
// Do not fail - just no icon will be shown
|
|
|
|
return true;
|
|
|
|
}
|
2011-06-13 21:02:13 +00:00
|
|
|
|
|
|
|
bits->AppendElements(aIconSize * aIconSize * 4);
|
|
|
|
|
|
|
|
AndroidBridge::Bridge()->GetIconForExtension(aFileExt, aIconSize, bits->Elements());
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-27 01:14:52 +00:00
|
|
|
bool
|
2011-09-29 06:19:26 +00:00
|
|
|
ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
|
2011-07-27 01:14:52 +00:00
|
|
|
{
|
|
|
|
// default behavior is to show the last password character
|
2011-10-17 14:59:28 +00:00
|
|
|
*showPassword = true;
|
2011-11-11 00:17:46 +00:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
|
|
|
if (AndroidBridge::Bridge() != nullptr)
|
2011-07-27 01:14:52 +00:00
|
|
|
*showPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-09 04:46:19 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvFirstIdle()
|
|
|
|
{
|
|
|
|
// 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
|
|
|
|
// child process and slowing it down.
|
|
|
|
ScheduleDelayedPreallocateAppProcess();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-06 03:01:58 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAudioChannelGetMuted(const AudioChannelType& aType,
|
|
|
|
const bool& aMozHidden,
|
|
|
|
bool* aValue)
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
*aValue = false;
|
|
|
|
if (service) {
|
|
|
|
*aValue = service->GetMuted(aType, aMozHidden);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvAudioChannelRegisterType(const AudioChannelType& aType)
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
if (service) {
|
2012-12-28 17:57:35 +00:00
|
|
|
service->RegisterType(aType, mChildID);
|
2012-12-06 03:01:58 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvAudioChannelUnregisterType(const AudioChannelType& aType)
|
|
|
|
{
|
|
|
|
nsRefPtr<AudioChannelService> service =
|
|
|
|
AudioChannelService::GetAudioChannelService();
|
|
|
|
if (service) {
|
2012-12-28 17:57:35 +00:00
|
|
|
service->UnregisterType(aType, mChildID);
|
2012-12-06 03:01:58 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-21 06:36:17 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS3(ContentParent,
|
2010-02-02 01:53:52 +00:00
|
|
|
nsIObserver,
|
2010-09-21 04:16:37 +00:00
|
|
|
nsIThreadObserver,
|
2012-03-21 06:36:17 +00:00
|
|
|
nsIDOMGeoPositionCallback)
|
2009-09-03 00:18:27 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
2009-09-03 00:18:27 +00:00
|
|
|
{
|
|
|
|
if (!strcmp(aTopic, "xpcom-shutdown") && mSubprocess) {
|
2012-11-27 20:43:52 +00:00
|
|
|
ShutDownProcess();
|
2010-11-24 13:58:21 +00:00
|
|
|
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
|
2009-09-03 00:18:27 +00:00
|
|
|
}
|
2010-05-11 12:44:12 +00:00
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
if (!mIsAlive || !mSubprocess)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-12-11 22:36:08 +00:00
|
|
|
// listening for memory pressure event
|
2012-11-08 01:07:57 +00:00
|
|
|
if (!strcmp(aTopic, "memory-pressure") &&
|
|
|
|
!NS_LITERAL_STRING("low-memory-no-forward").Equals(aData)) {
|
2010-12-26 20:03:52 +00:00
|
|
|
unused << SendFlushMemory(nsDependentString(aData));
|
2010-12-11 22:36:08 +00:00
|
|
|
}
|
2010-05-26 00:13:47 +00:00
|
|
|
// listening for remotePrefs...
|
2010-12-11 22:36:08 +00:00
|
|
|
else if (!strcmp(aTopic, "nsPref:changed")) {
|
2010-05-26 00:13:47 +00:00
|
|
|
// We know prefs are ASCII here.
|
|
|
|
NS_LossyConvertUTF16toASCII strData(aData);
|
2010-10-19 20:35:08 +00:00
|
|
|
|
2012-08-22 20:00:21 +00:00
|
|
|
PrefSetting pref(strData, null_t(), null_t());
|
|
|
|
Preferences::GetPreference(&pref);
|
|
|
|
if (!SendPreferenceUpdate(pref)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2011-01-06 04:54:47 +00:00
|
|
|
}
|
2010-05-26 00:13:47 +00:00
|
|
|
}
|
2010-07-19 18:33:33 +00:00
|
|
|
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
|
2010-05-11 12:44:12 +00:00
|
|
|
NS_ConvertUTF16toUTF8 dataStr(aData);
|
|
|
|
const char *offline = dataStr.get();
|
2010-07-19 18:33:33 +00:00
|
|
|
if (!SendSetOffline(!strcmp(offline, "true") ? true : false))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2010-05-11 12:44:12 +00:00
|
|
|
}
|
2010-09-15 16:44:57 +00:00
|
|
|
// listening for alert notifications
|
|
|
|
else if (!strcmp(aTopic, "alertfinished") ||
|
|
|
|
!strcmp(aTopic, "alertclickcallback") ) {
|
|
|
|
if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
|
|
|
|
nsDependentString(aData)))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2011-02-16 18:43:23 +00:00
|
|
|
else if (!strcmp(aTopic, "child-memory-reporter-request")) {
|
2011-09-18 19:02:27 +00:00
|
|
|
unused << SendPMemoryReportRequestConstructor();
|
2011-09-13 17:53:51 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "child-gc-request")){
|
2012-07-17 23:59:44 +00:00
|
|
|
unused << SendGarbageCollect();
|
2011-09-13 17:53:51 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(aTopic, "child-cc-request")){
|
2012-07-17 23:59:44 +00:00
|
|
|
unused << SendCycleCollect();
|
2011-02-16 18:43:23 +00:00
|
|
|
}
|
2012-04-20 00:13:20 +00:00
|
|
|
else if (!strcmp(aTopic, "last-pb-context-exited")) {
|
|
|
|
unused << SendLastPrivateDocShellDestroyed();
|
|
|
|
}
|
2012-08-18 02:43:00 +00:00
|
|
|
else if (!strcmp(aTopic, "file-watcher-update")) {
|
|
|
|
nsCString creason;
|
|
|
|
CopyUTF16toUTF8(aData, creason);
|
2012-08-30 22:17:37 +00:00
|
|
|
DeviceStorageFile* file = static_cast<DeviceStorageFile*>(aSubject);
|
2012-08-18 02:43:00 +00:00
|
|
|
|
|
|
|
nsString path;
|
2012-08-30 22:17:37 +00:00
|
|
|
file->mFile->GetPath(path);
|
|
|
|
|
|
|
|
unused << SendFilePathUpdate(file->mStorageType, path, creason);
|
2012-08-18 02:43:00 +00:00
|
|
|
}
|
2012-08-03 23:48:58 +00: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 15:56:38 +00:00
|
|
|
int32_t state;
|
2012-08-03 23:48:58 +00:00
|
|
|
|
|
|
|
vol->GetName(volName);
|
|
|
|
vol->GetMountPoint(mountPoint);
|
|
|
|
vol->GetState(&state);
|
|
|
|
|
|
|
|
unused << SendFileSystemUpdate(volName, mountPoint, state);
|
|
|
|
}
|
|
|
|
#endif
|
2011-07-21 04:37:32 +00: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")) {
|
2011-09-18 19:02:27 +00:00
|
|
|
unused << SendActivateA11y();
|
2011-07-21 04:37:32 +00:00
|
|
|
}
|
|
|
|
#endif
|
2011-02-16 18:43:23 +00:00
|
|
|
|
2009-09-03 00:18:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
PCompositorParent*
|
2012-08-02 06:02:29 +00:00
|
|
|
ContentParent::AllocPCompositor(mozilla::ipc::Transport* aTransport,
|
2012-07-17 23:59:45 +00:00
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return CompositorParent::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2012-08-29 12:24:48 +00:00
|
|
|
PImageBridgeParent*
|
|
|
|
ContentParent::AllocPImageBridge(mozilla::ipc::Transport* aTransport,
|
|
|
|
base::ProcessId aOtherProcess)
|
|
|
|
{
|
|
|
|
return ImageBridgeParent::Create(aTransport, aOtherProcess);
|
|
|
|
}
|
|
|
|
|
2012-09-05 00:36:16 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvGetProcessAttributes(uint64_t* aId, bool* aStartBackground,
|
|
|
|
bool* aIsForApp, bool* aIsForBrowser)
|
|
|
|
{
|
2012-11-17 15:05:18 +00:00
|
|
|
*aId = mChildID = gContentChildID++;
|
2012-09-05 00:36:16 +00:00
|
|
|
*aStartBackground =
|
|
|
|
(mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL);
|
|
|
|
*aIsForApp = IsForApp();
|
|
|
|
*aIsForBrowser = mIsForBrowser;
|
2012-11-08 21:09:39 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIOService> io(do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "No IO service?");
|
|
|
|
DebugOnly<nsresult> rv = io->GetOffline(aIsOffline);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed getting offline?");
|
|
|
|
|
2012-09-05 00:36:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:33:33 +00:00
|
|
|
PBrowserParent*
|
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 18:32:37 +00:00
|
|
|
ContentParent::AllocPBrowser(const IPCTabContext& aContext,
|
|
|
|
const uint32_t &aChromeFlags)
|
2009-08-12 16:18:08 +00: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 18:32:37 +00:00
|
|
|
unused << aChromeFlags;
|
|
|
|
|
2012-11-27 20:43:52 +00:00
|
|
|
const IPCTabAppBrowserContext& appBrowser = aContext.appBrowserContext();
|
|
|
|
|
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 18:32:37 +00:00
|
|
|
// We don't trust the IPCTabContext we receive from the child, so we'll bail
|
|
|
|
// if we receive an IPCTabContext that's not a PopupIPCTabContext.
|
|
|
|
// (PopupIPCTabContext lets the child process prove that it has access to
|
|
|
|
// the app it's trying to open.)
|
2012-11-27 20:43:52 +00:00
|
|
|
if (appBrowser.type() != IPCTabAppBrowserContext::TPopupIPCTabContext) {
|
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 18:32:37 +00:00
|
|
|
NS_ERROR("Unexpected IPCTabContext type. Aborting AllocPBrowser.");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-11-27 20:43:52 +00:00
|
|
|
const PopupIPCTabContext& popupContext = appBrowser.get_PopupIPCTabContext();
|
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 18:32:37 +00:00
|
|
|
TabParent* opener = static_cast<TabParent*>(popupContext.openerParent());
|
|
|
|
if (!opener) {
|
|
|
|
NS_ERROR("Got null opener from child; aborting AllocPBrowser.");
|
2012-08-09 02:58:06 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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 18:32:37 +00:00
|
|
|
// Popup windows of isBrowser frames must be isBrowser if the parent
|
|
|
|
// isBrowser. Allocating a !isBrowser frame with same app ID would allow
|
|
|
|
// the content to access data it's not supposed to.
|
|
|
|
if (!popupContext.isBrowserElement() && opener->IsBrowserElement()) {
|
|
|
|
NS_ERROR("Child trying to escalate privileges! Aborting AllocPBrowser.");
|
2012-08-09 02:58:06 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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 18:32:37 +00:00
|
|
|
TabParent* parent = new TabParent(TabContext(aContext));
|
|
|
|
|
2012-08-09 02:58:06 +00:00
|
|
|
// We release this ref in DeallocPBrowser()
|
2010-03-26 18:39:39 +00:00
|
|
|
NS_ADDREF(parent);
|
2012-08-09 02:58:06 +00:00
|
|
|
return parent;
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::DeallocPBrowser(PBrowserParent* frame)
|
2009-08-12 16:18:08 +00:00
|
|
|
{
|
2012-08-09 02:58:06 +00:00
|
|
|
TabParent* parent = static_cast<TabParent*>(frame);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
return true;
|
2009-08-12 16:18:08 +00:00
|
|
|
}
|
|
|
|
|
2012-06-19 23:14:39 +00:00
|
|
|
PDeviceStorageRequestParent*
|
|
|
|
ContentParent::AllocPDeviceStorageRequest(const DeviceStorageParams& aParams)
|
|
|
|
{
|
2012-11-30 05:41:40 +00:00
|
|
|
nsRefPtr<DeviceStorageRequestParent> result = new DeviceStorageRequestParent(aParams);
|
|
|
|
if (!result->EnsureRequiredPermissions(this)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
result->Dispatch();
|
|
|
|
return result.forget().get();
|
2012-06-19 23:14:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPDeviceStorageRequest(PDeviceStorageRequestParent* doomed)
|
|
|
|
{
|
2012-08-09 22:41:18 +00:00
|
|
|
DeviceStorageRequestParent *parent = static_cast<DeviceStorageRequestParent*>(doomed);
|
|
|
|
NS_RELEASE(parent);
|
2012-06-19 23:14:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
PBlobParent*
|
|
|
|
ContentParent::AllocPBlob(const BlobConstructorParams& aParams)
|
|
|
|
{
|
|
|
|
return BlobParent::Create(aParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPBlob(PBlobParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
BlobParent*
|
|
|
|
ContentParent::GetOrCreateActorForBlob(nsIDOMBlob* aBlob)
|
|
|
|
{
|
2012-08-03 06:25:30 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2012-08-02 06:02:29 +00:00
|
|
|
NS_ASSERTION(aBlob, "Null pointer!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRemoteBlob> remoteBlob = do_QueryInterface(aBlob);
|
|
|
|
if (remoteBlob) {
|
|
|
|
BlobParent* actor =
|
|
|
|
static_cast<BlobParent*>(
|
|
|
|
static_cast<PBlobParent*>(remoteBlob->GetPBlob()));
|
|
|
|
NS_ASSERTION(actor, "Null actor?!");
|
|
|
|
|
2012-10-25 18:45:15 +00:00
|
|
|
if (static_cast<ContentParent*>(actor->Manager()) == this) {
|
2012-10-25 18:45:14 +00:00
|
|
|
return actor;
|
|
|
|
}
|
2012-08-02 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
// XXX This is only safe so long as all blob implementations in our tree
|
|
|
|
// inherit nsDOMFileBase. If that ever changes then this will need to grow
|
|
|
|
// a real interface or something.
|
|
|
|
const nsDOMFileBase* blob = static_cast<nsDOMFileBase*>(aBlob);
|
|
|
|
|
2012-08-02 06:02:29 +00:00
|
|
|
BlobConstructorParams params;
|
|
|
|
|
2012-10-29 16:54:35 +00:00
|
|
|
if (blob->IsSizeUnknown() || blob->IsDateUnknown()) {
|
2012-10-18 18:29:32 +00:00
|
|
|
// We don't want to call GetSize or GetLastModifiedDate
|
|
|
|
// yet since that may stat a file on the main thread
|
|
|
|
// here. Instead we'll learn the size lazily from the
|
|
|
|
// other process.
|
2012-08-03 06:25:30 +00:00
|
|
|
params = MysteryBlobConstructorParams();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsString contentType;
|
|
|
|
nsresult rv = aBlob->GetType(contentType);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t length;
|
2012-08-03 06:25:30 +00:00
|
|
|
rv = aBlob->GetSize(&length);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
nsCOMPtr<nsIDOMFile> file = do_QueryInterface(aBlob);
|
|
|
|
if (file) {
|
|
|
|
FileBlobConstructorParams fileParams;
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-10-18 18:29:32 +00:00
|
|
|
rv = file->GetMozLastModifiedDate(&fileParams.modDate());
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
rv = file->GetName(fileParams.name());
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
fileParams.contentType() = contentType;
|
|
|
|
fileParams.length() = length;
|
2012-08-02 06:02:29 +00:00
|
|
|
|
2012-08-03 06:25:30 +00:00
|
|
|
params = fileParams;
|
|
|
|
} else {
|
|
|
|
NormalBlobConstructorParams blobParams;
|
|
|
|
blobParams.contentType() = contentType;
|
|
|
|
blobParams.length() = length;
|
|
|
|
params = blobParams;
|
|
|
|
}
|
2012-08-02 06:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlobParent* actor = BlobParent::Create(aBlob);
|
|
|
|
NS_ENSURE_TRUE(actor, nullptr);
|
|
|
|
|
|
|
|
if (!SendPBlobConstructor(actor, params)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return actor;
|
|
|
|
}
|
|
|
|
|
2012-09-05 22:18:48 +00:00
|
|
|
void
|
|
|
|
ContentParent::KillHard()
|
|
|
|
{
|
|
|
|
// This ensures the process is eventually killed, but doesn't
|
|
|
|
// immediately KILLITWITHFIRE because we want to get a minidump if
|
|
|
|
// possible. After a timeout though, the process is forceably
|
|
|
|
// killed.
|
|
|
|
if (!KillProcess(OtherProcess(), 1, false)) {
|
|
|
|
NS_WARNING("failed to kill subprocess!");
|
|
|
|
}
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(&ProcessWatcher::EnsureProcessTerminated,
|
|
|
|
OtherProcess(), /*force=*/true));
|
|
|
|
}
|
|
|
|
|
2010-11-24 14:15:03 +00:00
|
|
|
PCrashReporterParent*
|
2011-06-08 19:56:31 +00:00
|
|
|
ContentParent::AllocPCrashReporter(const NativeThreadId& tid,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType)
|
2010-11-24 14:15:03 +00:00
|
|
|
{
|
2011-06-08 19:56:31 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2011-06-30 03:44:28 +00:00
|
|
|
return new CrashReporterParent();
|
2011-06-08 19:56:31 +00:00
|
|
|
#else
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-06-08 19:56:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPCrashReporterConstructor(PCrashReporterParent* actor,
|
|
|
|
const NativeThreadId& tid,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& processType)
|
2011-06-08 19:56:31 +00:00
|
|
|
{
|
|
|
|
static_cast<CrashReporterParent*>(actor)->SetChildData(tid, processType);
|
|
|
|
return true;
|
2010-11-24 14:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPCrashReporter(PCrashReporterParent* crashreporter)
|
|
|
|
{
|
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-05 22:15:45 +00:00
|
|
|
PHalParent*
|
|
|
|
ContentParent::AllocPHal()
|
|
|
|
{
|
|
|
|
return CreateHalParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPHal(PHalParent* aHal)
|
|
|
|
{
|
|
|
|
delete aHal;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-14 11:24:20 +00:00
|
|
|
PIndexedDBParent*
|
|
|
|
ContentParent::AllocPIndexedDB()
|
|
|
|
{
|
2012-10-25 17:12:14 +00:00
|
|
|
return new IndexedDBParent(this);
|
2012-07-14 11:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPIndexedDB(PIndexedDBParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPIndexedDBConstructor(PIndexedDBParent* aActor)
|
|
|
|
{
|
|
|
|
nsRefPtr<IndexedDatabaseManager> mgr = IndexedDatabaseManager::GetOrCreate();
|
|
|
|
NS_ENSURE_TRUE(mgr, false);
|
|
|
|
|
|
|
|
if (!IndexedDatabaseManager::IsMainProcess()) {
|
|
|
|
NS_RUNTIMEABORT("Not supported yet!");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<IDBFactory> factory;
|
2012-08-02 06:02:29 +00:00
|
|
|
nsresult rv = IDBFactory::Create(this, getter_AddRefs(factory));
|
2012-07-14 11:24:20 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
|
|
|
|
|
|
|
NS_ASSERTION(factory, "This should never be null!");
|
|
|
|
|
|
|
|
IndexedDBParent* actor = static_cast<IndexedDBParent*>(aActor);
|
|
|
|
actor->mFactory = factory;
|
|
|
|
actor->mASCIIOrigin = factory->GetASCIIOrigin();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-02-16 18:43:23 +00:00
|
|
|
PMemoryReportRequestParent*
|
|
|
|
ContentParent::AllocPMemoryReportRequest()
|
|
|
|
{
|
|
|
|
MemoryReportRequestParent* parent = new MemoryReportRequestParent();
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPMemoryReportRequest(PMemoryReportRequestParent* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentParent::SetChildMemoryReporters(const InfallibleTArray<MemoryReport>& report)
|
|
|
|
{
|
2011-06-16 18:34:09 +00:00
|
|
|
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
|
|
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < mMemoryReporters.Count(); i++)
|
2011-02-16 18:43:23 +00:00
|
|
|
mgr->UnregisterReporter(mMemoryReporters[i]);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < report.Length(); i++) {
|
2011-06-06 01:22:45 +00:00
|
|
|
nsCString process = report[i].process();
|
|
|
|
nsCString path = report[i].path();
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t kind = report[i].kind();
|
|
|
|
int32_t units = report[i].units();
|
|
|
|
int64_t amount = report[i].amount();
|
2011-06-06 01:22:45 +00:00
|
|
|
nsCString desc = report[i].desc();
|
2011-02-16 18:43:23 +00:00
|
|
|
|
2011-06-16 18:34:09 +00:00
|
|
|
nsRefPtr<nsMemoryReporter> r =
|
|
|
|
new nsMemoryReporter(process, path, kind, units, amount, desc);
|
|
|
|
|
|
|
|
mMemoryReporters.AppendObject(r);
|
|
|
|
mgr->RegisterReporter(r);
|
2011-02-16 18:43:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> obs =
|
|
|
|
do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
if (obs)
|
2012-07-30 14:20:58 +00:00
|
|
|
obs->NotifyObservers(nullptr, "child-memory-reporter-update", nullptr);
|
2011-02-16 18:43:23 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
PTestShellParent*
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::AllocPTestShell()
|
2009-08-12 18:31:48 +00:00
|
|
|
{
|
|
|
|
return new TestShellParent();
|
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::DeallocPTestShell(PTestShellParent* shell)
|
2009-08-12 18:31:48 +00:00
|
|
|
{
|
|
|
|
delete shell;
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-08-12 18:31:48 +00:00
|
|
|
}
|
2010-11-17 04:14:19 +00:00
|
|
|
|
2009-08-18 19:05:15 +00:00
|
|
|
PNeckoParent*
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::AllocPNecko()
|
2009-08-18 19:05:15 +00:00
|
|
|
{
|
|
|
|
return new NeckoParent();
|
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::DeallocPNecko(PNeckoParent* necko)
|
2009-08-18 19:05:15 +00:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-08-18 19:05:15 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
PExternalHelperAppParent*
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentParent::AllocPExternalHelperApp(const OptionalURIParams& uri,
|
2010-09-15 22:55:08 +00:00
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
2012-08-22 15:56:38 +00:00
|
|
|
const int64_t& aContentLength,
|
2012-08-23 19:33:46 +00:00
|
|
|
const OptionalURIParams& aReferrer)
|
2010-09-15 22:55:08 +00:00
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
|
|
|
|
parent->AddRef();
|
2010-11-21 19:21:59 +00:00
|
|
|
parent->Init(this, aMimeContentType, aContentDisposition, aForceSave, aReferrer);
|
2010-09-15 22:55:08 +00:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
|
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = static_cast<ExternalHelperAppParent *>(aService);
|
|
|
|
parent->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-20 22:40:53 +00:00
|
|
|
PSmsParent*
|
|
|
|
ContentParent::AllocPSms()
|
|
|
|
{
|
2012-09-25 18:52:30 +00:00
|
|
|
if (!AssertAppProcessPermission(this, "sms")) {
|
2012-08-16 19:34:53 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-11-06 21:29:30 +00:00
|
|
|
|
|
|
|
SmsParent* parent = new SmsParent();
|
|
|
|
parent->AddRef();
|
|
|
|
return parent;
|
2011-11-20 22:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPSms(PSmsParent* aSms)
|
|
|
|
{
|
2012-11-06 21:29:30 +00:00
|
|
|
static_cast<SmsParent*>(aSms)->Release();
|
2011-11-20 22:40:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-19 01:15:23 +00:00
|
|
|
PStorageParent*
|
|
|
|
ContentParent::AllocPStorage(const StorageConstructData& aData)
|
|
|
|
{
|
|
|
|
return new StorageParent(aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPStorage(PStorageParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-13 16:37:14 +00:00
|
|
|
PBluetoothParent*
|
|
|
|
ContentParent::AllocPBluetooth()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
2012-09-25 18:52:30 +00:00
|
|
|
if (!AssertAppProcessPermission(this, "bluetooth")) {
|
2012-09-13 16:37:14 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return new mozilla::dom::bluetooth::BluetoothParent();
|
|
|
|
#else
|
|
|
|
MOZ_NOT_REACHED("No support for bluetooth on this platform!");
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPBluetooth(PBluetoothParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
MOZ_NOT_REACHED("No support for bluetooth on this platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvPBluetoothConstructor(PBluetoothParent* aActor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_B2G_BT
|
|
|
|
nsRefPtr<BluetoothService> btService = BluetoothService::Get();
|
|
|
|
NS_ENSURE_TRUE(btService, false);
|
|
|
|
|
|
|
|
return static_cast<BluetoothParent*>(aActor)->InitWithService(btService);
|
|
|
|
#else
|
|
|
|
MOZ_NOT_REACHED("No support for bluetooth on this platform!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-03-29 20:29:45 +00:00
|
|
|
void
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::ReportChildAlreadyBlocked()
|
2010-03-29 20:29:45 +00:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-02 01:53:52 +00:00
|
|
|
bool
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::RequestRunToCompletion()
|
2010-02-02 01:53:52 +00:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth &&
|
|
|
|
BlockChild()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
2010-03-29 20:29:45 +00:00
|
|
|
mShouldCallUnblockChild = true;
|
2010-02-02 01:53:52 +00:00
|
|
|
}
|
|
|
|
return !!mRunToCompletionDepth;
|
|
|
|
}
|
|
|
|
|
2010-07-02 15:50:41 +00:00
|
|
|
bool
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentParent::RecvStartVisitedQuery(const URIParams& aURI)
|
2010-07-02 15:50:41 +00:00
|
|
|
{
|
2012-08-23 19:33:46 +00:00
|
|
|
nsCOMPtr<nsIURI> newURI = DeserializeURI(aURI);
|
|
|
|
if (!newURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-05 17:07:46 +00:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 19:33:46 +00:00
|
|
|
history->RegisterVisitedCallback(newURI, nullptr);
|
2010-08-05 17:07:46 +00:00
|
|
|
}
|
2010-07-02 15:50:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 15:50:24 +00:00
|
|
|
|
|
|
|
bool
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentParent::RecvVisitURI(const URIParams& uri,
|
|
|
|
const OptionalURIParams& referrer,
|
|
|
|
const uint32_t& flags)
|
2010-07-02 15:50:24 +00:00
|
|
|
{
|
2012-08-23 19:33:46 +00:00
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> ourReferrer = DeserializeURI(referrer);
|
2010-08-05 17:07:46 +00:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 19:33:46 +00:00
|
|
|
history->VisitURI(ourURI, ourReferrer, flags);
|
2010-08-05 17:07:46 +00:00
|
|
|
}
|
2010-07-02 15:50:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 15:53:42 +00:00
|
|
|
|
|
|
|
bool
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentParent::RecvSetURITitle(const URIParams& uri,
|
|
|
|
const nsString& title)
|
2010-07-02 15:53:42 +00:00
|
|
|
{
|
2012-08-23 19:33:46 +00:00
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-08-05 17:07:46 +00:00
|
|
|
nsCOMPtr<IHistory> history = services::GetHistoryService();
|
|
|
|
if (history) {
|
2012-08-23 19:33:46 +00:00
|
|
|
history->SetURITitle(ourURI, title);
|
2010-08-05 17:07:46 +00:00
|
|
|
}
|
2010-07-02 15:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-20 15:19:24 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
ContentParent::RecvShowFilePicker(const int16_t& mode,
|
|
|
|
const int16_t& selectedType,
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool& addToRecentDocs,
|
2010-10-20 15:19:24 +00:00
|
|
|
const nsString& title,
|
|
|
|
const nsString& defaultFile,
|
|
|
|
const nsString& defaultExtension,
|
2010-11-09 02:49:00 +00:00
|
|
|
const InfallibleTArray<nsString>& filters,
|
|
|
|
const InfallibleTArray<nsString>& filterNames,
|
|
|
|
InfallibleTArray<nsString>* files,
|
2012-08-22 15:56:38 +00:00
|
|
|
int16_t* retValue,
|
2010-10-20 15:19:24 +00:00
|
|
|
nsresult* result)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1");
|
|
|
|
if (!filePicker) {
|
|
|
|
*result = NS_ERROR_NOT_AVAILABLE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// as the parent given to the content process would be meaningless in this
|
|
|
|
// process, always use active window as the parent
|
|
|
|
nsCOMPtr<nsIWindowWatcher> ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID);
|
|
|
|
nsCOMPtr<nsIDOMWindow> window;
|
|
|
|
ww->GetActiveWindow(getter_AddRefs(window));
|
|
|
|
|
|
|
|
// initialize the "real" picker with all data given
|
|
|
|
*result = filePicker->Init(window, title, mode);
|
|
|
|
if (NS_FAILED(*result))
|
|
|
|
return true;
|
2011-05-24 12:28:19 +00:00
|
|
|
|
|
|
|
filePicker->SetAddToRecentDocs(addToRecentDocs);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = filters.Length();
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
2010-10-20 15:19:24 +00:00
|
|
|
filePicker->AppendFilter(filterNames[i], filters[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
filePicker->SetDefaultString(defaultFile);
|
|
|
|
filePicker->SetDefaultExtension(defaultExtension);
|
|
|
|
filePicker->SetFilterIndex(selectedType);
|
|
|
|
|
|
|
|
// and finally open the dialog
|
|
|
|
*result = filePicker->Show(retValue);
|
|
|
|
if (NS_FAILED(*result))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (mode == nsIFilePicker::modeOpenMultiple) {
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> fileIter;
|
|
|
|
*result = filePicker->GetFiles(getter_AddRefs(fileIter));
|
|
|
|
|
2012-06-06 02:08:30 +00:00
|
|
|
nsCOMPtr<nsIFile> singleFile;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool loop = true;
|
2010-10-20 15:19:24 +00:00
|
|
|
while (NS_SUCCEEDED(fileIter->HasMoreElements(&loop)) && loop) {
|
|
|
|
fileIter->GetNext(getter_AddRefs(singleFile));
|
|
|
|
if (singleFile) {
|
|
|
|
nsAutoString filePath;
|
|
|
|
singleFile->GetPath(filePath);
|
|
|
|
files->AppendElement(filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-06-06 02:08:30 +00:00
|
|
|
nsCOMPtr<nsIFile> file;
|
2010-10-20 15:19:24 +00:00
|
|
|
filePicker->GetFile(getter_AddRefs(file));
|
|
|
|
|
|
|
|
// even with NS_OK file can be null if nothing was selected
|
|
|
|
if (file) {
|
|
|
|
nsAutoString filePath;
|
|
|
|
file->GetPath(filePath);
|
|
|
|
files->AppendElement(filePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-10 17:14:45 +00:00
|
|
|
bool
|
2012-08-23 19:33:46 +00:00
|
|
|
ContentParent::RecvLoadURIExternal(const URIParams& uri)
|
2010-08-10 17:14:45 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIExternalProtocolService> extProtService(do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
|
2012-08-23 19:33:46 +00:00
|
|
|
if (!extProtService) {
|
2010-08-10 17:14:45 +00:00
|
|
|
return true;
|
2012-08-23 19:33:46 +00:00
|
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> ourURI = DeserializeURI(uri);
|
|
|
|
if (!ourURI) {
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
extProtService->LoadURI(ourURI, nullptr);
|
2010-08-10 17:14:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-02 01:53:52 +00:00
|
|
|
/* void onDispatchedEvent (in nsIThreadInternal thread); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)
|
2012-01-18 10:23:28 +00:00
|
|
|
{
|
2011-12-02 12:33:05 +00:00
|
|
|
NS_NOTREACHED("OnDispatchedEvent unimplemented");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2010-02-02 01:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* void onProcessNextEvent (in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::OnProcessNextEvent(nsIThreadInternal *thread,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mayWait,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t recursionDepth)
|
2010-02-02 01:53:52 +00:00
|
|
|
{
|
|
|
|
if (mRunToCompletionDepth)
|
|
|
|
++mRunToCompletionDepth;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void afterProcessNextEvent (in nsIThreadInternal thread, in unsigned long recursionDepth); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 18:33:33 +00:00
|
|
|
ContentParent::AfterProcessNextEvent(nsIThreadInternal *thread,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t recursionDepth)
|
2010-02-02 01:53:52 +00:00
|
|
|
{
|
|
|
|
if (mRunToCompletionDepth &&
|
|
|
|
!--mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("... ran to completion.\n");
|
|
|
|
#endif
|
2010-03-29 20:29:45 +00:00
|
|
|
if (mShouldCallUnblockChild) {
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
UnblockChild();
|
|
|
|
}
|
2010-02-02 01:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-08-05 18:11:32 +00:00
|
|
|
|
2010-09-15 16:44:57 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsString& aText, const bool& aTextClickable,
|
2010-09-15 16:44:57 +00:00
|
|
|
const nsString& aCookie, const nsString& aName)
|
|
|
|
{
|
2012-12-20 19:06:42 +00:00
|
|
|
if (!AssertAppProcessPermission(this, "desktop-notification")) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-15 16:44:57 +00:00
|
|
|
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID));
|
|
|
|
if (sysAlerts) {
|
|
|
|
sysAlerts->ShowAlertNotification(aImageUrl, aTitle, aText, aTextClickable,
|
|
|
|
aCookie, this, aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-31 18:58:35 +00:00
|
|
|
|
|
|
|
bool
|
2012-08-02 06:02:29 +00:00
|
|
|
ContentParent::RecvSyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData,
|
2010-11-09 02:49:00 +00:00
|
|
|
InfallibleTArray<nsString>* aRetvals)
|
2010-08-31 18:58:35 +00:00
|
|
|
{
|
2011-08-02 19:57:48 +00:00
|
|
|
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
2010-08-31 18:58:35 +00:00
|
|
|
if (ppm) {
|
2012-08-02 06:02:29 +00:00
|
|
|
const SerializedStructuredCloneBuffer& buffer = aData.data();
|
|
|
|
const InfallibleTArray<PBlobParent*>& blobParents = aData.blobsParent();
|
|
|
|
StructuredCloneData cloneData;
|
|
|
|
cloneData.mData = buffer.data;
|
|
|
|
cloneData.mDataLength = buffer.dataLength;
|
|
|
|
if (!blobParents.IsEmpty()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length = blobParents.Length();
|
2012-08-02 06:02:29 +00:00
|
|
|
cloneData.mClosure.mBlobs.SetCapacity(length);
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t index = 0; index < length; index++) {
|
2012-08-02 06:02:29 +00:00
|
|
|
BlobParent* blobParent = static_cast<BlobParent*>(blobParents[index]);
|
|
|
|
MOZ_ASSERT(blobParent);
|
|
|
|
nsCOMPtr<nsIDOMBlob> blob = blobParent->GetBlob();
|
|
|
|
MOZ_ASSERT(blob);
|
|
|
|
cloneData.mClosure.mBlobs.AppendElement(blob);
|
|
|
|
}
|
|
|
|
}
|
2010-08-31 18:58:35 +00:00
|
|
|
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
2012-08-02 06:02:29 +00:00
|
|
|
aMsg, true, &cloneData, nullptr, aRetvals);
|
2010-08-31 18:58:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-08-02 06:02:29 +00:00
|
|
|
ContentParent::RecvAsyncMessage(const nsString& aMsg,
|
|
|
|
const ClonedMessageData& aData)
|
2010-08-31 18:58:35 +00:00
|
|
|
{
|
2011-08-02 19:57:48 +00:00
|
|
|
nsRefPtr<nsFrameMessageManager> ppm = mMessageManager;
|
2010-08-31 18:58:35 +00:00
|
|
|
if (ppm) {
|
2012-08-02 06:02:29 +00:00
|
|
|
const SerializedStructuredCloneBuffer& buffer = aData.data();
|
|
|
|
const InfallibleTArray<PBlobParent*>& blobParents = aData.blobsParent();
|
|
|
|
StructuredCloneData cloneData;
|
|
|
|
cloneData.mData = buffer.data;
|
|
|
|
cloneData.mDataLength = buffer.dataLength;
|
|
|
|
if (!blobParents.IsEmpty()) {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length = blobParents.Length();
|
2012-08-02 06:02:29 +00:00
|
|
|
cloneData.mClosure.mBlobs.SetCapacity(length);
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t index = 0; index < length; index++) {
|
2012-08-02 06:02:29 +00:00
|
|
|
BlobParent* blobParent = static_cast<BlobParent*>(blobParents[index]);
|
|
|
|
MOZ_ASSERT(blobParent);
|
|
|
|
nsCOMPtr<nsIDOMBlob> blob = blobParent->GetBlob();
|
|
|
|
MOZ_ASSERT(blob);
|
|
|
|
cloneData.mClosure.mBlobs.AppendElement(blob);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-31 18:58:35 +00:00
|
|
|
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
2012-08-02 06:02:29 +00:00
|
|
|
aMsg, false, &cloneData, nullptr, nullptr);
|
2010-08-31 18:58:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-21 04:16:37 +00:00
|
|
|
|
|
|
|
bool
|
2010-11-05 17:43:13 +00:00
|
|
|
ContentParent::RecvAddGeolocationListener()
|
2010-09-21 04:16:37 +00:00
|
|
|
{
|
2010-09-27 21:23:35 +00:00
|
|
|
if (mGeolocationWatchID == -1) {
|
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-16 19:08:48 +00:00
|
|
|
jsval dummy = JSVAL_VOID;
|
2012-07-30 14:20:58 +00:00
|
|
|
geo->WatchPosition(this, nullptr, dummy, nullptr, &mGeolocationWatchID);
|
2010-09-21 04:16:37 +00:00
|
|
|
}
|
2010-09-21 04:16:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-05 17:43:13 +00:00
|
|
|
ContentParent::RecvRemoveGeolocationListener()
|
2010-09-21 04:16:37 +00:00
|
|
|
{
|
2012-12-04 00:03:16 +00:00
|
|
|
if (mGeolocationWatchID != -1) {
|
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
geo->ClearWatch(mGeolocationWatchID);
|
|
|
|
mGeolocationWatchID = -1;
|
2012-12-02 02:21:56 +00:00
|
|
|
}
|
2010-09-21 04:16:37 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-12-31 16:36:46 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvSetGeolocationHigherAccuracy(const bool& aEnable)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsGeolocationService> geoSvc =
|
|
|
|
nsGeolocationService::GetGeolocationService();
|
|
|
|
geoSvc->SetHigherAccuracy(aEnable);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-21 04:16:37 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentParent::HandleEvent(nsIDOMGeoPosition* postion)
|
|
|
|
{
|
2010-12-26 20:03:52 +00:00
|
|
|
unused << SendGeolocationUpdate(GeoPosition(postion));
|
2010-09-21 04:16:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-09 17:52:09 +00:00
|
|
|
nsConsoleService *
|
|
|
|
ContentParent::GetConsoleService()
|
|
|
|
{
|
|
|
|
if (mConsoleService) {
|
|
|
|
return mConsoleService.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
nsCOMPtr<nsConsoleService> consoleService(do_GetService(consoleServiceCID));
|
|
|
|
mConsoleService = consoleService;
|
|
|
|
return mConsoleService.get();
|
|
|
|
}
|
|
|
|
|
2010-09-24 01:39:32 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvConsoleMessage(const nsString& aMessage)
|
|
|
|
{
|
2012-11-09 17:52:09 +00:00
|
|
|
nsRefPtr<nsConsoleService> consoleService = GetConsoleService();
|
|
|
|
if (!consoleService) {
|
2010-09-24 01:39:32 +00:00
|
|
|
return true;
|
2012-11-09 17:52:09 +00:00
|
|
|
}
|
2010-09-24 01:39:32 +00:00
|
|
|
|
|
|
|
nsRefPtr<nsConsoleMessage> msg(new nsConsoleMessage(aMessage.get()));
|
2012-11-09 17:52:09 +00:00
|
|
|
consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
|
2010-09-24 01:39:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvScriptError(const nsString& aMessage,
|
|
|
|
const nsString& aSourceName,
|
|
|
|
const nsString& aSourceLine,
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint32_t& aLineNumber,
|
|
|
|
const uint32_t& aColNumber,
|
|
|
|
const uint32_t& aFlags,
|
2010-09-24 01:39:32 +00:00
|
|
|
const nsCString& aCategory)
|
|
|
|
{
|
2012-11-09 17:52:09 +00:00
|
|
|
nsRefPtr<nsConsoleService> consoleService = GetConsoleService();
|
|
|
|
if (!consoleService) {
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-24 01:39:32 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> msg(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
2012-09-09 23:29:12 +00:00
|
|
|
nsresult rv = msg->Init(aMessage, aSourceName, aSourceLine,
|
2010-09-24 01:39:32 +00:00
|
|
|
aLineNumber, aColNumber, aFlags, aCategory.get());
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return true;
|
|
|
|
|
2012-11-09 17:52:09 +00:00
|
|
|
consoleService->LogMessageWithMode(msg, nsConsoleService::SuppressLog);
|
2010-09-24 01:39:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-04-20 00:13:20 +00:00
|
|
|
bool
|
|
|
|
ContentParent::RecvPrivateDocShellsExist(const bool& aExist)
|
|
|
|
{
|
|
|
|
if (!gPrivateContent)
|
2012-07-13 21:10:20 +00:00
|
|
|
gPrivateContent = new nsTArray<ContentParent*>();
|
2012-04-20 00:13:20 +00:00
|
|
|
if (aExist) {
|
|
|
|
gPrivateContent->AppendElement(this);
|
|
|
|
} else {
|
|
|
|
gPrivateContent->RemoveElement(this);
|
|
|
|
if (!gPrivateContent->Length()) {
|
|
|
|
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
2012-07-30 14:20:58 +00:00
|
|
|
obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
|
2012-04-20 00:13:20 +00:00
|
|
|
delete gPrivateContent;
|
|
|
|
gPrivateContent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-09-28 05:43:12 +00:00
|
|
|
bool
|
|
|
|
ContentParent::DoSendAsyncMessage(const nsAString& aMessage,
|
|
|
|
const mozilla::dom::StructuredCloneData& aData)
|
|
|
|
{
|
|
|
|
ClonedMessageData data;
|
|
|
|
SerializedStructuredCloneBuffer& buffer = data.data();
|
|
|
|
buffer.data = aData.mData;
|
|
|
|
buffer.dataLength = aData.mDataLength;
|
|
|
|
const nsTArray<nsCOMPtr<nsIDOMBlob> >& blobs = aData.mClosure.mBlobs;
|
|
|
|
if (!blobs.IsEmpty()) {
|
|
|
|
InfallibleTArray<PBlobParent*>& blobParents = data.blobsParent();
|
|
|
|
uint32_t length = blobs.Length();
|
|
|
|
blobParents.SetCapacity(length);
|
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
|
|
|
BlobParent* blobParent = GetOrCreateActorForBlob(blobs[i]);
|
|
|
|
if (!blobParent) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
blobParents.AppendElement(blobParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SendAsyncMessage(nsString(aMessage), data);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::CheckPermission(const nsAString& aPermission)
|
|
|
|
{
|
|
|
|
return AssertAppProcessPermission(this, NS_ConvertUTF16toUTF8(aPermission).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-12 16:18:08 +00:00
|
|
|
} // namespace dom
|
2012-08-02 06:32:04 +00:00
|
|
|
} // namespace mozilla
|