2009-08-18 12:05:15 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2009-09-09 15:00:14 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Content App.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* The Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2010-05-25 17:13:47 -07:00
|
|
|
* Frederic Plourde <frederic.plourde@collabora.co.uk>
|
2009-09-09 15:00:14 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#endif
|
|
|
|
|
2010-10-08 14:48:37 -07:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
2010-10-08 23:05:50 -07:00
|
|
|
#include "nsQAppInstance.h"
|
2010-10-08 14:48:37 -07:00
|
|
|
#endif
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "ContentChild.h"
|
2010-11-24 06:15:03 -08:00
|
|
|
#include "CrashReporterChild.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
#include "TabChild.h"
|
2010-11-16 20:14:19 -08:00
|
|
|
#include "AudioChild.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
#include "mozilla/ipc/TestShellChild.h"
|
2009-08-18 12:05:15 -07:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2009-11-06 12:43:39 -08:00
|
|
|
#include "mozilla/ipc/XPCShellEnvironment.h"
|
|
|
|
#include "mozilla/jsipc/PContextWrapperChild.h"
|
2010-09-15 15:55:08 -07:00
|
|
|
#include "mozilla/dom/ExternalHelperAppChild.h"
|
2010-11-18 17:15:23 -08:00
|
|
|
#include "mozilla/dom/StorageChild.h"
|
2010-11-24 06:15:03 -08:00
|
|
|
#include "mozilla/dom/PCrashReporterChild.h"
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2010-11-16 20:14:19 -08:00
|
|
|
#include "nsAudioStream.h"
|
|
|
|
|
2010-07-21 11:42:32 -07:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsTObserverArray.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIPrefService.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-08-25 16:39:30 -07:00
|
|
|
#include "nsXULAppAPI.h"
|
2010-07-21 11:42:32 -07:00
|
|
|
#include "nsWeakReference.h"
|
2010-09-23 18:39:32 -07:00
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsIConsoleService.h"
|
2009-08-25 16:07:22 -07:00
|
|
|
|
2010-07-02 08:50:41 -07:00
|
|
|
#include "History.h"
|
|
|
|
#include "nsDocShellCID.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "base/message_loop.h"
|
|
|
|
#include "base/task.h"
|
|
|
|
|
2010-03-10 21:33:00 -08:00
|
|
|
#include "nsChromeRegistryContent.h"
|
|
|
|
#include "mozilla/chrome/RegistryMessageUtils.h"
|
2010-08-31 11:58:35 -07:00
|
|
|
#include "nsFrameMessageManager.h"
|
2010-03-10 21:33:00 -08:00
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
#include "nsIGeolocationProvider.h"
|
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
#include "nsPermission.h"
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2010-11-05 09:38:17 -07:00
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
|
|
|
// TODO: For other platforms that support setpriority, figure out
|
|
|
|
// appropriate values of niceness
|
|
|
|
static const int kRelativeNiceness = 10;
|
|
|
|
#endif
|
|
|
|
|
2010-11-05 10:43:13 -07:00
|
|
|
#include "nsAccelerometer.h"
|
|
|
|
|
2010-11-24 06:15:03 -08:00
|
|
|
#if defined(ANDROID)
|
|
|
|
#include "APKOpen.h"
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
using namespace mozilla::ipc;
|
2009-08-18 12:05:15 -07:00
|
|
|
using namespace mozilla::net;
|
2010-07-02 08:50:41 -07:00
|
|
|
using namespace mozilla::places;
|
2010-10-20 10:12:32 -07:00
|
|
|
using namespace mozilla::docshell;
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2010-09-15 09:44:57 -07:00
|
|
|
class AlertObserver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
AlertObserver(nsIObserver *aObserver, const nsString& aData)
|
|
|
|
: mData(aData)
|
|
|
|
, mObserver(aObserver)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~AlertObserver() {}
|
|
|
|
|
|
|
|
bool ShouldRemoveFrom(nsIObserver* aObserver,
|
|
|
|
const nsString& aData) const
|
|
|
|
{
|
|
|
|
return (mObserver == aObserver &&
|
|
|
|
mData == aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Observes(const nsString& aData) const
|
|
|
|
{
|
|
|
|
return mData.Equals(aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Notify(const nsCString& aType) const
|
|
|
|
{
|
|
|
|
mObserver->Observe(nsnull, aType.get(), mData.get());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIObserver> mObserver;
|
|
|
|
nsString mData;
|
|
|
|
};
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
class ConsoleListener : public nsIConsoleListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ConsoleListener(ContentChild* aChild)
|
|
|
|
: mChild(aChild) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSICONSOLELISTENER
|
|
|
|
|
|
|
|
private:
|
|
|
|
ContentChild* mChild;
|
|
|
|
friend class ContentChild;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(ConsoleListener, nsIConsoleListener)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ConsoleListener::Observe(nsIConsoleMessage* aMessage)
|
|
|
|
{
|
|
|
|
if (!mChild)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
|
|
|
|
if (scriptError) {
|
|
|
|
nsString msg, sourceName, sourceLine;
|
|
|
|
nsXPIDLCString category;
|
|
|
|
PRUint32 lineNum, colNum, flags;
|
|
|
|
|
|
|
|
nsresult rv = scriptError->GetErrorMessage(msg);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetSourceName(sourceName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetSourceLine(sourceLine);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetCategory(getter_Copies(category));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetLineNumber(&lineNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetColumnNumber(&colNum);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = scriptError->GetFlags(&flags);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mChild->SendScriptError(msg, sourceName, sourceLine,
|
|
|
|
lineNum, colNum, flags, category);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsXPIDLString msg;
|
|
|
|
nsresult rv = aMessage->GetMessageMoz(getter_Copies(msg));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
mChild->SendConsoleMessage(msg);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-07-21 11:42:32 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild* ContentChild::sSingleton;
|
2009-08-12 17:32:50 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::ContentChild()
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::~ContentChild()
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::Init(MessageLoop* aIOLoop,
|
|
|
|
base::ProcessHandle aParentHandle,
|
|
|
|
IPC::Channel* aChannel)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-08-20 16:24:40 -07:00
|
|
|
#ifdef MOZ_WIDGET_GTK2
|
|
|
|
// sigh
|
|
|
|
gtk_init(NULL, NULL);
|
|
|
|
#endif
|
2010-10-08 14:48:37 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
// sigh, seriously
|
2010-10-08 23:05:50 -07:00
|
|
|
nsQAppInstance::AddRef();
|
2010-10-08 14:48:37 -07:00
|
|
|
#endif
|
2010-08-20 16:24:40 -07:00
|
|
|
|
2010-09-09 18:25:26 -07:00
|
|
|
#ifdef MOZ_X11
|
|
|
|
// Do this after initializing GDK, or GDK will install its own handler.
|
|
|
|
XRE_InstallX11ErrorHandler();
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
NS_ASSERTION(!sSingleton, "only one ContentChild per child");
|
2010-11-05 09:38:17 -07:00
|
|
|
|
|
|
|
#if defined(ANDROID) || defined(LINUX)
|
|
|
|
// XXX We change the behavior of Linux child processes here. That
|
|
|
|
// means that, not just in Fennec, but also in Firefox, once it has
|
|
|
|
// child processes, those will be niced. IOW, Firefox with child processes
|
|
|
|
// will have different performance profiles on Linux than other
|
|
|
|
// platforms. This may alter Talos results and so forth.
|
|
|
|
char* relativeNicenessStr = getenv("MOZ_CHILD_PROCESS_RELATIVE_NICENESS");
|
|
|
|
setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0) +
|
|
|
|
(relativeNicenessStr ? atoi(relativeNicenessStr) :
|
|
|
|
kRelativeNiceness));
|
|
|
|
#endif
|
|
|
|
|
2009-10-27 14:52:37 -07:00
|
|
|
Open(aChannel, aParentHandle, aIOLoop);
|
2009-08-12 17:32:50 -07:00
|
|
|
sSingleton = this;
|
|
|
|
|
2010-11-24 06:15:03 -08:00
|
|
|
#if defined(ANDROID)
|
|
|
|
PCrashReporterChild* crashreporter = SendPCrashReporterConstructor();
|
|
|
|
InfallibleTArray<Mapping> mappings;
|
|
|
|
const struct mapping_info *info = getLibraryMapping();
|
|
|
|
while (info->name) {
|
|
|
|
mappings.AppendElement(Mapping(nsDependentCString(info->name),
|
|
|
|
nsDependentCString(info->file_id),
|
|
|
|
info->base,
|
|
|
|
info->len,
|
|
|
|
info->offset));
|
|
|
|
info++;
|
|
|
|
}
|
|
|
|
crashreporter->SendAddLibraryMappings(mappings);
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 17:32:50 -07:00
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
void
|
|
|
|
ContentChild::InitXPCOM()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!svc) {
|
|
|
|
NS_WARNING("Couldn't acquire console service");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mConsoleListener = new ConsoleListener(this);
|
|
|
|
if (NS_FAILED(svc->RegisterListener(mConsoleListener)))
|
|
|
|
NS_WARNING("Couldn't register console listener for child process");
|
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserChild*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::AllocPBrowser(const PRUint32& aChromeFlags)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-08-20 16:24:40 -07:00
|
|
|
nsRefPtr<TabChild> iframe = new TabChild(aChromeFlags);
|
|
|
|
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget().get() : NULL;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::DeallocPBrowser(PBrowserChild* iframe)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
TabChild* child = static_cast<TabChild*>(iframe);
|
|
|
|
NS_RELEASE(child);
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2010-11-24 06:15:03 -08:00
|
|
|
PCrashReporterChild*
|
|
|
|
ContentChild::AllocPCrashReporter()
|
|
|
|
{
|
|
|
|
return new CrashReporterChild();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPCrashReporter(PCrashReporterChild* crashreporter)
|
|
|
|
{
|
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PTestShellChild*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::AllocPTestShell()
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
return new TestShellChild();
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::DeallocPTestShell(PTestShellChild* shell)
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
2010-05-14 22:27:52 -07:00
|
|
|
delete shell;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-25 16:07:22 -07:00
|
|
|
}
|
|
|
|
|
2009-11-06 12:43:39 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::RecvPTestShellConstructor(PTestShellChild* actor)
|
2009-11-06 12:43:39 -08:00
|
|
|
{
|
|
|
|
actor->SendPContextWrapperConstructor()->SendPObjectWrapperConstructor(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-16 20:14:19 -08:00
|
|
|
PAudioChild*
|
|
|
|
ContentChild::AllocPAudio(const PRInt32& numChannels,
|
|
|
|
const PRInt32& rate,
|
|
|
|
const PRInt32& format)
|
|
|
|
{
|
|
|
|
PAudioChild *child = new AudioChild();
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPAudio(PAudioChild* doomed)
|
|
|
|
{
|
|
|
|
delete doomed;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-08-18 12:05:15 -07:00
|
|
|
PNeckoChild*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::AllocPNecko()
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
|
|
|
return new NeckoChild();
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::DeallocPNecko(PNeckoChild* necko)
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-18 12:05:15 -07:00
|
|
|
}
|
|
|
|
|
2010-09-15 15:55:08 -07:00
|
|
|
PExternalHelperAppChild*
|
|
|
|
ContentChild::AllocPExternalHelperApp(const IPC::URI& uri,
|
|
|
|
const nsCString& aMimeContentType,
|
|
|
|
const nsCString& aContentDisposition,
|
|
|
|
const bool& aForceSave,
|
2010-11-21 11:21:59 -08:00
|
|
|
const PRInt64& aContentLength,
|
|
|
|
const IPC::URI& aReferrer)
|
2010-09-15 15:55:08 -07:00
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = new ExternalHelperAppChild();
|
|
|
|
child->AddRef();
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPExternalHelperApp(PExternalHelperAppChild* aService)
|
|
|
|
{
|
|
|
|
ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
|
|
|
|
child->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-18 17:15:23 -08:00
|
|
|
PStorageChild*
|
|
|
|
ContentChild::AllocPStorage(const StorageConstructData& aData)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::DeallocPStorage(PStorageChild* aActor)
|
|
|
|
{
|
|
|
|
StorageChild* child = static_cast<StorageChild*>(aActor);
|
|
|
|
child->ReleaseIPDLReference();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-10 21:33:00 -08:00
|
|
|
bool
|
2010-11-08 18:49:00 -08:00
|
|
|
ContentChild::RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
|
|
|
|
const InfallibleTArray<ResourceMapping>& resources,
|
|
|
|
const InfallibleTArray<OverrideMapping>& overrides)
|
2010-03-10 21:33:00 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryContent* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryContent*>(registrySvc.get());
|
|
|
|
chromeRegistry->RegisterRemoteChrome(packages, resources, overrides);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-11 05:44:12 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::RecvSetOffline(const PRBool& offline)
|
2010-05-11 05:44:12 -07:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIIOService> io (do_GetIOService());
|
|
|
|
NS_ASSERTION(io, "IO Service can not be null");
|
|
|
|
|
|
|
|
io->SetOffline(offline);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-12-06 22:03:49 -08:00
|
|
|
void
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentChild::ActorDestroy(ActorDestroyReason why)
|
2009-09-02 17:18:27 -07:00
|
|
|
{
|
2010-08-20 16:24:40 -07:00
|
|
|
if (AbnormalShutdown == why) {
|
|
|
|
NS_WARNING("shutting down early because of crash!");
|
|
|
|
QuickExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
// In release builds, there's no point in the content process
|
|
|
|
// going through the full XPCOM shutdown path, because it doesn't
|
|
|
|
// keep persistent state.
|
|
|
|
QuickExit();
|
|
|
|
#endif
|
2009-09-02 17:18:27 -07:00
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
mAlertObservers.Clear();
|
2010-09-23 18:39:32 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (svc) {
|
|
|
|
svc->UnregisterListener(mConsoleListener);
|
|
|
|
mConsoleListener->mChild = nsnull;
|
|
|
|
}
|
|
|
|
|
2009-12-06 22:03:49 -08:00
|
|
|
XRE_ShutdownChildProcess();
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
|
|
|
|
2010-08-20 16:24:40 -07:00
|
|
|
void
|
|
|
|
ContentChild::ProcessingError(Result what)
|
|
|
|
{
|
|
|
|
switch (what) {
|
|
|
|
case MsgDropped:
|
|
|
|
QuickExit();
|
|
|
|
|
|
|
|
case MsgNotKnown:
|
|
|
|
case MsgNotAllowed:
|
|
|
|
case MsgPayloadError:
|
|
|
|
case MsgProcessingError:
|
|
|
|
case MsgRouteError:
|
|
|
|
case MsgValueError:
|
|
|
|
NS_RUNTIMEABORT("aborting because of fatal error");
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentChild::QuickExit()
|
|
|
|
{
|
|
|
|
NS_WARNING("content process _exit()ing");
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
nsresult
|
|
|
|
ContentChild::AddRemoteAlertObserver(const nsString& aData,
|
|
|
|
nsIObserver* aObserver)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aObserver, "Adding a null observer?");
|
|
|
|
mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
bool
|
2010-10-19 13:35:08 -07:00
|
|
|
ContentChild::RecvPreferenceUpdate(const PrefTuple& aPref)
|
2010-07-21 11:42:32 -07:00
|
|
|
{
|
2010-09-28 10:02:37 -07:00
|
|
|
nsCOMPtr<nsIPrefServiceInternal> prefs = do_GetService("@mozilla.org/preferences-service;1");
|
2010-10-19 13:35:08 -07:00
|
|
|
if (!prefs)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
prefs->SetPreference(&aPref);
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
|
|
|
|
{
|
|
|
|
for (PRUint32 i = 0; i < mAlertObservers.Length();
|
|
|
|
/*we mutate the array during the loop; ++i iff no mutation*/) {
|
|
|
|
AlertObserver* observer = mAlertObservers[i];
|
|
|
|
if (observer->Observes(aData) && observer->Notify(aType)) {
|
|
|
|
// if aType == alertfinished, this alert is done. we can
|
|
|
|
// remove the observer.
|
|
|
|
if (aType.Equals(nsDependentCString("alertfinished"))) {
|
|
|
|
mAlertObservers.RemoveElementAt(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:50:41 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvNotifyVisited(const IPC::URI& aURI)
|
|
|
|
{
|
2010-07-26 12:59:34 -07:00
|
|
|
nsCOMPtr<nsIURI> newURI(aURI);
|
2010-07-02 08:50:41 -07:00
|
|
|
History::GetService()->NotifyVisited(newURI);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-31 11:58:35 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentChild::RecvAsyncMessage(const nsString& aMsg, const nsString& aJSON)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsFrameMessageManager> cpm = nsFrameMessageManager::sChildProcessManager;
|
|
|
|
if (cpm) {
|
|
|
|
cpm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(cpm.get()),
|
|
|
|
aMsg, PR_FALSE, aJSON, nsnull, nsnull);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvGeolocationUpdate(const GeoPosition& somewhere)
|
|
|
|
{
|
2010-09-20 21:16:37 -07:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> gs = do_GetService("@mozilla.org/geolocation/service;1");
|
2010-09-21 19:36:58 -07:00
|
|
|
if (!gs) {
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMGeoPosition> position = somewhere;
|
|
|
|
gs->Update(position);
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAddPermission(const IPC::Permission& permission)
|
|
|
|
{
|
|
|
|
#if MOZ_PERMISSIONS
|
2010-10-21 11:36:14 -07:00
|
|
|
nsRefPtr<nsPermissionManager> permissionManager =
|
|
|
|
nsPermissionManager::GetSingleton();
|
2010-10-09 11:07:38 -07:00
|
|
|
NS_ABORT_IF_FALSE(permissionManager,
|
|
|
|
"We have no permissionManager in the Content process !");
|
|
|
|
|
|
|
|
permissionManager->AddInternal(nsCString(permission.host),
|
|
|
|
nsCString(permission.type),
|
|
|
|
permission.capability,
|
|
|
|
0,
|
|
|
|
permission.expireType,
|
|
|
|
permission.expireTime,
|
|
|
|
nsPermissionManager::eNotify,
|
|
|
|
nsPermissionManager::eNoDBOperation);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-05 10:43:13 -07:00
|
|
|
bool
|
|
|
|
ContentChild::RecvAccelerationChanged(const double& x, const double& y,
|
|
|
|
const double& z)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccelerometerUpdate> acu =
|
|
|
|
do_GetService(NS_ACCELEROMETER_CONTRACTID);
|
|
|
|
if (acu)
|
|
|
|
acu->AccelerationChanged(x, y, z);
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-09 11:07:38 -07:00
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|