Bug 1129795 - Convert docshell/base/ to Gecko style. r=mccr8,smaug
This commit is contained in:
@@ -14,9 +14,9 @@ class nsString;
|
|||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
class Link;
|
class Link;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0057c9d3-b98e-4933-bdc5-0275d06705e1
|
// 0057c9d3-b98e-4933-bdc5-0275d06705e1
|
||||||
#define IHISTORY_IID \
|
#define IHISTORY_IID \
|
||||||
@@ -25,121 +25,120 @@ namespace mozilla {
|
|||||||
class IHistory : public nsISupports
|
class IHistory : public nsISupports
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(IHISTORY_IID)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the Link for notifications about the visited-ness of aURI.
|
||||||
|
* Consumers should assume that the URI is unvisited after calling this, and
|
||||||
|
* they will be notified if that state (unvisited) changes by having
|
||||||
|
* SetLinkState called on themselves. This function is guaranteed to run to
|
||||||
|
* completion before aLink is notified. After the node is notified, it will
|
||||||
|
* be unregistered.
|
||||||
|
*
|
||||||
|
* @note SetLinkState must not call RegisterVisitedCallback or
|
||||||
|
* UnregisterVisitedCallback.
|
||||||
|
*
|
||||||
|
* @pre aURI must not be null.
|
||||||
|
* @pre aLink may be null only in the parent (chrome) process.
|
||||||
|
*
|
||||||
|
* @param aURI
|
||||||
|
* The URI to check.
|
||||||
|
* @param aLink
|
||||||
|
* The link to update whenever the history status changes. The
|
||||||
|
* implementation will only hold onto a raw pointer, so if this
|
||||||
|
* object should be destroyed, be sure to call
|
||||||
|
* UnregisterVistedCallback first.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters a previously registered Link object. This must be called
|
||||||
|
* before destroying the registered object.
|
||||||
|
*
|
||||||
|
* @pre aURI must not be null.
|
||||||
|
* @pre aLink must not be null.
|
||||||
|
*
|
||||||
|
* @param aURI
|
||||||
|
* The URI that aLink was registered for.
|
||||||
|
* @param aLink
|
||||||
|
* The link object to unregister for aURI.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
|
||||||
|
|
||||||
|
enum VisitFlags
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Registers the Link for notifications about the visited-ness of aURI.
|
* Indicates whether the URI was loaded in a top-level window.
|
||||||
* Consumers should assume that the URI is unvisited after calling this, and
|
|
||||||
* they will be notified if that state (unvisited) changes by having
|
|
||||||
* SetLinkState called on themselves. This function is guaranteed to run to
|
|
||||||
* completion before aLink is notified. After the node is notified, it will
|
|
||||||
* be unregistered.
|
|
||||||
*
|
|
||||||
* @note SetLinkState must not call RegisterVisitedCallback or
|
|
||||||
* UnregisterVisitedCallback.
|
|
||||||
*
|
|
||||||
* @pre aURI must not be null.
|
|
||||||
* @pre aLink may be null only in the parent (chrome) process.
|
|
||||||
*
|
|
||||||
* @param aURI
|
|
||||||
* The URI to check.
|
|
||||||
* @param aLink
|
|
||||||
* The link to update whenever the history status changes. The
|
|
||||||
* implementation will only hold onto a raw pointer, so if this
|
|
||||||
* object should be destroyed, be sure to call
|
|
||||||
* UnregisterVistedCallback first.
|
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
|
TOP_LEVEL = 1 << 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a previously registered Link object. This must be called
|
* Indicates whether the URI was loaded as part of a permanent redirect.
|
||||||
* before destroying the registered object.
|
|
||||||
*
|
|
||||||
* @pre aURI must not be null.
|
|
||||||
* @pre aLink must not be null.
|
|
||||||
*
|
|
||||||
* @param aURI
|
|
||||||
* The URI that aLink was registered for.
|
|
||||||
* @param aLink
|
|
||||||
* The link object to unregister for aURI.
|
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, dom::Link *aLink) = 0;
|
REDIRECT_PERMANENT = 1 << 1,
|
||||||
|
|
||||||
enum VisitFlags {
|
|
||||||
/**
|
|
||||||
* Indicates whether the URI was loaded in a top-level window.
|
|
||||||
*/
|
|
||||||
TOP_LEVEL = 1 << 0,
|
|
||||||
/**
|
|
||||||
* Indicates whether the URI was loaded as part of a permanent redirect.
|
|
||||||
*/
|
|
||||||
REDIRECT_PERMANENT = 1 << 1,
|
|
||||||
/**
|
|
||||||
* Indicates whether the URI was loaded as part of a temporary redirect.
|
|
||||||
*/
|
|
||||||
REDIRECT_TEMPORARY = 1 << 2,
|
|
||||||
/**
|
|
||||||
* Indicates the URI is redirecting (Response code 3xx).
|
|
||||||
*/
|
|
||||||
REDIRECT_SOURCE = 1 << 3,
|
|
||||||
/**
|
|
||||||
* Indicates the URI caused an error that is unlikely fixable by a
|
|
||||||
* retry, like a not found or unfetchable page.
|
|
||||||
*/
|
|
||||||
UNRECOVERABLE_ERROR = 1 << 4
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a history visit for the URI.
|
* Indicates whether the URI was loaded as part of a temporary redirect.
|
||||||
*
|
|
||||||
* @pre aURI must not be null.
|
|
||||||
*
|
|
||||||
* @param aURI
|
|
||||||
* The URI of the page being visited.
|
|
||||||
* @param aLastVisitedURI
|
|
||||||
* The URI of the last visit in the chain.
|
|
||||||
* @param aFlags
|
|
||||||
* The VisitFlags describing this visit.
|
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD VisitURI(
|
REDIRECT_TEMPORARY = 1 << 2,
|
||||||
nsIURI *aURI,
|
|
||||||
nsIURI *aLastVisitedURI,
|
|
||||||
uint32_t aFlags
|
|
||||||
) = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the title of the URI.
|
* Indicates the URI is redirecting (Response code 3xx).
|
||||||
*
|
|
||||||
* @pre aURI must not be null.
|
|
||||||
*
|
|
||||||
* @param aURI
|
|
||||||
* The URI to set the title for.
|
|
||||||
* @param aTitle
|
|
||||||
* The title string.
|
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
|
REDIRECT_SOURCE = 1 << 3,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies about the visited status of a given URI.
|
* Indicates the URI caused an error that is unlikely fixable by a
|
||||||
*
|
* retry, like a not found or unfetchable page.
|
||||||
* @param aURI
|
|
||||||
* The URI to notify about.
|
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
|
UNRECOVERABLE_ERROR = 1 << 4
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a history visit for the URI.
|
||||||
|
*
|
||||||
|
* @pre aURI must not be null.
|
||||||
|
*
|
||||||
|
* @param aURI
|
||||||
|
* The URI of the page being visited.
|
||||||
|
* @param aLastVisitedURI
|
||||||
|
* The URI of the last visit in the chain.
|
||||||
|
* @param aFlags
|
||||||
|
* The VisitFlags describing this visit.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD VisitURI(nsIURI* aURI,
|
||||||
|
nsIURI* aLastVisitedURI,
|
||||||
|
uint32_t aFlags) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the title of the URI.
|
||||||
|
*
|
||||||
|
* @pre aURI must not be null.
|
||||||
|
*
|
||||||
|
* @param aURI
|
||||||
|
* The URI to set the title for.
|
||||||
|
* @param aTitle
|
||||||
|
* The title string.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies about the visited status of a given URI.
|
||||||
|
*
|
||||||
|
* @param aURI
|
||||||
|
* The URI to notify about.
|
||||||
|
*/
|
||||||
|
NS_IMETHOD NotifyVisited(nsIURI* aURI) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(IHistory, IHISTORY_IID)
|
||||||
|
|
||||||
#define NS_DECL_IHISTORY \
|
#define NS_DECL_IHISTORY \
|
||||||
NS_IMETHOD RegisterVisitedCallback(nsIURI *aURI, \
|
NS_IMETHOD RegisterVisitedCallback(nsIURI* aURI, \
|
||||||
mozilla::dom::Link *aContent) MOZ_OVERRIDE; \
|
mozilla::dom::Link* aContent) MOZ_OVERRIDE; \
|
||||||
NS_IMETHOD UnregisterVisitedCallback(nsIURI *aURI, \
|
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, \
|
||||||
mozilla::dom::Link *aContent) MOZ_OVERRIDE; \
|
mozilla::dom::Link* aContent) MOZ_OVERRIDE; \
|
||||||
NS_IMETHOD VisitURI(nsIURI *aURI, \
|
NS_IMETHOD VisitURI(nsIURI* aURI, \
|
||||||
nsIURI *aLastVisitedURI, \
|
nsIURI* aLastVisitedURI, \
|
||||||
uint32_t aFlags) MOZ_OVERRIDE; \
|
uint32_t aFlags) MOZ_OVERRIDE; \
|
||||||
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) MOZ_OVERRIDE; \
|
NS_IMETHOD SetURITitle(nsIURI* aURI, const nsAString& aTitle) MOZ_OVERRIDE; \
|
||||||
NS_IMETHOD NotifyVisited(nsIURI* aURI) MOZ_OVERRIDE;
|
NS_IMETHOD NotifyVisited(nsIURI* aURI) MOZ_OVERRIDE;
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ LoadContext::GetAppId(uint32_t* aAppId)
|
|||||||
// LoadContext::nsIInterfaceRequestor
|
// LoadContext::nsIInterfaceRequestor
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadContext::GetInterface(const nsIID &aIID, void **aResult)
|
LoadContext::GetInterface(const nsIID& aIID, void** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
*aResult = nullptr;
|
*aResult = nullptr;
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ namespace mozilla {
|
|||||||
* to separate the safebrowsing cookie.
|
* to separate the safebrowsing cookie.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class LoadContext MOZ_FINAL : public nsILoadContext,
|
class LoadContext MOZ_FINAL
|
||||||
public nsIInterfaceRequestor
|
: public nsILoadContext
|
||||||
|
, public nsIInterfaceRequestor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
@@ -112,15 +113,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
~LoadContext() {}
|
~LoadContext() {}
|
||||||
|
|
||||||
nsWeakPtr mTopFrameElement;
|
nsWeakPtr mTopFrameElement;
|
||||||
uint64_t mNestedFrameId;
|
uint64_t mNestedFrameId;
|
||||||
uint32_t mAppId;
|
uint32_t mAppId;
|
||||||
bool mIsContent;
|
bool mIsContent;
|
||||||
bool mUsePrivateBrowsing;
|
bool mUsePrivateBrowsing;
|
||||||
bool mUseRemoteTabs;
|
bool mUseRemoteTabs;
|
||||||
bool mIsInBrowserElement;
|
bool mIsInBrowserElement;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool mIsNotNull;
|
bool mIsNotNull;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -93,12 +93,12 @@ LoadInfo::TriggeringPrincipal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetLoadingDocument(nsIDOMDocument** outLoadingDocument)
|
LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
||||||
if (node) {
|
if (node) {
|
||||||
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
|
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
|
||||||
context.forget(outLoadingDocument);
|
context.forget(aResult);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -111,16 +111,17 @@ LoadInfo::LoadingNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetSecurityFlags(nsSecurityFlags* outSecurityFlags)
|
LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
|
||||||
{
|
{
|
||||||
*outSecurityFlags = mSecurityFlags;
|
*aResult = mSecurityFlags;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
||||||
{
|
{
|
||||||
*aInheritPrincipal = (mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
*aInheritPrincipal =
|
||||||
|
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,9 +133,9 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
|
LoadInfo::GetContentPolicyType(nsContentPolicyType* aResult)
|
||||||
{
|
{
|
||||||
*outContentPolicyType = mContentPolicyType;
|
*aResult = mContentPolicyType;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,9 +154,9 @@ LoadInfo::BaseURI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LoadInfo::GetInnerWindowID(uint32_t* outInnerWindowID)
|
LoadInfo::GetInnerWindowID(uint32_t* aResult)
|
||||||
{
|
{
|
||||||
*outInnerWindowID = mInnerWindowID;
|
*aResult = mInnerWindowID;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ private:
|
|||||||
|
|
||||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||||
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
|
||||||
nsWeakPtr mLoadingContext;
|
nsWeakPtr mLoadingContext;
|
||||||
nsSecurityFlags mSecurityFlags;
|
nsSecurityFlags mSecurityFlags;
|
||||||
nsContentPolicyType mContentPolicyType;
|
nsContentPolicyType mContentPolicyType;
|
||||||
nsCOMPtr<nsIURI> mBaseURI;
|
nsCOMPtr<nsIURI> mBaseURI;
|
||||||
uint32_t mInnerWindowID;
|
uint32_t mInnerWindowID;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
|
|||||||
bool isOverriden = false;
|
bool isOverriden = false;
|
||||||
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
|
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
|
||||||
if (pbChannel &&
|
if (pbChannel &&
|
||||||
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) &&
|
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
|
||||||
|
&isOverriden)) &&
|
||||||
isOverriden) {
|
isOverriden) {
|
||||||
mUsePrivateBrowsing = isPrivate;
|
mUsePrivateBrowsing = isPrivate;
|
||||||
mIsPrivateBitValid = true;
|
mIsPrivateBitValid = true;
|
||||||
|
|||||||
@@ -37,26 +37,19 @@ public:
|
|||||||
|
|
||||||
void Init(nsILoadContext* aLoadContext);
|
void Init(nsILoadContext* aLoadContext);
|
||||||
|
|
||||||
bool IsNotNull() const
|
bool IsNotNull() const { return mIsNotNull; }
|
||||||
{
|
bool IsPrivateBitValid() const { return mIsPrivateBitValid; }
|
||||||
return mIsNotNull;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsPrivateBitValid() const
|
|
||||||
{
|
|
||||||
return mIsPrivateBitValid;
|
|
||||||
}
|
|
||||||
|
|
||||||
// used to indicate if child-side LoadContext * was null.
|
// used to indicate if child-side LoadContext * was null.
|
||||||
bool mIsNotNull;
|
bool mIsNotNull;
|
||||||
// used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
|
// used to indicate if child-side mUsePrivateBrowsing flag is valid, even if
|
||||||
// mIsNotNull is false, i.e., child LoadContext was null.
|
// mIsNotNull is false, i.e., child LoadContext was null.
|
||||||
bool mIsPrivateBitValid;
|
bool mIsPrivateBitValid;
|
||||||
bool mIsContent;
|
bool mIsContent;
|
||||||
bool mUsePrivateBrowsing;
|
bool mUsePrivateBrowsing;
|
||||||
bool mUseRemoteTabs;
|
bool mUseRemoteTabs;
|
||||||
bool mIsInBrowserElement;
|
bool mIsInBrowserElement;
|
||||||
uint32_t mAppId;
|
uint32_t mAppId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to serialize over IPDL
|
// Function to serialize over IPDL
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public:
|
|||||||
// Check whether two markers should be considered the same,
|
// Check whether two markers should be considered the same,
|
||||||
// for the purpose of pairing start and end markers. Normally
|
// for the purpose of pairing start and end markers. Normally
|
||||||
// this definition suffices.
|
// this definition suffices.
|
||||||
virtual bool Equals(const TimelineMarker* other)
|
virtual bool Equals(const TimelineMarker* aOther)
|
||||||
{
|
{
|
||||||
return strcmp(mName, other->mName) == 0;
|
return strcmp(mName, aOther->mName) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add details specific to this marker type to aMarker. The
|
// Add details specific to this marker type to aMarker. The
|
||||||
@@ -44,34 +44,18 @@ public:
|
|||||||
// called on both the starting and ending markers of a pair.
|
// called on both the starting and ending markers of a pair.
|
||||||
// Ordinarily the ending marker doesn't need to do anything
|
// Ordinarily the ending marker doesn't need to do anything
|
||||||
// here.
|
// here.
|
||||||
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker)
|
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void AddLayerRectangles(mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
|
virtual void AddLayerRectangles(
|
||||||
|
mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT_UNREACHABLE("can only be called on layer markers");
|
MOZ_ASSERT_UNREACHABLE("can only be called on layer markers");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetName() const
|
const char* GetName() const { return mName; }
|
||||||
{
|
TracingMetadata GetMetaData() const { return mMetaData; }
|
||||||
return mName;
|
DOMHighResTimeStamp GetTime() const { return mTime; }
|
||||||
}
|
const nsString& GetCause() const { return mCause; }
|
||||||
|
|
||||||
TracingMetadata GetMetaData() const
|
|
||||||
{
|
|
||||||
return mMetaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
DOMHighResTimeStamp GetTime() const
|
|
||||||
{
|
|
||||||
return mTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nsString& GetCause() const
|
|
||||||
{
|
|
||||||
return mCause;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSObject* GetStack()
|
JSObject* GetStack()
|
||||||
{
|
{
|
||||||
@@ -82,7 +66,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void CaptureStack()
|
void CaptureStack()
|
||||||
{
|
{
|
||||||
JSContext* ctx = nsContentUtils::GetCurrentJSContext();
|
JSContext* ctx = nsContentUtils::GetCurrentJSContext();
|
||||||
@@ -97,7 +80,6 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const char* mName;
|
const char* mName;
|
||||||
TracingMetadata mMetaData;
|
TracingMetadata mMetaData;
|
||||||
DOMHighResTimeStamp mTime;
|
DOMHighResTimeStamp mTime;
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
|
NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
|
||||||
|
|
||||||
struct RedirEntry {
|
struct RedirEntry
|
||||||
const char* id;
|
{
|
||||||
const char* url;
|
const char* id;
|
||||||
uint32_t flags;
|
const char* url;
|
||||||
|
uint32_t flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -29,142 +30,169 @@ struct RedirEntry {
|
|||||||
URI. Perhaps we should separate the two concepts out...
|
URI. Perhaps we should separate the two concepts out...
|
||||||
*/
|
*/
|
||||||
static RedirEntry kRedirMap[] = {
|
static RedirEntry kRedirMap[] = {
|
||||||
{ "", "chrome://global/content/about.xhtml",
|
{
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
"", "chrome://global/content/about.xhtml",
|
||||||
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
{ "credits", "http://www.mozilla.org/credits/",
|
},
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
|
||||||
{ "mozilla", "chrome://global/content/mozilla.xhtml",
|
{
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
"credits", "http://www.mozilla.org/credits/",
|
||||||
{ "plugins", "chrome://global/content/plugins.html", 0 },
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||||
{ "config", "chrome://global/content/config.xul", 0 },
|
},
|
||||||
|
{
|
||||||
|
"mozilla", "chrome://global/content/mozilla.xhtml",
|
||||||
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||||
|
},
|
||||||
|
{ "plugins", "chrome://global/content/plugins.html", 0 },
|
||||||
|
{ "config", "chrome://global/content/config.xul", 0 },
|
||||||
#ifdef MOZ_CRASHREPORTER
|
#ifdef MOZ_CRASHREPORTER
|
||||||
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
|
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
|
||||||
#endif
|
#endif
|
||||||
{ "logo", "chrome://branding/content/about.png",
|
{
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT},
|
"logo", "chrome://branding/content/about.png",
|
||||||
{ "buildconfig", "chrome://global/content/buildconfig.html",
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
},
|
||||||
{ "license", "chrome://global/content/license.html",
|
{
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
|
"buildconfig", "chrome://global/content/buildconfig.html",
|
||||||
{ "neterror", "chrome://global/content/netError.xhtml",
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
},
|
||||||
|
{
|
||||||
|
"license", "chrome://global/content/license.html",
|
||||||
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"neterror", "chrome://global/content/netError.xhtml",
|
||||||
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||||
nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
|
nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
|
||||||
nsIAboutModule::ALLOW_SCRIPT |
|
nsIAboutModule::ALLOW_SCRIPT |
|
||||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||||
{ "memory", "chrome://global/content/aboutMemory.xhtml",
|
},
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
{
|
||||||
{ "compartments", "chrome://global/content/aboutCompartments.xhtml",
|
"memory", "chrome://global/content/aboutMemory.xhtml",
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
{ "addons", "chrome://mozapps/content/extensions/extensions.xul",
|
},
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
{
|
||||||
{ "newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
|
"compartments", "chrome://global/content/aboutCompartments.xhtml",
|
||||||
nsIAboutModule::ALLOW_SCRIPT |
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
|
},
|
||||||
{ "support", "chrome://global/content/aboutSupport.xhtml",
|
{
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
"addons", "chrome://mozapps/content/extensions/extensions.xul",
|
||||||
{ "telemetry", "chrome://global/content/aboutTelemetry.xhtml",
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
},
|
||||||
{ "networking", "chrome://global/content/aboutNetworking.xhtml",
|
{
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
"newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
|
||||||
{ "webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
|
nsIAboutModule::ALLOW_SCRIPT |
|
||||||
nsIAboutModule::ALLOW_SCRIPT },
|
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||||
// about:srcdoc is unresolvable by specification. It is included here
|
},
|
||||||
// because the security manager would disallow srcdoc iframes otherwise.
|
{
|
||||||
{ "srcdoc", "about:blank",
|
"support", "chrome://global/content/aboutSupport.xhtml",
|
||||||
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
nsIAboutModule::HIDE_FROM_ABOUTABOUT }
|
},
|
||||||
|
{
|
||||||
|
"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
|
||||||
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"networking", "chrome://global/content/aboutNetworking.xhtml",
|
||||||
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
|
||||||
|
nsIAboutModule::ALLOW_SCRIPT
|
||||||
|
},
|
||||||
|
// about:srcdoc is unresolvable by specification. It is included here
|
||||||
|
// because the security manager would disallow srcdoc iframes otherwise.
|
||||||
|
{
|
||||||
|
"srcdoc", "about:blank",
|
||||||
|
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
|
||||||
|
nsIAboutModule::HIDE_FROM_ABOUTABOUT
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
|
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAboutRedirector::NewChannel(nsIURI* aURI,
|
nsAboutRedirector::NewChannel(nsIURI* aURI,
|
||||||
nsILoadInfo* aLoadInfo,
|
nsILoadInfo* aLoadInfo,
|
||||||
nsIChannel** result)
|
nsIChannel** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aURI);
|
NS_ENSURE_ARG_POINTER(aURI);
|
||||||
NS_ASSERTION(result, "must not be null");
|
NS_ASSERTION(aResult, "must not be null");
|
||||||
|
|
||||||
nsAutoCString path;
|
nsAutoCString path;
|
||||||
nsresult rv = NS_GetAboutModuleName(aURI, path);
|
nsresult rv = NS_GetAboutModuleName(aURI, path);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
for (int i = 0; i < kRedirTotal; i++) {
|
||||||
|
if (!strcmp(path.get(), kRedirMap[i].id)) {
|
||||||
|
nsCOMPtr<nsIChannel> tempChannel;
|
||||||
|
nsCOMPtr<nsIURI> tempURI;
|
||||||
|
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
// Bug 1087720 (and Bug 1099296):
|
||||||
|
// Once all callsites have been updated to call NewChannel2()
|
||||||
|
// instead of NewChannel() we should have a non-null loadInfo
|
||||||
|
// consistently. Until then we have to branch on the loadInfo.
|
||||||
|
if (aLoadInfo) {
|
||||||
|
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
|
||||||
|
tempURI,
|
||||||
|
aLoadInfo);
|
||||||
|
} else {
|
||||||
|
rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
|
||||||
|
}
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i=0; i<kRedirTotal; i++)
|
tempChannel->SetOriginalURI(aURI);
|
||||||
{
|
|
||||||
if (!strcmp(path.get(), kRedirMap[i].id))
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIChannel> tempChannel;
|
|
||||||
nsCOMPtr<nsIURI> tempURI;
|
|
||||||
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
// Bug 1087720 (and Bug 1099296):
|
|
||||||
// Once all callsites have been updated to call NewChannel2()
|
|
||||||
// instead of NewChannel() we should have a non-null loadInfo
|
|
||||||
// consistently. Until then we have to branch on the loadInfo.
|
|
||||||
if (aLoadInfo) {
|
|
||||||
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
|
|
||||||
tempURI,
|
|
||||||
aLoadInfo);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rv = ioService->NewChannelFromURI(tempURI,
|
|
||||||
getter_AddRefs(tempChannel));
|
|
||||||
}
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
tempChannel->SetOriginalURI(aURI);
|
NS_ADDREF(*aResult = tempChannel);
|
||||||
|
return rv;
|
||||||
NS_ADDREF(*result = tempChannel);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||||
return NS_ERROR_ILLEGAL_VALUE;
|
return NS_ERROR_ILLEGAL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
|
nsAboutRedirector::GetURIFlags(nsIURI* aURI, uint32_t* aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aURI);
|
NS_ENSURE_ARG_POINTER(aURI);
|
||||||
|
|
||||||
nsAutoCString name;
|
nsAutoCString name;
|
||||||
nsresult rv = NS_GetAboutModuleName(aURI, name);
|
nsresult rv = NS_GetAboutModuleName(aURI, name);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
for (int i=0; i < kRedirTotal; i++)
|
for (int i = 0; i < kRedirTotal; i++) {
|
||||||
{
|
if (name.EqualsASCII(kRedirMap[i].id)) {
|
||||||
if (name.EqualsASCII(kRedirMap[i].id))
|
*aResult = kRedirMap[i].flags;
|
||||||
{
|
return NS_OK;
|
||||||
*result = kRedirMap[i].flags;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_ERROR("nsAboutRedirector called for unknown case");
|
NS_ERROR("nsAboutRedirector called for unknown case");
|
||||||
return NS_ERROR_ILLEGAL_VALUE;
|
return NS_ERROR_ILLEGAL_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI *aURI, nsAString &result)
|
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult)
|
||||||
{
|
{
|
||||||
SetDOMStringToNull(result);
|
SetDOMStringToNull(aResult);
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsAboutRedirector::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||||
{
|
{
|
||||||
nsAboutRedirector* about = new nsAboutRedirector();
|
nsAboutRedirector* about = new nsAboutRedirector();
|
||||||
if (about == nullptr)
|
if (!about) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
NS_ADDREF(about);
|
}
|
||||||
nsresult rv = about->QueryInterface(aIID, aResult);
|
NS_ADDREF(about);
|
||||||
NS_RELEASE(about);
|
nsresult rv = about->QueryInterface(aIID, aResult);
|
||||||
return rv;
|
NS_RELEASE(about);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,17 +11,16 @@
|
|||||||
class nsAboutRedirector : public nsIAboutModule
|
class nsAboutRedirector : public nsIAboutModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_DECL_NSIABOUTMODULE
|
NS_DECL_NSIABOUTMODULE
|
||||||
|
|
||||||
nsAboutRedirector() {}
|
nsAboutRedirector() {}
|
||||||
|
|
||||||
static nsresult
|
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
|
||||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsAboutRedirector() {}
|
virtual ~nsAboutRedirector() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NS_ABOUT_REDIRECTOR_MODULE_CID \
|
#define NS_ABOUT_REDIRECTOR_MODULE_CID \
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ using namespace mozilla;
|
|||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
nsDSURIContentListener::nsDSURIContentListener(nsDocShell* aDocShell)
|
nsDSURIContentListener::nsDSURIContentListener(nsDocShell* aDocShell)
|
||||||
: mDocShell(aDocShell)
|
: mDocShell(aDocShell)
|
||||||
, mExistingJPEGRequest(nullptr)
|
, mExistingJPEGRequest(nullptr)
|
||||||
, mParentContentListener(nullptr)
|
, mParentContentListener(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,439 +40,437 @@ nsDSURIContentListener::~nsDSURIContentListener()
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDSURIContentListener::Init()
|
nsDSURIContentListener::Init()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get webnav info");
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDSURIContentListener::nsISupports
|
// nsDSURIContentListener::nsISupports
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsDSURIContentListener)
|
NS_IMPL_ADDREF(nsDSURIContentListener)
|
||||||
NS_IMPL_RELEASE(nsDSURIContentListener)
|
NS_IMPL_RELEASE(nsDSURIContentListener)
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(nsDSURIContentListener)
|
NS_INTERFACE_MAP_BEGIN(nsDSURIContentListener)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDSURIContentListener::nsIURIContentListener
|
// nsDSURIContentListener::nsIURIContentListener
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
|
nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
|
||||||
{
|
{
|
||||||
// If mDocShell is null here, that means someone's starting a load
|
// If mDocShell is null here, that means someone's starting a load
|
||||||
// in our docshell after it's already been destroyed. Don't let
|
// in our docshell after it's already been destroyed. Don't let
|
||||||
// that happen.
|
// that happen.
|
||||||
if (!mDocShell) {
|
if (!mDocShell) {
|
||||||
*aAbortOpen = true;
|
*aAbortOpen = true;
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
|
||||||
GetParentContentListener(getter_AddRefs(parentListener));
|
|
||||||
if (parentListener)
|
|
||||||
return parentListener->OnStartURIOpen(aURI, aAbortOpen);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||||
|
GetParentContentListener(getter_AddRefs(parentListener));
|
||||||
|
if (parentListener) {
|
||||||
|
return parentListener->OnStartURIOpen(aURI, aAbortOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::DoContent(const char* aContentType,
|
nsDSURIContentListener::DoContent(const char* aContentType,
|
||||||
bool aIsContentPreferred,
|
bool aIsContentPreferred,
|
||||||
nsIRequest* request,
|
nsIRequest* aRequest,
|
||||||
nsIStreamListener** aContentHandler,
|
nsIStreamListener** aContentHandler,
|
||||||
bool* aAbortProcess)
|
bool* aAbortProcess)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
NS_ENSURE_ARG_POINTER(aContentHandler);
|
NS_ENSURE_ARG_POINTER(aContentHandler);
|
||||||
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
// Check whether X-Frame-Options permits us to load this content in an
|
|
||||||
// iframe and abort the load (unless we've disabled x-frame-options
|
|
||||||
// checking).
|
|
||||||
if (!CheckFrameOptions(request)) {
|
|
||||||
*aAbortProcess = true;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
*aAbortProcess = false;
|
|
||||||
|
|
||||||
// determine if the channel has just been retargeted to us...
|
|
||||||
nsLoadFlags loadFlags = 0;
|
|
||||||
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
|
|
||||||
|
|
||||||
if (aOpenedChannel)
|
|
||||||
aOpenedChannel->GetLoadFlags(&loadFlags);
|
|
||||||
|
|
||||||
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
|
|
||||||
{
|
|
||||||
// XXX: Why does this not stop the content too?
|
|
||||||
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
|
|
||||||
|
|
||||||
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case of multipart jpeg request (mjpeg) we don't really want to
|
|
||||||
// create new viewer since the one we already have is capable of
|
|
||||||
// rendering multipart jpeg correctly (see bug 625012)
|
|
||||||
nsCOMPtr<nsIChannel> baseChannel;
|
|
||||||
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(request)) {
|
|
||||||
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool reuseCV = baseChannel
|
|
||||||
&& baseChannel == mExistingJPEGRequest
|
|
||||||
&& nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
|
|
||||||
|
|
||||||
if (mExistingJPEGStreamListener && reuseCV) {
|
|
||||||
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
|
|
||||||
copy.forget(aContentHandler);
|
|
||||||
rv = NS_OK;
|
|
||||||
} else {
|
|
||||||
rv = mDocShell->CreateContentViewer(aContentType, request, aContentHandler);
|
|
||||||
if (NS_SUCCEEDED(rv) && reuseCV) {
|
|
||||||
mExistingJPEGStreamListener = *aContentHandler;
|
|
||||||
} else {
|
|
||||||
mExistingJPEGStreamListener = nullptr;
|
|
||||||
}
|
|
||||||
mExistingJPEGRequest = baseChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (rv == NS_ERROR_REMOTE_XUL) {
|
|
||||||
request->Cancel(rv);
|
|
||||||
*aAbortProcess = true;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
// we don't know how to handle the content
|
|
||||||
*aContentHandler = nullptr;
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
|
||||||
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow()
|
|
||||||
: nullptr;
|
|
||||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
|
||||||
domWindow->Focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Check whether X-Frame-Options permits us to load this content in an
|
||||||
|
// iframe and abort the load (unless we've disabled x-frame-options
|
||||||
|
// checking).
|
||||||
|
if (!CheckFrameOptions(aRequest)) {
|
||||||
|
*aAbortProcess = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*aAbortProcess = false;
|
||||||
|
|
||||||
|
// determine if the channel has just been retargeted to us...
|
||||||
|
nsLoadFlags loadFlags = 0;
|
||||||
|
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
|
||||||
|
|
||||||
|
if (aOpenedChannel) {
|
||||||
|
aOpenedChannel->GetLoadFlags(&loadFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||||
|
// XXX: Why does this not stop the content too?
|
||||||
|
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
|
||||||
|
|
||||||
|
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case of multipart jpeg request (mjpeg) we don't really want to
|
||||||
|
// create new viewer since the one we already have is capable of
|
||||||
|
// rendering multipart jpeg correctly (see bug 625012)
|
||||||
|
nsCOMPtr<nsIChannel> baseChannel;
|
||||||
|
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
|
||||||
|
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
|
||||||
|
nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
|
||||||
|
|
||||||
|
if (mExistingJPEGStreamListener && reuseCV) {
|
||||||
|
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
|
||||||
|
copy.forget(aContentHandler);
|
||||||
|
rv = NS_OK;
|
||||||
|
} else {
|
||||||
|
rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
|
||||||
|
if (NS_SUCCEEDED(rv) && reuseCV) {
|
||||||
|
mExistingJPEGStreamListener = *aContentHandler;
|
||||||
|
} else {
|
||||||
|
mExistingJPEGStreamListener = nullptr;
|
||||||
|
}
|
||||||
|
mExistingJPEGRequest = baseChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rv == NS_ERROR_REMOTE_XUL) {
|
||||||
|
aRequest->Cancel(rv);
|
||||||
|
*aAbortProcess = true;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
// we don't know how to handle the content
|
||||||
|
*aContentHandler = nullptr;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||||
|
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||||
|
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||||
|
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||||
|
domWindow->Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::IsPreferred(const char* aContentType,
|
nsDSURIContentListener::IsPreferred(const char* aContentType,
|
||||||
char ** aDesiredContentType,
|
char** aDesiredContentType,
|
||||||
bool* aCanHandle)
|
bool* aCanHandle)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aCanHandle);
|
NS_ENSURE_ARG_POINTER(aCanHandle);
|
||||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||||
|
|
||||||
// the docshell has no idea if it is the preferred content provider or not.
|
// the docshell has no idea if it is the preferred content provider or not.
|
||||||
// It needs to ask its parent if it is the preferred content handler or not...
|
// It needs to ask its parent if it is the preferred content handler or not...
|
||||||
|
|
||||||
nsCOMPtr<nsIURIContentListener> parentListener;
|
nsCOMPtr<nsIURIContentListener> parentListener;
|
||||||
GetParentContentListener(getter_AddRefs(parentListener));
|
GetParentContentListener(getter_AddRefs(parentListener));
|
||||||
if (parentListener) {
|
if (parentListener) {
|
||||||
return parentListener->IsPreferred(aContentType,
|
return parentListener->IsPreferred(aContentType,
|
||||||
aDesiredContentType,
|
aDesiredContentType,
|
||||||
aCanHandle);
|
aCanHandle);
|
||||||
}
|
}
|
||||||
// we used to return false here if we didn't have a parent properly
|
// we used to return false here if we didn't have a parent properly
|
||||||
// registered at the top of the docshell hierarchy to dictate what
|
// registered at the top of the docshell hierarchy to dictate what
|
||||||
// content types this docshell should be a preferred handler for. But
|
// content types this docshell should be a preferred handler for. But
|
||||||
// this really makes it hard for developers using iframe or browser tags
|
// this really makes it hard for developers using iframe or browser tags
|
||||||
// because then they need to make sure they implement
|
// because then they need to make sure they implement
|
||||||
// nsIURIContentListener otherwise all link clicks would get sent to
|
// nsIURIContentListener otherwise all link clicks would get sent to
|
||||||
// another window because we said we weren't the preferred handler type.
|
// another window because we said we weren't the preferred handler type.
|
||||||
// I'm going to change the default now...if we can handle the content,
|
// I'm going to change the default now...if we can handle the content,
|
||||||
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
|
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
|
||||||
// of our docshell chain, then we'll now always attempt to process the
|
// of our docshell chain, then we'll now always attempt to process the
|
||||||
// content ourselves...
|
// content ourselves...
|
||||||
return CanHandleContent(aContentType,
|
return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
|
||||||
true,
|
|
||||||
aDesiredContentType,
|
|
||||||
aCanHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
nsDSURIContentListener::CanHandleContent(const char* aContentType,
|
||||||
bool aIsContentPreferred,
|
bool aIsContentPreferred,
|
||||||
char ** aDesiredContentType,
|
char** aDesiredContentType,
|
||||||
bool* aCanHandleContent)
|
bool* aCanHandleContent)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
NS_PRECONDITION(aCanHandleContent, "Null out param?");
|
||||||
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
NS_ENSURE_ARG_POINTER(aDesiredContentType);
|
||||||
|
|
||||||
*aCanHandleContent = false;
|
*aCanHandleContent = false;
|
||||||
*aDesiredContentType = nullptr;
|
*aDesiredContentType = nullptr;
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
if (aContentType) {
|
if (aContentType) {
|
||||||
uint32_t canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
uint32_t canHandle = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
rv = mNavInfo->IsTypeSupported(nsDependentCString(aContentType),
|
||||||
mDocShell,
|
mDocShell,
|
||||||
&canHandle);
|
&canHandle);
|
||||||
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
*aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::GetLoadCookie(nsISupports ** aLoadCookie)
|
nsDSURIContentListener::GetLoadCookie(nsISupports** aLoadCookie)
|
||||||
{
|
{
|
||||||
NS_IF_ADDREF(*aLoadCookie = nsDocShell::GetAsSupports(mDocShell));
|
NS_IF_ADDREF(*aLoadCookie = nsDocShell::GetAsSupports(mDocShell));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::SetLoadCookie(nsISupports * aLoadCookie)
|
nsDSURIContentListener::SetLoadCookie(nsISupports* aLoadCookie)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsRefPtr<nsDocLoader> cookieAsDocLoader =
|
nsRefPtr<nsDocLoader> cookieAsDocLoader =
|
||||||
nsDocLoader::GetAsDocLoader(aLoadCookie);
|
nsDocLoader::GetAsDocLoader(aLoadCookie);
|
||||||
NS_ASSERTION(cookieAsDocLoader && cookieAsDocLoader == mDocShell,
|
NS_ASSERTION(cookieAsDocLoader && cookieAsDocLoader == mDocShell,
|
||||||
"Invalid load cookie being set!");
|
"Invalid load cookie being set!");
|
||||||
#endif
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
|
|
||||||
aParentListener)
|
|
||||||
{
|
|
||||||
if (mWeakParentContentListener)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIURIContentListener> tempListener =
|
|
||||||
do_QueryReferent(mWeakParentContentListener);
|
|
||||||
*aParentListener = tempListener;
|
|
||||||
NS_IF_ADDREF(*aParentListener);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*aParentListener = mParentContentListener;
|
|
||||||
NS_IF_ADDREF(*aParentListener);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
|
nsDSURIContentListener::GetParentContentListener(
|
||||||
aParentListener)
|
nsIURIContentListener** aParentListener)
|
||||||
{
|
{
|
||||||
if (aParentListener)
|
if (mWeakParentContentListener) {
|
||||||
{
|
nsCOMPtr<nsIURIContentListener> tempListener =
|
||||||
// Store the parent listener as a weak ref. Parents not supporting
|
do_QueryReferent(mWeakParentContentListener);
|
||||||
// nsISupportsWeakReference assert but may still be used.
|
*aParentListener = tempListener;
|
||||||
mParentContentListener = nullptr;
|
NS_IF_ADDREF(*aParentListener);
|
||||||
mWeakParentContentListener = do_GetWeakReference(aParentListener);
|
} else {
|
||||||
if (!mWeakParentContentListener)
|
*aParentListener = mParentContentListener;
|
||||||
{
|
NS_IF_ADDREF(*aParentListener);
|
||||||
mParentContentListener = aParentListener;
|
}
|
||||||
}
|
return NS_OK;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mWeakParentContentListener = nullptr;
|
|
||||||
mParentContentListener = nullptr;
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChannel,
|
NS_IMETHODIMP
|
||||||
const nsAString& policy) {
|
nsDSURIContentListener::SetParentContentListener(
|
||||||
static const char allowFrom[] = "allow-from";
|
nsIURIContentListener* aParentListener)
|
||||||
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
|
{
|
||||||
bool isAllowFrom =
|
if (aParentListener) {
|
||||||
StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
|
// Store the parent listener as a weak ref. Parents not supporting
|
||||||
|
// nsISupportsWeakReference assert but may still be used.
|
||||||
// return early if header does not have one of the values with meaning
|
mParentContentListener = nullptr;
|
||||||
if (!policy.LowerCaseEqualsLiteral("deny") &&
|
mWeakParentContentListener = do_GetWeakReference(aParentListener);
|
||||||
!policy.LowerCaseEqualsLiteral("sameorigin") &&
|
if (!mWeakParentContentListener) {
|
||||||
!isAllowFrom)
|
mParentContentListener = aParentListener;
|
||||||
return true;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
|
||||||
httpChannel->GetURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
// XXXkhuey when does this happen? Is returning true safe here?
|
|
||||||
if (!mDocShell) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mWeakParentContentListener = nullptr;
|
||||||
|
mParentContentListener = nullptr;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to check the location of this window and the location of the top
|
bool
|
||||||
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
|
nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
|
||||||
// document must be same-origin with top window. X-F-O: DENY requires that
|
const nsAString& aPolicy)
|
||||||
// the document must never be framed.
|
{
|
||||||
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
|
static const char allowFrom[] = "allow-from";
|
||||||
// If we don't have DOMWindow there is no risk of clickjacking
|
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
|
||||||
if (!thisWindow)
|
bool isAllowFrom =
|
||||||
return true;
|
StringHead(aPolicy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
|
||||||
|
|
||||||
// GetScriptableTop, not GetTop, because we want this to respect
|
|
||||||
// <iframe mozbrowser> boundaries.
|
|
||||||
nsCOMPtr<nsIDOMWindow> topWindow;
|
|
||||||
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
|
||||||
|
|
||||||
// if the document is in the top window, it's not in a frame.
|
|
||||||
if (thisWindow == topWindow)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Find the top docshell in our parent chain that doesn't have the system
|
|
||||||
// principal and use it for the principal comparison. Finding the top
|
|
||||||
// content-type docshell doesn't work because some chrome documents are
|
|
||||||
// loaded in content docshells (see bug 593387).
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(do_QueryInterface(
|
|
||||||
static_cast<nsIDocShell*> (mDocShell)));
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem,
|
|
||||||
curDocShellItem = thisDocShellItem;
|
|
||||||
nsCOMPtr<nsIDocument> topDoc;
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIScriptSecurityManager> ssm =
|
|
||||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
|
||||||
if (!ssm) {
|
|
||||||
MOZ_CRASH();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Traverse up the parent chain and stop when we see a docshell whose
|
|
||||||
// parent has a system principal, or a docshell corresponding to
|
|
||||||
// <iframe mozbrowser>.
|
|
||||||
while (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
|
|
||||||
parentDocShellItem) {
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
|
|
||||||
if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool system = false;
|
|
||||||
topDoc = parentDocShellItem->GetDocument();
|
|
||||||
if (topDoc) {
|
|
||||||
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
|
|
||||||
&system)) && system) {
|
|
||||||
// Found a system-principled doc: last docshell was top.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
curDocShellItem = parentDocShellItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this document has the top non-SystemPrincipal docshell it is not being
|
|
||||||
// framed or it is being framed by a chrome document, which we allow.
|
|
||||||
if (curDocShellItem == thisDocShellItem)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If the value of the header is DENY, and the previous condition is
|
|
||||||
// not met (current docshell is not the top docshell), prohibit the
|
|
||||||
// load.
|
|
||||||
if (policy.LowerCaseEqualsLiteral("deny")) {
|
|
||||||
ReportXFOViolation(curDocShellItem, uri, eDENY);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
topDoc = curDocShellItem->GetDocument();
|
|
||||||
nsCOMPtr<nsIURI> topUri;
|
|
||||||
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
|
|
||||||
|
|
||||||
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
|
|
||||||
// parent chain must be from the same origin as this document.
|
|
||||||
if (policy.LowerCaseEqualsLiteral("sameorigin")) {
|
|
||||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
|
|
||||||
return false; /* wasn't same-origin */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the X-Frame-Options value is "allow-from [uri]", then the top
|
|
||||||
// frame in the parent chain must be from that origin
|
|
||||||
if (isAllowFrom) {
|
|
||||||
if (policy.Length() == allowFromLen ||
|
|
||||||
(policy[allowFromLen] != ' ' &&
|
|
||||||
policy[allowFromLen] != '\t')) {
|
|
||||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rv = NS_NewURI(getter_AddRefs(uri),
|
|
||||||
Substring(policy, allowFromLen));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// return early if header does not have one of the values with meaning
|
||||||
|
if (!aPolicy.LowerCaseEqualsLiteral("deny") &&
|
||||||
|
!aPolicy.LowerCaseEqualsLiteral("sameorigin") &&
|
||||||
|
!isAllowFrom) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
aHttpChannel->GetURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
|
// XXXkhuey when does this happen? Is returning true safe here?
|
||||||
|
if (!mDocShell) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to check the location of this window and the location of the top
|
||||||
|
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
|
||||||
|
// document must be same-origin with top window. X-F-O: DENY requires that
|
||||||
|
// the document must never be framed.
|
||||||
|
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
|
||||||
|
// If we don't have DOMWindow there is no risk of clickjacking
|
||||||
|
if (!thisWindow) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetScriptableTop, not GetTop, because we want this to respect
|
||||||
|
// <iframe mozbrowser> boundaries.
|
||||||
|
nsCOMPtr<nsIDOMWindow> topWindow;
|
||||||
|
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
|
||||||
|
|
||||||
|
// if the document is in the top window, it's not in a frame.
|
||||||
|
if (thisWindow == topWindow) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the top docshell in our parent chain that doesn't have the system
|
||||||
|
// principal and use it for the principal comparison. Finding the top
|
||||||
|
// content-type docshell doesn't work because some chrome documents are
|
||||||
|
// loaded in content docshells (see bug 593387).
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(
|
||||||
|
do_QueryInterface(static_cast<nsIDocShell*>(mDocShell)));
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = thisDocShellItem;
|
||||||
|
nsCOMPtr<nsIDocument> topDoc;
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIScriptSecurityManager> ssm =
|
||||||
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||||
|
if (!ssm) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traverse up the parent chain and stop when we see a docshell whose
|
||||||
|
// parent has a system principal, or a docshell corresponding to
|
||||||
|
// <iframe mozbrowser>.
|
||||||
|
while (NS_SUCCEEDED(
|
||||||
|
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
|
||||||
|
parentDocShellItem) {
|
||||||
|
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
|
||||||
|
if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool system = false;
|
||||||
|
topDoc = parentDocShellItem->GetDocument();
|
||||||
|
if (topDoc) {
|
||||||
|
if (NS_SUCCEEDED(
|
||||||
|
ssm->IsSystemPrincipal(topDoc->NodePrincipal(), &system)) &&
|
||||||
|
system) {
|
||||||
|
// Found a system-principled doc: last docshell was top.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
curDocShellItem = parentDocShellItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this document has the top non-SystemPrincipal docshell it is not being
|
||||||
|
// framed or it is being framed by a chrome document, which we allow.
|
||||||
|
if (curDocShellItem == thisDocShellItem) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the value of the header is DENY, and the previous condition is
|
||||||
|
// not met (current docshell is not the top docshell), prohibit the
|
||||||
|
// load.
|
||||||
|
if (aPolicy.LowerCaseEqualsLiteral("deny")) {
|
||||||
|
ReportXFOViolation(curDocShellItem, uri, eDENY);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
topDoc = curDocShellItem->GetDocument();
|
||||||
|
nsCOMPtr<nsIURI> topUri;
|
||||||
|
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
|
||||||
|
|
||||||
|
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
|
||||||
|
// parent chain must be from the same origin as this document.
|
||||||
|
if (aPolicy.LowerCaseEqualsLiteral("sameorigin")) {
|
||||||
|
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
|
||||||
|
return false; /* wasn't same-origin */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the X-Frame-Options value is "allow-from [uri]", then the top
|
||||||
|
// frame in the parent chain must be from that origin
|
||||||
|
if (isAllowFrom) {
|
||||||
|
if (aPolicy.Length() == allowFromLen ||
|
||||||
|
(aPolicy[allowFromLen] != ' ' &&
|
||||||
|
aPolicy[allowFromLen] != '\t')) {
|
||||||
|
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
rv = NS_NewURI(getter_AddRefs(uri), Substring(aPolicy, allowFromLen));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = ssm->CheckSameOriginURI(uri, topUri, true);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if X-Frame-Options permits this document to be loaded as a subdocument.
|
// Check if X-Frame-Options permits this document to be loaded as a subdocument.
|
||||||
// This will iterate through and check any number of X-Frame-Options policies
|
// This will iterate through and check any number of X-Frame-Options policies
|
||||||
// in the request (comma-separated in a header, multiple headers, etc).
|
// in the request (comma-separated in a header, multiple headers, etc).
|
||||||
bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
|
bool
|
||||||
|
nsDSURIContentListener::CheckFrameOptions(nsIRequest* aRequest)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIChannel> chan = do_QueryInterface(request);
|
nsCOMPtr<nsIChannel> chan = do_QueryInterface(aRequest);
|
||||||
if (!chan) {
|
if (!chan) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(chan);
|
|
||||||
if (!httpChannel) {
|
|
||||||
// check if it is hiding in a multipart channel
|
|
||||||
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
|
|
||||||
if (NS_FAILED(rv))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!httpChannel) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoCString xfoHeaderCValue;
|
|
||||||
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-Frame-Options"),
|
|
||||||
xfoHeaderCValue);
|
|
||||||
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
|
|
||||||
|
|
||||||
// if no header value, there's nothing to do.
|
|
||||||
if (xfoHeaderValue.IsEmpty())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// iterate through all the header values (usually there's only one, but can
|
|
||||||
// be many. If any want to deny the load, deny the load.
|
|
||||||
nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
|
||||||
const nsSubstring& tok = tokenizer.nextToken();
|
|
||||||
if (!CheckOneFrameOptionsPolicy(httpChannel, tok)) {
|
|
||||||
// cancel the load and display about:blank
|
|
||||||
httpChannel->Cancel(NS_BINDING_ABORTED);
|
|
||||||
if (mDocShell) {
|
|
||||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(mDocShell));
|
|
||||||
if (webNav) {
|
|
||||||
webNav->LoadURI(MOZ_UTF16("about:blank"),
|
|
||||||
0, nullptr, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(chan);
|
||||||
|
if (!httpChannel) {
|
||||||
|
// check if it is hiding in a multipart channel
|
||||||
|
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!httpChannel) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoCString xfoHeaderCValue;
|
||||||
|
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-Frame-Options"),
|
||||||
|
xfoHeaderCValue);
|
||||||
|
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
|
||||||
|
|
||||||
|
// if no header value, there's nothing to do.
|
||||||
|
if (xfoHeaderValue.IsEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate through all the header values (usually there's only one, but can
|
||||||
|
// be many. If any want to deny the load, deny the load.
|
||||||
|
nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
|
||||||
|
while (tokenizer.hasMoreTokens()) {
|
||||||
|
const nsSubstring& tok = tokenizer.nextToken();
|
||||||
|
if (!CheckOneFrameOptionsPolicy(httpChannel, tok)) {
|
||||||
|
// cancel the load and display about:blank
|
||||||
|
httpChannel->Cancel(NS_BINDING_ABORTED);
|
||||||
|
if (mDocShell) {
|
||||||
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(mDocShell));
|
||||||
|
if (webNav) {
|
||||||
|
webNav->LoadURI(MOZ_UTF16("about:blank"),
|
||||||
|
0, nullptr, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -482,67 +480,75 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
|
|||||||
{
|
{
|
||||||
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
|
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
|
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
|
||||||
if (!topOuterWindow)
|
if (!topOuterWindow) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
|
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
|
||||||
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
|
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
|
||||||
if (!topInnerWindow)
|
if (!topInnerWindow) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> topURI;
|
nsCOMPtr<nsIURI> topURI;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
|
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
|
||||||
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!topURI)
|
if (!topURI) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsCString topURIString;
|
nsCString topURIString;
|
||||||
nsCString thisURIString;
|
nsCString thisURIString;
|
||||||
|
|
||||||
rv = topURI->GetSpec(topURIString);
|
rv = topURI->GetSpec(topURIString);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rv = aThisURI->GetSpec(thisURIString);
|
rv = aThisURI->GetSpec(thisURIString);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIConsoleService> consoleService =
|
nsCOMPtr<nsIConsoleService> consoleService =
|
||||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||||
nsCOMPtr<nsIScriptError> errorObject =
|
nsCOMPtr<nsIScriptError> errorObject =
|
||||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||||
|
|
||||||
if (!consoleService || !errorObject)
|
if (!consoleService || !errorObject) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
|
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
|
||||||
msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
|
msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
|
||||||
|
|
||||||
switch (aHeader) {
|
switch (aHeader) {
|
||||||
case eDENY:
|
case eDENY:
|
||||||
msg.AppendLiteral(" does not permit framing.");
|
msg.AppendLiteral(" does not permit framing.");
|
||||||
break;
|
break;
|
||||||
case eSAMEORIGIN:
|
case eSAMEORIGIN:
|
||||||
msg.AppendLiteral(" does not permit cross-origin framing.");
|
msg.AppendLiteral(" does not permit cross-origin framing.");
|
||||||
break;
|
break;
|
||||||
case eALLOWFROM:
|
case eALLOWFROM:
|
||||||
msg.AppendLiteral(" does not permit framing by ");
|
msg.AppendLiteral(" does not permit framing by ");
|
||||||
msg.Append(NS_ConvertUTF8toUTF16(topURIString));
|
msg.Append(NS_ConvertUTF8toUTF16(topURIString));
|
||||||
msg.Append('.');
|
msg.Append('.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = errorObject->InitWithWindowID(msg, EmptyString(), EmptyString(), 0, 0,
|
rv = errorObject->InitWithWindowID(msg, EmptyString(), EmptyString(), 0, 0,
|
||||||
nsIScriptError::errorFlag,
|
nsIScriptError::errorFlag,
|
||||||
"X-Frame-Options",
|
"X-Frame-Options",
|
||||||
topInnerWindow->WindowID());
|
topInnerWindow->WindowID());
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
consoleService->LogMessage(errorObject);
|
consoleService->LogMessage(errorObject);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,56 +16,59 @@ class nsIWebNavigationInfo;
|
|||||||
class nsIHttpChannel;
|
class nsIHttpChannel;
|
||||||
class nsAString;
|
class nsAString;
|
||||||
|
|
||||||
class nsDSURIContentListener MOZ_FINAL :
|
class nsDSURIContentListener MOZ_FINAL
|
||||||
public nsIURIContentListener,
|
: public nsIURIContentListener
|
||||||
public nsSupportsWeakReference
|
, public nsSupportsWeakReference
|
||||||
|
|
||||||
{
|
{
|
||||||
friend class nsDocShell;
|
friend class nsDocShell;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NS_DECL_THREADSAFE_ISUPPORTS
|
NS_DECL_THREADSAFE_ISUPPORTS
|
||||||
NS_DECL_NSIURICONTENTLISTENER
|
NS_DECL_NSIURICONTENTLISTENER
|
||||||
|
|
||||||
nsresult Init();
|
nsresult Init();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit nsDSURIContentListener(nsDocShell* aDocShell);
|
explicit nsDSURIContentListener(nsDocShell* aDocShell);
|
||||||
virtual ~nsDSURIContentListener();
|
virtual ~nsDSURIContentListener();
|
||||||
|
|
||||||
void DropDocShellreference() {
|
void DropDocShellReference()
|
||||||
mDocShell = nullptr;
|
{
|
||||||
mExistingJPEGRequest = nullptr;
|
mDocShell = nullptr;
|
||||||
mExistingJPEGStreamListener = nullptr;
|
mExistingJPEGRequest = nullptr;
|
||||||
}
|
mExistingJPEGStreamListener = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine if X-Frame-Options allows content to be framed
|
// Determine if X-Frame-Options allows content to be framed
|
||||||
// as a subdocument
|
// as a subdocument
|
||||||
bool CheckFrameOptions(nsIRequest* request);
|
bool CheckFrameOptions(nsIRequest* aRequest);
|
||||||
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel,
|
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
|
||||||
const nsAString& policy);
|
const nsAString& aPolicy);
|
||||||
|
|
||||||
enum XFOHeader {
|
enum XFOHeader
|
||||||
eDENY,
|
{
|
||||||
eSAMEORIGIN,
|
eDENY,
|
||||||
eALLOWFROM
|
eSAMEORIGIN,
|
||||||
};
|
eALLOWFROM
|
||||||
|
};
|
||||||
|
|
||||||
|
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
|
||||||
|
nsIURI* aThisURI,
|
||||||
|
XFOHeader aHeader);
|
||||||
|
|
||||||
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
|
|
||||||
nsIURI* aThisURI,
|
|
||||||
XFOHeader aHeader);
|
|
||||||
protected:
|
protected:
|
||||||
nsDocShell* mDocShell;
|
nsDocShell* mDocShell;
|
||||||
// Hack to handle multipart images without creating a new viewer
|
// Hack to handle multipart images without creating a new viewer
|
||||||
nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
|
nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
|
||||||
nsCOMPtr<nsIChannel> mExistingJPEGRequest;
|
nsCOMPtr<nsIChannel> mExistingJPEGRequest;
|
||||||
|
|
||||||
// Store the parent listener in either of these depending on
|
// Store the parent listener in either of these depending on
|
||||||
// if supports weak references or not. Proper weak refs are
|
// if supports weak references or not. Proper weak refs are
|
||||||
// preferred and encouraged!
|
// preferred and encouraged!
|
||||||
nsWeakPtr mWeakParentContentListener;
|
nsWeakPtr mWeakParentContentListener;
|
||||||
nsIURIContentListener* mParentContentListener;
|
nsIURIContentListener* mParentContentListener;
|
||||||
|
|
||||||
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsDSURIContentListener_h__ */
|
#endif /* nsDSURIContentListener_h__ */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -15,56 +15,56 @@ class nsDefaultURIFixupInfo;
|
|||||||
class nsDefaultURIFixup : public nsIURIFixup
|
class nsDefaultURIFixup : public nsIURIFixup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIURIFIXUP
|
NS_DECL_NSIURIFIXUP
|
||||||
|
|
||||||
nsDefaultURIFixup();
|
nsDefaultURIFixup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsDefaultURIFixup();
|
virtual ~nsDefaultURIFixup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* additional members */
|
/* additional members */
|
||||||
nsresult FileURIFixup(const nsACString &aStringURI, nsIURI** aURI);
|
nsresult FileURIFixup(const nsACString& aStringURI, nsIURI** aURI);
|
||||||
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aOut);
|
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aResult);
|
||||||
nsresult FixupURIProtocol(const nsACString& aIn,
|
nsresult FixupURIProtocol(const nsACString& aIn,
|
||||||
nsDefaultURIFixupInfo* aFixupInfo,
|
nsDefaultURIFixupInfo* aFixupInfo,
|
||||||
nsIURI** aURI);
|
nsIURI** aURI);
|
||||||
nsresult KeywordURIFixup(const nsACString &aStringURI,
|
nsresult KeywordURIFixup(const nsACString& aStringURI,
|
||||||
nsDefaultURIFixupInfo* aFixupInfo,
|
nsDefaultURIFixupInfo* aFixupInfo,
|
||||||
nsIInputStream** aPostData);
|
nsIInputStream** aPostData);
|
||||||
nsresult TryKeywordFixupForURIInfo(const nsACString &aStringURI,
|
nsresult TryKeywordFixupForURIInfo(const nsACString& aStringURI,
|
||||||
nsDefaultURIFixupInfo* aFixupInfo,
|
nsDefaultURIFixupInfo* aFixupInfo,
|
||||||
nsIInputStream** aPostData);
|
nsIInputStream** aPostData);
|
||||||
bool PossiblyByteExpandedFileName(const nsAString& aIn);
|
bool PossiblyByteExpandedFileName(const nsAString& aIn);
|
||||||
bool PossiblyHostPortUrl(const nsACString& aUrl);
|
bool PossiblyHostPortUrl(const nsACString& aUrl);
|
||||||
bool MakeAlternateURI(nsIURI *aURI);
|
bool MakeAlternateURI(nsIURI* aURI);
|
||||||
bool IsLikelyFTP(const nsCString& aHostSpec);
|
bool IsLikelyFTP(const nsCString& aHostSpec);
|
||||||
bool IsDomainWhitelisted(const nsAutoCString aAsciiHost,
|
bool IsDomainWhitelisted(const nsAutoCString aAsciiHost,
|
||||||
const uint32_t aDotLoc);
|
const uint32_t aDotLoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsDefaultURIFixupInfo : public nsIURIFixupInfo
|
class nsDefaultURIFixupInfo : public nsIURIFixupInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIURIFIXUPINFO
|
NS_DECL_NSIURIFIXUPINFO
|
||||||
|
|
||||||
explicit nsDefaultURIFixupInfo(const nsACString& aOriginalInput);
|
explicit nsDefaultURIFixupInfo(const nsACString& aOriginalInput);
|
||||||
|
|
||||||
friend class nsDefaultURIFixup;
|
friend class nsDefaultURIFixup;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsDefaultURIFixupInfo();
|
virtual ~nsDefaultURIFixupInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsISupports> mConsumer;
|
nsCOMPtr<nsISupports> mConsumer;
|
||||||
nsCOMPtr<nsIURI> mPreferredURI;
|
nsCOMPtr<nsIURI> mPreferredURI;
|
||||||
nsCOMPtr<nsIURI> mFixedURI;
|
nsCOMPtr<nsIURI> mFixedURI;
|
||||||
bool mFixupChangedProtocol;
|
bool mFixupChangedProtocol;
|
||||||
bool mFixupCreatedAlternateURI;
|
bool mFixupCreatedAlternateURI;
|
||||||
nsString mKeywordProviderName;
|
nsString mKeywordProviderName;
|
||||||
nsString mKeywordAsSent;
|
nsString mKeywordAsSent;
|
||||||
nsAutoCString mOriginalInput;
|
nsAutoCString mOriginalInput;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,6 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
|
||||||
#include "nsDocShellEditorData.h"
|
#include "nsDocShellEditorData.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
@@ -14,28 +13,16 @@
|
|||||||
#include "nsIEditingSession.h"
|
#include "nsIEditingSession.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell)
|
||||||
|
: mDocShell(aOwningDocShell)
|
||||||
nsDocShellEditorData
|
, mMakeEditable(false)
|
||||||
|
, mIsDetached(false)
|
||||||
----------------------------------------------------------------------------*/
|
, mDetachedMakeEditable(false)
|
||||||
|
, mDetachedEditingState(nsIHTMLDocument::eOff)
|
||||||
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
|
|
||||||
: mDocShell(inOwningDocShell)
|
|
||||||
, mMakeEditable(false)
|
|
||||||
, mIsDetached(false)
|
|
||||||
, mDetachedMakeEditable(false)
|
|
||||||
, mDetachedEditingState(nsIHTMLDocument::eOff)
|
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mDocShell, "Where is my docShell?");
|
NS_ASSERTION(mDocShell, "Where is my docShell?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
~nsDocShellEditorData
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsDocShellEditorData::~nsDocShellEditorData()
|
nsDocShellEditorData::~nsDocShellEditorData()
|
||||||
{
|
{
|
||||||
TearDownEditor();
|
TearDownEditor();
|
||||||
@@ -52,143 +39,103 @@ nsDocShellEditorData::TearDownEditor()
|
|||||||
mIsDetached = false;
|
mIsDetached = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
MakeEditable
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::MakeEditable(bool inWaitForUriLoad)
|
nsDocShellEditorData::MakeEditable(bool aInWaitForUriLoad)
|
||||||
{
|
{
|
||||||
if (mMakeEditable)
|
if (mMakeEditable) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
// if we are already editable, and are getting turned off,
|
// if we are already editable, and are getting turned off,
|
||||||
// nuke the editor.
|
// nuke the editor.
|
||||||
if (mEditor)
|
if (mEditor) {
|
||||||
{
|
|
||||||
NS_WARNING("Destroying existing editor on frame");
|
NS_WARNING("Destroying existing editor on frame");
|
||||||
|
|
||||||
mEditor->PreDestroy(false);
|
mEditor->PreDestroy(false);
|
||||||
mEditor = nullptr;
|
mEditor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inWaitForUriLoad)
|
if (aInWaitForUriLoad) {
|
||||||
mMakeEditable = true;
|
mMakeEditable = true;
|
||||||
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
GetEditable
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
bool
|
bool
|
||||||
nsDocShellEditorData::GetEditable()
|
nsDocShellEditorData::GetEditable()
|
||||||
{
|
{
|
||||||
return mMakeEditable || (mEditor != nullptr);
|
return mMakeEditable || (mEditor != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CreateEditor
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::CreateEditor()
|
nsDocShellEditorData::CreateEditor()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIEditingSession> editingSession;
|
nsCOMPtr<nsIEditingSession> editingSession;
|
||||||
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
|
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||||
rv = editingSession->SetupEditorOnWindow(domWindow);
|
rv = editingSession->SetupEditorOnWindow(domWindow);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
GetEditingSession
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::GetEditingSession(nsIEditingSession **outEditingSession)
|
nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult)
|
||||||
{
|
{
|
||||||
nsresult rv = EnsureEditingSession();
|
nsresult rv = EnsureEditingSession();
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
NS_ADDREF(*outEditingSession = mEditingSession);
|
NS_ADDREF(*aResult = mEditingSession);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
GetEditor
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::GetEditor(nsIEditor **outEditor)
|
nsDocShellEditorData::GetEditor(nsIEditor** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(outEditor);
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
NS_IF_ADDREF(*outEditor = mEditor);
|
NS_IF_ADDREF(*aResult = mEditor);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
SetEditor
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::SetEditor(nsIEditor *inEditor)
|
nsDocShellEditorData::SetEditor(nsIEditor* aEditor)
|
||||||
{
|
{
|
||||||
// destroy any editor that we have. Checks for equality are
|
// destroy any editor that we have. Checks for equality are
|
||||||
// necessary to ensure that assigment into the nsCOMPtr does
|
// necessary to ensure that assigment into the nsCOMPtr does
|
||||||
// not temporarily reduce the refCount of the editor to zero
|
// not temporarily reduce the refCount of the editor to zero
|
||||||
if (mEditor.get() != inEditor)
|
if (mEditor.get() != aEditor) {
|
||||||
{
|
if (mEditor) {
|
||||||
if (mEditor)
|
|
||||||
{
|
|
||||||
mEditor->PreDestroy(false);
|
mEditor->PreDestroy(false);
|
||||||
mEditor = nullptr;
|
mEditor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
mEditor = inEditor; // owning addref
|
mEditor = aEditor; // owning addref
|
||||||
if (!mEditor)
|
if (!mEditor) {
|
||||||
mMakeEditable = false;
|
mMakeEditable = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This creates the editing session on the content docShell that owns 'this'.
|
||||||
/*---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
EnsureEditingSession
|
|
||||||
|
|
||||||
This creates the editing session on the content docShell that owns
|
|
||||||
'this'.
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------*/
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDocShellEditorData::EnsureEditingSession()
|
nsDocShellEditorData::EnsureEditingSession()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mDocShell, "Should have docShell here");
|
NS_ASSERTION(mDocShell, "Should have docShell here");
|
||||||
NS_ASSERTION(!mIsDetached, "This will stomp editing session!");
|
NS_ASSERTION(!mIsDetached, "This will stomp editing session!");
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
if (!mEditingSession)
|
if (!mEditingSession) {
|
||||||
{
|
|
||||||
mEditingSession =
|
mEditingSession =
|
||||||
do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv);
|
do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv);
|
||||||
}
|
}
|
||||||
@@ -201,7 +148,7 @@ nsDocShellEditorData::DetachFromWindow()
|
|||||||
{
|
{
|
||||||
NS_ASSERTION(mEditingSession,
|
NS_ASSERTION(mEditingSession,
|
||||||
"Can't detach when we don't have a session to detach!");
|
"Can't detach when we don't have a session to detach!");
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||||
nsresult rv = mEditingSession->DetachFromWindow(domWindow);
|
nsresult rv = mEditingSession->DetachFromWindow(domWindow);
|
||||||
@@ -214,8 +161,9 @@ nsDocShellEditorData::DetachFromWindow()
|
|||||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
||||||
if (htmlDoc)
|
if (htmlDoc) {
|
||||||
mDetachedEditingState = htmlDoc->GetEditingState();
|
mDetachedEditingState = htmlDoc->GetEditingState();
|
||||||
|
}
|
||||||
|
|
||||||
mDocShell = nullptr;
|
mDocShell = nullptr;
|
||||||
|
|
||||||
@@ -238,8 +186,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
|
|||||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||||
domWindow->GetDocument(getter_AddRefs(domDoc));
|
domWindow->GetDocument(getter_AddRefs(domDoc));
|
||||||
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
|
||||||
if (htmlDoc)
|
if (htmlDoc) {
|
||||||
htmlDoc->SetEditingState(mDetachedEditingState);
|
htmlDoc->SetEditingState(mDetachedEditingState);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,26 +19,24 @@ class nsIEditor;
|
|||||||
class nsDocShellEditorData
|
class nsDocShellEditorData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
|
||||||
explicit nsDocShellEditorData(nsIDocShell* inOwningDocShell);
|
|
||||||
~nsDocShellEditorData();
|
~nsDocShellEditorData();
|
||||||
|
|
||||||
nsresult MakeEditable(bool inWaitForUriLoad);
|
nsresult MakeEditable(bool aWaitForUriLoad);
|
||||||
bool GetEditable();
|
bool GetEditable();
|
||||||
nsresult CreateEditor();
|
nsresult CreateEditor();
|
||||||
nsresult GetEditingSession(nsIEditingSession **outEditingSession);
|
nsresult GetEditingSession(nsIEditingSession** aResult);
|
||||||
nsresult GetEditor(nsIEditor **outEditor);
|
nsresult GetEditor(nsIEditor** aResult);
|
||||||
nsresult SetEditor(nsIEditor *inEditor);
|
nsresult SetEditor(nsIEditor* aEditor);
|
||||||
void TearDownEditor();
|
void TearDownEditor();
|
||||||
nsresult DetachFromWindow();
|
nsresult DetachFromWindow();
|
||||||
nsresult ReattachToWindow(nsIDocShell *aDocShell);
|
nsresult ReattachToWindow(nsIDocShell* aDocShell);
|
||||||
bool WaitingForLoad() const { return mMakeEditable; }
|
bool WaitingForLoad() const { return mMakeEditable; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
nsresult EnsureEditingSession();
|
nsresult EnsureEditingSession();
|
||||||
|
|
||||||
// The doc shell that owns us. Weak ref, since it always outlives us.
|
// The doc shell that owns us. Weak ref, since it always outlives us.
|
||||||
nsIDocShell* mDocShell;
|
nsIDocShell* mDocShell;
|
||||||
|
|
||||||
// Only present for the content root docShell. Session is owned here.
|
// Only present for the content root docShell. Session is owned here.
|
||||||
@@ -46,7 +44,7 @@ protected:
|
|||||||
|
|
||||||
// Indicates whether to make an editor after a url load.
|
// Indicates whether to make an editor after a url load.
|
||||||
bool mMakeEditable;
|
bool mMakeEditable;
|
||||||
|
|
||||||
// If this frame is editable, store editor here. Editor is owned here.
|
// If this frame is editable, store editor here. Editor is owned here.
|
||||||
nsCOMPtr<nsIEditor> mEditor;
|
nsCOMPtr<nsIEditor> mEditor;
|
||||||
|
|
||||||
@@ -63,5 +61,4 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // nsDocShellEditorData_h__
|
#endif // nsDocShellEditorData_h__
|
||||||
|
|||||||
@@ -4,17 +4,16 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
|
||||||
#include "nsDocShellEnumerator.h"
|
#include "nsDocShellEnumerator.h"
|
||||||
|
|
||||||
#include "nsIDocShellTreeItem.h"
|
#include "nsIDocShellTreeItem.h"
|
||||||
|
|
||||||
nsDocShellEnumerator::nsDocShellEnumerator(int32_t inEnumerationDirection)
|
nsDocShellEnumerator::nsDocShellEnumerator(int32_t aEnumerationDirection)
|
||||||
: mRootItem(nullptr)
|
: mRootItem(nullptr)
|
||||||
, mCurIndex(0)
|
, mCurIndex(0)
|
||||||
, mDocShellType(nsIDocShellTreeItem::typeAll)
|
, mDocShellType(nsIDocShellTreeItem::typeAll)
|
||||||
, mArrayValid(false)
|
, mArrayValid(false)
|
||||||
, mEnumerationDirection(inEnumerationDirection)
|
, mEnumerationDirection(aEnumerationDirection)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,40 +23,47 @@ nsDocShellEnumerator::~nsDocShellEnumerator()
|
|||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
|
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
|
||||||
|
|
||||||
|
|
||||||
/* nsISupports getNext (); */
|
/* nsISupports getNext (); */
|
||||||
NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellEnumerator::GetNext(nsISupports** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(outCurItem);
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
*outCurItem = nullptr;
|
*aResult = nullptr;
|
||||||
|
|
||||||
nsresult rv = EnsureDocShellArray();
|
nsresult rv = EnsureDocShellArray();
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
if (mCurIndex >= mItemArray.Length()) {
|
if (mCurIndex >= mItemArray.Length()) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// post-increment is important here
|
// post-increment is important here
|
||||||
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
|
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
|
||||||
item.forget(outCurItem);
|
item.forget(aResult);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* boolean hasMoreElements (); */
|
/* boolean hasMoreElements (); */
|
||||||
NS_IMETHODIMP nsDocShellEnumerator::HasMoreElements(bool *outHasMore)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellEnumerator::HasMoreElements(bool* aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(outHasMore);
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
*outHasMore = false;
|
*aResult = false;
|
||||||
|
|
||||||
nsresult rv = EnsureDocShellArray();
|
nsresult rv = EnsureDocShellArray();
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
*outHasMore = (mCurIndex < mItemArray.Length());
|
*aResult = (mCurIndex < mItemArray.Length());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem)
|
nsresult
|
||||||
|
nsDocShellEnumerator::GetEnumerationRootItem(
|
||||||
|
nsIDocShellTreeItem** aEnumerationRootItem)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
|
NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
|
||||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||||
@@ -65,45 +71,51 @@ nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEn
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem)
|
nsresult
|
||||||
|
nsDocShellEnumerator::SetEnumerationRootItem(
|
||||||
|
nsIDocShellTreeItem* aEnumerationRootItem)
|
||||||
{
|
{
|
||||||
mRootItem = do_GetWeakReference(aEnumerationRootItem);
|
mRootItem = do_GetWeakReference(aEnumerationRootItem);
|
||||||
ClearState();
|
ClearState();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::GetEnumDocShellType(int32_t *aEnumerationItemType)
|
nsresult
|
||||||
|
nsDocShellEnumerator::GetEnumDocShellType(int32_t* aEnumerationItemType)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aEnumerationItemType);
|
NS_ENSURE_ARG_POINTER(aEnumerationItemType);
|
||||||
*aEnumerationItemType = mDocShellType;
|
*aEnumerationItemType = mDocShellType;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
|
nsresult
|
||||||
|
nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
|
||||||
{
|
{
|
||||||
mDocShellType = aEnumerationItemType;
|
mDocShellType = aEnumerationItemType;
|
||||||
ClearState();
|
ClearState();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::First()
|
nsresult
|
||||||
|
nsDocShellEnumerator::First()
|
||||||
{
|
{
|
||||||
mCurIndex = 0;
|
mCurIndex = 0;
|
||||||
return EnsureDocShellArray();
|
return EnsureDocShellArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::EnsureDocShellArray()
|
nsresult
|
||||||
|
nsDocShellEnumerator::EnsureDocShellArray()
|
||||||
{
|
{
|
||||||
if (!mArrayValid)
|
if (!mArrayValid) {
|
||||||
{
|
|
||||||
mArrayValid = true;
|
mArrayValid = true;
|
||||||
return BuildDocShellArray(mItemArray);
|
return BuildDocShellArray(mItemArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::ClearState()
|
nsresult
|
||||||
|
nsDocShellEnumerator::ClearState()
|
||||||
{
|
{
|
||||||
mItemArray.Clear();
|
mItemArray.Clear();
|
||||||
mArrayValid = false;
|
mArrayValid = false;
|
||||||
@@ -111,66 +123,84 @@ nsresult nsDocShellEnumerator::ClearState()
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray)
|
nsresult
|
||||||
|
nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
|
||||||
inItemArray.Clear();
|
aItemArray.Clear();
|
||||||
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
|
||||||
return BuildArrayRecursive(item, inItemArray);
|
return BuildArrayRecursive(item, aItemArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
nsresult
|
||||||
|
nsDocShellForwardsEnumerator::BuildArrayRecursive(
|
||||||
|
nsIDocShellTreeItem* aItem,
|
||||||
|
nsTArray<nsWeakPtr>& aItemArray)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
// add this item to the array
|
// add this item to the array
|
||||||
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
||||||
inItem->ItemType() == mDocShellType) {
|
aItem->ItemType() == mDocShellType) {
|
||||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numChildren;
|
int32_t numChildren;
|
||||||
rv = inItem->GetChildCount(&numChildren);
|
rv = aItem->GetChildCount(&numChildren);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
for (int32_t i = 0; i < numChildren; ++i)
|
}
|
||||||
{
|
|
||||||
|
for (int32_t i = 0; i < numChildren; ++i) {
|
||||||
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
||||||
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
|
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
rv = BuildArrayRecursive(curChild, inItemArray);
|
}
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
rv = BuildArrayRecursive(curChild, aItemArray);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
|
nsDocShellBackwardsEnumerator::BuildArrayRecursive(
|
||||||
|
nsIDocShellTreeItem* aItem,
|
||||||
|
nsTArray<nsWeakPtr>& aItemArray)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
int32_t numChildren;
|
int32_t numChildren;
|
||||||
rv = inItem->GetChildCount(&numChildren);
|
rv = aItem->GetChildCount(&numChildren);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
for (int32_t i = numChildren - 1; i >= 0; --i)
|
}
|
||||||
{
|
|
||||||
|
for (int32_t i = numChildren - 1; i >= 0; --i) {
|
||||||
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
nsCOMPtr<nsIDocShellTreeItem> curChild;
|
||||||
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
|
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
rv = BuildArrayRecursive(curChild, inItemArray);
|
}
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
rv = BuildArrayRecursive(curChild, aItemArray);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add this item to the array
|
// add this item to the array
|
||||||
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
|
||||||
inItem->ItemType() == mDocShellType) {
|
aItem->ItemType() == mDocShellType) {
|
||||||
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
|
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -32,82 +32,77 @@ class nsIDocShellTreeItem;
|
|||||||
class nsDocShellEnumerator : public nsISimpleEnumerator
|
class nsDocShellEnumerator : public nsISimpleEnumerator
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
enum
|
||||||
enum {
|
{
|
||||||
enumerateForwards,
|
enumerateForwards,
|
||||||
enumerateBackwards
|
enumerateBackwards
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~nsDocShellEnumerator();
|
virtual ~nsDocShellEnumerator();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit nsDocShellEnumerator(int32_t aEnumerationDirection);
|
||||||
explicit nsDocShellEnumerator(int32_t inEnumerationDirection);
|
|
||||||
|
|
||||||
// nsISupports
|
// nsISupports
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
// nsISimpleEnumerator
|
// nsISimpleEnumerator
|
||||||
NS_DECL_NSISIMPLEENUMERATOR
|
NS_DECL_NSISIMPLEENUMERATOR
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
|
||||||
|
nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
|
||||||
|
|
||||||
nsresult GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem);
|
nsresult GetEnumDocShellType(int32_t* aEnumerationItemType);
|
||||||
nsresult SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem);
|
nsresult SetEnumDocShellType(int32_t aEnumerationItemType);
|
||||||
|
|
||||||
nsresult GetEnumDocShellType(int32_t *aEnumerationItemType);
|
nsresult First();
|
||||||
nsresult SetEnumDocShellType(int32_t aEnumerationItemType);
|
|
||||||
|
|
||||||
nsresult First();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
nsresult EnsureDocShellArray();
|
||||||
|
nsresult ClearState();
|
||||||
|
|
||||||
|
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray);
|
||||||
|
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||||
|
nsTArray<nsWeakPtr>& aItemArray) = 0;
|
||||||
|
|
||||||
nsresult EnsureDocShellArray();
|
|
||||||
nsresult ClearState();
|
|
||||||
|
|
||||||
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
|
|
||||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
nsWeakPtr mRootItem; // weak ref!
|
||||||
|
|
||||||
nsWeakPtr mRootItem; // weak ref!
|
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
|
||||||
|
uint32_t mCurIndex;
|
||||||
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
|
|
||||||
uint32_t mCurIndex;
|
|
||||||
|
|
||||||
int32_t mDocShellType; // only want shells of this type
|
|
||||||
bool mArrayValid; // is mItemArray up to date?
|
|
||||||
|
|
||||||
const int8_t mEnumerationDirection;
|
int32_t mDocShellType; // only want shells of this type
|
||||||
|
bool mArrayValid; // is mItemArray up to date?
|
||||||
|
|
||||||
|
const int8_t mEnumerationDirection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
|
class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
nsDocShellForwardsEnumerator()
|
||||||
nsDocShellForwardsEnumerator()
|
: nsDocShellEnumerator(enumerateForwards)
|
||||||
: nsDocShellEnumerator(enumerateForwards)
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
nsTArray<nsWeakPtr>& aItemArray);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
|
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
nsDocShellBackwardsEnumerator()
|
||||||
|
: nsDocShellEnumerator(enumerateBackwards)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
nsDocShellBackwardsEnumerator()
|
|
||||||
: nsDocShellEnumerator(enumerateBackwards)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
|
||||||
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
|
nsTArray<nsWeakPtr>& aItemArray);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsDocShellEnumerator_h___
|
#endif // nsDocShellEnumerator_h___
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
nsDocShellLoadInfo::nsDocShellLoadInfo()
|
nsDocShellLoadInfo::nsDocShellLoadInfo()
|
||||||
: mInheritOwner(false),
|
: mInheritOwner(false)
|
||||||
mOwnerIsExplicit(false),
|
, mOwnerIsExplicit(false)
|
||||||
mSendReferrer(true),
|
, mSendReferrer(true)
|
||||||
mReferrerPolicy(mozilla::net::RP_Default),
|
, mReferrerPolicy(mozilla::net::RP_Default)
|
||||||
mLoadType(nsIDocShellLoadInfo::loadNormal),
|
, mLoadType(nsIDocShellLoadInfo::loadNormal)
|
||||||
mIsSrcdocLoad(false)
|
, mIsSrcdocLoad(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,123 +32,136 @@ nsDocShellLoadInfo::~nsDocShellLoadInfo()
|
|||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDocShellLoadInfo::nsISupports
|
// nsDocShellLoadInfo::nsISupports
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsDocShellLoadInfo)
|
NS_IMPL_ADDREF(nsDocShellLoadInfo)
|
||||||
NS_IMPL_RELEASE(nsDocShellLoadInfo)
|
NS_IMPL_RELEASE(nsDocShellLoadInfo)
|
||||||
|
|
||||||
NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
|
NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
|
NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
// nsDocShellLoadInfo::nsIDocShellLoadInfo
|
// nsDocShellLoadInfo::nsIDocShellLoadInfo
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aReferrer);
|
|
||||||
|
|
||||||
*aReferrer = mReferrer;
|
|
||||||
NS_IF_ADDREF(*aReferrer);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
|
||||||
{
|
|
||||||
mReferrer = aReferrer;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aOwner);
|
|
||||||
|
|
||||||
*aOwner = mOwner;
|
|
||||||
NS_IF_ADDREF(*aOwner);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
|
|
||||||
{
|
|
||||||
mOwner = aOwner;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aInheritOwner);
|
|
||||||
|
|
||||||
*aInheritOwner = mInheritOwner;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
|
|
||||||
{
|
|
||||||
mInheritOwner = aInheritOwner;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
|
|
||||||
{
|
|
||||||
*aOwnerIsExplicit = mOwnerIsExplicit;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
|
|
||||||
{
|
|
||||||
mOwnerIsExplicit = aOwnerIsExplicit;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aLoadType);
|
|
||||||
|
|
||||||
*aLoadType = mLoadType;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
|
|
||||||
{
|
|
||||||
mLoadType = aLoadType;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aSHEntry);
|
|
||||||
|
|
||||||
*aSHEntry = mSHEntry;
|
|
||||||
NS_IF_ADDREF(*aSHEntry);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
|
|
||||||
{
|
|
||||||
mSHEntry = aSHEntry;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aTarget);
|
|
||||||
|
|
||||||
*aTarget = ToNewUnicode(mTarget);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
|
|
||||||
{
|
|
||||||
mTarget.Assign(aTarget);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
|
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aReferrer);
|
||||||
|
|
||||||
|
*aReferrer = mReferrer;
|
||||||
|
NS_IF_ADDREF(*aReferrer);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
||||||
|
{
|
||||||
|
mReferrer = aReferrer;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aOwner);
|
||||||
|
|
||||||
|
*aOwner = mOwner;
|
||||||
|
NS_IF_ADDREF(*aOwner);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
|
||||||
|
{
|
||||||
|
mOwner = aOwner;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aInheritOwner);
|
||||||
|
|
||||||
|
*aInheritOwner = mInheritOwner;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
|
||||||
|
{
|
||||||
|
mInheritOwner = aInheritOwner;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
|
||||||
|
{
|
||||||
|
*aOwnerIsExplicit = mOwnerIsExplicit;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
|
||||||
|
{
|
||||||
|
mOwnerIsExplicit = aOwnerIsExplicit;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aLoadType);
|
||||||
|
|
||||||
|
*aLoadType = mLoadType;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
|
||||||
|
{
|
||||||
|
mLoadType = aLoadType;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aSHEntry);
|
||||||
|
|
||||||
|
*aSHEntry = mSHEntry;
|
||||||
|
NS_IF_ADDREF(*aSHEntry);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
|
||||||
|
{
|
||||||
|
mSHEntry = aSHEntry;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aTarget);
|
||||||
|
|
||||||
|
*aTarget = ToNewUnicode(mTarget);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
|
||||||
|
{
|
||||||
|
mTarget.Assign(aTarget);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
NS_ENSURE_ARG_POINTER(aResult);
|
||||||
|
|
||||||
@@ -158,106 +171,112 @@ nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream *aStream)
|
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
|
||||||
{
|
{
|
||||||
mPostDataStream = aStream;
|
mPostDataStream = aStream;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* attribute nsIInputStream headersStream; */
|
/* attribute nsIInputStream headersStream; */
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetHeadersStream(nsIInputStream * *aHeadersStream)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aHeadersStream);
|
NS_ENSURE_ARG_POINTER(aHeadersStream);
|
||||||
*aHeadersStream = mHeadersStream;
|
*aHeadersStream = mHeadersStream;
|
||||||
NS_IF_ADDREF(*aHeadersStream);
|
NS_IF_ADDREF(*aHeadersStream);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetHeadersStream(nsIInputStream * aHeadersStream)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
|
||||||
{
|
{
|
||||||
mHeadersStream = aHeadersStream;
|
mHeadersStream = aHeadersStream;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aSendReferrer);
|
NS_ENSURE_ARG_POINTER(aSendReferrer);
|
||||||
|
|
||||||
*aSendReferrer = mSendReferrer;
|
*aSendReferrer = mSendReferrer;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
|
||||||
{
|
{
|
||||||
mSendReferrer = aSendReferrer;
|
mSendReferrer = aSendReferrer;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrerPolicy(nsDocShellInfoReferrerPolicy* aReferrerPolicy)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetReferrerPolicy(
|
||||||
|
nsDocShellInfoReferrerPolicy* aReferrerPolicy)
|
||||||
{
|
{
|
||||||
*aReferrerPolicy = mReferrerPolicy;
|
*aReferrerPolicy = mReferrerPolicy;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrerPolicy(nsDocShellInfoReferrerPolicy aReferrerPolicy)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetReferrerPolicy(
|
||||||
|
nsDocShellInfoReferrerPolicy aReferrerPolicy)
|
||||||
{
|
{
|
||||||
mReferrerPolicy = aReferrerPolicy;
|
mReferrerPolicy = aReferrerPolicy;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
|
||||||
{
|
{
|
||||||
*aIsSrcdocLoad = mIsSrcdocLoad;
|
*aIsSrcdocLoad = mIsSrcdocLoad;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSrcdocData(nsAString &aSrcdocData)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData)
|
||||||
{
|
{
|
||||||
aSrcdocData = mSrcdocData;
|
aSrcdocData = mSrcdocData;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSrcdocData(const nsAString &aSrcdocData)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
|
||||||
{
|
{
|
||||||
mSrcdocData = aSrcdocData;
|
mSrcdocData = aSrcdocData;
|
||||||
mIsSrcdocLoad = true;
|
mIsSrcdocLoad = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aSourceDocShell);
|
MOZ_ASSERT(aSourceDocShell);
|
||||||
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
|
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
|
||||||
result.forget(aSourceDocShell);
|
result.forget(aSourceDocShell);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
||||||
{
|
{
|
||||||
mSourceDocShell = aSourceDocShell;
|
mSourceDocShell = aSourceDocShell;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||||
|
|
||||||
*aBaseURI = mBaseURI;
|
*aBaseURI = mBaseURI;
|
||||||
NS_IF_ADDREF(*aBaseURI);
|
NS_IF_ADDREF(*aBaseURI);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
NS_IMETHODIMP
|
||||||
|
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
||||||
{
|
{
|
||||||
mBaseURI = aBaseURI;
|
mBaseURI = aBaseURI;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// nsDocShellLoadInfo: Helpers
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|
||||||
//*****************************************************************************
|
|
||||||
// nsDocShellLoadInfo: Accessors
|
|
||||||
//*****************************************************************************
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#ifndef nsDocShellLoadInfo_h__
|
#ifndef nsDocShellLoadInfo_h__
|
||||||
#define nsDocShellLoadInfo_h__
|
#define nsDocShellLoadInfo_h__
|
||||||
|
|
||||||
|
|
||||||
// Helper Classes
|
// Helper Classes
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
@@ -32,21 +31,21 @@ protected:
|
|||||||
virtual ~nsDocShellLoadInfo();
|
virtual ~nsDocShellLoadInfo();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCOMPtr<nsIURI> mReferrer;
|
nsCOMPtr<nsIURI> mReferrer;
|
||||||
nsCOMPtr<nsISupports> mOwner;
|
nsCOMPtr<nsISupports> mOwner;
|
||||||
bool mInheritOwner;
|
bool mInheritOwner;
|
||||||
bool mOwnerIsExplicit;
|
bool mOwnerIsExplicit;
|
||||||
bool mSendReferrer;
|
bool mSendReferrer;
|
||||||
nsDocShellInfoReferrerPolicy mReferrerPolicy;
|
nsDocShellInfoReferrerPolicy mReferrerPolicy;
|
||||||
nsDocShellInfoLoadType mLoadType;
|
nsDocShellInfoLoadType mLoadType;
|
||||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||||
nsString mTarget;
|
nsString mTarget;
|
||||||
nsCOMPtr<nsIInputStream> mPostDataStream;
|
nsCOMPtr<nsIInputStream> mPostDataStream;
|
||||||
nsCOMPtr<nsIInputStream> mHeadersStream;
|
nsCOMPtr<nsIInputStream> mHeadersStream;
|
||||||
bool mIsSrcdocLoad;
|
bool mIsSrcdocLoad;
|
||||||
nsString mSrcdocData;
|
nsString mSrcdocData;
|
||||||
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
nsCOMPtr<nsIDocShell> mSourceDocShell;
|
||||||
nsCOMPtr<nsIURI> mBaseURI;
|
nsCOMPtr<nsIURI> mBaseURI;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsDocShellLoadInfo_h__ */
|
#endif /* nsDocShellLoadInfo_h__ */
|
||||||
|
|||||||
@@ -32,49 +32,48 @@
|
|||||||
LOAD_FLAGS_ALLOW_POPUPS | \
|
LOAD_FLAGS_ALLOW_POPUPS | \
|
||||||
0xffff0000)
|
0xffff0000)
|
||||||
|
|
||||||
|
/* load types are legal combinations of load commands and flags
|
||||||
|
*
|
||||||
/* load types are legal combinations of load commands and flags
|
|
||||||
*
|
|
||||||
* NOTE:
|
* NOTE:
|
||||||
* Remember to update the IsValidLoadType function below if you change this
|
* Remember to update the IsValidLoadType function below if you change this
|
||||||
* enum to ensure bad flag combinations will be rejected.
|
* enum to ensure bad flag combinations will be rejected.
|
||||||
*/
|
*/
|
||||||
enum LoadType {
|
enum LoadType
|
||||||
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
||||||
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
|
||||||
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
|
|
||||||
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
||||||
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
||||||
LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
||||||
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
||||||
LOAD_NORMAL_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
||||||
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
||||||
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
||||||
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
||||||
LOAD_RELOAD_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
||||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
||||||
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
|
||||||
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
|
||||||
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
|
||||||
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
|
||||||
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
|
||||||
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
|
||||||
LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
||||||
LOAD_REPLACE_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
||||||
/**
|
|
||||||
* Load type for an error page. These loads are never triggered by users of
|
|
||||||
* Docshell. Instead, Docshell triggers the load itself when a
|
|
||||||
* consumer-triggered load failed.
|
|
||||||
*/
|
|
||||||
LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
|
|
||||||
|
|
||||||
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
|
||||||
};
|
|
||||||
static inline bool IsValidLoadType(uint32_t aLoadType)
|
|
||||||
{
|
{
|
||||||
switch (aLoadType)
|
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||||
{
|
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||||
|
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
|
||||||
|
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||||
|
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||||
|
LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||||
|
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||||
|
LOAD_NORMAL_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||||
|
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||||
|
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||||
|
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||||
|
LOAD_RELOAD_ALLOW_MIXED_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||||
|
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
||||||
|
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
||||||
|
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
||||||
|
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
||||||
|
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
||||||
|
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
||||||
|
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
||||||
|
LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE, nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||||
|
LOAD_REPLACE_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
||||||
|
/**
|
||||||
|
* Load type for an error page. These loads are never triggered by users of
|
||||||
|
* Docshell. Instead, Docshell triggers the load itself when a
|
||||||
|
* consumer-triggered load failed.
|
||||||
|
*/
|
||||||
|
LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
|
||||||
|
|
||||||
|
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
||||||
|
};
|
||||||
|
static inline bool
|
||||||
|
IsValidLoadType(uint32_t aLoadType)
|
||||||
|
{
|
||||||
|
switch (aLoadType) {
|
||||||
case LOAD_NORMAL:
|
case LOAD_NORMAL:
|
||||||
case LOAD_NORMAL_REPLACE:
|
case LOAD_NORMAL_REPLACE:
|
||||||
case LOAD_NORMAL_EXTERNAL:
|
case LOAD_NORMAL_EXTERNAL:
|
||||||
@@ -97,10 +96,10 @@ static inline bool IsValidLoadType(uint32_t aLoadType)
|
|||||||
case LOAD_PUSHSTATE:
|
case LOAD_PUSHSTATE:
|
||||||
case LOAD_REPLACE_BYPASS_CACHE:
|
case LOAD_REPLACE_BYPASS_CACHE:
|
||||||
case LOAD_ERROR_PAGE:
|
case LOAD_ERROR_PAGE:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MOZILLA_INTERNAL_API
|
#endif // MOZILLA_INTERNAL_API
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ nsTransferableHookData::nsTransferableHookData()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsTransferableHookData::~nsTransferableHookData()
|
nsTransferableHookData::~nsTransferableHookData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -24,33 +23,34 @@ NS_IMPL_ISUPPORTS(nsTransferableHookData, nsIClipboardDragDropHookList)
|
|||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransferableHookData::AddClipboardDragDropHooks(
|
nsTransferableHookData::AddClipboardDragDropHooks(
|
||||||
nsIClipboardDragDropHooks *aOverrides)
|
nsIClipboardDragDropHooks* aOverrides)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aOverrides);
|
NS_ENSURE_ARG(aOverrides);
|
||||||
|
|
||||||
// don't let a hook be added more than once
|
// don't let a hook be added more than once
|
||||||
if (mHookList.IndexOfObject(aOverrides) == -1)
|
if (mHookList.IndexOfObject(aOverrides) == -1) {
|
||||||
{
|
if (!mHookList.AppendObject(aOverrides)) {
|
||||||
if (!mHookList.AppendObject(aOverrides))
|
return NS_ERROR_FAILURE;
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransferableHookData::RemoveClipboardDragDropHooks(
|
nsTransferableHookData::RemoveClipboardDragDropHooks(
|
||||||
nsIClipboardDragDropHooks *aOverrides)
|
nsIClipboardDragDropHooks* aOverrides)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aOverrides);
|
NS_ENSURE_ARG(aOverrides);
|
||||||
if (!mHookList.RemoveObject(aOverrides))
|
if (!mHookList.RemoveObject(aOverrides)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsTransferableHookData::GetHookEnumerator(nsISimpleEnumerator **aResult)
|
nsTransferableHookData::GetHookEnumerator(nsISimpleEnumerator** aResult)
|
||||||
{
|
{
|
||||||
return NS_NewArrayEnumerator(aResult, mHookList);
|
return NS_NewArrayEnumerator(aResult, mHookList);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ class nsIClipboardDragDropHooks;
|
|||||||
class nsTransferableHookData : public nsIClipboardDragDropHookList
|
class nsTransferableHookData : public nsIClipboardDragDropHookList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsTransferableHookData();
|
nsTransferableHookData();
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSICLIPBOARDDRAGDROPHOOKLIST
|
NS_DECL_NSICLIPBOARDDRAGDROPHOOKLIST
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~nsTransferableHookData();
|
virtual ~nsTransferableHookData();
|
||||||
|
|
||||||
nsCOMArray<nsIClipboardDragDropHooks> mHookList;
|
nsCOMArray<nsIClipboardDragDropHooks> mHookList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsDocShellTransferableHooks_h__
|
#endif // nsDocShellTransferableHooks_h__
|
||||||
|
|||||||
@@ -20,17 +20,18 @@ NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
|
|||||||
//// nsIDownloadHistory
|
//// nsIDownloadHistory
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDownloadHistory::AddDownload(nsIURI *aSource,
|
nsDownloadHistory::AddDownload(nsIURI* aSource,
|
||||||
nsIURI *aReferrer,
|
nsIURI* aReferrer,
|
||||||
PRTime aStartTime,
|
PRTime aStartTime,
|
||||||
nsIURI *aDestination)
|
nsIURI* aDestination)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aSource);
|
NS_ENSURE_ARG_POINTER(aSource);
|
||||||
|
|
||||||
nsCOMPtr<nsIGlobalHistory2> history =
|
nsCOMPtr<nsIGlobalHistory2> history =
|
||||||
do_GetService("@mozilla.org/browser/global-history;2");
|
do_GetService("@mozilla.org/browser/global-history;2");
|
||||||
if (!history)
|
if (!history) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
bool visited;
|
bool visited;
|
||||||
nsresult rv = history->IsVisited(aSource, &visited);
|
nsresult rv = history->IsVisited(aSource, &visited);
|
||||||
@@ -38,12 +39,13 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
|
|||||||
|
|
||||||
rv = history->AddURI(aSource, false, true, aReferrer);
|
rv = history->AddURI(aSource, false, true, aReferrer);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (!visited) {
|
if (!visited) {
|
||||||
nsCOMPtr<nsIObserverService> os =
|
nsCOMPtr<nsIObserverService> os =
|
||||||
do_GetService("@mozilla.org/observer-service;1");
|
do_GetService("@mozilla.org/observer-service;1");
|
||||||
if (os)
|
if (os) {
|
||||||
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ class nsString;
|
|||||||
/**
|
/**
|
||||||
* Interface used for handling clicks on links
|
* Interface used for handling clicks on links
|
||||||
*/
|
*/
|
||||||
class nsILinkHandler : public nsISupports {
|
class nsILinkHandler : public nsISupports
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ public:
|
|||||||
* @param aTargetSpec indicates where the link is targeted (it may be an empty
|
* @param aTargetSpec indicates where the link is targeted (it may be an empty
|
||||||
* string)
|
* string)
|
||||||
*/
|
*/
|
||||||
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
NS_IMETHOD OnOverLink(nsIContent* aContent,
|
||||||
nsIURI* aURLSpec,
|
nsIURI* aURLSpec,
|
||||||
const char16_t* aTargetSpec) = 0;
|
const char16_t* aTargetSpec) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ public:
|
|||||||
* Called when an async panning/zooming transform has started being applied
|
* Called when an async panning/zooming transform has started being applied
|
||||||
* and passed the scroll offset
|
* and passed the scroll offset
|
||||||
*/
|
*/
|
||||||
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint scrollPos){};
|
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint aScrollPos) {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an async panning/zooming transform is no longer applied
|
* Called when an async panning/zooming transform is no longer applied
|
||||||
* and passed the scroll offset
|
* and passed the scroll offset
|
||||||
*/
|
*/
|
||||||
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint scrollPos){};
|
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint aScrollPos) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
class nsIWebShellServices : public nsISupports {
|
class nsIWebShellServices : public nsISupports
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
|
||||||
|
|
||||||
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
|
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
|
||||||
int32_t aSource = kCharsetUninitialized) = 0;
|
int32_t aSource = kCharsetUninitialized) = 0;
|
||||||
NS_IMETHOD StopDocumentLoad(void) = 0;
|
NS_IMETHOD StopDocumentLoad(void) = 0;
|
||||||
};
|
};
|
||||||
@@ -29,7 +30,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
|
|||||||
|
|
||||||
/* Use this macro when declaring classes that implement this interface. */
|
/* Use this macro when declaring classes that implement this interface. */
|
||||||
#define NS_DECL_NSIWEBSHELLSERVICES \
|
#define NS_DECL_NSIWEBSHELLSERVICES \
|
||||||
NS_IMETHOD ReloadDocument(const char *aCharset=nullptr, int32_t aSource=kCharsetUninitialized) MOZ_OVERRIDE; \
|
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr, \
|
||||||
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE; \
|
int32_t aSource = kCharsetUninitialized) MOZ_OVERRIDE; \
|
||||||
|
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE;
|
||||||
|
|
||||||
#endif /* nsIWebShellServices_h___ */
|
#endif /* nsIWebShellServices_h___ */
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ NS_IMPL_ISUPPORTS(nsWebNavigationInfo, nsIWebNavigationInfo)
|
|||||||
|
|
||||||
#define CONTENT_DLF_CONTRACT "@mozilla.org/content/document-loader-factory;1"
|
#define CONTENT_DLF_CONTRACT "@mozilla.org/content/document-loader-factory;1"
|
||||||
#define PLUGIN_DLF_CONTRACT \
|
#define PLUGIN_DLF_CONTRACT \
|
||||||
"@mozilla.org/content/plugin/document-loader-factory;1"
|
"@mozilla.org/content/plugin/document-loader-factory;1"
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsWebNavigationInfo::Init()
|
nsWebNavigationInfo::Init()
|
||||||
@@ -38,7 +38,7 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
|||||||
// Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
|
// Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or
|
||||||
// an nsSHistory, but not much we can do with that). So if we start using
|
// an nsSHistory, but not much we can do with that). So if we start using
|
||||||
// it here, we need to be careful to get to the docshell correctly.
|
// it here, we need to be careful to get to the docshell correctly.
|
||||||
|
|
||||||
// For now just report what the Gecko-Content-Viewers category has
|
// For now just report what the Gecko-Content-Viewers category has
|
||||||
// to say for itself.
|
// to say for itself.
|
||||||
*aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
*aIsTypeSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
@@ -55,7 +55,8 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
|
|||||||
// there's no need to try and find a plugin to handle it.
|
// there's no need to try and find a plugin to handle it.
|
||||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
|
||||||
bool allowed;
|
bool allowed;
|
||||||
if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
|
if (docShell &&
|
||||||
|
NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,36 +85,34 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
|
|||||||
{
|
{
|
||||||
NS_PRECONDITION(aIsSupported, "Null out param?");
|
NS_PRECONDITION(aIsSupported, "Null out param?");
|
||||||
|
|
||||||
|
|
||||||
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
|
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
|
||||||
|
|
||||||
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
|
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
|
||||||
nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
|
nsContentUtils::FindInternalContentViewer(aType.get(), &vtype);
|
||||||
|
|
||||||
switch (vtype) {
|
switch (vtype) {
|
||||||
case nsContentUtils::TYPE_UNSUPPORTED:
|
case nsContentUtils::TYPE_UNSUPPORTED:
|
||||||
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
*aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsContentUtils::TYPE_PLUGIN:
|
case nsContentUtils::TYPE_PLUGIN:
|
||||||
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
|
*aIsSupported = nsIWebNavigationInfo::PLUGIN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsContentUtils::TYPE_UNKNOWN:
|
case nsContentUtils::TYPE_UNKNOWN:
|
||||||
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case nsContentUtils::TYPE_CONTENT:
|
|
||||||
// XXXbz we only need this because images register for the same
|
|
||||||
// contractid as documents, so we can't tell them apart based on
|
|
||||||
// contractid.
|
|
||||||
if (imgLoader::SupportImageWithMimeType(aType.get())) {
|
|
||||||
*aIsSupported = nsIWebNavigationInfo::IMAGE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
case nsContentUtils::TYPE_CONTENT:
|
||||||
|
// XXXbz we only need this because images register for the same
|
||||||
|
// contractid as documents, so we can't tell them apart based on
|
||||||
|
// contractid.
|
||||||
|
if (imgLoader::SupportImageWithMimeType(aType.get())) {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::IMAGE;
|
||||||
|
} else {
|
||||||
|
*aIsSupported = nsIWebNavigationInfo::OTHER;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class nsWebNavigationInfo MOZ_FINAL : public nsIWebNavigationInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsWebNavigationInfo() {}
|
nsWebNavigationInfo() {}
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_DECL_NSIWEBNAVIGATIONINFO
|
NS_DECL_NSIWEBNAVIGATIONINFO
|
||||||
@@ -30,12 +30,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
~nsWebNavigationInfo() {}
|
~nsWebNavigationInfo() {}
|
||||||
|
|
||||||
// Check whether aType is supported. If this method throws, the
|
// Check whether aType is supported. If this method throws, the
|
||||||
// value of aIsSupported is not changed.
|
// value of aIsSupported is not changed.
|
||||||
nsresult IsTypeSupportedInternal(const nsCString& aType,
|
nsresult IsTypeSupportedInternal(const nsCString& aType,
|
||||||
uint32_t* aIsSupported);
|
uint32_t* aIsSupported);
|
||||||
|
|
||||||
nsCOMPtr<nsICategoryManager> mCategoryManager;
|
nsCOMPtr<nsICategoryManager> mCategoryManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user