2009-08-12 17:32:50 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: sw=4 ts=4 et : */
|
2009-08-12 09:18:08 -07:00
|
|
|
|
|
|
|
#include "ContentProcessChild.h"
|
|
|
|
#include "TabChild.h"
|
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
#include "mozilla/ipc/TestShellChild.h"
|
|
|
|
|
2009-08-25 16:07:22 -07:00
|
|
|
#include "mozilla/XPCOM.h"
|
|
|
|
#include "nsXPFEComponentsCID.h"
|
|
|
|
#include "nsIAppStartup.h"
|
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2009-08-12 17:32:50 -07:00
|
|
|
ContentProcessChild* ContentProcessChild::sSingleton;
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
ContentProcessChild::ContentProcessChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ContentProcessChild::~ContentProcessChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ContentProcessChild::Init(MessageLoop* aIOLoop, IPC::Channel* aChannel)
|
|
|
|
{
|
2009-08-12 17:32:50 -07:00
|
|
|
NS_ASSERTION(!sSingleton, "only one ContentProcessChild per child");
|
|
|
|
|
|
|
|
Open(aChannel, aIOLoop);
|
|
|
|
sSingleton = this;
|
|
|
|
|
|
|
|
return true;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
IFrameEmbeddingProtocolChild*
|
|
|
|
ContentProcessChild::IFrameEmbeddingConstructor(const MagicWindowHandle& hwnd)
|
|
|
|
{
|
2009-08-25 16:07:22 -07:00
|
|
|
IFrameEmbeddingProtocolChild* iframe = new TabChild(hwnd);
|
|
|
|
if (iframe && mIFrames.AppendElement(iframe)) {
|
|
|
|
return iframe;
|
|
|
|
}
|
|
|
|
delete iframe;
|
|
|
|
return nsnull;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ContentProcessChild::IFrameEmbeddingDestructor(IFrameEmbeddingProtocolChild* iframe)
|
|
|
|
{
|
2009-08-25 16:07:22 -07:00
|
|
|
mIFrames.RemoveElement(iframe);
|
2009-08-12 17:32:50 -07:00
|
|
|
return NS_OK;
|
2009-08-12 09:18:08 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 11:31:48 -07:00
|
|
|
TestShellProtocolChild*
|
|
|
|
ContentProcessChild::TestShellConstructor()
|
|
|
|
{
|
2009-08-25 16:07:22 -07:00
|
|
|
TestShellProtocolChild* testshell = new TestShellChild();
|
|
|
|
if (testshell && mTestShells.AppendElement(testshell)) {
|
|
|
|
return testshell;
|
|
|
|
}
|
|
|
|
delete testshell;
|
|
|
|
return nsnull;
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ContentProcessChild::TestShellDestructor(TestShellProtocolChild* shell)
|
|
|
|
{
|
2009-08-25 16:07:22 -07:00
|
|
|
mTestShells.RemoveElement(shell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ContentProcessChild::Quit()
|
|
|
|
{
|
|
|
|
mIFrames.Clear();
|
|
|
|
mTestShells.Clear();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
|
|
|
|
if (appStartup) {
|
|
|
|
appStartup->Quit(nsIAppStartup::eForceQuit);
|
|
|
|
}
|
2009-08-12 11:31:48 -07:00
|
|
|
}
|
|
|
|
|
2009-08-12 09:18:08 -07:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|