mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Bug 570620, part d: Add some helper methods and functions to TabChild and TabParent. sr=smaug
This commit is contained in:
parent
47008bf78c
commit
8861068e37
@ -60,12 +60,16 @@
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIDialogCreator.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
@ -293,6 +297,25 @@ private:
|
||||
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
|
||||
};
|
||||
|
||||
inline TabChild*
|
||||
GetTabChildFrom(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsITabChild> tc = do_GetInterface(aDocShell);
|
||||
return static_cast<TabChild*>(tc.get());
|
||||
}
|
||||
|
||||
inline TabChild*
|
||||
GetTabChildFrom(nsIPresShell* aPresShell)
|
||||
{
|
||||
nsIDocument* doc = aPresShell->GetDocument();
|
||||
if (!doc) {
|
||||
return nsnull;
|
||||
}
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
|
||||
return GetTabChildFrom(docShell);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,12 +95,9 @@ TabParent::~TabParent()
|
||||
void
|
||||
TabParent::ActorDestroy(ActorDestroyReason why)
|
||||
{
|
||||
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(mFrameElement);
|
||||
if (frameLoaderOwner) {
|
||||
nsRefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
|
||||
if (frameLoader) {
|
||||
frameLoader->DestroyChild();
|
||||
}
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader) {
|
||||
frameLoader->DestroyChild();
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,29 +513,25 @@ TabParent::ReceiveMessage(const nsString& aMessage,
|
||||
const nsString& aJSON,
|
||||
nsTArray<nsString>* aJSONRetVal)
|
||||
{
|
||||
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner =
|
||||
do_QueryInterface(mFrameElement);
|
||||
if (frameLoaderOwner) {
|
||||
nsRefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
|
||||
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
||||
nsFrameMessageManager* manager = frameLoader->GetFrameMessageManager();
|
||||
JSContext* ctx = manager->GetJSContext();
|
||||
JSAutoRequest ar(ctx);
|
||||
PRUint32 len = 0; //TODO: obtain a real value in bug 572685
|
||||
// Because we want JS messages to have always the same properties,
|
||||
// create array even if len == 0.
|
||||
JSObject* objectsArray = JS_NewArrayObject(ctx, len, NULL);
|
||||
if (!objectsArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
manager->ReceiveMessage(mFrameElement,
|
||||
aMessage,
|
||||
aSync,
|
||||
aJSON,
|
||||
objectsArray,
|
||||
aJSONRetVal);
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (frameLoader && frameLoader->GetFrameMessageManager()) {
|
||||
nsFrameMessageManager* manager = frameLoader->GetFrameMessageManager();
|
||||
JSContext* ctx = manager->GetJSContext();
|
||||
JSAutoRequest ar(ctx);
|
||||
PRUint32 len = 0; //TODO: obtain a real value in bug 572685
|
||||
// Because we want JS messages to have always the same properties,
|
||||
// create array even if len == 0.
|
||||
JSObject* objectsArray = JS_NewArrayObject(ctx, len, NULL);
|
||||
if (!objectsArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
manager->ReceiveMessage(mFrameElement,
|
||||
aMessage,
|
||||
aSync,
|
||||
aJSON,
|
||||
objectsArray,
|
||||
aJSONRetVal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -709,14 +702,19 @@ TabParent::HandleDelayedDialogs()
|
||||
PRBool
|
||||
TabParent::ShouldDelayDialogs()
|
||||
{
|
||||
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(mFrameElement);
|
||||
NS_ENSURE_TRUE(frameLoaderOwner, PR_TRUE);
|
||||
nsRefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
NS_ENSURE_TRUE(frameLoader, PR_TRUE);
|
||||
PRBool delay = PR_FALSE;
|
||||
frameLoader->GetDelayRemoteDialogs(&delay);
|
||||
return delay;
|
||||
}
|
||||
|
||||
already_AddRefed<nsFrameLoader>
|
||||
TabParent::GetFrameLoader() const
|
||||
{
|
||||
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(mFrameElement);
|
||||
return frameLoaderOwner ? frameLoaderOwner->GetFrameLoader() : nsnull;
|
||||
}
|
||||
|
||||
} // namespace tabs
|
||||
} // namespace mozilla
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsIAuthPromptProvider.h"
|
||||
|
||||
class nsFrameLoader;
|
||||
class nsIURI;
|
||||
class nsIDOMElement;
|
||||
struct gfxMatrix;
|
||||
@ -222,6 +223,9 @@ protected:
|
||||
nsTArray<DelayedDialogData*> mDelayedDialogs;
|
||||
|
||||
PRBool ShouldDelayDialogs();
|
||||
|
||||
private:
|
||||
already_AddRefed<nsFrameLoader> GetFrameLoader() const;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -96,6 +96,7 @@
|
||||
#define MAX_GEO_REQUESTS_PER_WINDOW 1500
|
||||
|
||||
using mozilla::unused; // <snicker>
|
||||
using namespace mozilla::dom;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsDOMGeoPositionError
|
||||
@ -1014,27 +1015,12 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
|
||||
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());
|
||||
TabChild* child = GetTabChildFrom(window->GetDocShell());
|
||||
|
||||
mozilla::dom::PGeolocationRequestChild* a =
|
||||
child->SendPGeolocationRequestConstructor(request, IPC::URI(mURI));
|
||||
PGeolocationRequestChild* a =
|
||||
child->SendPGeolocationRequestConstructor(request, IPC::URI(mURI));
|
||||
|
||||
(void) a->Sendprompt();
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user