зеркало из https://github.com/mozilla/pjs.git
Bug 552822 - IPC remoting of geolocation prompt. r=olli/r=jdm
This commit is contained in:
Родитель
ade1133f29
Коммит
b2b1085458
|
@ -109,6 +109,11 @@ ifdef MOZ_JSDEBUGGER
|
|||
DEFINES += -DMOZ_JSDEBUGGER
|
||||
endif
|
||||
|
||||
ifdef MOZ_IPC
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef MOZ_X11
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "base/basictypes.h"
|
||||
#endif
|
||||
|
||||
// Local Includes
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsScreen.h"
|
||||
|
|
|
@ -81,6 +81,7 @@ XPIDLSRCS = \
|
|||
nsIDOMClientRectList.idl \
|
||||
nsIFocusManager.idl \
|
||||
nsIQueryContentEventResult.idl \
|
||||
nsITabChild.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
interface nsIURI;
|
||||
interface nsIDOMWindow;
|
||||
interface nsIDOMElement;
|
||||
interface nsIDOMGeoPosition;
|
||||
interface nsIGeolocationPrompt;
|
||||
|
||||
|
@ -54,6 +55,8 @@ interface nsIGeolocationRequest : nsISupports {
|
|||
readonly attribute nsIURI requestingURI;
|
||||
readonly attribute nsIDOMWindow requestingWindow;
|
||||
|
||||
readonly attribute nsIDOMElement requestingElement;
|
||||
|
||||
void cancel();
|
||||
void allow();
|
||||
};
|
||||
|
|
|
@ -77,6 +77,7 @@ include $(topsrcdir)/config/rules.mk
|
|||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../../content/base/src \
|
||||
-I$(srcdir)/../../content/events/src \
|
||||
-I$(srcdir)/../src/geolocation \
|
||||
-I$(topsrcdir)/chrome/src \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -42,11 +42,14 @@ include protocol PDocumentRenderer;
|
|||
include protocol PDocumentRendererShmem;
|
||||
include protocol PObjectWrapper;
|
||||
include protocol PContextWrapper;
|
||||
include protocol PGeolocationRequest;
|
||||
|
||||
include "mozilla/TabTypes.h";
|
||||
include "TabMessageUtils.h";
|
||||
include "gfxMatrix.h";
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
|
||||
using IPC::URI;
|
||||
using MagicWindowHandle;
|
||||
using RemoteDOMEvent;
|
||||
using gfxMatrix;
|
||||
|
@ -60,6 +63,7 @@ rpc protocol PIFrameEmbedding
|
|||
manages PDocumentRenderer;
|
||||
manages PDocumentRendererShmem;
|
||||
manages PContextWrapper;
|
||||
manages PGeolocationRequest;
|
||||
|
||||
child:
|
||||
__delete__();
|
||||
|
@ -99,6 +103,9 @@ parent:
|
|||
returns (nsString[] retval);
|
||||
|
||||
sendAsyncMessageToParent(nsString aMessage, nsString aJSON);
|
||||
|
||||
PGeolocationRequest(URI uri);
|
||||
|
||||
child:
|
||||
createWidget(MagicWindowHandle parentWidget);
|
||||
|
||||
|
|
|
@ -137,11 +137,12 @@ TabChild::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS10(TabChild, nsIWebBrowserChrome, nsIWebBrowserChrome2,
|
||||
NS_IMPL_ISUPPORTS11(TabChild, nsIWebBrowserChrome, nsIWebBrowserChrome2,
|
||||
nsIEmbeddingSiteWindow, nsIEmbeddingSiteWindow2,
|
||||
nsIWebBrowserChromeFocus, nsIInterfaceRequestor,
|
||||
nsIWindowProvider, nsIWebProgressListener,
|
||||
nsIWebProgressListener2, nsSupportsWeakReference)
|
||||
nsIWebProgressListener2, nsSupportsWeakReference,
|
||||
nsITabChild)
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChild::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
|
||||
|
@ -670,6 +671,22 @@ TabChild::RecvPDocumentRendererShmemConstructor(
|
|||
aBuf);
|
||||
}
|
||||
|
||||
/* The PGeolocationRequestChild actor is implemented by a refcounted
|
||||
nsGeolocationRequest, and has an identical lifetime. */
|
||||
|
||||
PGeolocationRequestChild*
|
||||
TabChild::AllocPGeolocationRequest(const IPC::URI&)
|
||||
{
|
||||
NS_RUNTIMEABORT("unused");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::DeallocPGeolocationRequest(PGeolocationRequestChild* actor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::RecvactivateFrameEvent(const nsString& aType, const bool& capture)
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITabChild.h"
|
||||
|
||||
class gfxMatrix;
|
||||
|
||||
|
@ -148,7 +149,8 @@ class TabChild : public PIFrameEmbeddingChild,
|
|||
public nsIWebBrowserChromeFocus,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWindowProvider,
|
||||
public nsSupportsWeakReference
|
||||
public nsSupportsWeakReference,
|
||||
public nsITabChild
|
||||
{
|
||||
public:
|
||||
TabChild();
|
||||
|
@ -236,6 +238,9 @@ public:
|
|||
const PRInt32& aBufH,
|
||||
Shmem& aBuf);
|
||||
|
||||
virtual PGeolocationRequestChild* AllocPGeolocationRequest(const IPC::URI& uri);
|
||||
virtual bool DeallocPGeolocationRequest(PGeolocationRequestChild* actor);
|
||||
|
||||
nsIWebNavigation* WebNavigation() { return mWebNav; }
|
||||
|
||||
JSContext* GetJSContext() { return mCx; }
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "jsarray.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGeolocationOOP.h"
|
||||
#include "nsIDOMNSHTMLFrameElement.h"
|
||||
|
||||
using mozilla::ipc::DocumentRendererParent;
|
||||
using mozilla::ipc::DocumentRendererShmemParent;
|
||||
|
@ -449,6 +451,19 @@ TabParent::DeallocPContextWrapper(PContextWrapperParent* actor)
|
|||
return true;
|
||||
}
|
||||
|
||||
PGeolocationRequestParent*
|
||||
TabParent::AllocPGeolocationRequest(const URI::URI& uri)
|
||||
{
|
||||
return new GeolocationRequestParent(mFrameElement, uri);
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::DeallocPGeolocationRequest(PGeolocationRequestParent* actor)
|
||||
{
|
||||
delete actor;
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool
|
||||
TabParent::GetGlobalJSObject(JSContext* cx, JSObject** globalp)
|
||||
{
|
||||
|
|
|
@ -160,6 +160,9 @@ public:
|
|||
virtual PContextWrapperParent* AllocPContextWrapper();
|
||||
virtual bool DeallocPContextWrapper(PContextWrapperParent* actor);
|
||||
|
||||
virtual PGeolocationRequestParent* AllocPGeolocationRequest(const IPC::URI& uri);
|
||||
virtual bool DeallocPGeolocationRequest(PGeolocationRequestParent* actor);
|
||||
|
||||
JSBool GetGlobalJSObject(JSContext* cx, JSObject** globalp);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
|
|
@ -59,6 +59,9 @@ EXTRA_DSO_LDOPTS = \
|
|||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(topsrcdir)/dom/base \
|
||||
-I$(topsrcdir)/dom/ipc \
|
||||
-I$(topsrcdir)/content/base/src \
|
||||
-I$(topsrcdir)/content/events/src \
|
||||
$(NULL)
|
||||
|
||||
ifdef WINCE_WINDOWS_MOBILE
|
||||
|
@ -76,6 +79,8 @@ EXTRA_COMPONENTS = \
|
|||
$(NULL)
|
||||
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_LAYOUT
|
||||
|
|
|
@ -34,6 +34,27 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "nsGeolocationOOP.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "mozilla/dom/PIFrameEmbeddingChild.h"
|
||||
#include "mozilla/dom/PIFrameEmbeddingParent.h"
|
||||
#include "mozilla/dom/ContentProcessChild.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsFrameManager.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsIFrameLoader.h"
|
||||
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIWebProgressListener2.h"
|
||||
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "TabChild.h"
|
||||
#endif
|
||||
|
||||
#include "nsGeolocation.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -230,6 +251,14 @@ nsGeolocationRequest::GetRequestingWindow(nsIDOMWindow * *aRequestingWindow)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequest::GetRequestingElement(nsIDOMElement * *aRequestingElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingElement);
|
||||
*aRequestingElement = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequest::Cancel()
|
||||
{
|
||||
|
@ -340,6 +369,16 @@ nsGeolocationRequest::Shutdown()
|
|||
mErrorCallback = nsnull;
|
||||
}
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
bool nsGeolocationRequest::Recv__delete__(const bool& allow)
|
||||
{
|
||||
if (allow)
|
||||
(void) Allow();
|
||||
else
|
||||
(void) Cancel();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
////////////////////////////////////////////////////
|
||||
// nsGeolocationService
|
||||
////////////////////////////////////////////////////
|
||||
|
@ -856,12 +895,7 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
|||
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
|
||||
|
||||
if (mOwner) {
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
if (prompt == nsnull)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
prompt->Prompt(request);
|
||||
|
||||
RegisterRequestWithPrompt(request);
|
||||
mPendingCallbacks.AppendElement(request);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -900,11 +934,7 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback,
|
|||
return NS_ERROR_FAILURE; // this as OKAY. not sure why we wouldn't throw. xxx dft
|
||||
|
||||
if (mOwner) {
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
if (prompt == nsnull)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
prompt->Prompt(request);
|
||||
RegisterRequestWithPrompt(request);
|
||||
|
||||
// need to hand back an index/reference.
|
||||
mWatchingCallbacks.AppendElement(request);
|
||||
|
@ -962,7 +992,150 @@ nsGeolocation::WindowOwnerStillExists()
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mOwner);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
nsIDocShell *docshell = window->GetDocShell();
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
|
||||
NS_ASSERTION(item, "doc shell tree item is null");
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeOwner> owner;
|
||||
item->GetTreeOwner(getter_AddRefs(owner));
|
||||
NS_ASSERTION(owner, "doc shell tree owner is null");
|
||||
|
||||
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
|
||||
if (!tabchild)
|
||||
return;
|
||||
|
||||
// because owner implements nsITabChild, we can assume that it is
|
||||
// the one and only TabChild.
|
||||
mozilla::dom::TabChild* child = static_cast<mozilla::dom::TabChild*>(tabchild.get());
|
||||
|
||||
mozilla::dom::PGeolocationRequestChild* a =
|
||||
child->SendPGeolocationRequestConstructor(request, IPC::URI(mURI));
|
||||
|
||||
(void) a->Sendprompt();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
NS_ASSERTION(prompt, "null geolocation prompt. geolocation will not work without one.");
|
||||
if (prompt)
|
||||
prompt->Prompt(request);
|
||||
}
|
||||
|
||||
#ifndef WINCE_WINDOWS_MOBILE
|
||||
DOMCI_DATA(GeoPositionCoords, void)
|
||||
DOMCI_DATA(GeoPosition, void)
|
||||
#endif
|
||||
|
||||
nsGeolocationRequestProxy::nsGeolocationRequestProxy()
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsGeolocationRequestProxy);
|
||||
}
|
||||
|
||||
nsGeolocationRequestProxy::~nsGeolocationRequestProxy()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsGeolocationRequestProxy);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGeolocationRequestProxy::Init(mozilla::dom::GeolocationRequestParent* parent)
|
||||
{
|
||||
NS_ASSERTION(parent, "null parent");
|
||||
mParent = parent;
|
||||
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
NS_ASSERTION(prompt, "null geolocation prompt. geolocation will not work without one.");
|
||||
if (!prompt)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
(void) prompt->Prompt(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGeolocationRequestProxy, nsIGeolocationRequest);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequestProxy::GetRequestingWindow(nsIDOMWindow * *aRequestingWindow)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingWindow);
|
||||
*aRequestingWindow = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequestProxy::GetRequestingURI(nsIURI * *aRequestingURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingURI);
|
||||
NS_ASSERTION(mParent, "No parent for request");
|
||||
|
||||
NS_ADDREF(*aRequestingURI = mParent->mURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequestProxy::GetRequestingElement(nsIDOMElement * *aRequestingElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRequestingElement);
|
||||
NS_ASSERTION(mParent && mParent->mElement.get(), "No parent for request");
|
||||
NS_ADDREF(*aRequestingElement = mParent->mElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequestProxy::Cancel()
|
||||
{
|
||||
NS_ASSERTION(mParent, "No parent for request");
|
||||
(void) mozilla::dom::GeolocationRequestParent::Send__delete__(mParent, false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequestProxy::Allow()
|
||||
{
|
||||
NS_ASSERTION(mParent, "No parent for request");
|
||||
(void) mozilla::dom::GeolocationRequestParent::Send__delete__(mParent, true);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
GeolocationRequestParent::GeolocationRequestParent(nsIDOMElement *element, const IPC::URI& uri)
|
||||
{
|
||||
MOZ_COUNT_CTOR(GeolocationRequestParent);
|
||||
|
||||
mURI = uri;
|
||||
mElement = element;
|
||||
mProxy = nsnull;
|
||||
}
|
||||
|
||||
GeolocationRequestParent::~GeolocationRequestParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(GeolocationRequestParent);
|
||||
delete mProxy;
|
||||
}
|
||||
|
||||
bool
|
||||
GeolocationRequestParent::Recvprompt()
|
||||
{
|
||||
mProxy = new nsGeolocationRequestProxy();
|
||||
NS_ASSERTION(mProxy, "Alloc of request proxy failed");
|
||||
if (NS_FAILED(mProxy->Init(this)))
|
||||
mProxy->Cancel();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "mozilla/dom/PGeolocationRequestChild.h"
|
||||
#endif
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -61,7 +64,12 @@
|
|||
class nsGeolocationService;
|
||||
class nsGeolocation;
|
||||
|
||||
class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallback
|
||||
class nsGeolocationRequest
|
||||
: public nsIGeolocationRequest
|
||||
, public nsITimerCallback
|
||||
#ifdef MOZ_IPC
|
||||
, public mozilla::dom::PGeolocationRequestChild
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -83,6 +91,10 @@ class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallba
|
|||
|
||||
~nsGeolocationRequest();
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
bool Recv__delete__(const bool& allow);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
void NotifyError(PRInt16 errorCode);
|
||||
|
@ -204,6 +216,8 @@ private:
|
|||
|
||||
~nsGeolocation();
|
||||
|
||||
void RegisterRequestWithPrompt(nsGeolocationRequest* request);
|
||||
|
||||
// Two callback arrays. The first |mPendingCallbacks| holds objects for only
|
||||
// one callback and then they are released/removed from the array. The second
|
||||
// |mWatchingCallbacks| holds objects until the object is explictly removed or
|
||||
|
@ -223,3 +237,4 @@ private:
|
|||
// owning back pointer.
|
||||
nsRefPtr<nsGeolocationService> mService;
|
||||
};
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ EXPORT_LIBRARY = 1
|
|||
## When you add IPDL files to a source directory, list the directory here.
|
||||
##
|
||||
IPDLDIRS = \
|
||||
dom/src/geolocation \
|
||||
dom/plugins \
|
||||
dom/ipc \
|
||||
netwerk/ipc \
|
||||
|
|
|
@ -237,6 +237,11 @@ OS_LIBS += -framework CoreAudio -framework AudioToolbox -framework AudioUnit -fr
|
|||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_IPC
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../base \
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
#include "base/basictypes.h"
|
||||
#endif
|
||||
|
||||
#include "xpcmodule.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsContentCID.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче