Bug 1130096 - Convert embedding/browser/ to Gecko style. r=mccr8

This commit is contained in:
Birunthan Mohanathas 2015-05-11 12:35:13 -07:00
parent 24ee07fb04
commit 1956a8969b
14 changed files with 1289 additions and 1271 deletions

View File

@ -25,32 +25,29 @@ NS_DEFINE_NAMED_CID(NS_COMMANDHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_WEBBROWSERCONTENTPOLICY_CID);
static const mozilla::Module::CIDEntry kWebBrowserCIDs[] = {
{ &kNS_WEBBROWSER_CID, false, nullptr, nsWebBrowserConstructor },
{ &kNS_COMMANDHANDLER_CID, false, nullptr, nsCommandHandlerConstructor },
{ &kNS_WEBBROWSERCONTENTPOLICY_CID, false, nullptr, nsWebBrowserContentPolicyConstructor },
{ nullptr }
{ &kNS_WEBBROWSER_CID, false, nullptr, nsWebBrowserConstructor },
{ &kNS_COMMANDHANDLER_CID, false, nullptr, nsCommandHandlerConstructor },
{ &kNS_WEBBROWSERCONTENTPOLICY_CID, false, nullptr, nsWebBrowserContentPolicyConstructor },
{ nullptr }
};
static const mozilla::Module::ContractIDEntry kWebBrowserContracts[] = {
{ NS_WEBBROWSER_CONTRACTID, &kNS_WEBBROWSER_CID },
{ NS_COMMANDHANDLER_CONTRACTID, &kNS_COMMANDHANDLER_CID },
{ NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, &kNS_WEBBROWSERCONTENTPOLICY_CID },
{ nullptr }
{ NS_WEBBROWSER_CONTRACTID, &kNS_WEBBROWSER_CID },
{ NS_COMMANDHANDLER_CONTRACTID, &kNS_COMMANDHANDLER_CID },
{ NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, &kNS_WEBBROWSERCONTENTPOLICY_CID },
{ nullptr }
};
static const mozilla::Module::CategoryEntry kWebBrowserCategories[] = {
{ "content-policy", NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, NS_WEBBROWSERCONTENTPOLICY_CONTRACTID },
{ nullptr }
{ "content-policy", NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, NS_WEBBROWSERCONTENTPOLICY_CONTRACTID },
{ nullptr }
};
static const mozilla::Module kWebBrowserModule = {
mozilla::Module::kVersion,
kWebBrowserCIDs,
kWebBrowserContracts,
kWebBrowserCategories
mozilla::Module::kVersion,
kWebBrowserCIDs,
kWebBrowserContracts,
kWebBrowserCategories
};
NSMODULE_DEFN(Browser_Embedding_Module) = &kWebBrowserModule;

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -9,6 +9,6 @@
#include "nsITooltipTextProvider.h"
#define NS_TOOLTIPTEXTPROVIDER_CONTRACTID \
"@mozilla.org/embedcomp/tooltiptextprovider;1"
"@mozilla.org/embedcomp/tooltiptextprovider;1"
#endif

View File

