2009-08-18 23:05:15 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set sw=4 ts=8 et tw=80 : */
|
2009-09-10 02:00:14 +04: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-26 04:13:47 +04:00
|
|
|
* Frederic Plourde <frederic.plourde@collabora.co.uk>
|
2009-09-10 02:00:14 +04: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 22:33:33 +04:00
|
|
|
#include "ContentParent.h"
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2009-08-12 22:31:48 +04:00
|
|
|
#include "TabParent.h"
|
2010-07-02 19:50:41 +04:00
|
|
|
#include "History.h"
|
2009-08-12 22:31:48 +04:00
|
|
|
#include "mozilla/ipc/TestShellParent.h"
|
2009-08-18 23:05:15 +04:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
2010-05-26 04:13:47 +04:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefBranch2.h"
|
2010-05-26 23:29:15 +04:00
|
|
|
#include "nsIPrefLocalizedString.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "nsIObserverService.h"
|
2010-07-02 19:50:24 +04:00
|
|
|
#include "nsContentUtils.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2010-03-11 08:33:00 +03:00
|
|
|
#include "nsChromeRegistryChrome.h"
|
2010-08-10 21:14:45 +04:00
|
|
|
#include "nsExternalHelperAppService.h"
|
|
|
|
#include "nsCExternalHandlerService.h"
|
2009-09-03 04:18:27 +04:00
|
|
|
|
2010-08-05 22:11:32 +04:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include "AndroidBridge.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
#endif
|
|
|
|
|
2009-08-12 22:31:48 +04:00
|
|
|
using namespace mozilla::ipc;
|
2009-08-18 23:05:15 +04:00
|
|
|
using namespace mozilla::net;
|
2010-07-02 19:50:41 +04:00
|
|
|
using namespace mozilla::places;
|
2009-09-03 04:18:27 +04:00
|
|
|
using mozilla::MonitorAutoEnter;
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2010-05-11 21:22:34 +04:00
|
|
|
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
2010-05-11 16:44:12 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent* ContentParent::gSingleton;
|
2009-08-12 20:18:08 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent*
|
|
|
|
ContentParent::GetSingleton(PRBool aForceNew)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2010-04-12 04:24:45 +04:00
|
|
|
if (gSingleton && !gSingleton->IsAlive())
|
|
|
|
gSingleton = nsnull;
|
|
|
|
|
2010-05-11 21:29:57 +04:00
|
|
|
if (!gSingleton && aForceNew) {
|
2010-07-19 22:33:33 +04:00
|
|
|
nsRefPtr<ContentParent> parent = new ContentParent();
|
2009-09-03 04:18:27 +04: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-26 04:13:47 +04:00
|
|
|
nsCOMPtr<nsIPrefBranch2> prefs
|
|
|
|
(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
if (prefs) {
|
|
|
|
prefs->AddObserver("", parent, PR_FALSE);
|
|
|
|
}
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
2010-05-11 16:44:12 +04:00
|
|
|
obs->AddObserver(
|
2010-05-11 21:22:34 +04:00
|
|
|
parent, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, PR_FALSE);
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
2010-02-02 04:53:52 +03:00
|
|
|
nsCOMPtr<nsIThreadInternal>
|
|
|
|
threadInt(do_QueryInterface(NS_GetCurrentThread()));
|
|
|
|
if (threadInt) {
|
|
|
|
threadInt->GetObserver(getter_AddRefs(parent->mOldObserver));
|
|
|
|
threadInt->SetObserver(parent);
|
|
|
|
}
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return gSingleton;
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2010-02-02 04:53:52 +03:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::ActorDestroy(ActorDestroyReason why)
|
2010-02-02 04:53:52 +03:00
|
|
|
{
|
|
|
|
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-12 04:24:45 +04:00
|
|
|
|
|
|
|
mIsAlive = false;
|
2010-02-02 04:53:52 +03:00
|
|
|
}
|
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
TabParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::CreateTab(PRUint32 aChromeFlags)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2010-07-19 22:33:33 +04:00
|
|
|
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags));
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2009-08-12 22:31:48 +04:00
|
|
|
TestShellParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::CreateTestShell()
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
2009-09-10 02:00:14 +04:00
|
|
|
return static_cast<TestShellParent*>(SendPTestShellConstructor());
|
2009-08-12 22:31:48 +04:00
|
|
|
}
|
|
|
|
|
2009-11-11 11:34:08 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::DestroyTestShell(TestShellParent* aTestShell)
|
2009-11-11 11:34:08 +03:00
|
|
|
{
|
2009-12-03 11:16:14 +03:00
|
|
|
return PTestShellParent::Send__delete__(aTestShell);
|
2009-11-11 11:34:08 +03:00
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::ContentParent()
|
|
|
|
: mMonitor("ContentParent::mMonitor")
|
2010-02-02 04:53:52 +03:00
|
|
|
, mRunToCompletionDepth(0)
|
2010-03-30 00:29:45 +04:00
|
|
|
, mShouldCallUnblockChild(false)
|
2010-04-12 04:24:45 +04:00
|
|
|
, mIsAlive(true)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2009-09-03 04:18:27 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2009-12-07 09:03:49 +03:00
|
|
|
mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content);
|
2009-11-19 00:43:53 +03:00
|
|
|
mSubprocess->AsyncLaunch();
|
2009-10-28 00:52:37 +03:00
|
|
|
Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
|
2010-03-11 08:33:00 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
|
|
|
nsChromeRegistryChrome* chromeRegistry =
|
|
|
|
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
|
|
|
|
chromeRegistry->SendRegisteredChrome(this);
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::~ContentParent()
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2009-09-03 04:18:27 +04:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
2010-04-12 04:24:45 +04: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 22:33:33 +04:00
|
|
|
ContentParent::IsAlive()
|
2010-04-12 04:24:45 +04:00
|
|
|
{
|
|
|
|
return mIsAlive;
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
|
|
|
|
2010-05-26 04:13:47 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetPrefType(const nsCString& prefName,
|
|
|
|
PRInt32* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
*retValue = 0;
|
|
|
|
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->GetPrefType(prefName.get(), retValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetBoolPref(const nsCString& prefName,
|
|
|
|
PRBool* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
*retValue = PR_FALSE;
|
|
|
|
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->GetBoolPref(prefName.get(), retValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetIntPref(const nsCString& prefName,
|
|
|
|
PRInt32* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
*retValue = 0;
|
|
|
|
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->GetIntPref(prefName.get(), retValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetCharPref(const nsCString& prefName,
|
|
|
|
nsCString* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->GetCharPref(prefName.get(), getter_Copies(*retValue));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-26 23:29:15 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetPrefLocalizedString(const nsCString& prefName,
|
|
|
|
nsString* retValue, nsresult* rv)
|
2010-05-26 23:29:15 +04:00
|
|
|
{
|
|
|
|
EnsurePrefService();
|
|
|
|
nsCOMPtr<nsIPrefLocalizedString> string;
|
|
|
|
*rv = mPrefService->GetComplexValue(prefName.get(),
|
|
|
|
NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(string));
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(*rv))
|
|
|
|
string->GetData(getter_Copies(*retValue));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-26 04:13:47 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvPrefHasUserValue(const nsCString& prefName,
|
|
|
|
PRBool* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
*retValue = PR_FALSE;
|
|
|
|
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->PrefHasUserValue(prefName.get(), retValue);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvPrefIsLocked(const nsCString& prefName,
|
|
|
|
PRBool* retValue, nsresult* rv)
|
2010-05-26 04:13:47 +04:00
|
|
|
{
|
|
|
|
*retValue = PR_FALSE;
|
|
|
|
|
|
|
|
EnsurePrefService();
|
|
|
|
*rv = mPrefService->PrefIsLocked(prefName.get(), retValue);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-28 22:09:15 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvGetChildList(const nsCString& domain,
|
|
|
|
nsTArray<nsCString>* list, nsresult* rv)
|
2010-05-28 22:09:15 +04:00
|
|
|
{
|
|
|
|
EnsurePrefService();
|
|
|
|
|
|
|
|
PRUint32 count;
|
|
|
|
char **childArray;
|
|
|
|
*rv = mPrefService->GetChildList(domain.get(), &count, &childArray);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(*rv)) {
|
|
|
|
list->SetCapacity(count);
|
|
|
|
for (PRUint32 i = 0; i < count; ++i)
|
|
|
|
*(list->AppendElement()) = childArray[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-15 18:04:25 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RecvTestPermission(const IPC::URI& aUri,
|
|
|
|
const nsCString& aType,
|
|
|
|
const PRBool& aExact,
|
|
|
|
PRUint32* retValue)
|
2010-07-15 18:04:25 +04:00
|
|
|
{
|
|
|
|
EnsurePermissionService();
|
|
|
|
|
2010-07-26 23:59:34 +04:00
|
|
|
nsCOMPtr<nsIURI> uri(aUri);
|
2010-07-15 18:04:25 +04:00
|
|
|
if (aExact) {
|
|
|
|
mPermissionService->TestExactPermission(uri, aType.get(), retValue);
|
|
|
|
} else {
|
|
|
|
mPermissionService->TestPermission(uri, aType.get(), retValue);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-26 04:13:47 +04:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::EnsurePrefService()
|
2010-05-26 04:13:47 +04: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-07-15 18:04:25 +04:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::EnsurePermissionService()
|
2010-07-15 18:04:25 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
if (!mPermissionService) {
|
|
|
|
mPermissionService = do_GetService(
|
|
|
|
NS_PERMISSIONMANAGER_CONTRACTID, &rv);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"We lost permissionService in the Chrome process !");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS2(ContentParent,
|
2010-02-02 04:53:52 +03:00
|
|
|
nsIObserver,
|
|
|
|
nsIThreadObserver)
|
2009-09-03 04:18:27 +04:00
|
|
|
|
2009-12-07 09:03:49 +03:00
|
|
|
namespace {
|
|
|
|
void
|
|
|
|
DeleteSubprocess(GeckoChildProcessHost* aSubprocess)
|
|
|
|
{
|
|
|
|
delete aSubprocess;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-03 04:18:27 +04:00
|
|
|
NS_IMETHODIMP
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::Observe(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const PRUnichar* aData)
|
2009-09-03 04:18:27 +04:00
|
|
|
{
|
|
|
|
if (!strcmp(aTopic, "xpcom-shutdown") && mSubprocess) {
|
2010-05-26 04:13:47 +04:00
|
|
|
// remove the global remote preferences observers
|
|
|
|
nsCOMPtr<nsIPrefBranch2> prefs
|
|
|
|
(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
if (prefs) {
|
|
|
|
if (gSingleton) {
|
|
|
|
prefs->RemoveObserver("", this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-07 09:03:49 +03:00
|
|
|
Close();
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
NewRunnableFunction(DeleteSubprocess, mSubprocess));
|
|
|
|
mSubprocess = nsnull;
|
2009-09-03 04:18:27 +04:00
|
|
|
}
|
2010-05-11 16:44:12 +04:00
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
if (!mIsAlive || !mSubprocess)
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-05-26 04:13:47 +04:00
|
|
|
// listening for remotePrefs...
|
|
|
|
if (!strcmp(aTopic, "nsPref:changed")) {
|
|
|
|
// We know prefs are ASCII here.
|
|
|
|
NS_LossyConvertUTF16toASCII strData(aData);
|
2010-07-19 22:33:33 +04:00
|
|
|
if (!SendNotifyRemotePrefObserver(strData))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2010-05-26 04:13:47 +04:00
|
|
|
}
|
2010-07-19 22:33:33 +04:00
|
|
|
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
|
2010-05-11 16:44:12 +04:00
|
|
|
NS_ConvertUTF16toUTF8 dataStr(aData);
|
|
|
|
const char *offline = dataStr.get();
|
2010-07-19 22:33:33 +04:00
|
|
|
if (!SendSetOffline(!strcmp(offline, "true") ? true : false))
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2010-05-11 16:44:12 +04:00
|
|
|
}
|
2009-09-03 04:18:27 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
PBrowserParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2010-03-26 21:39:39 +03:00
|
|
|
TabParent* parent = new TabParent();
|
|
|
|
if (parent){
|
|
|
|
NS_ADDREF(parent);
|
|
|
|
}
|
|
|
|
return parent;
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::DeallocPBrowser(PBrowserParent* frame)
|
2009-08-12 20:18:08 +04:00
|
|
|
{
|
2010-03-26 21:39:39 +03:00
|
|
|
TabParent* parent = static_cast<TabParent*>(frame);
|
|
|
|
NS_RELEASE(parent);
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-12 20:18:08 +04:00
|
|
|
}
|
|
|
|
|
2009-09-10 02:59:06 +04:00
|
|
|
PTestShellParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::AllocPTestShell()
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
|
|
|
return new TestShellParent();
|
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::DeallocPTestShell(PTestShellParent* shell)
|
2009-08-12 22:31:48 +04:00
|
|
|
{
|
|
|
|
delete shell;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-12 22:31:48 +04:00
|
|
|
}
|
|
|
|
|
2009-08-18 23:05:15 +04:00
|
|
|
PNeckoParent*
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::AllocPNecko()
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
|
|
|
return new NeckoParent();
|
|
|
|
}
|
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::DeallocPNecko(PNeckoParent* necko)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
|
|
|
delete necko;
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2010-03-30 00:29:45 +04:00
|
|
|
void
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::ReportChildAlreadyBlocked()
|
2010-03-30 00:29:45 +04:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-02 04:53:52 +03:00
|
|
|
bool
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::RequestRunToCompletion()
|
2010-02-02 04:53:52 +03:00
|
|
|
{
|
|
|
|
if (!mRunToCompletionDepth &&
|
|
|
|
BlockChild()) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("Running to completion...\n");
|
|
|
|
#endif
|
|
|
|
mRunToCompletionDepth = 1;
|
2010-03-30 00:29:45 +04:00
|
|
|
mShouldCallUnblockChild = true;
|
2010-02-02 04:53:52 +03:00
|
|
|
}
|
|
|
|
return !!mRunToCompletionDepth;
|
|
|
|
}
|
|
|
|
|
2010-07-02 19:50:41 +04:00
|
|
|
bool
|
|
|
|
ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
|
|
|
|
{
|
2010-07-26 23:59:34 +04:00
|
|
|
nsCOMPtr<nsIURI> newURI(aURI);
|
2010-08-06 22:53:39 +04:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 19:50:41 +04:00
|
|
|
history->RegisterVisitedCallback(newURI, nsnull);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 19:50:24 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvVisitURI(const IPC::URI& uri,
|
2010-08-02 19:29:10 +04:00
|
|
|
const IPC::URI& referrer,
|
|
|
|
const PRUint32& flags)
|
2010-07-02 19:50:24 +04:00
|
|
|
{
|
2010-07-26 23:59:34 +04:00
|
|
|
nsCOMPtr<nsIURI> ourURI(uri);
|
|
|
|
nsCOMPtr<nsIURI> ourReferrer(referrer);
|
2010-08-06 22:53:39 +04:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 19:50:24 +04:00
|
|
|
history->VisitURI(ourURI, ourReferrer, flags);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-02 19:53:42 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvSetURITitle(const IPC::URI& uri,
|
|
|
|
const nsString& title)
|
|
|
|
{
|
2010-07-26 23:59:34 +04:00
|
|
|
nsCOMPtr<nsIURI> ourURI(uri);
|
2010-08-06 22:53:39 +04:00
|
|
|
IHistory *history = nsContentUtils::GetHistory();
|
2010-07-02 19:53:42 +04:00
|
|
|
history->SetURITitle(ourURI, title);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-10 21:14:45 +04: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-02 04:53:52 +03:00
|
|
|
/* void onDispatchedEvent (in nsIThreadInternal thread); */
|
|
|
|
NS_IMETHODIMP
|
2010-07-19 22:33:33 +04:00
|
|
|
ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)
|
2010-02-02 04:53:52 +03: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 22:33:33 +04:00
|
|
|
ContentParent::OnProcessNextEvent(nsIThreadInternal *thread,
|
|
|
|
PRBool mayWait,
|
|
|
|
PRUint32 recursionDepth)
|
2010-02-02 04:53:52 +03: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 22:33:33 +04:00
|
|
|
ContentParent::AfterProcessNextEvent(nsIThreadInternal *thread,
|
|
|
|
PRUint32 recursionDepth)
|
2010-02-02 04:53:52 +03:00
|
|
|
{
|
|
|
|
if (mRunToCompletionDepth &&
|
|
|
|
!--mRunToCompletionDepth) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("... ran to completion.\n");
|
|
|
|
#endif
|
2010-03-30 00:29:45 +04:00
|
|
|
if (mShouldCallUnblockChild) {
|
|
|
|
mShouldCallUnblockChild = false;
|
|
|
|
UnblockChild();
|
|
|
|
}
|
2010-02-02 04:53:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mOldObserver)
|
|
|
|
return mOldObserver->AfterProcessNextEvent(thread, recursionDepth);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-08-05 22:11:32 +04:00
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvNotifyIMEChange(const nsString& aText,
|
|
|
|
const PRUint32& aTextLen,
|
|
|
|
const int& aStart, const int& aEnd,
|
|
|
|
const int& aNewEnd)
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
AndroidBridge::Bridge()->NotifyIMEChange(aText.get(), aTextLen,
|
|
|
|
aStart, aEnd, aNewEnd);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentParent::RecvNotifyIME(const int& aType, const int& aStatus)
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
AndroidBridge::Bridge()->NotifyIME(aType, aStatus);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2010-02-02 04:53:52 +03:00
|
|
|
|
2009-08-12 20:18:08 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|