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 ***** */
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
#include "ContentParent.h"
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
#include "TabParent.h"
|
2010-11-24 06:15:03 -08:00
|
|
|
#include "CrashReporterParent.h"
|
2010-07-02 08:50:41 -07:00
|
|
|
#include "History.h"
|
2009-08-12 11:31:48 -07:00
|
|
|
#include "mozilla/ipc/TestShellParent.h"
|
2009-08-18 12:05:15 -07:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
2010-11-24 05:58:21 -08:00
|
|
|
#include "nsHashPropertyBag.h"
|
2010-10-20 08:19:24 -07:00
|
|
|
#include "nsIFilePicker.h"
|
|
|
|
#include "nsIWindowWatcher.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
2010-05-25 17:13:47 -07:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefBranch2.h"
|
2010-09-28 10:02:37 -07:00
|
|
|
#include "nsIPrefService.h"
|
2010-05-26 12:29:15 -07:00
|
|
|
#include "nsIPrefLocalizedString.h"
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "nsIObserverService.h"
|
2010-07-02 08:50:24 -07:00
|
|
|
#include "nsContentUtils.h"
|
2009-09-02 17:18:27 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2010-03-10 21:33:00 -08:00
|
|
|
#include "nsChromeRegistryChrome.h"
|
2010-08-10 10:14:45 -07:00
|
|
|
#include "nsExternalHelperAppService.h"
|
|
|
|
#include "nsCExternalHandlerService.h"
|
2010-08-31 11:58:35 -07:00
|
|
|
#include "nsFrameMessageManager.h"
|
2010-09-15 09:44:57 -07:00
|
|
|
#include "nsIAlertsService.h"
|
|
|
|
#include "nsToolkitCompsCID.h"
|
2010-09-20 21:16:37 -07:00
|
|
|
#include "nsIDOMGeoGeolocation.h"
|
2010-09-23 18:39:32 -07:00
|
|
|
#include "nsIConsoleService.h"
|
|
|
|
#include "nsIScriptError.h"
|
|
|
|
#include "nsConsoleMessage.h"
|
2010-11-16 20:14:19 -08:00
|
|
|
#include "AudioParent.h"
|
2009-09-02 17:18:27 -07:00
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
#ifdef MOZ_PERMISSIONS
|
|
|
|
#include "nsPermissionManager.h"
|
|
|
|
#endif
|
|
|
|
|
2010-11-24 05:58:21 -08:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2010-09-15 15:55:08 -07:00
|
|
|
#include "mozilla/dom/ExternalHelperAppParent.h"
|
2010-11-18 17:15:23 -08:00
|
|
|
#include "mozilla/dom/StorageParent.h"
|
2010-11-05 10:43:13 -07:00
|
|
|
#include "nsAccelerometer.h"
|
2010-09-15 15:55:08 -07:00
|
|
|
|
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;
|
2009-09-02 17:18:27 -07:00
|
|
|
using mozilla::MonitorAutoEnter;
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2010-05-11 10:22:34 -07:00
|
|
|
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
2010-05-11 05:44:12 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent* ContentParent::gSingleton;
|
2009-08-12 09:18:08 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent*
|
|
|
|
ContentParent::GetSingleton(PRBool aForceNew)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-04-11 17:24:45 -07:00
|
|
|
if (gSingleton && !gSingleton->IsAlive())
|
|
|
|
gSingleton = nsnull;
|
|
|
|
|
2010-05-11 10:29:57 -07:00
|
|
|
if (!gSingleton && aForceNew) {
|
2010-07-19 11:33:33 -07:00
|
|
|
nsRefPtr<ContentParent> parent = new ContentParent();
|
2009-09-02 17:18:27 -07:00
|
|
|
if (parent) {
|
|
|
|
nsCOMPtr<nsIObserverService> obs =
|
|
|
|
do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
if (obs) {
|
|
|
|
if (NS_SUCCEEDED(obs->AddObserver(parent, "xpcom-shutdown",
|
|
|
|
PR_FALSE))) {
|
|
|
|
gSingleton = parent;
|
2010-05-25 17:13:47 -07:00
|
|
|
nsCOMPtr<nsIPrefBranch2> prefs
|
|
|
|
(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
if (prefs) {
|
|
|
|
prefs->AddObserver("", parent, PR_FALSE);
|
|
|
|
}
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
2010-05-11 05:44:12 -07:00
|
|
|
obs->AddObserver(
|
2010-05-11 10:22:34 -07:00
|
|
|
parent, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, PR_FALSE);
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
2010-02-01 17:53:52 -08:00
|
|
|
nsCOMPtr<nsIThreadInternal>
|
|
|
|
threadInt(do_QueryInterface(NS_GetCurrentThread()));
|
|
|
|
if (threadInt) {
|
|
|
|
threadInt->GetObserver(getter_AddRefs(parent->mOldObserver));
|
|
|
|
threadInt->SetObserver(parent);
|
|
|
|
}
|
2010-11-24 10:22:40 -08:00
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nsnull, "ipc:content-created", nsnull);
|
|
|
|
}
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return gSingleton;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2010-11-24 05:58:21 -08:00
|
|
|
void
|
|
|
|
ContentParent::OnChannelConnected(int32 pid)
|
|
|
|
{
|
|
|
|
ProcessHandle handle;
|
|
|
|
if (!base::OpenPrivilegedProcessHandle(pid, &handle)) {
|
|
|
|
NS_WARNING("Can't open handle to child process.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetOtherProcess(handle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
void
|
|
|
|
DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
|
|
|
{
|
|
|
|
XRE_GetIOMessageLoop()
|
|
|
|
->PostTask(FROM_HERE,
|
|
|
|
new DeleteTask<GeckoChildProcessHost>(aSubprocess));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-01 17:53:52 -08:00
|
|
|
void
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::ActorDestroy(ActorDestroyReason why)
|
2010-02-01 17:53:52 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIThreadObserver>
|
|
|
|
kungFuDeathGrip(static_cast<nsIThreadObserver*>(this));
|
|
|
|
nsCOMPtr<nsIObserverService>
|
|
|
|
obs(do_GetService("@mozilla.org/observer-service;1"));
|
|
|
|
if (obs)
|
|
|
|
obs->RemoveObserver(static_cast<nsIObserver*>(this), "xpcom-shutdown");
|
|
|
|
nsCOMPtr<nsIThreadInternal>
|
|
|
|
threadInt(do_QueryInterface(NS_GetCurrentThread()));
|
|
|
|
if (threadInt)
|
|
|
|
threadInt->SetObserver(mOldObserver);
|
|
|
|
if (mRunToCompletionDepth)
|
|
|
|
mRunToCompletionDepth = 0;
|
2010-04-11 17:24:45 -07:00
|
|
|
|
|
|
|
mIsAlive = false;
|
2010-10-08 12:12:40 -07:00
|
|
|
|
|
|
|
if (obs) {
|
2010-11-24 05:58:21 -08:00
|
|
|
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
|
|
|
props->Init();
|
|
|
|
|
|
|
|
if (AbnormalShutdown == why) {
|
|
|
|
props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), PR_TRUE);
|
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
nsAutoString dumpID;
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> crashDump;
|
|
|
|
TakeMinidump(getter_AddRefs(crashDump)) &&
|
|
|
|
CrashReporter::GetIDFromMinidump(crashDump, dumpID);
|
|
|
|
|
2010-11-30 06:54:31 -08:00
|
|
|
if (!dumpID.IsEmpty()) {
|
2010-11-24 05:58:21 -08:00
|
|
|
props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"),
|
|
|
|
dumpID);
|
2010-11-30 06:54:31 -08:00
|
|
|
|
|
|
|
CrashReporter::AnnotationTable notes;
|
|
|
|
notes.Init();
|
|
|
|
notes.Put(NS_LITERAL_CSTRING("ProcessType"), NS_LITERAL_CSTRING("content"));
|
|
|
|
// TODO: Additional per-process annotations.
|
|
|
|
CrashReporter::AppendExtraData(dumpID, notes);
|
|
|
|
}
|
2010-11-24 05:58:21 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", nsnull);
|
|
|
|
}
|
2010-10-08 12:12:40 -07:00
|
|
|
}
|
2010-11-24 05:58:21 -08:00
|
|
|
|
|
|
|
MessageLoop::current()->
|
|
|
|
PostTask(FROM_HERE,
|
|
|
|
NewRunnableFunction(DelayedDeleteSubprocess, mSubprocess));
|
|
|
|
mSubprocess = NULL;
|
2010-02-01 17:53:52 -08:00
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
TabParent*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::CreateTab(PRUint32 aChromeFlags)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-07-19 11:33:33 -07:00
|
|
|
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags));
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
TestShellParent*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::CreateTestShell()
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
2009-09-09 15:00:14 -07:00
|
|
|
return static_cast<TestShellParent*>(SendPTestShellConstructor());
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
|
|
|
|
2009-11-11 00:34:08 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::DestroyTestShell(TestShellParent* aTestShell)
|
2009-11-11 00:34:08 -08:00
|
|
|
{
|
2009-12-03 00:16:14 -08:00
|
|
|
return PTestShellParent::Send__delete__(aTestShell);
|
2009-11-11 00:34:08 -08:00
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::ContentParent()
|
|
|
|
: mMonitor("ContentParent::mMonitor")
|
2010-09-20 21:16:37 -07:00
|
|
|
, mGeolocationWatchID(-1)
|
2010-02-01 17:53:52 -08:00
|
|
|
, mRunToCompletionDepth(0)
|
2010-03-29 13:29:45 -07:00
|
|
|
, mShouldCallUnblockChild(false)
|
2010-04-11 17:24:45 -07:00
|
|
|
, mIsAlive(true)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2009-09-02 17:18:27 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2009-12-06 22:03:49 -08:00
|
|
|
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content);
|
2009-11-18 13:43:53 -08:00
|
|
|
mSubprocess->AsyncLaunch();
|
2009-10-27 14:52:37 -07:00
|
|
|
Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
|
2010-03-10 21:33:00 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryChrome* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
|
|
|
chromeRegistry->SendRegisteredChrome(this);
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::~ContentParent()
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-11-24 05:58:21 -08:00
|
|
|
if (OtherProcess())
|
|
|
|
base::CloseProcessHandle(OtherProcess());
|
|
|
|
|
2009-09-02 17:18:27 -07:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-04-11 17:24:45 -07:00
|
|
|
//If the previous content process has died, a new one could have
|
|
|
|
//been started since.
|
|
|
|
if (gSingleton == this)
|
|
|
|
gSingleton = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::IsAlive()
|
2010-04-11 17:24:45 -07:00
|
|
|
{
|
|
|
|
return mIsAlive;
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
bool
|
2010-11-08 18:49:00 -08:00
|
|
|
ContentParent::RecvReadPrefsArray(InfallibleTArray<PrefTuple> *prefs)
|
2010-05-25 17:13:47 -07:00
|
|
|
{
|
|
|
|
EnsurePrefService();
|
2010-10-19 13:35:08 -07:00
|
|
|
mPrefService->MirrorPreferences(prefs);
|
2010-05-28 11:09:15 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
void
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::EnsurePrefService()
|
2010-05-25 17:13:47 -07:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
if (!mPrefService) {
|
|
|
|
mPrefService = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"We lost prefService in the Chrome process !");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-09 11:07:38 -07:00
|
|
|
bool
|
2010-11-08 18:49:00 -08:00
|
|
|
ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
|
2010-07-15 07:04:25 -07:00
|
|
|
{
|
2010-10-09 11:07:38 -07:00
|
|
|
#ifdef 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 Chrome process !");
|
|
|
|
|
2010-10-21 11:36:39 -07:00
|
|
|
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
|
|
|
nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
|
2010-10-09 11:07:38 -07:00
|
|
|
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Could not get enumerator!");
|
|
|
|
while(1) {
|
|
|
|
PRBool hasMore;
|
|
|
|
enumerator->HasMoreElements(&hasMore);
|
|
|
|
if (!hasMore)
|
|
|
|
break;
|
2010-10-21 11:36:39 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> supp;
|
|
|
|
enumerator->GetNext(getter_AddRefs(supp));
|
2010-10-09 11:07:38 -07:00
|
|
|
nsCOMPtr<nsIPermission> perm = do_QueryInterface(supp);
|
|
|
|
|
|
|
|
nsCString host;
|
|
|
|
perm->GetHost(host);
|
|
|
|
nsCString type;
|
|
|
|
perm->GetType(type);
|
|
|
|
PRUint32 capability;
|
|
|
|
perm->GetCapability(&capability);
|
|
|
|
PRUint32 expireType;
|
|
|
|
perm->GetExpireType(&expireType);
|
|
|
|
PRInt64 expireTime;
|
|
|
|
perm->GetExpireTime(&expireTime);
|
|
|
|
|
|
|
|
aPermissions->AppendElement(IPC::Permission(host, type, capability,
|
|
|
|
expireType, expireTime));
|
2010-07-15 07:04:25 -07:00
|
|
|
}
|
2010-10-09 11:07:38 -07:00
|
|
|
|
|
|
|
// Ask for future changes
|
|
|
|
permissionManager->ChildRequestPermissions();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
2010-07-15 07:04:25 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS3(ContentParent,
|
2010-02-01 17:53:52 -08:00
|
|
|
nsIObserver,
|
2010-09-20 21:16:37 -07:00
|
|
|
nsIThreadObserver,
|
|
|
|
nsIDOMGeoPositionCallback)
|
2009-09-02 17:18:27 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
2009-09-02 17:18:27 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(aTopic, "xpcom-shutdown") && mSubprocess) {
|
2010-05-25 17:13:47 -07:00
|
|
|
// remove the global remote preferences observers
|
|
|
|
nsCOMPtr<nsIPrefBranch2> prefs
|
|
|
|
(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
if (prefs) {
|
|
|
|
if (gSingleton) {
|
|
|
|
prefs->RemoveObserver("", this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:43:13 -07:00
|
|
|
RecvRemoveGeolocationListener();
|
2010-09-20 21:16:37 -07:00
|
|
|
|
2009-12-06 22:03:49 -08:00
|
|
|
Close();
|
2010-11-24 05:58:21 -08:00
|
|
|
NS_ASSERTION(!mSubprocess, "Close should have nulled mSubprocess");
|
2009-09-02 17:18:27 -07:00
|
|
|
}
|
2010-05-11 05:44:12 -07:00
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
if (!mIsAlive || !mSubprocess)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-05-25 17:13:47 -07:00
|
|
|
// listening for remotePrefs...
|
|
|
|
if (!strcmp(aTopic, "nsPref:changed")) {
|
|
|
|
// We know prefs are ASCII here.
|
|
|
|
NS_LossyConvertUTF16toASCII strData(aData);
|
2010-10-19 13:35:08 -07:00
|
|
|
|
|
|
|
PrefTuple pref;
|
|
|
|
nsCOMPtr<nsIPrefServiceInternal> prefService =
|
|
|
|
do_GetService("@mozilla.org/preferences-service;1");
|
|
|
|
|
|
|
|
prefService->MirrorPreference(strData, &pref);
|
|
|
|
|
|
|
|
if (!SendPreferenceUpdate(pref))
|
2010-07-19 11:33:33 -07:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2010-05-25 17:13:47 -07:00
|
|
|
}
|
2010-07-19 11:33:33 -07:00
|
|
|
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
|
2010-05-11 05:44:12 -07:00
|
|
|
NS_ConvertUTF16toUTF8 dataStr(aData);
|
|
|
|
const char *offline = dataStr.get();
|
2010-07-19 11:33:33 -07:00
|
|
|
if (!SendSetOffline(!strcmp(offline, "true") ? true : false))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2010-05-11 05:44:12 -07:00
|
|
|
}
|
2010-09-15 09:44:57 -07:00
|
|
|
// listening for alert notifications
|
|
|
|
else if (!strcmp(aTopic, "alertfinished") ||
|
|
|
|
!strcmp(aTopic, "alertclickcallback") ) {
|
|
|
|
if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
|
|
|
|
nsDependentString(aData)))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
2009-09-02 17:18:27 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 11:33:33 -07:00
|
|
|
PBrowserParent*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-03-26 11:39:39 -07:00
|
|
|
TabParent* parent = new TabParent();
|
|
|
|
if (parent){
|
|
|
|
NS_ADDREF(parent);
|
|
|
|
}
|
|
|
|
return parent;
|
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
|
|
|
ContentParent::DeallocPBrowser(PBrowserParent* frame)
|
2009-08-12 09:18:08 -07:00
|
|
|
{
|
2010-03-26 11:39:39 -07:00
|
|
|
TabParent* parent = static_cast<TabParent*>(frame);
|
|
|
|
NS_RELEASE(parent);
|
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
|
|
|
PCrashReporterParent*
|
|
|
|
ContentParent::AllocPCrashReporter()
|
|
|
|
{
|
|
|
|
return new CrashReporterParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPCrashReporter(PCrashReporterParent* crashreporter)
|
|
|
|
{
|
|
|
|
delete crashreporter;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-09 15:59:06 -07:00
|
|
|
PTestShellParent*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::AllocPTestShell()
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
|
|
|
return new TestShellParent();
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::DeallocPTestShell(PTestShellParent* shell)
|
2009-08-12 11:31:48 -07:00
|
|
|
{
|
|
|
|
delete shell;
|
2009-09-17 16:09:20 -07:00
|
|
|
return true;
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
2010-11-16 20:14:19 -08:00
|
|
|
|
|
|
|
PAudioParent*
|
|
|
|
ContentParent::AllocPAudio(const PRInt32& numChannels,
|
|
|
|
const PRInt32& rate,
|
|
|
|
const PRInt32& format)
|
|
|
|
{
|
|
|
|
AudioParent *parent = new AudioParent(numChannels, rate, format);
|
2010-11-25 20:13:54 -08:00
|
|
|
NS_ADDREF(parent);
|
2010-11-16 20:14:19 -08:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPAudio(PAudioParent* doomed)
|
|
|
|
{
|
|
|
|
AudioParent *parent = static_cast<AudioParent*>(doomed);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
return true;
|
|
|
|
}
|
2009-08-12 11:31:48 -07:00
|
|
|
|
2009-08-18 12:05:15 -07:00
|
|
|
PNeckoParent*
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::AllocPNecko()
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
|
|
|
return new NeckoParent();
|
|
|
|
}
|
|
|
|
|
2009-09-17 16:09:20 -07:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::DeallocPNecko(PNeckoParent* 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
|
|
|
PExternalHelperAppParent*
|
|
|
|
ContentParent::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
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
|
|
|
|
parent->AddRef();
|
2010-11-21 11:21:59 -08:00
|
|
|
parent->Init(this, aMimeContentType, aContentDisposition, aForceSave, aReferrer);
|
2010-09-15 15:55:08 -07:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
|
|
|
|
{
|
|
|
|
ExternalHelperAppParent *parent = static_cast<ExternalHelperAppParent *>(aService);
|
|
|
|
parent->Release();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-18 17:15:23 -08:00
|
|
|
PStorageParent*
|
|
|
|
ContentParent::AllocPStorage(const StorageConstructData& aData)
|
|
|
|
{
|
|
|
|
return new StorageParent(aData);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::DeallocPStorage(PStorageParent* aActor)
|
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-29 13:29:45 -07:00
|
|
|
void
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::ReportChildAlreadyBlocked()
|
2010-03-29 13:29:45 -07:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-01 17:53:52 -08:00
|
|
|
bool
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::RequestRunToCompletion()
|
2010-02-01 17:53:52 -08:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth &&
|
|
|
|
BlockChild()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
2010-03-29 13:29:45 -07:00
|
|
|
mShouldCallUnblockChild = true;
|
2010-02-01 17:53:52 -08:00
|
|
|
}
|
|
|
|
return !!mRunToCompletionDepth;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:50:41 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
|
|
|
|
{
|
2010-07-26 12:59:34 -07:00
|
|
|
nsCOMPtr<nsIURI> newURI(aURI);
|
2010-08-06 11:53:39 -07:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 08:50:41 -07:00
|
|
|
history->RegisterVisitedCallback(newURI, nsnull);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:50:24 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvVisitURI(const IPC::URI& uri,
|
2010-08-02 08:29:10 -07:00
|
|
|
const IPC::URI& referrer,
|
|
|
|
const PRUint32& flags)
|
2010-07-02 08:50:24 -07:00
|
|
|
{
|
2010-07-26 12:59:34 -07:00
|
|
|
nsCOMPtr<nsIURI> ourURI(uri);
|
|
|
|
nsCOMPtr<nsIURI> ourReferrer(referrer);
|
2010-08-06 11:53:39 -07:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 08:50:24 -07:00
|
|
|
history->VisitURI(ourURI, ourReferrer, flags);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 08:53:42 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvSetURITitle(const IPC::URI& uri,
|
|
|
|
const nsString& title)
|
|
|
|
{
|
2010-07-26 12:59:34 -07:00
|
|
|
nsCOMPtr<nsIURI> ourURI(uri);
|
2010-08-06 11:53:39 -07:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 08:53:42 -07:00
|
|
|
history->SetURITitle(ourURI, title);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-20 08:19:24 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvShowFilePicker(const PRInt16& mode,
|
|
|
|
const PRInt16& selectedType,
|
|
|
|
const nsString& title,
|
|
|
|
const nsString& defaultFile,
|
|
|
|
const nsString& defaultExtension,
|
2010-11-08 18:49:00 -08:00
|
|
|
const InfallibleTArray<nsString>& filters,
|
|
|
|
const InfallibleTArray<nsString>& filterNames,
|
|
|
|
InfallibleTArray<nsString>* files,
|
2010-10-20 08:19:24 -07:00
|
|
|
PRInt16* retValue,
|
|
|
|
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;
|
|
|
|
|
|
|
|
PRUint32 count = filters.Length();
|
|
|
|
for (PRUint32 i = 0; i < count; ++i) {
|
|
|
|
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));
|
|
|
|
|
|
|
|
nsCOMPtr<nsILocalFile> singleFile;
|
|
|
|
PRBool loop = PR_TRUE;
|
|
|
|
while (NS_SUCCEEDED(fileIter->HasMoreElements(&loop)) && loop) {
|
|
|
|
fileIter->GetNext(getter_AddRefs(singleFile));
|
|
|
|
if (singleFile) {
|
|
|
|
nsAutoString filePath;
|
|
|
|
singleFile->GetPath(filePath);
|
|
|
|
files->AppendElement(filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsILocalFile> file;
|
|
|
|
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 10:14:45 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvLoadURIExternal(const IPC::URI& uri)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIExternalProtocolService> extProtService(do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
|
|
|
|
if (!extProtService)
|
|
|
|
return true;
|
|
|
|
nsCOMPtr<nsIURI> ourURI(uri);
|
|
|
|
extProtService->LoadURI(ourURI, nsnull);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-01 17:53:52 -08:00
|
|
|
/* void onDispatchedEvent (in nsIThreadInternal thread); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)
|
2010-02-01 17:53:52 -08:00
|
|
|
{
|
|
|
|
if (mOldObserver)
|
|
|
|
return mOldObserver->OnDispatchedEvent(thread);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void onProcessNextEvent (in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::OnProcessNextEvent(nsIThreadInternal *thread,
|
|
|
|
PRBool mayWait,
|
|
|
|
PRUint32 recursionDepth)
|
2010-02-01 17:53:52 -08:00
|
|
|
{
|
|
|
|
if (mRunToCompletionDepth)
|
|
|
|
++mRunToCompletionDepth;
|
|
|
|
|
|
|
|
if (mOldObserver)
|
|
|
|
return mOldObserver->OnProcessNextEvent(thread, mayWait, recursionDepth);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* void afterProcessNextEvent (in nsIThreadInternal thread, in unsigned long recursionDepth); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 11:33:33 -07:00
|
|
|
ContentParent::AfterProcessNextEvent(nsIThreadInternal *thread,
|
|
|
|
PRUint32 recursionDepth)
|
2010-02-01 17:53:52 -08:00
|
|
|
{
|
|
|
|
if (mRunToCompletionDepth &&
|
|
|
|
!--mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("... ran to completion.\n");
|
|
|
|
#endif
|
2010-03-29 13:29:45 -07:00
|
|
|
if (mShouldCallUnblockChild) {
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
UnblockChild();
|
|
|
|
}
|
2010-02-01 17:53:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mOldObserver)
|
|
|
|
return mOldObserver->AfterProcessNextEvent(thread, recursionDepth);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-08-05 11:11:32 -07:00
|
|
|
|
2010-09-15 09:44:57 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsString& aTitle,
|
|
|
|
const nsString& aText, const PRBool& aTextClickable,
|
|
|
|
const nsString& aCookie, const nsString& aName)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAlertsService> sysAlerts(do_GetService(NS_ALERTSERVICE_CONTRACTID));
|
|
|
|
if (sysAlerts) {
|
|
|
|
sysAlerts->ShowAlertNotification(aImageUrl, aTitle, aText, aTextClickable,
|
|
|
|
aCookie, this, aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-08-31 11:58:35 -07:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvSyncMessage(const nsString& aMsg, const nsString& aJSON,
|
2010-11-08 18:49:00 -08:00
|
|
|
InfallibleTArray<nsString>* aRetvals)
|
2010-08-31 11:58:35 -07:00
|
|
|
{
|
|
|
|
nsRefPtr<nsFrameMessageManager> ppm = nsFrameMessageManager::sParentProcessManager;
|
|
|
|
if (ppm) {
|
|
|
|
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
|
|
|
aMsg,PR_TRUE, aJSON, nsnull, aRetvals);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvAsyncMessage(const nsString& aMsg, const nsString& aJSON)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsFrameMessageManager> ppm = nsFrameMessageManager::sParentProcessManager;
|
|
|
|
if (ppm) {
|
|
|
|
ppm->ReceiveMessage(static_cast<nsIContentFrameMessageManager*>(ppm.get()),
|
|
|
|
aMsg, PR_FALSE, aJSON, nsnull, nsnull);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-20 21:16:37 -07:00
|
|
|
|
|
|
|
bool
|
2010-11-05 10:43:13 -07:00
|
|
|
ContentParent::RecvAddGeolocationListener()
|
2010-09-20 21:16:37 -07:00
|
|
|
{
|
2010-09-27 14:23:35 -07:00
|
|
|
if (mGeolocationWatchID == -1) {
|
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
geo->WatchPosition(this, nsnull, nsnull, &mGeolocationWatchID);
|
2010-09-20 21:16:37 -07:00
|
|
|
}
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-11-05 10:43:13 -07:00
|
|
|
ContentParent::RecvRemoveGeolocationListener()
|
2010-09-20 21:16:37 -07:00
|
|
|
{
|
2010-09-27 14:23:35 -07:00
|
|
|
if (mGeolocationWatchID != -1) {
|
|
|
|
nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
|
|
|
|
if (!geo) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
geo->ClearWatch(mGeolocationWatchID);
|
|
|
|
mGeolocationWatchID = -1;
|
2010-09-20 21:16:37 -07:00
|
|
|
}
|
2010-09-20 21:16:37 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:43:13 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvAddAccelerometerListener()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccelerometer> ac =
|
|
|
|
do_GetService(NS_ACCELEROMETER_CONTRACTID);
|
|
|
|
if (ac)
|
|
|
|
ac->AddListener(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvRemoveAccelerometerListener()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccelerometer> ac =
|
|
|
|
do_GetService(NS_ACCELEROMETER_CONTRACTID);
|
|
|
|
if (ac)
|
|
|
|
ac->RemoveListener(this);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-20 21:16:37 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentParent::HandleEvent(nsIDOMGeoPosition* postion)
|
|
|
|
{
|
|
|
|
SendGeolocationUpdate(GeoPosition(postion));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-09-23 18:39:32 -07:00
|
|
|
bool
|
|
|
|
ContentParent::RecvConsoleMessage(const nsString& aMessage)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!svc)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
nsRefPtr<nsConsoleMessage> msg(new nsConsoleMessage(aMessage.get()));
|
|
|
|
svc->LogMessage(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvScriptError(const nsString& aMessage,
|
|
|
|
const nsString& aSourceName,
|
|
|
|
const nsString& aSourceLine,
|
|
|
|
const PRUint32& aLineNumber,
|
|
|
|
const PRUint32& aColNumber,
|
|
|
|
const PRUint32& aFlags,
|
|
|
|
const nsCString& aCategory)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!svc)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> msg(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
|
|
|
nsresult rv = msg->Init(aMessage.get(), aSourceName.get(), aSourceLine.get(),
|
|
|
|
aLineNumber, aColNumber, aFlags, aCategory.get());
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
svc->LogMessage(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:43:13 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
ContentParent::OnAccelerationChange(nsIAcceleration *aAcceleration)
|
|
|
|
{
|
|
|
|
double x, y, z;
|
|
|
|
aAcceleration->GetX(&x);
|
|
|
|
aAcceleration->GetY(&y);
|
|
|
|
aAcceleration->GetZ(&z);
|
|
|
|
|
|
|
|
mozilla::dom::ContentParent::GetSingleton()->
|
|
|
|
SendAccelerationChanged(x, y, z);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|