@ -11,8 +11,8 @@
#include "nsMemory.h"
#include "nsPIDOMWindow.h"
nsCommandHandler::nsCommandHandler() :
mWindow(nullptr)
nsCommandHandler::nsCommandHandler()
: mWindow(nullptr)
{
}
@ -20,128 +20,125 @@ nsCommandHandler::~nsCommandHandler()
{
}
nsresult nsCommandHandler::GetCommandHandler(nsICommandHandler **aCommandHandler)
nsresult
nsCommandHandler::GetCommandHandler(nsICommandHandler** aCommandHandler)
{
NS_ENSURE_ARG_POINTER(aCommandHandler);
NS_ENSURE_ARG_POINTER(aCommandHandler);
*aCommandHandler = nullptr;
if (mWindow == nullptr)
{
return NS_ERROR_FAILURE;
*aCommandHandler = nullptr;
if (!mWindow) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mWindow));
if (!window) {
return NS_ERROR_FAILURE;
}
// Get the document tree owner
nsCOMPtr<nsIDocShellTreeItem> docShellAsTreeItem =
do_QueryInterface(window->GetDocShell());
nsIDocShellTreeOwner* treeOwner = nullptr;
docShellAsTreeItem->GetTreeOwner(&treeOwner);
// Make sure the tree owner is an an nsDocShellTreeOwner object
// by QI'ing for a hidden interface. If it doesn't have the interface
// then it's not safe to do the casting.
nsCOMPtr<nsICDocShellTreeOwner> realTreeOwner(do_QueryInterface(treeOwner));
if (realTreeOwner) {
nsDocShellTreeOwner* tree = static_cast<nsDocShellTreeOwner*>(treeOwner);
if (tree->mTreeOwner) {
nsresult rv;
rv = tree->mTreeOwner->QueryInterface(NS_GET_IID(nsICommandHandler),
(void**)aCommandHandler);
NS_RELEASE(treeOwner);
return rv;
}
nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(mWindow));
if (!window)
{
return NS_ERROR_FAILURE;
}
NS_RELEASE(treeOwner);
}
// Get the document tree owner
*aCommandHandler = nullptr;
nsCOMPtr<nsIDocShellTreeItem> docShellAsTreeItem =
do_QueryInterface(window->GetDocShell());
nsIDocShellTreeOwner *treeOwner = nullptr;
docShellAsTreeItem->GetTreeOwner(&treeOwner);
// Make sure the tree owner is an an nsDocShellTreeOwner object
// by QI'ing for a hidden interface. If it doesn't have the interface
// then it's not safe to do the casting.
nsCOMPtr<nsICDocShellTreeOwner> realTreeOwner(do_QueryInterface(treeOwner));
if (realTreeOwner)
{
nsDocShellTreeOwner *tree = static_cast<nsDocShellTreeOwner *>(treeOwner);
if (tree->mTreeOwner)
{
nsresult rv;
rv = tree->mTreeOwner->QueryInterface(NS_GET_IID(nsICommandHandler), (void **)aCommandHandler);
NS_RELEASE(treeOwner);
return rv;
}
NS_RELEASE(treeOwner);
}
*aCommandHandler = nullptr;
return NS_OK;
return NS_OK;
}
NS_IMPL_ADDREF(nsCommandHandler)
NS_IMPL_RELEASE(nsCommandHandler)
NS_INTERFACE_MAP_BEGIN(nsCommandHandler)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandHandler)
NS_INTERFACE_MAP_ENTRY(nsICommandHandlerInit)
NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandHandler)
NS_INTERFACE_MAP_ENTRY(nsICommandHandlerInit)
NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
NS_INTERFACE_MAP_END
///////////////////////////////////////////////////////////////////////////////
// nsICommandHandlerInit implementation
/* attribute nsIDocShell docShell; */
NS_IMETHODIMP nsCommandHandler::GetWindow(nsIDOMWindow * *aWindow)
NS_IMETHODIMP
nsCommandHandler::GetWindow(nsIDOMWindow** aWindow)
{
*aWindow = nullptr;
return NS_OK;
*aWindow = nullptr;
return NS_OK;
}
NS_IMETHODIMP nsCommandHandler::SetWindow(nsIDOMWindow * aWindow)
NS_IMETHODIMP
nsCommandHandler::SetWindow(nsIDOMWindow* aWindow)
{
if (aWindow == nullptr)
{
return NS_ERROR_FAILURE;
}
mWindow = aWindow;
return NS_OK;
if (!aWindow) {
return NS_ERROR_FAILURE;
}
mWindow = aWindow;
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
// nsICommandHandler implementation
/* string exec (in string aCommand, in string aStatus); */
NS_IMETHODIMP nsCommandHandler::Exec(const char *aCommand, const char *aStatus, char **aResult)
NS_IMETHODIMP
nsCommandHandler::Exec(const char* aCommand, const char* aStatus,
char** aResult)
{
NS_ENSURE_ARG_POINTER(aCommand);
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_ARG_POINTER(aCommand);
NS_ENSURE_ARG_POINTER(aResult);
nsCOMPtr<nsICommandHandler> commandHandler;
GetCommandHandler(getter_AddRefs(commandHandler));
nsCOMPtr<nsICommandHandler> commandHandler;
GetCommandHandler(getter_AddRefs(commandHandler));
// Call the client's command handler to deal with this command
if (commandHandler)
{
*aResult = nullptr;
return commandHandler->Exec(aCommand, aStatus, aResult);
}
// Call the client's command handler to deal with this command
if (commandHandler) {
*aResult = nullptr;
return commandHandler->Exec(aCommand, aStatus, aResult);
}
// Return an empty string
const char szEmpty[] = "";
*aResult = (char *) nsMemory::Clone(szEmpty, sizeof(szEmpty));
// Return an empty string
const char szEmpty[] = "";
*aResult = (char*)nsMemory::Clone(szEmpty, sizeof(szEmpty));
return NS_OK;
return NS_OK;
}
/* string query (in string aCommand, in string aStatus); */
NS_IMETHODIMP nsCommandHandler::Query(const char *aCommand, const char *aStatus, char **aResult)
NS_IMETHODIMP
nsCommandHandler::Query(const char* aCommand, const char* aStatus,
char** aResult)
{
NS_ENSURE_ARG_POINTER(aCommand);
NS_ENSURE_ARG_POINTER(aResult);
NS_ENSURE_ARG_POINTER(aCommand);
NS_ENSURE_ARG_POINTER(aResult);
nsCOMPtr<nsICommandHandler> commandHandler;
GetCommandHandler(getter_AddRefs(commandHandler));
nsCOMPtr<nsICommandHandler> commandHandler;
GetCommandHandler(getter_AddRefs(commandHandler));
// Call the client's command handler to deal with this command
if (commandHandler)
{
*aResult = nullptr;
return commandHandler->Query(aCommand, aStatus, aResult);
}
// Call the client's command handler to deal with this command
if (commandHandler) {
*aResult = nullptr;
return commandHandler->Query(aCommand, aStatus, aResult);
}
// Return an empty string
const char szEmpty[] = "";
*aResult = (char *) nsMemory::Clone(szEmpty, sizeof(szEmpty));
// Return an empty string
const char szEmpty[] = "";
*aResult = (char*)nsMemory::Clone(szEmpty, sizeof(szEmpty));
return NS_OK;
return NS_OK;
}

View File

@ -11,24 +11,24 @@
#include "nsICommandHandler.h"
#include "nsIDOMWindow.h"
class nsCommandHandler :
public nsICommandHandlerInit,
public nsICommandHandler
class nsCommandHandler
: public nsICommandHandlerInit
, public nsICommandHandler
{
nsIDOMWindow *mWindow;
nsresult GetCommandHandler(nsICommandHandler **aCommandHandler);
public:
nsCommandHandler();
nsCommandHandler();
NS_DECL_ISUPPORTS
NS_DECL_NSICOMMANDHANDLERINIT
NS_DECL_NSICOMMANDHANDLER
NS_DECL_ISUPPORTS
NS_DECL_NSICOMMANDHANDLERINIT
NS_DECL_NSICOMMANDHANDLER
protected:
virtual ~nsCommandHandler();
virtual ~nsCommandHandler();
private:
nsresult GetCommandHandler(nsICommandHandler** aCommandHandler);
nsIDOMWindow* mWindow;
};
#endif

View File

@ -28,11 +28,6 @@
#include "nsAutoPtr.h"
#include "imgRequestProxy.h"
//*****************************************************************************
// class nsContextMenuInfo
//*****************************************************************************
NS_IMPL_ISUPPORTS(nsContextMenuInfo, nsIContextMenuInfo)
nsContextMenuInfo::nsContextMenuInfo()
@ -43,35 +38,33 @@ nsContextMenuInfo::~nsContextMenuInfo()
{
}
/* readonly attribute nsIDOMEvent mouseEvent; */
NS_IMETHODIMP
nsContextMenuInfo::GetMouseEvent(nsIDOMEvent **aEvent)
nsContextMenuInfo::GetMouseEvent(nsIDOMEvent** aEvent)
{
NS_ENSURE_ARG_POINTER(aEvent);
NS_IF_ADDREF(*aEvent = mMouseEvent);
return NS_OK;
}
/* readonly attribute nsIDOMNode targetNode; */
NS_IMETHODIMP
nsContextMenuInfo::GetTargetNode(nsIDOMNode **aNode)
nsContextMenuInfo::GetTargetNode(nsIDOMNode** aNode)
{
NS_ENSURE_ARG_POINTER(aNode);
NS_IF_ADDREF(*aNode = mDOMNode);
return NS_OK;
}
/* readonly attribute AString associatedLink; */
NS_IMETHODIMP
nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
{
NS_ENSURE_STATE(mAssociatedLink);
aHRef.Truncate(0);
nsCOMPtr<nsIDOMElement> content(do_QueryInterface(mAssociatedLink));
nsAutoString localName;
if (content)
if (content) {
content->GetLocalName(localName);
}
nsCOMPtr<nsIDOMElement> linkContent;
ToLowerCase(localName);
@ -83,27 +76,28 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
if (hasAttr) {
linkContent = content;
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(linkContent));
if (anchor)
if (anchor) {
anchor->GetHref(aHRef);
else {
} else {
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(linkContent));
if (area)
if (area) {
area->GetHref(aHRef);
else {
} else {
nsCOMPtr<nsIDOMHTMLLinkElement> link(do_QueryInterface(linkContent));
if (link)
if (link) {
link->GetHref(aHRef);
}
}
}
}
}
else {
} else {
nsCOMPtr<nsIDOMNode> curr;
mAssociatedLink->GetParentNode(getter_AddRefs(curr));
while (curr) {
content = do_QueryInterface(curr);
if (!content)
if (!content) {
break;
}
content->GetLocalName(localName);
ToLowerCase(localName);
if (localName.EqualsLiteral("a")) {
@ -111,12 +105,14 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
content->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr);
if (hasAttr) {
linkContent = content;
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(linkContent));
if (anchor)
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(
do_QueryInterface(linkContent));
if (anchor) {
anchor->GetHref(aHRef);
}
else
}
} else {
linkContent = nullptr; // Links can't be nested.
}
break;
}
@ -128,67 +124,64 @@ nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
return NS_OK;
}
/* readonly attribute imgIContainer imageContainer; */
NS_IMETHODIMP
nsContextMenuInfo::GetImageContainer(imgIContainer **aImageContainer)
nsContextMenuInfo::GetImageContainer(imgIContainer** aImageContainer)
{
NS_ENSURE_ARG_POINTER(aImageContainer);
NS_ENSURE_STATE(mDOMNode);
nsCOMPtr<imgIRequest> request;
GetImageRequest(mDOMNode, getter_AddRefs(request));
if (request)
if (request) {
return request->GetImage(aImageContainer);
}
return NS_ERROR_FAILURE;
}
/* readonly attribute nsIURI imageSrc; */
NS_IMETHODIMP
nsContextMenuInfo::GetImageSrc(nsIURI **aURI)
nsContextMenuInfo::GetImageSrc(nsIURI** aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_STATE(mDOMNode);
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
return content->GetCurrentURI(aURI);
}
/* readonly attribute imgIContainer backgroundImageContainer; */
NS_IMETHODIMP
nsContextMenuInfo::GetBackgroundImageContainer(imgIContainer **aImageContainer)
nsContextMenuInfo::GetBackgroundImageContainer(imgIContainer** aImageContainer)
{
NS_ENSURE_ARG_POINTER(aImageContainer);
NS_ENSURE_STATE(mDOMNode);
nsRefPtr<imgRequestProxy> request;
GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request));
if (request)
if (request) {
return request->GetImage(aImageContainer);
}
return NS_ERROR_FAILURE;
}
/* readonly attribute nsIURI backgroundImageSrc; */
NS_IMETHODIMP
nsContextMenuInfo::GetBackgroundImageSrc(nsIURI **aURI)
nsContextMenuInfo::GetBackgroundImageSrc(nsIURI** aURI)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_STATE(mDOMNode);
nsRefPtr<imgRequestProxy> request;
GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request));
if (request)
if (request) {
return request->GetURI(aURI);
}
return NS_ERROR_FAILURE;
}
//*****************************************************************************
nsresult
nsContextMenuInfo::GetImageRequest(nsIDOMNode *aDOMNode, imgIRequest **aRequest)
nsContextMenuInfo::GetImageRequest(nsIDOMNode* aDOMNode, imgIRequest** aRequest)
{
NS_ENSURE_ARG(aDOMNode);
NS_ENSURE_ARG_POINTER(aRequest);
@ -197,23 +190,23 @@ nsContextMenuInfo::GetImageRequest(nsIDOMNode *aDOMNode, imgIRequest **aRequest)
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(aDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
return content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
aRequest);
return content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, aRequest);
}
bool
nsContextMenuInfo::HasBackgroundImage(nsIDOMNode * aDOMNode)
nsContextMenuInfo::HasBackgroundImage(nsIDOMNode* aDOMNode)
{
NS_ENSURE_TRUE(aDOMNode, false);
nsRefPtr<imgRequestProxy> request;
GetBackgroundImageRequest(aDOMNode, getter_AddRefs(request));
return (request != nullptr);
}
nsresult
nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgRequestProxy **aRequest)
nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode* aDOMNode,
imgRequestProxy** aRequest)
{
NS_ENSURE_ARG(aDOMNode);
@ -230,8 +223,9 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgRequestPro
element->GetNamespaceURI(nameSpace);
if (nameSpace.IsEmpty()) {
nsresult rv = GetBackgroundImageRequestInternal(domNode, aRequest);
if (NS_SUCCEEDED(rv) && *aRequest)
if (NS_SUCCEEDED(rv) && *aRequest) {
return NS_OK;
}
// no background-image found
nsCOMPtr<nsIDOMDocument> document;
@ -249,7 +243,8 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgRequestPro
}
nsresult
nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRequestProxy **aRequest)
nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
imgRequestProxy** aRequest)
{
NS_ENSURE_ARG_POINTER(aDOMNode);
@ -273,8 +268,9 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe
while (true) {
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(domNode));
// bail for the parent node of the root element or null argument
if (!domElement)
if (!domElement) {
break;
}
nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
window->GetComputedStyle(domElement, EmptyString(),
@ -308,8 +304,9 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRe
primitiveValue = do_QueryInterface(cssValue);
if (primitiveValue) {
primitiveValue->GetStringValue(bgStringValue);
if (!bgStringValue.EqualsLiteral("transparent"))
if (!bgStringValue.EqualsLiteral("transparent")) {
return NS_ERROR_FAILURE;
}
}
}

View File

@ -17,51 +17,38 @@
class ChromeContextMenuListener;
class imgRequestProxy;
//*****************************************************************************
// class nsContextMenuInfo
//
// Helper class for implementors of nsIContextMenuListener2
//*****************************************************************************
class nsContextMenuInfo : public nsIContextMenuInfo
{
friend class ChromeContextMenuListener;
public:
nsContextMenuInfo();
public:
nsContextMenuInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSICONTEXTMENUINFO
private:
virtual ~nsContextMenuInfo();
virtual ~nsContextMenuInfo();
void SetMouseEvent(nsIDOMEvent *aEvent)
{ mMouseEvent = aEvent; }
void SetMouseEvent(nsIDOMEvent* aEvent) { mMouseEvent = aEvent; }
void SetDOMNode(nsIDOMNode* aNode) { mDOMNode = aNode; }
void SetAssociatedLink(nsIDOMNode* aLink) { mAssociatedLink = aLink; }
void SetDOMNode(nsIDOMNode *aNode)
{ mDOMNode = aNode; }
void SetAssociatedLink(nsIDOMNode *aLink)
{ mAssociatedLink = aLink; }
nsresult GetImageRequest(nsIDOMNode* aDOMNode, imgIRequest** aRequest);
nsresult GetImageRequest(nsIDOMNode *aDOMNode,
imgIRequest **aRequest);
bool HasBackgroundImage(nsIDOMNode* aDOMNode);
bool HasBackgroundImage(nsIDOMNode *aDOMNode);
nsresult GetBackgroundImageRequest(nsIDOMNode* aDOMNode,
imgRequestProxy** aRequest);
nsresult GetBackgroundImageRequest(nsIDOMNode *aDOMNode,
imgRequestProxy **aRequest);
nsresult GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
imgRequestProxy** aRequest);
nsresult GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode,
imgRequestProxy **aRequest);
private:
nsCOMPtr<nsIDOMEvent> mMouseEvent;
nsCOMPtr<nsIDOMNode> mDOMNode;
nsCOMPtr<nsIDOMNode> mAssociatedLink;
}; // class nsContextMenuInfo
nsCOMPtr<nsIDOMEvent> mMouseEvent;
nsCOMPtr<nsIDOMNode> mDOMNode;
nsCOMPtr<nsIDOMNode> mAssociatedLink;
};
#endif // nsContextMenuInfo_h__

File diff suppressed because it is too large Load Diff

View File

@ -43,22 +43,19 @@ class ChromeContextMenuListener;
// {6D10C180-6888-11d4-952B-0020183BF181}
#define NS_ICDOCSHELLTREEOWNER_IID \
{ 0x6d10c180, 0x6888, 0x11d4, { 0x95, 0x2b, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
{ 0x6d10c180, 0x6888, 0x11d4, { 0x95, 0x2b, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
/*
* This is a fake 'hidden' interface that nsDocShellTreeOwner implements.
* Classes such as nsCommandHandler can QI for this interface to be
* sure that they're dealing with a valid nsDocShellTreeOwner and not some
* other object that implements nsIDocShellTreeOwner.
*/
// This is a fake 'hidden' interface that nsDocShellTreeOwner implements.
// Classes such as nsCommandHandler can QI for this interface to be sure that
// they're dealing with a valid nsDocShellTreeOwner and not some other object
// that implements nsIDocShellTreeOwner.
class nsICDocShellTreeOwner : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICDOCSHELLTREEOWNER_IID)
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICDOCSHELLTREEOWNER_IID)
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICDocShellTreeOwner,
NS_ICDOCSHELLTREEOWNER_IID)
NS_DEFINE_STATIC_IID_ACCESSOR(nsICDocShellTreeOwner, NS_ICDOCSHELLTREEOWNER_IID)
class nsDocShellTreeOwner final : public nsIDocShellTreeOwner,
public nsIBaseWindow,
@ -68,83 +65,77 @@ class nsDocShellTreeOwner final : public nsIDocShellTreeOwner,
public nsICDocShellTreeOwner,
public nsSupportsWeakReference
{
friend class nsWebBrowser;
friend class nsCommandHandler;
friend class nsWebBrowser;
friend class nsCommandHandler;
public:
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
NS_DECL_NSIBASEWINDOW
NS_DECL_NSIDOCSHELLTREEOWNER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIBASEWINDOW
NS_DECL_NSIDOCSHELLTREEOWNER
NS_DECL_NSIDOMEVENTLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER
protected:
nsDocShellTreeOwner();
virtual ~nsDocShellTreeOwner();
nsDocShellTreeOwner();
virtual ~nsDocShellTreeOwner();
void WebBrowser(nsWebBrowser* aWebBrowser);
void WebBrowser(nsWebBrowser* aWebBrowser);
nsWebBrowser* WebBrowser();
NS_IMETHOD SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner);
NS_IMETHOD SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome);
nsWebBrowser* WebBrowser();
NS_IMETHOD SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner);
NS_IMETHOD SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome);
NS_IMETHOD AddChromeListeners();
NS_IMETHOD RemoveChromeListeners();
NS_IMETHOD AddChromeListeners();
NS_IMETHOD RemoveChromeListeners();
nsresult FindItemWithNameAcrossWindows(const char16_t* aName,
nsIDocShellTreeItem* aRequestor,
nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem **aFoundItem);
nsresult FindItemWithNameAcrossWindows(
const char16_t* aName,
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** aFoundItem);
void EnsurePrompter();
void EnsureAuthPrompter();
void EnsurePrompter();
void EnsureAuthPrompter();
void AddToWatcher();
void RemoveFromWatcher();
void AddToWatcher();
void RemoveFromWatcher();
// These helper functions return the correct instances of the requested
// interfaces. If the object passed to SetWebBrowserChrome() implements
// nsISupportsWeakReference, then these functions call QueryReferent on
// that object. Otherwise, they return an addrefed pointer. If the
// WebBrowserChrome object doesn't exist, they return nullptr.
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
already_AddRefed<nsIEmbeddingSiteWindow> GetOwnerWin();
already_AddRefed<nsIInterfaceRequestor> GetOwnerRequestor();
// These helper functions return the correct instances of the requested
// interfaces. If the object passed to SetWebBrowserChrome() implements
// nsISupportsWeakReference, then these functions call QueryReferent on
// that object. Otherwise, they return an addrefed pointer. If the
// WebBrowserChrome object doesn't exist, they return nullptr.
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
already_AddRefed<nsIEmbeddingSiteWindow> GetOwnerWin();
already_AddRefed<nsIInterfaceRequestor> GetOwnerRequestor();
protected:
// Weak References
nsWebBrowser* mWebBrowser;
nsIDocShellTreeOwner* mTreeOwner;
nsIDocShellTreeItem* mPrimaryContentShell;
// Weak References
nsWebBrowser* mWebBrowser;
nsIDocShellTreeOwner* mTreeOwner;
nsIDocShellTreeItem* mPrimaryContentShell;
nsIWebBrowserChrome* mWebBrowserChrome;
nsIEmbeddingSiteWindow* mOwnerWin;
nsIInterfaceRequestor* mOwnerRequestor;
nsIWebBrowserChrome* mWebBrowserChrome;
nsIEmbeddingSiteWindow* mOwnerWin;
nsIInterfaceRequestor* mOwnerRequestor;
nsWeakPtr mWebBrowserChromeWeak; // nsIWebBrowserChrome
nsWeakPtr mWebBrowserChromeWeak; // nsIWebBrowserChrome
// the objects that listen for chrome events like context menus and tooltips.
// They are separate objects to avoid circular references between |this|
// and the DOM.
nsRefPtr<ChromeTooltipListener> mChromeTooltipListener;
nsRefPtr<ChromeContextMenuListener> mChromeContextMenuListener;
// the objects that listen for chrome events like context menus and tooltips.
// They are separate objects to avoid circular references between |this|
// and the DOM.
nsRefPtr<ChromeTooltipListener> mChromeTooltipListener;
nsRefPtr<ChromeContextMenuListener> mChromeContextMenuListener;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
};
//
// class ChromeTooltipListener
//
// The class that listens to the chrome events and tells the embedding
// chrome to show tooltips, as appropriate. Handles registering itself
// with the DOM with AddChromeListeners() and removing itself with
// RemoveChromeListeners().
//
// The class that listens to the chrome events and tells the embedding chrome to
// show tooltips, as appropriate. Handles registering itself with the DOM with
// AddChromeListeners() and removing itself with RemoveChromeListeners().
class ChromeTooltipListener final : public nsIDOMEventListener
{
protected:
@ -153,69 +144,70 @@ protected:
public:
NS_DECL_ISUPPORTS
ChromeTooltipListener(nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome);
ChromeTooltipListener(nsWebBrowser* aInBrowser, nsIWebBrowserChrome* aInChrome);
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
// Add/remove the relevant listeners, based on what interfaces
// the embedding chrome implements.
// Add/remove the relevant listeners, based on what interfaces the embedding
// chrome implements.
NS_IMETHOD AddChromeListeners();
NS_IMETHOD RemoveChromeListeners();
private:
// various delays for tooltips
enum {
kTooltipAutoHideTime = 5000, // 5000ms = 5 seconds
kTooltipMouseMoveTolerance = 7 // 7 pixel tolerance for mousemove event
// various delays for tooltips
enum
{
kTooltipAutoHideTime = 5000, // ms
kTooltipMouseMoveTolerance = 7 // pixel tolerance for mousemove event
};
NS_IMETHOD AddTooltipListener();
NS_IMETHOD RemoveTooltipListener();
NS_IMETHOD ShowTooltip(int32_t inXCoords, int32_t inYCoords, const nsAString & inTipText);
NS_IMETHOD ShowTooltip(int32_t aInXCoords, int32_t aInYCoords,
const nsAString& aInTipText);
NS_IMETHOD HideTooltip();
nsWebBrowser* mWebBrowser;
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
nsCOMPtr<nsITooltipTextProvider> mTooltipTextProvider;
// This must be a strong ref in order to make sure we can hide the tooltip
// if the window goes away while we're displaying one. If we don't hold
// a strong ref, the chrome might have been disposed of before we get a chance
// to tell it, and no one would ever tell us of that fact.
// This must be a strong ref in order to make sure we can hide the tooltip if
// the window goes away while we're displaying one. If we don't hold a strong
// ref, the chrome might have been disposed of before we get a chance to tell
// it, and no one would ever tell us of that fact.
nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome;
bool mTooltipListenerInstalled;
nsCOMPtr<nsITimer> mTooltipTimer;
static void sTooltipCallback(nsITimer* aTimer, void* aListener);
int32_t mMouseClientX, mMouseClientY; // mouse coordinates for last mousemove event we saw
int32_t mMouseScreenX, mMouseScreenY; // mouse coordinates for tooltip event
// Mouse coordinates for last mousemove event we saw
int32_t mMouseClientX;
int32_t mMouseClientY;
// Mouse coordinates for tooltip event
int32_t mMouseScreenX;
int32_t mMouseScreenY;
bool mShowingTooltip;
bool mTooltipShownOnce;
// The node hovered over that fired the timer. This may turn into the node that
// triggered the tooltip, but only if the timer ever gets around to firing.
// This is a strong reference, because the tooltip content can be destroyed while we're
// waiting for the tooltip to pup up, and we need to detect that.
// It's set only when the tooltip timer is created and launched. The timer must
// either fire or be cancelled (or possibly released?), and we release this
// reference in each of those cases. So we don't leak.
// The node hovered over that fired the timer. This may turn into the node
// that triggered the tooltip, but only if the timer ever gets around to
// firing. This is a strong reference, because the tooltip content can be
// destroyed while we're waiting for the tooltip to pup up, and we need to
// detect that. It's set only when the tooltip timer is created and launched.
// The timer must either fire or be cancelled (or possibly released?), and we
// release this reference in each of those cases. So we don't leak.
nsCOMPtr<nsIDOMNode> mPossibleTooltipNode;
};
}; // ChromeTooltipListener
//
// class ChromeContextMenuListener
//
// The class that listens to the chrome events and tells the embedding
// chrome to show context menus, as appropriate. Handles registering itself
// with the DOM with AddChromeListeners() and removing itself with
// RemoveChromeListeners().
//
// The class that listens to the chrome events and tells the embedding chrome to
// show context menus, as appropriate. Handles registering itself with the DOM
// with AddChromeListeners() and removing itself with RemoveChromeListeners().
class ChromeContextMenuListener : public nsIDOMEventListener
{
protected:
@ -224,7 +216,8 @@ protected:
public:
NS_DECL_ISUPPORTS
ChromeContextMenuListener(nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome);
ChromeContextMenuListener(nsWebBrowser* aInBrowser,
nsIWebBrowserChrome* aInChrome);
// nsIDOMContextMenuListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
@ -235,7 +228,6 @@ public:
NS_IMETHOD RemoveChromeListeners();
private:
NS_IMETHOD AddContextMenuListener();
NS_IMETHOD RemoveContextMenuListener();
@ -244,9 +236,6 @@ private:
nsWebBrowser* mWebBrowser;
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome;
}; // class ChromeContextMenuListener
};
#endif /* nsDocShellTreeOwner_h__ */

View File

@ -25,7 +25,7 @@ nsEmbedStream::~nsEmbedStream()
}
void
nsEmbedStream::InitOwner(nsIWebBrowser *aOwner)
nsEmbedStream::InitOwner(nsIWebBrowser* aOwner)
{
mOwner = aOwner;
}
@ -37,36 +37,38 @@ nsEmbedStream::Init(void)
}
NS_METHOD
nsEmbedStream::OpenStream(nsIURI *aBaseURI, const nsACString& aContentType)
nsEmbedStream::OpenStream(nsIURI* aBaseURI, const nsACString& aContentType)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aBaseURI);
NS_ENSURE_TRUE(IsASCII(aContentType), NS_ERROR_INVALID_ARG);
// if we're already doing a stream, return an error
if (mOutputStream)
if (mOutputStream) {
return NS_ERROR_IN_PROGRESS;
}
nsCOMPtr<nsIAsyncInputStream> inputStream;
nsCOMPtr<nsIAsyncOutputStream> outputStream;
rv = NS_NewPipe2(getter_AddRefs(inputStream),
getter_AddRefs(outputStream),
rv = NS_NewPipe2(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
true, false, 0, UINT32_MAX);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mOwner);
rv = docShell->LoadStream(inputStream, aBaseURI, aContentType,
EmptyCString(), nullptr);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return rv;
}
mOutputStream = outputStream;
return rv;
}
NS_METHOD
nsEmbedStream::AppendToStream(const uint8_t *aData, uint32_t aLen)
nsEmbedStream::AppendToStream(const uint8_t* aData, uint32_t aLen)
{
nsresult rv;
NS_ENSURE_STATE(mOutputStream);
@ -74,8 +76,9 @@ nsEmbedStream::AppendToStream(const uint8_t *aData, uint32_t aLen)
uint32_t bytesWritten = 0;
rv = mOutputStream->Write(reinterpret_cast<const char*>(aData),
aLen, &bytesWritten);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return rv;
}
NS_ASSERTION(bytesWritten == aLen,
"underlying buffer couldn't handle the write");

View File

@ -13,24 +13,23 @@
class nsEmbedStream : public nsISupports
{
public:
public:
nsEmbedStream();
void InitOwner (nsIWebBrowser *aOwner);
NS_METHOD Init (void);
void InitOwner(nsIWebBrowser* aOwner);
NS_METHOD Init(void);
NS_METHOD OpenStream (nsIURI *aBaseURI, const nsACString& aContentType);
NS_METHOD AppendToStream (const uint8_t *aData, uint32_t aLen);
NS_METHOD CloseStream (void);
NS_METHOD OpenStream(nsIURI* aBaseURI, const nsACString& aContentType);
NS_METHOD AppendToStream(const uint8_t* aData, uint32_t aLen);
NS_METHOD CloseStream(void);
NS_DECL_ISUPPORTS
protected:
protected:
virtual ~nsEmbedStream();
private:
nsIWebBrowser *mOwner;
private:
nsIWebBrowser* mOwner;
nsCOMPtr<nsIOutputStream> mOutputStream;
};

File diff suppressed because it is too large Load Diff

View File

@ -44,20 +44,21 @@
class nsWebBrowserInitInfo
{
public:
//nsIBaseWindow Stuff
int32_t x;
int32_t y;
int32_t cx;
int32_t cy;
bool visible;
nsCOMPtr<nsISHistory> sessionHistory;
nsString name;
// nsIBaseWindow Stuff
int32_t x;
int32_t y;
int32_t cx;
int32_t cy;
bool visible;
nsCOMPtr<nsISHistory> sessionHistory;
nsString name;
};
class nsWebBrowserListenerState
{
public:
bool Equals(nsIWeakReference *aListener, const nsIID& aID) {
bool Equals(nsIWeakReference* aListener, const nsIID& aID)
{
return mWeakPtr.get() == aListener && mID.Equals(aID);
}
@ -67,7 +68,7 @@ public:
// {cda5863a-aa9c-411e-be49-ea0d525ab4b5} -
#define NS_WEBBROWSER_CID \
{0xcda5863a, 0xaa9c, 0x411e, { 0xbe, 0x49, 0xea, 0x0d, 0x52, 0x5a, 0xb4, 0xb5 }}
{ 0xcda5863a, 0xaa9c, 0x411e, { 0xbe, 0x49, 0xea, 0x0d, 0x52, 0x5a, 0xb4, 0xb5 } }
class nsWebBrowser final : public nsIWebBrowser,
@ -86,6 +87,7 @@ class nsWebBrowser final : public nsIWebBrowser,
public nsSupportsWeakReference
{
friend class nsDocShellTreeOwner;
public:
nsWebBrowser();
@ -112,9 +114,9 @@ protected:
// XXXbz why are these NS_IMETHOD? They're not interface methods!
NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
NS_IMETHOD EnsureDocShellTreeOwner();
NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindow **aDomWindow);
NS_IMETHOD BindListener(nsISupports *aListener, const nsIID& aIID);
NS_IMETHOD UnBindListener(nsISupports *aListener, const nsIID& aIID);
NS_IMETHOD GetPrimaryContentWindow(nsIDOMWindow** aDomWindow);
NS_IMETHOD BindListener(nsISupports* aListener, const nsIID& aIID);
NS_IMETHOD UnBindListener(nsISupports* aListener, const nsIID& aIID);
NS_IMETHOD EnableGlobalHistory(bool aEnable);
// nsIWidgetListener
@ -124,40 +126,41 @@ protected:
protected:
nsRefPtr<nsDocShellTreeOwner> mDocShellTreeOwner;
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
nsCOMPtr<nsIWidget> mInternalWidget;
nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
nsCOMPtr<nsIWidget> mInternalWidget;
nsCOMPtr<nsIWindowWatcher> mWWatch;
nsAutoPtr<nsWebBrowserInitInfo> mInitInfo;
uint32_t mContentType;
bool mActivating;
bool mShouldEnableHistory;
bool mIsActive;
nativeWindow mParentNativeWindow;
nsIWebProgressListener *mProgressListener;
nsCOMPtr<nsIWebProgress> mWebProgress;
uint32_t mContentType;
bool mActivating;
bool mShouldEnableHistory;
bool mIsActive;
nativeWindow mParentNativeWindow;
nsIWebProgressListener* mProgressListener;
nsCOMPtr<nsIWebProgress> mWebProgress;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
// cached background color
nscolor mBackgroundColor;
nscolor mBackgroundColor;
// persistence object
nsCOMPtr<nsIWebBrowserPersist> mPersist;
uint32_t mPersistCurrentState;
nsresult mPersistResult;
uint32_t mPersistFlags;
uint32_t mPersistCurrentState;
nsresult mPersistResult;
uint32_t mPersistFlags;
// stream
nsRefPtr<nsEmbedStream> mStream;
nsRefPtr<nsEmbedStream> mStream;
//Weak Reference interfaces...
nsIWidget* mParentWidget;
nsAutoPtr<nsTArray<nsWebBrowserListenerState>> mListenerArray;
// Weak Reference interfaces...
nsIWidget* mParentWidget;
nsAutoPtr<nsTArray<nsWebBrowserListenerState> > mListenerArray;
};
#endif /* nsWebBrowser_h__ */

View File

@ -13,91 +13,91 @@
nsWebBrowserContentPolicy::nsWebBrowserContentPolicy()
{
MOZ_COUNT_CTOR(nsWebBrowserContentPolicy);
MOZ_COUNT_CTOR(nsWebBrowserContentPolicy);
}
nsWebBrowserContentPolicy::~nsWebBrowserContentPolicy()
{
MOZ_COUNT_DTOR(nsWebBrowserContentPolicy);
MOZ_COUNT_DTOR(nsWebBrowserContentPolicy);
}
NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
NS_IMETHODIMP
nsWebBrowserContentPolicy::ShouldLoad(uint32_t contentType,
nsIURI *contentLocation,
nsIURI *requestingLocation,
nsISupports *requestingContext,
const nsACString &mimeGuess,
nsISupports *extra,
nsIPrincipal *requestPrincipal,
int16_t *shouldLoad)
nsWebBrowserContentPolicy::ShouldLoad(uint32_t aContentType,
nsIURI* aContentLocation,
nsIURI* aRequestingLocation,
nsISupports* aRequestingContext,
const nsACString& aMimeGuess,
nsISupports* aExtra,
nsIPrincipal* aRequestPrincipal,
int16_t* aShouldLoad)
{
NS_PRECONDITION(shouldLoad, "Null out param");
NS_PRECONDITION(aShouldLoad, "Null out param");
*shouldLoad = nsIContentPolicy::ACCEPT;
*aShouldLoad = nsIContentPolicy::ACCEPT;
nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
/* We're going to dereference shell, so make sure it isn't null */
if (!shell) {
return NS_OK;
}
nsIDocShell* shell = NS_CP_GetDocShellFromContext(aRequestingContext);
/* We're going to dereference shell, so make sure it isn't null */
if (!shell) {
return NS_OK;
}
nsresult rv;
bool allowed = true;
nsresult rv;
bool allowed = true;
switch (contentType) {
case nsIContentPolicy::TYPE_SCRIPT:
rv = shell->GetAllowJavascript(&allowed);
break;
case nsIContentPolicy::TYPE_SUBDOCUMENT:
rv = shell->GetAllowSubframes(&allowed);
break;
switch (aContentType) {
case nsIContentPolicy::TYPE_SCRIPT:
rv = shell->GetAllowJavascript(&allowed);
break;
case nsIContentPolicy::TYPE_SUBDOCUMENT:
rv = shell->GetAllowSubframes(&allowed);
break;
#if 0
/* XXXtw: commented out in old code; add during conpol phase 2 */
case nsIContentPolicy::TYPE_REFRESH:
rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
break;
/* XXXtw: commented out in old code; add during conpol phase 2 */
case nsIContentPolicy::TYPE_REFRESH:
rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
break;
#endif
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_IMAGESET:
rv = shell->GetAllowImages(&allowed);
break;
default:
return NS_OK;
}
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_IMAGESET:
rv = shell->GetAllowImages(&allowed);
break;
default:
return NS_OK;
}
if (NS_SUCCEEDED(rv) && !allowed) {
*shouldLoad = nsIContentPolicy::REJECT_TYPE;
}
return rv;
if (NS_SUCCEEDED(rv) && !allowed) {
*aShouldLoad = nsIContentPolicy::REJECT_TYPE;
}
return rv;
}
NS_IMETHODIMP
nsWebBrowserContentPolicy::ShouldProcess(uint32_t contentType,
nsIURI *contentLocation,
nsIURI *requestingLocation,
nsISupports *requestingContext,
const nsACString &mimeGuess,
nsISupports *extra,
nsIPrincipal *requestPrincipal,
int16_t *shouldProcess)
nsWebBrowserContentPolicy::ShouldProcess(uint32_t aContentType,
nsIURI* aContentLocation,
nsIURI* aRequestingLocation,
nsISupports* aRequestingContext,
const nsACString& aMimeGuess,
nsISupports* aExtra,
nsIPrincipal* aRequestPrincipal,
int16_t* aShouldProcess)
{
NS_PRECONDITION(shouldProcess, "Null out param");
NS_PRECONDITION(aShouldProcess, "Null out param");
*shouldProcess = nsIContentPolicy::ACCEPT;
// Object tags will always open channels with TYPE_OBJECT, but may end up
// loading with TYPE_IMAGE or TYPE_DOCUMENT as their final type, so we block
// actual-plugins at the process stage
if (contentType != nsIContentPolicy::TYPE_OBJECT) {
return NS_OK;
}
nsIDocShell *shell = NS_CP_GetDocShellFromContext(requestingContext);
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
*shouldProcess = nsIContentPolicy::REJECT_TYPE;
}
*aShouldProcess = nsIContentPolicy::ACCEPT;
// Object tags will always open channels with TYPE_OBJECT, but may end up
// loading with TYPE_IMAGE or TYPE_DOCUMENT as their final type, so we block
// actual-plugins at the process stage
if (aContentType != nsIContentPolicy::TYPE_OBJECT) {
return NS_OK;
}
nsIDocShell* shell = NS_CP_GetDocShellFromContext(aRequestingContext);
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
*aShouldProcess = nsIContentPolicy::REJECT_TYPE;
}
return NS_OK;
}

View File

@ -8,19 +8,19 @@
/* f66bc334-1dd1-11b2-bab2-90e04fe15c19 */
#define NS_WEBBROWSERCONTENTPOLICY_CID \
{ 0xf66bc334, 0x1dd1, 0x11b2, { 0xba, 0xb2, 0x90, 0xe0, 0x4f, 0xe1, 0x5c, 0x19 } }
{ 0xf66bc334, 0x1dd1, 0x11b2, { 0xba, 0xb2, 0x90, 0xe0, 0x4f, 0xe1, 0x5c, 0x19 } }
#define NS_WEBBROWSERCONTENTPOLICY_CONTRACTID "@mozilla.org/embedding/browser/content-policy;1"
#define NS_WEBBROWSERCONTENTPOLICY_CONTRACTID \
"@mozilla.org/embedding/browser/content-policy;1"
class nsWebBrowserContentPolicy : public nsIContentPolicy
{
protected:
virtual ~nsWebBrowserContentPolicy();
virtual ~nsWebBrowserContentPolicy();
public:
nsWebBrowserContentPolicy();
nsWebBrowserContentPolicy();
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTPOLICY
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTPOLICY
};