зеркало из https://github.com/mozilla/gecko-dev.git
Merge the last PGO-green inbound changeset to m-c.
This commit is contained in:
Коммит
dca08c3a1c
|
@ -203,8 +203,7 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsINode *aNode, PRUint32 aOffset)
|
||||||
{
|
{
|
||||||
if (aNode && aNode->IsElement()) {
|
if (aNode && aNode->IsElement()) {
|
||||||
PRUint32 childCount = aNode->GetChildCount();
|
PRUint32 childCount = aNode->GetChildCount();
|
||||||
NS_ASSERTION(aOffset >= 0 && aOffset <= childCount,
|
NS_ASSERTION(aOffset <= childCount, "Wrong offset of the DOM point!");
|
||||||
"Wrong offset of the DOM point!");
|
|
||||||
|
|
||||||
// The offset can be after last child of container node that means DOM point
|
// The offset can be after last child of container node that means DOM point
|
||||||
// is placed immediately after the last child. In this case use the DOM node
|
// is placed immediately after the last child. In this case use the DOM node
|
||||||
|
|
|
@ -265,7 +265,7 @@ ARIAGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
|
||||||
void
|
void
|
||||||
ARIAGridAccessible::SelectedCellIndices(nsTArray<PRUint32>* aCells)
|
ARIAGridAccessible::SelectedCellIndices(nsTArray<PRUint32>* aCells)
|
||||||
{
|
{
|
||||||
PRUint32 rowCount = RowCount(), colCount = ColCount();
|
PRUint32 colCount = ColCount();
|
||||||
|
|
||||||
AccIterator rowIter(this, filters::GetRow);
|
AccIterator rowIter(this, filters::GetRow);
|
||||||
Accessible* row = nsnull;
|
Accessible* row = nsnull;
|
||||||
|
|
|
@ -1808,8 +1808,6 @@ HyperTextAccessible::SetSelectionBounds(PRInt32 aSelectionNum,
|
||||||
if (rangeCount < static_cast<PRUint32>(aSelectionNum))
|
if (rangeCount < static_cast<PRUint32>(aSelectionNum))
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
// Caret is a collapsed selection
|
|
||||||
bool isOnlyCaret = (aStartOffset == aEndOffset);
|
|
||||||
nsRefPtr<nsRange> range;
|
nsRefPtr<nsRange> range;
|
||||||
if (aSelectionNum == rangeCount)
|
if (aSelectionNum == rangeCount)
|
||||||
range = new nsRange();
|
range = new nsRange();
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "nsArrayUtils.h"
|
#include "nsArrayUtils.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
|
|
||||||
|
using namespace mozilla;
|
||||||
using namespace mozilla::a11y;
|
using namespace mozilla::a11y;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -766,10 +767,11 @@ HTMLTableAccessible::ColExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
PRInt32 columnExtent = 0;
|
PRInt32 columnExtent = 0;
|
||||||
|
|
||||||
tableLayout->
|
DebugOnly<nsresult> rv = tableLayout->
|
||||||
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
|
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
|
||||||
startRowIndex, startColIndex, rowSpan, colSpan,
|
startRowIndex, startColIndex, rowSpan, colSpan,
|
||||||
actualRowSpan, columnExtent, isSelected);
|
actualRowSpan, columnExtent, isSelected);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
|
||||||
|
|
||||||
return columnExtent;
|
return columnExtent;
|
||||||
}
|
}
|
||||||
|
@ -786,10 +788,11 @@ HTMLTableAccessible::RowExtentAt(PRUint32 aRowIdx, PRUint32 aColIdx)
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
PRInt32 rowExtent = 0;
|
PRInt32 rowExtent = 0;
|
||||||
|
|
||||||
tableLayout->
|
DebugOnly<nsresult> rv = tableLayout->
|
||||||
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
|
GetCellDataAt(aRowIdx, aColIdx, *getter_AddRefs(domElement),
|
||||||
startRowIndex, startColIndex, rowSpan, colSpan,
|
startRowIndex, startColIndex, rowSpan, colSpan,
|
||||||
rowExtent, actualColSpan, isSelected);
|
rowExtent, actualColSpan, isSelected);
|
||||||
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get cell data");
|
||||||
|
|
||||||
return rowExtent;
|
return rowExtent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIMutableArray.h"
|
#include "nsIMutableArray.h"
|
||||||
|
#include "mozilla/Attributes.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace a11y {
|
namespace a11y {
|
||||||
|
@ -19,7 +20,7 @@ class Relation;
|
||||||
/**
|
/**
|
||||||
* Class represents an accessible relation.
|
* Class represents an accessible relation.
|
||||||
*/
|
*/
|
||||||
class nsAccessibleRelation : public nsIAccessibleRelation
|
class nsAccessibleRelation MOZ_FINAL : public nsIAccessibleRelation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsAccessibleRelation(PRUint32 aType, Relation* aRel);
|
nsAccessibleRelation(PRUint32 aType, Relation* aRel);
|
||||||
|
|
|
@ -3871,6 +3871,12 @@ ReadSourceFromFilename(JSContext *cx, const char *filename, jschar **src, PRUint
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
|
// mozJSSubScriptLoader prefixes the filenames of the scripts it loads with
|
||||||
|
// the filename of its caller. Axe that if present.
|
||||||
|
const char *arrow = strstr(filename, " -> ");
|
||||||
|
if (arrow)
|
||||||
|
filename = arrow + strlen(" -> ");
|
||||||
|
|
||||||
// Get the URI.
|
// Get the URI.
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
rv = NS_NewURI(getter_AddRefs(uri), filename);
|
rv = NS_NewURI(getter_AddRefs(uri), filename);
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
|
|
||||||
#include "mozilla/dom/sms/SmsChild.h"
|
#include "mozilla/dom/sms/SmsChild.h"
|
||||||
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
#include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
|
||||||
|
#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
|
||||||
|
|
||||||
using namespace mozilla::docshell;
|
using namespace mozilla::docshell;
|
||||||
using namespace mozilla::dom::devicestorage;
|
using namespace mozilla::dom::devicestorage;
|
||||||
|
|
|
@ -21,6 +21,9 @@ public:
|
||||||
* Implementations per-platform are responsible for actually handling this.
|
* Implementations per-platform are responsible for actually handling this.
|
||||||
*/
|
*/
|
||||||
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
|
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) = 0;
|
||||||
|
|
||||||
|
GeckoContentController() {};
|
||||||
|
virtual ~GeckoContentController() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<script type="application/javascript"><![CDATA[
|
<script type="application/javascript"><![CDATA[
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
function inlinefunction() {
|
function inlinefunction() {
|
||||||
return 42;
|
return 42;
|
||||||
|
@ -29,7 +30,11 @@ is(src.charAt(src.length - 1), "}", "inline XUL source should end with '}'");
|
||||||
src = outoflinefunction.toSource();
|
src = outoflinefunction.toSource();
|
||||||
isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source")
|
isnot(src.indexOf("return 42"), -1, "out of line XUL script should have source")
|
||||||
is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'");
|
is(src.charAt(src.length - 1), "}", "out of line XUL source should end with '}'");
|
||||||
src = NetUtil.asyncFetch.toSource()
|
src = NetUtil.asyncFetch.toSource();
|
||||||
isnot(src.indexOf("return"), -1, "JSM should have source");
|
isnot(src.indexOf("return"), -1, "JSM should have source");
|
||||||
|
var ns = {};
|
||||||
|
Services.scriptloader.loadSubScript("resource://gre/modules/NetUtil.jsm", ns);
|
||||||
|
src = ns.NetUtil.asyncFetch.toSource();
|
||||||
|
isnot(src.indexOf("return"), -1, "subscript should have source");
|
||||||
]]></script>
|
]]></script>
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -58,7 +58,6 @@ XPIDLSRCS = \
|
||||||
nsINetworkLinkService.idl \
|
nsINetworkLinkService.idl \
|
||||||
nsIPermission.idl \
|
nsIPermission.idl \
|
||||||
nsIPermissionManager.idl \
|
nsIPermissionManager.idl \
|
||||||
nsIPrivateBrowsingConsumer.idl \
|
|
||||||
nsIPrivateBrowsingService.idl \
|
nsIPrivateBrowsingService.idl \
|
||||||
nsIProgressEventSink.idl \
|
nsIProgressEventSink.idl \
|
||||||
nsIPrompt.idl \
|
nsIPrompt.idl \
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
|
||||||
|
|
||||||
[scriptable, uuid(5deb421c-592b-4375-b425-9ac11532aa30)]
|
|
||||||
interface nsIPrivateBrowsingConsumer : nsISupports
|
|
||||||
{
|
|
||||||
readonly attribute boolean usingPrivateBrowsing;
|
|
||||||
|
|
||||||
%{C++
|
|
||||||
/**
|
|
||||||
* De-XPCOMed getter to make call-sites cleaner.
|
|
||||||
*/
|
|
||||||
bool UsePrivateBrowsing() {
|
|
||||||
bool usingPB;
|
|
||||||
GetUsingPrivateBrowsing(&usingPB);
|
|
||||||
return usingPB;
|
|
||||||
}
|
|
||||||
%}
|
|
||||||
};
|
|
|
@ -74,6 +74,7 @@
|
||||||
#include "nsISocketProvider.h"
|
#include "nsISocketProvider.h"
|
||||||
#include "nsIRedirectChannelRegistrar.h"
|
#include "nsIRedirectChannelRegistrar.h"
|
||||||
#include "nsIMIMEHeaderParam.h"
|
#include "nsIMIMEHeaderParam.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
|
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
|
@ -1296,6 +1297,21 @@ NS_QueryNotificationCallbacks(nsIInterfaceRequestor *callbacks,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if channel is using Private Browsing, or false if not.
|
||||||
|
*
|
||||||
|
* Note: you may get a false negative if you call this before AsyncOpen has been
|
||||||
|
* called (technically, before the channel's notificationCallbacks are set: this
|
||||||
|
* is almost always done before AsyncOpen).
|
||||||
|
*/
|
||||||
|
inline bool
|
||||||
|
NS_UsePrivateBrowsing(nsIChannel *channel)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
|
NS_QueryNotificationCallbacks(channel, loadContext);
|
||||||
|
return loadContext && loadContext->UsePrivateBrowsing();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This
|
* Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This
|
||||||
* method is provided mainly for use by other methods in this file.
|
* method is provided mainly for use by other methods in this file.
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#ifndef mozilla_net_PrivateBrowsingConsumer_h
|
|
||||||
#define mozilla_net_PrivateBrowsingConsumer_h
|
|
||||||
|
|
||||||
#include "nsIPrivateBrowsingConsumer.h"
|
|
||||||
#include "nsILoadContext.h"
|
|
||||||
#include "nsNetUtil.h"
|
|
||||||
#include "nsXULAppAPI.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace net {
|
|
||||||
|
|
||||||
class PrivateBrowsingConsumer : public nsIPrivateBrowsingConsumer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PrivateBrowsingConsumer(nsIChannel* aSelf) : mSelf(aSelf), mUsingPB(false), mOverride(false) {}
|
|
||||||
|
|
||||||
NS_IMETHOD GetUsingPrivateBrowsing(bool *aUsingPB)
|
|
||||||
{
|
|
||||||
*aUsingPB = (mOverride ? mUsingPB : UsingPrivateBrowsingInternal());
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverridePrivateBrowsing(bool aUsingPrivateBrowsing)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!mOverride);
|
|
||||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
|
|
||||||
mOverride = true;
|
|
||||||
mUsingPB = aUsingPrivateBrowsing;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool UsingPrivateBrowsingInternal()
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsILoadContext> loadContext;
|
|
||||||
NS_QueryNotificationCallbacks(mSelf, loadContext);
|
|
||||||
return loadContext && loadContext->UsePrivateBrowsing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
nsIChannel* mSelf;
|
|
||||||
|
|
||||||
// Private browsing capabilities can only be determined in content
|
|
||||||
// processes, so when networking occurs these values are used in
|
|
||||||
// lieu of UsingPrivateBrowsing().
|
|
||||||
bool mUsingPB;
|
|
||||||
bool mOverride;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // mozilla_net_PrivateBrowsingConsumer_h
|
|
|
@ -245,7 +245,6 @@ private:
|
||||||
friend class RedirectRunnable;
|
friend class RedirectRunnable;
|
||||||
|
|
||||||
nsRefPtr<nsInputStreamPump> mPump;
|
nsRefPtr<nsInputStreamPump> mPump;
|
||||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
|
||||||
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
||||||
nsCOMPtr<nsIURI> mOriginalURI;
|
nsCOMPtr<nsIURI> mOriginalURI;
|
||||||
nsCOMPtr<nsIURI> mURI;
|
nsCOMPtr<nsIURI> mURI;
|
||||||
|
@ -264,6 +263,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||||
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||||
nsCOMPtr<nsIStreamListener> mListener;
|
nsCOMPtr<nsIStreamListener> mListener;
|
||||||
nsCOMPtr<nsISupports> mListenerContext;
|
nsCOMPtr<nsISupports> mListenerContext;
|
||||||
nsresult mStatus;
|
nsresult mStatus;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "nsMimeTypes.h"
|
#include "nsMimeTypes.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsIURIFixup.h"
|
#include "nsIURIFixup.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "nsCDefaultURIFixup.h"
|
#include "nsCDefaultURIFixup.h"
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
|
|
||||||
|
@ -23,8 +24,7 @@ namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
FTPChannelChild::FTPChannelChild(nsIURI* uri)
|
FTPChannelChild::FTPChannelChild(nsIURI* uri)
|
||||||
: PrivateBrowsingConsumer(this)
|
: mIPCOpen(false)
|
||||||
, mIPCOpen(false)
|
|
||||||
, ALLOW_THIS_IN_INITIALIZER_LIST(mEventQ(static_cast<nsIFTPChannel*>(this)))
|
, ALLOW_THIS_IN_INITIALIZER_LIST(mEventQ(static_cast<nsIFTPChannel*>(this)))
|
||||||
, mCanceled(false)
|
, mCanceled(false)
|
||||||
, mSuspendCount(0)
|
, mSuspendCount(0)
|
||||||
|
@ -160,8 +160,27 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||||
if (mLoadGroup)
|
if (mLoadGroup)
|
||||||
mLoadGroup->AddRequest(this, nsnull);
|
mLoadGroup->AddRequest(this, nsnull);
|
||||||
|
|
||||||
|
// Get info from nsILoadContext, if any
|
||||||
|
bool haveLoadContext = false;
|
||||||
|
bool isContent = false;
|
||||||
|
bool usePrivateBrowsing = false;
|
||||||
|
bool isInBrowserElement = false;
|
||||||
|
PRUint32 appId = 0;
|
||||||
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
|
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
|
||||||
|
NS_GET_IID(nsILoadContext),
|
||||||
|
getter_AddRefs(loadContext));
|
||||||
|
if (loadContext) {
|
||||||
|
haveLoadContext = true;
|
||||||
|
loadContext->GetIsContent(&isContent);
|
||||||
|
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
|
||||||
|
loadContext->GetIsInBrowserElement(&isInBrowserElement);
|
||||||
|
loadContext->GetAppId(&appId);
|
||||||
|
}
|
||||||
|
|
||||||
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID,
|
SendAsyncOpen(nsBaseChannel::URI(), mStartPos, mEntityID,
|
||||||
IPC::InputStream(mUploadStream), UsePrivateBrowsing());
|
IPC::InputStream(mUploadStream), haveLoadContext, isContent,
|
||||||
|
usePrivateBrowsing, isInBrowserElement, appId);
|
||||||
|
|
||||||
// The socket transport layer in the chrome process now has a logical ref to
|
// The socket transport layer in the chrome process now has a logical ref to
|
||||||
// us until OnStopRequest is called.
|
// us until OnStopRequest is called.
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "nsIProxiedChannel.h"
|
#include "nsIProxiedChannel.h"
|
||||||
#include "nsIResumableChannel.h"
|
#include "nsIResumableChannel.h"
|
||||||
#include "nsIChildChannel.h"
|
#include "nsIChildChannel.h"
|
||||||
#include "PrivateBrowsingConsumer.h"
|
|
||||||
|
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
|
|
||||||
|
@ -35,7 +34,6 @@ class FTPChannelChild : public PFTPChannelChild
|
||||||
, public nsIResumableChannel
|
, public nsIResumableChannel
|
||||||
, public nsIProxiedChannel
|
, public nsIProxiedChannel
|
||||||
, public nsIChildChannel
|
, public nsIChildChannel
|
||||||
, public PrivateBrowsingConsumer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ::nsIStreamListener nsIStreamListener;
|
typedef ::nsIStreamListener nsIStreamListener;
|
||||||
|
|
|
@ -19,7 +19,12 @@ namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
FTPChannelParent::FTPChannelParent()
|
FTPChannelParent::FTPChannelParent()
|
||||||
: mIPCClosed(false)
|
: mIPCClosed(false)
|
||||||
|
, mHaveLoadContext(false)
|
||||||
|
, mIsContent(false)
|
||||||
|
, mUsePrivateBrowsing(false)
|
||||||
|
, mIsInBrowserElement(false)
|
||||||
|
, mAppId(0)
|
||||||
{
|
{
|
||||||
nsIProtocolHandler* handler;
|
nsIProtocolHandler* handler;
|
||||||
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &handler);
|
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp", &handler);
|
||||||
|
@ -43,10 +48,11 @@ FTPChannelParent::ActorDestroy(ActorDestroyReason why)
|
||||||
// FTPChannelParent::nsISupports
|
// FTPChannelParent::nsISupports
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS4(FTPChannelParent,
|
NS_IMPL_ISUPPORTS5(FTPChannelParent,
|
||||||
nsIStreamListener,
|
nsIStreamListener,
|
||||||
nsIParentChannel,
|
nsIParentChannel,
|
||||||
nsIInterfaceRequestor,
|
nsIInterfaceRequestor,
|
||||||
|
nsILoadContext,
|
||||||
nsIRequestObserver);
|
nsIRequestObserver);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -58,7 +64,11 @@ FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
const PRUint64& aStartPos,
|
const PRUint64& aStartPos,
|
||||||
const nsCString& aEntityID,
|
const nsCString& aEntityID,
|
||||||
const IPC::InputStream& aUploadStream,
|
const IPC::InputStream& aUploadStream,
|
||||||
const bool& aUsePrivateBrowsing)
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usePrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri(aURI);
|
nsCOMPtr<nsIURI> uri(aURI);
|
||||||
|
|
||||||
|
@ -93,7 +103,13 @@ FTPChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return SendFailedAsyncOpen(rv);
|
return SendFailedAsyncOpen(rv);
|
||||||
|
|
||||||
mChannel->OverridePrivateBrowsing(aUsePrivateBrowsing);
|
// fields needed to impersonate nsILoadContext
|
||||||
|
mHaveLoadContext = haveLoadContext;
|
||||||
|
mIsContent = isContent;
|
||||||
|
mUsePrivateBrowsing = usePrivateBrowsing;
|
||||||
|
mIsInBrowserElement = isInBrowserElement;
|
||||||
|
mAppId = appId;
|
||||||
|
mChannel->SetNotificationCallbacks(this);
|
||||||
|
|
||||||
rv = mChannel->AsyncOpen(this, nsnull);
|
rv = mChannel->AsyncOpen(this, nsnull);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
@ -229,9 +245,82 @@ FTPChannelParent::Delete()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
FTPChannelParent::GetInterface(const nsIID& uuid, void** result)
|
FTPChannelParent::GetInterface(const nsIID& uuid, void** result)
|
||||||
{
|
{
|
||||||
|
// Only support nsILoadContext if child channel's callbacks did too
|
||||||
|
if (uuid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
|
||||||
|
return NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
return QueryInterface(uuid, result);
|
return QueryInterface(uuid, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// FTPChannelParent::nsILoadContext
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetAssociatedWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetTopWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::IsAppOfType(PRUint32, bool*)
|
||||||
|
{
|
||||||
|
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetIsContent(bool *aIsContent)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsContent);
|
||||||
|
|
||||||
|
*aIsContent = mIsContent;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
|
||||||
|
|
||||||
|
*aUsePrivateBrowsing = mUsePrivateBrowsing;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
// We shouldn't need this on parent...
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
|
||||||
|
|
||||||
|
*aIsInBrowserElement = mIsInBrowserElement;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
FTPChannelParent::GetAppId(PRUint32* aAppId)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aAppId);
|
||||||
|
|
||||||
|
*aAppId = mAppId;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "mozilla/net/NeckoCommon.h"
|
#include "mozilla/net/NeckoCommon.h"
|
||||||
#include "nsIParentChannel.h"
|
#include "nsIParentChannel.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
|
|
||||||
class nsFtpChannel;
|
class nsFtpChannel;
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ namespace net {
|
||||||
class FTPChannelParent : public PFTPChannelParent
|
class FTPChannelParent : public PFTPChannelParent
|
||||||
, public nsIParentChannel
|
, public nsIParentChannel
|
||||||
, public nsIInterfaceRequestor
|
, public nsIInterfaceRequestor
|
||||||
|
, public nsILoadContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
@ -28,6 +30,7 @@ public:
|
||||||
NS_DECL_NSISTREAMLISTENER
|
NS_DECL_NSISTREAMLISTENER
|
||||||
NS_DECL_NSIPARENTCHANNEL
|
NS_DECL_NSIPARENTCHANNEL
|
||||||
NS_DECL_NSIINTERFACEREQUESTOR
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
|
NS_DECL_NSILOADCONTEXT
|
||||||
|
|
||||||
FTPChannelParent();
|
FTPChannelParent();
|
||||||
virtual ~FTPChannelParent();
|
virtual ~FTPChannelParent();
|
||||||
|
@ -37,7 +40,11 @@ protected:
|
||||||
const PRUint64& startPos,
|
const PRUint64& startPos,
|
||||||
const nsCString& entityID,
|
const nsCString& entityID,
|
||||||
const IPC::InputStream& uploadStream,
|
const IPC::InputStream& uploadStream,
|
||||||
const bool& aUsePrivateBrowsing);
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usingPrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId);
|
||||||
NS_OVERRIDE virtual bool RecvConnectChannel(const PRUint32& channelId);
|
NS_OVERRIDE virtual bool RecvConnectChannel(const PRUint32& channelId);
|
||||||
NS_OVERRIDE virtual bool RecvCancel(const nsresult& status);
|
NS_OVERRIDE virtual bool RecvCancel(const nsresult& status);
|
||||||
NS_OVERRIDE virtual bool RecvSuspend();
|
NS_OVERRIDE virtual bool RecvSuspend();
|
||||||
|
@ -48,6 +55,14 @@ protected:
|
||||||
nsRefPtr<nsFtpChannel> mChannel;
|
nsRefPtr<nsFtpChannel> mChannel;
|
||||||
|
|
||||||
bool mIPCClosed;
|
bool mIPCClosed;
|
||||||
|
|
||||||
|
// fields for impersonating nsILoadContext
|
||||||
|
bool mHaveLoadContext : 1;
|
||||||
|
bool mIsContent : 1;
|
||||||
|
bool mUsePrivateBrowsing : 1;
|
||||||
|
bool mIsInBrowserElement : 1;
|
||||||
|
|
||||||
|
PRUint32 mAppId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|
|
@ -23,8 +23,15 @@ async protocol PFTPChannel
|
||||||
parent:
|
parent:
|
||||||
__delete__();
|
__delete__();
|
||||||
|
|
||||||
AsyncOpen(URI uri, PRUint64 startPos, nsCString entityID,
|
AsyncOpen(URI uri,
|
||||||
InputStream uploadStream, bool usePrivateBrowsing);
|
PRUint64 startPos,
|
||||||
|
nsCString entityID,
|
||||||
|
InputStream uploadStream,
|
||||||
|
bool haveLoadContext,
|
||||||
|
bool isContent,
|
||||||
|
bool usePrivateBrowsing,
|
||||||
|
bool isInBrowserElement,
|
||||||
|
PRUint32 appID);
|
||||||
ConnectChannel(PRUint32 channelId);
|
ConnectChannel(PRUint32 channelId);
|
||||||
Cancel(nsresult status);
|
Cancel(nsresult status);
|
||||||
Suspend();
|
Suspend();
|
||||||
|
|
|
@ -28,14 +28,13 @@
|
||||||
#include "nsIResumableChannel.h"
|
#include "nsIResumableChannel.h"
|
||||||
#include "nsHashPropertyBag.h"
|
#include "nsHashPropertyBag.h"
|
||||||
#include "nsFtpProtocolHandler.h"
|
#include "nsFtpProtocolHandler.h"
|
||||||
#include "PrivateBrowsingConsumer.h"
|
#include "nsNetUtil.h"
|
||||||
|
|
||||||
class nsFtpChannel : public nsBaseChannel,
|
class nsFtpChannel : public nsBaseChannel,
|
||||||
public nsIFTPChannel,
|
public nsIFTPChannel,
|
||||||
public nsIUploadChannel,
|
public nsIUploadChannel,
|
||||||
public nsIResumableChannel,
|
public nsIResumableChannel,
|
||||||
public nsIProxiedChannel,
|
public nsIProxiedChannel
|
||||||
public mozilla::net::PrivateBrowsingConsumer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
@ -44,8 +43,7 @@ public:
|
||||||
NS_DECL_NSIPROXIEDCHANNEL
|
NS_DECL_NSIPROXIEDCHANNEL
|
||||||
|
|
||||||
nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
|
nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi)
|
||||||
: mozilla::net::PrivateBrowsingConsumer(this)
|
: mProxyInfo(pi)
|
||||||
, mProxyInfo(pi)
|
|
||||||
, mStartPos(0)
|
, mStartPos(0)
|
||||||
, mResumeRequested(false)
|
, mResumeRequested(false)
|
||||||
, mLastModifiedTime(0)
|
, mLastModifiedTime(0)
|
||||||
|
|
|
@ -2217,7 +2217,7 @@ nsFtpState::CheckCache()
|
||||||
if (!cache)
|
if (!cache)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isPrivate = mChannel->UsePrivateBrowsing();
|
bool isPrivate = NS_UsePrivateBrowsing(mChannel);
|
||||||
const char* sessionName = isPrivate ? "FTP-private" : "FTP";
|
const char* sessionName = isPrivate ? "FTP-private" : "FTP";
|
||||||
nsCacheStoragePolicy policy =
|
nsCacheStoragePolicy policy =
|
||||||
isPrivate ? nsICache::STORE_IN_MEMORY : nsICache::STORE_ANYWHERE;
|
isPrivate ? nsICache::STORE_IN_MEMORY : nsICache::STORE_ANYWHERE;
|
||||||
|
|
|
@ -27,8 +27,7 @@ namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
HttpBaseChannel::HttpBaseChannel()
|
HttpBaseChannel::HttpBaseChannel()
|
||||||
: PrivateBrowsingConsumer(this)
|
: mStartPos(LL_MAXUINT)
|
||||||
, mStartPos(LL_MAXUINT)
|
|
||||||
, mStatus(NS_OK)
|
, mStatus(NS_OK)
|
||||||
, mLoadFlags(LOAD_NORMAL)
|
, mLoadFlags(LOAD_NORMAL)
|
||||||
, mPriority(PRIORITY_NORMAL)
|
, mPriority(PRIORITY_NORMAL)
|
||||||
|
@ -49,6 +48,7 @@ HttpBaseChannel::HttpBaseChannel()
|
||||||
, mTracingEnabled(true)
|
, mTracingEnabled(true)
|
||||||
, mTimingEnabled(false)
|
, mTimingEnabled(false)
|
||||||
, mAllowSpdy(true)
|
, mAllowSpdy(true)
|
||||||
|
, mPrivateBrowsing(false)
|
||||||
, mSuspendCount(0)
|
, mSuspendCount(0)
|
||||||
{
|
{
|
||||||
LOG(("Creating HttpBaseChannel @%x\n", this));
|
LOG(("Creating HttpBaseChannel @%x\n", this));
|
||||||
|
@ -140,7 +140,7 @@ HttpBaseChannel::Init(nsIURI *aURI,
|
||||||
// HttpBaseChannel::nsISupports
|
// HttpBaseChannel::nsISupports
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS_INHERITED10(HttpBaseChannel,
|
NS_IMPL_ISUPPORTS_INHERITED9( HttpBaseChannel,
|
||||||
nsHashPropertyBag,
|
nsHashPropertyBag,
|
||||||
nsIRequest,
|
nsIRequest,
|
||||||
nsIChannel,
|
nsIChannel,
|
||||||
|
@ -150,8 +150,7 @@ NS_IMPL_ISUPPORTS_INHERITED10(HttpBaseChannel,
|
||||||
nsIUploadChannel,
|
nsIUploadChannel,
|
||||||
nsIUploadChannel2,
|
nsIUploadChannel2,
|
||||||
nsISupportsPriority,
|
nsISupportsPriority,
|
||||||
nsITraceableChannel,
|
nsITraceableChannel)
|
||||||
nsIPrivateBrowsingConsumer)
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// HttpBaseChannel::nsIRequest
|
// HttpBaseChannel::nsIRequest
|
||||||
|
@ -273,6 +272,9 @@ HttpBaseChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
|
||||||
{
|
{
|
||||||
mCallbacks = aCallbacks;
|
mCallbacks = aCallbacks;
|
||||||
mProgressSink = nsnull;
|
mProgressSink = nsnull;
|
||||||
|
|
||||||
|
// Will never change unless SetNotificationCallbacks called again, so cache
|
||||||
|
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
#include "nsIApplicationCache.h"
|
#include "nsIApplicationCache.h"
|
||||||
#include "nsIResumableChannel.h"
|
#include "nsIResumableChannel.h"
|
||||||
#include "nsITraceableChannel.h"
|
#include "nsITraceableChannel.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "mozilla/net/NeckoCommon.h"
|
#include "mozilla/net/NeckoCommon.h"
|
||||||
#include "PrivateBrowsingConsumer.h"
|
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
@ -50,7 +50,6 @@ class HttpBaseChannel : public nsHashPropertyBag
|
||||||
, public nsISupportsPriority
|
, public nsISupportsPriority
|
||||||
, public nsIResumableChannel
|
, public nsIResumableChannel
|
||||||
, public nsITraceableChannel
|
, public nsITraceableChannel
|
||||||
, public PrivateBrowsingConsumer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS_INHERITED
|
NS_DECL_ISUPPORTS_INHERITED
|
||||||
|
@ -265,6 +264,7 @@ protected:
|
||||||
// True if timing collection is enabled
|
// True if timing collection is enabled
|
||||||
PRUint32 mTimingEnabled : 1;
|
PRUint32 mTimingEnabled : 1;
|
||||||
PRUint32 mAllowSpdy : 1;
|
PRUint32 mAllowSpdy : 1;
|
||||||
|
PRUint32 mPrivateBrowsing : 1;
|
||||||
|
|
||||||
// Current suspension depth for this channel object
|
// Current suspension depth for this channel object
|
||||||
PRUint32 mSuspendCount;
|
PRUint32 mSuspendCount;
|
||||||
|
|
|
@ -1015,6 +1015,22 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get info from nsILoadContext, if any
|
||||||
|
bool haveLoadContext = false;
|
||||||
|
bool isContent = false;
|
||||||
|
bool usePrivateBrowsing = false;
|
||||||
|
bool isInBrowserElement = false;
|
||||||
|
PRUint32 appId = 0;
|
||||||
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
|
GetCallback(loadContext);
|
||||||
|
if (loadContext) {
|
||||||
|
haveLoadContext = true;
|
||||||
|
loadContext->GetIsContent(&isContent);
|
||||||
|
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
|
||||||
|
loadContext->GetIsInBrowserElement(&isInBrowserElement);
|
||||||
|
loadContext->GetAppId(&appId);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Send request to the chrome process...
|
// Send request to the chrome process...
|
||||||
//
|
//
|
||||||
|
@ -1041,7 +1057,8 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
||||||
mPriority, mRedirectionLimit, mAllowPipelining,
|
mPriority, mRedirectionLimit, mAllowPipelining,
|
||||||
mForceAllowThirdPartyCookie, mSendResumeAt,
|
mForceAllowThirdPartyCookie, mSendResumeAt,
|
||||||
mStartPos, mEntityID, mChooseApplicationCache,
|
mStartPos, mEntityID, mChooseApplicationCache,
|
||||||
appCacheClientId, mAllowSpdy, UsePrivateBrowsing());
|
appCacheClientId, mAllowSpdy, haveLoadContext, isContent,
|
||||||
|
usePrivateBrowsing, isInBrowserElement, appId);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,11 @@ HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding)
|
||||||
, mSentRedirect1Begin(false)
|
, mSentRedirect1Begin(false)
|
||||||
, mSentRedirect1BeginFailed(false)
|
, mSentRedirect1BeginFailed(false)
|
||||||
, mReceivedRedirect2Verify(false)
|
, mReceivedRedirect2Verify(false)
|
||||||
|
, mHaveLoadContext(false)
|
||||||
|
, mIsContent(false)
|
||||||
|
, mUsePrivateBrowsing(false)
|
||||||
|
, mIsInBrowserElement(false)
|
||||||
|
, mAppId(0)
|
||||||
{
|
{
|
||||||
// Ensure gHttpHandler is initialized: we need the atom table up and running.
|
// Ensure gHttpHandler is initialized: we need the atom table up and running.
|
||||||
nsIHttpProtocolHandler* handler;
|
nsIHttpProtocolHandler* handler;
|
||||||
|
@ -62,7 +67,8 @@ HttpChannelParent::ActorDestroy(ActorDestroyReason why)
|
||||||
// HttpChannelParent::nsISupports
|
// HttpChannelParent::nsISupports
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS6(HttpChannelParent,
|
NS_IMPL_ISUPPORTS7(HttpChannelParent,
|
||||||
|
nsILoadContext,
|
||||||
nsIInterfaceRequestor,
|
nsIInterfaceRequestor,
|
||||||
nsIProgressEventSink,
|
nsIProgressEventSink,
|
||||||
nsIRequestObserver,
|
nsIRequestObserver,
|
||||||
|
@ -85,6 +91,11 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
|
||||||
return mTabParent->QueryInterface(aIID, result);
|
return mTabParent->QueryInterface(aIID, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only support nsILoadContext if child channel's callbacks did too
|
||||||
|
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
|
||||||
|
return NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
return QueryInterface(aIID, result);
|
return QueryInterface(aIID, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +123,11 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
const bool& chooseApplicationCache,
|
const bool& chooseApplicationCache,
|
||||||
const nsCString& appCacheClientID,
|
const nsCString& appCacheClientID,
|
||||||
const bool& allowSpdy,
|
const bool& allowSpdy,
|
||||||
const bool& usingPrivateBrowsing)
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usePrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri(aURI);
|
nsCOMPtr<nsIURI> uri(aURI);
|
||||||
nsCOMPtr<nsIURI> originalUri(aOriginalURI);
|
nsCOMPtr<nsIURI> originalUri(aOriginalURI);
|
||||||
|
@ -134,6 +149,13 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return SendFailedAsyncOpen(rv);
|
return SendFailedAsyncOpen(rv);
|
||||||
|
|
||||||
|
// fields needed to impersonate nsILoadContext
|
||||||
|
mHaveLoadContext = haveLoadContext;
|
||||||
|
mIsContent = isContent;
|
||||||
|
mUsePrivateBrowsing = usePrivateBrowsing;
|
||||||
|
mIsInBrowserElement = isInBrowserElement;
|
||||||
|
mAppId = appId;
|
||||||
|
|
||||||
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
||||||
|
|
||||||
if (doResumeAt)
|
if (doResumeAt)
|
||||||
|
@ -209,8 +231,6 @@ HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
httpChan->OverridePrivateBrowsing(usingPrivateBrowsing);
|
|
||||||
|
|
||||||
rv = httpChan->AsyncOpen(channelListener, nsnull);
|
rv = httpChan->AsyncOpen(channelListener, nsnull);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return SendFailedAsyncOpen(rv);
|
return SendFailedAsyncOpen(rv);
|
||||||
|
@ -586,4 +606,72 @@ HttpChannelParent::CompleteRedirect(bool succeeded)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// HttpChannelParent::nsILoadContext
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetAssociatedWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetTopWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::IsAppOfType(PRUint32, bool*)
|
||||||
|
{
|
||||||
|
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetIsContent(bool *aIsContent)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsContent);
|
||||||
|
|
||||||
|
*aIsContent = mIsContent;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
|
||||||
|
|
||||||
|
*aUsePrivateBrowsing = mUsePrivateBrowsing;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
// We shouldn't need this on parent...
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
|
||||||
|
|
||||||
|
*aIsInBrowserElement = mIsInBrowserElement;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
HttpChannelParent::GetAppId(PRUint32* aAppId)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aAppId);
|
||||||
|
|
||||||
|
*aAppId = mAppId;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
}} // mozilla::net
|
}} // mozilla::net
|
||||||
|
|
|
@ -31,6 +31,7 @@ class HttpChannelParent : public PHttpChannelParent
|
||||||
, public nsIParentRedirectingChannel
|
, public nsIParentRedirectingChannel
|
||||||
, public nsIProgressEventSink
|
, public nsIProgressEventSink
|
||||||
, public nsIInterfaceRequestor
|
, public nsIInterfaceRequestor
|
||||||
|
, public nsILoadContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
@ -40,6 +41,7 @@ public:
|
||||||
NS_DECL_NSIPARENTREDIRECTINGCHANNEL
|
NS_DECL_NSIPARENTREDIRECTINGCHANNEL
|
||||||
NS_DECL_NSIPROGRESSEVENTSINK
|
NS_DECL_NSIPROGRESSEVENTSINK
|
||||||
NS_DECL_NSIINTERFACEREQUESTOR
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
|
NS_DECL_NSILOADCONTEXT
|
||||||
|
|
||||||
HttpChannelParent(PBrowserParent* iframeEmbedding);
|
HttpChannelParent(PBrowserParent* iframeEmbedding);
|
||||||
virtual ~HttpChannelParent();
|
virtual ~HttpChannelParent();
|
||||||
|
@ -64,7 +66,11 @@ protected:
|
||||||
const bool& chooseApplicationCache,
|
const bool& chooseApplicationCache,
|
||||||
const nsCString& appCacheClientID,
|
const nsCString& appCacheClientID,
|
||||||
const bool& allowSpdy,
|
const bool& allowSpdy,
|
||||||
const bool& usingPrivateBrowsing);
|
const bool & haveLoadContext,
|
||||||
|
const bool & isContent,
|
||||||
|
const bool& usingPrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId);
|
||||||
|
|
||||||
virtual bool RecvConnectChannel(const PRUint32& channelId);
|
virtual bool RecvConnectChannel(const PRUint32& channelId);
|
||||||
virtual bool RecvSetPriority(const PRUint16& priority);
|
virtual bool RecvSetPriority(const PRUint16& priority);
|
||||||
|
@ -104,9 +110,17 @@ private:
|
||||||
PRUint64 mStoredProgress;
|
PRUint64 mStoredProgress;
|
||||||
PRUint64 mStoredProgressMax;
|
PRUint64 mStoredProgressMax;
|
||||||
|
|
||||||
bool mSentRedirect1Begin : 1;
|
bool mSentRedirect1Begin : 1;
|
||||||
bool mSentRedirect1BeginFailed : 1;
|
bool mSentRedirect1BeginFailed : 1;
|
||||||
bool mReceivedRedirect2Verify : 1;
|
bool mReceivedRedirect2Verify : 1;
|
||||||
|
|
||||||
|
// fields for impersonating nsILoadContext
|
||||||
|
bool mHaveLoadContext : 1;
|
||||||
|
bool mIsContent : 1;
|
||||||
|
bool mUsePrivateBrowsing : 1;
|
||||||
|
bool mIsInBrowserElement : 1;
|
||||||
|
|
||||||
|
PRUint32 mAppId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|
|
@ -50,7 +50,13 @@ parent:
|
||||||
bool chooseApplicationCache,
|
bool chooseApplicationCache,
|
||||||
nsCString appCacheClientID,
|
nsCString appCacheClientID,
|
||||||
bool allowSpdy,
|
bool allowSpdy,
|
||||||
bool usePrivateBrowsing);
|
// If child channel callbacks implement nsILoadContext, we implement
|
||||||
|
// it in HttpChannelParent too
|
||||||
|
bool haveLoadContext,
|
||||||
|
bool isContent,
|
||||||
|
bool usePrivateBrowsing,
|
||||||
|
bool isInBrowserElement,
|
||||||
|
PRUint32 appID);
|
||||||
|
|
||||||
// Used to connect redirected-to channel on the parent with redirected-to
|
// Used to connect redirected-to channel on the parent with redirected-to
|
||||||
// channel on the child.
|
// channel on the child.
|
||||||
|
|
|
@ -544,7 +544,7 @@ nsHttpChannel::SpeculativeConnect()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
|
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
|
||||||
mConnectionInfo->SetPrivate(UsingPrivateBrowsing());
|
mConnectionInfo->SetPrivate(mPrivateBrowsing);
|
||||||
gHttpHandler->SpeculativeConnect(mConnectionInfo,
|
gHttpHandler->SpeculativeConnect(mConnectionInfo,
|
||||||
callbacks, NS_GetCurrentThread());
|
callbacks, NS_GetCurrentThread());
|
||||||
}
|
}
|
||||||
|
@ -839,7 +839,7 @@ nsHttpChannel::SetupTransaction()
|
||||||
mCaps |= NS_HTTP_TIMING_ENABLED;
|
mCaps |= NS_HTTP_TIMING_ENABLED;
|
||||||
|
|
||||||
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
|
mConnectionInfo->SetAnonymous((mLoadFlags & LOAD_ANONYMOUS) != 0);
|
||||||
mConnectionInfo->SetPrivate(UsingPrivateBrowsing());
|
mConnectionInfo->SetPrivate(mPrivateBrowsing);
|
||||||
|
|
||||||
if (mUpgradeProtocolCallback) {
|
if (mUpgradeProtocolCallback) {
|
||||||
mRequestHead.SetHeader(nsHttp::Upgrade, mUpgradeProtocol, false);
|
mRequestHead.SetHeader(nsHttp::Upgrade, mUpgradeProtocol, false);
|
||||||
|
@ -2447,7 +2447,7 @@ nsHttpChannel::OpenCacheEntry(bool usingSSL)
|
||||||
// us from writing to the offline cache as a normal cache entry.
|
// us from writing to the offline cache as a normal cache entry.
|
||||||
mCacheQuery = new HttpCacheQuery(
|
mCacheQuery = new HttpCacheQuery(
|
||||||
this, appCacheClientID,
|
this, appCacheClientID,
|
||||||
nsICache::STORE_OFFLINE, UsingPrivateBrowsing(),
|
nsICache::STORE_OFFLINE, mPrivateBrowsing,
|
||||||
cacheKey, nsICache::ACCESS_READ,
|
cacheKey, nsICache::ACCESS_READ,
|
||||||
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
|
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
|
||||||
usingSSL, true);
|
usingSSL, true);
|
||||||
|
@ -2548,10 +2548,9 @@ nsHttpChannel::OpenNormalCacheEntry(bool usingSSL)
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
bool isPrivate = UsingPrivateBrowsing();
|
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
|
||||||
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy(isPrivate);
|
|
||||||
nsDependentCString clientID(
|
nsDependentCString clientID(
|
||||||
GetCacheSessionNameForStoragePolicy(storagePolicy, isPrivate));
|
GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing));
|
||||||
|
|
||||||
nsCAutoString cacheKey;
|
nsCAutoString cacheKey;
|
||||||
GenerateCacheKey(mPostID, cacheKey);
|
GenerateCacheKey(mPostID, cacheKey);
|
||||||
|
@ -2563,8 +2562,7 @@ nsHttpChannel::OpenNormalCacheEntry(bool usingSSL)
|
||||||
|
|
||||||
mCacheQuery = new HttpCacheQuery(
|
mCacheQuery = new HttpCacheQuery(
|
||||||
this, clientID, storagePolicy,
|
this, clientID, storagePolicy,
|
||||||
UsingPrivateBrowsing(), cacheKey,
|
mPrivateBrowsing, cacheKey, accessRequested,
|
||||||
accessRequested,
|
|
||||||
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
|
mLoadFlags & LOAD_BYPASS_LOCAL_CACHE_IF_BUSY,
|
||||||
usingSSL, false);
|
usingSSL, false);
|
||||||
|
|
||||||
|
@ -5873,10 +5871,9 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
|
||||||
// one point by using only READ_ONLY access-policy. I think this is safe.
|
// one point by using only READ_ONLY access-policy. I think this is safe.
|
||||||
|
|
||||||
// First, find session holding the cache-entry - use current storage-policy
|
// First, find session holding the cache-entry - use current storage-policy
|
||||||
bool isPrivate = UsingPrivateBrowsing();
|
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
|
||||||
nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy(isPrivate);
|
const char * clientID =
|
||||||
const char * clientID = GetCacheSessionNameForStoragePolicy(storagePolicy,
|
GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing);
|
||||||
isPrivate);
|
|
||||||
|
|
||||||
LOG(("DoInvalidateCacheEntry [channel=%p session=%s policy=%d key=%s]",
|
LOG(("DoInvalidateCacheEntry [channel=%p session=%s policy=%d key=%s]",
|
||||||
this, clientID, PRIntn(storagePolicy), key.get()));
|
this, clientID, PRIntn(storagePolicy), key.get()));
|
||||||
|
@ -5891,7 +5888,7 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
|
||||||
getter_AddRefs(session));
|
getter_AddRefs(session));
|
||||||
}
|
}
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = session->SetIsPrivate(UsingPrivateBrowsing());
|
rv = session->SetIsPrivate(mPrivateBrowsing);
|
||||||
}
|
}
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
rv = session->DoomEntry(key, nsnull);
|
rv = session->DoomEntry(key, nsnull);
|
||||||
|
@ -5902,10 +5899,10 @@ nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCacheStoragePolicy
|
nsCacheStoragePolicy
|
||||||
nsHttpChannel::DetermineStoragePolicy(bool isPrivate)
|
nsHttpChannel::DetermineStoragePolicy()
|
||||||
{
|
{
|
||||||
nsCacheStoragePolicy policy = nsICache::STORE_ANYWHERE;
|
nsCacheStoragePolicy policy = nsICache::STORE_ANYWHERE;
|
||||||
if (isPrivate)
|
if (mPrivateBrowsing)
|
||||||
policy = nsICache::STORE_IN_MEMORY;
|
policy = nsICache::STORE_IN_MEMORY;
|
||||||
else if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
|
else if (mLoadFlags & INHIBIT_PERSISTENT_CACHING)
|
||||||
policy = nsICache::STORE_IN_MEMORY;
|
policy = nsICache::STORE_IN_MEMORY;
|
||||||
|
|
|
@ -145,16 +145,6 @@ public: /* internal necko use only */
|
||||||
|
|
||||||
OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker();
|
OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this channel is operating in private browsing mode,
|
|
||||||
* false otherwise.
|
|
||||||
*/
|
|
||||||
bool UsingPrivateBrowsing() {
|
|
||||||
bool usingPB;
|
|
||||||
GetUsingPrivateBrowsing(&usingPB);
|
|
||||||
return usingPB;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);
|
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);
|
||||||
|
|
||||||
|
@ -235,7 +225,7 @@ private:
|
||||||
nsresult InstallCacheListener(PRUint32 offset = 0);
|
nsresult InstallCacheListener(PRUint32 offset = 0);
|
||||||
nsresult InstallOfflineCacheListener();
|
nsresult InstallOfflineCacheListener();
|
||||||
void MaybeInvalidateCacheEntryForSubsequentGet();
|
void MaybeInvalidateCacheEntryForSubsequentGet();
|
||||||
nsCacheStoragePolicy DetermineStoragePolicy(bool isPrivate);
|
nsCacheStoragePolicy DetermineStoragePolicy();
|
||||||
nsresult DetermineCacheAccess(nsCacheAccessMode *_retval);
|
nsresult DetermineCacheAccess(nsCacheAccessMode *_retval);
|
||||||
void AsyncOnExamineCachedResponse();
|
void AsyncOnExamineCachedResponse();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,15 @@ async protocol PWebSocket
|
||||||
|
|
||||||
parent:
|
parent:
|
||||||
// Forwarded methods corresponding to methods on nsIWebSocketChannel
|
// Forwarded methods corresponding to methods on nsIWebSocketChannel
|
||||||
AsyncOpen(URI aURI, nsCString aOrigin, nsCString aProtocol, bool aSecure);
|
AsyncOpen(URI aURI,
|
||||||
|
nsCString aOrigin,
|
||||||
|
nsCString aProtocol,
|
||||||
|
bool aSecure,
|
||||||
|
bool haveLoadContext,
|
||||||
|
bool isContent,
|
||||||
|
bool usePrivateBrowsing,
|
||||||
|
bool isInBrowserElement,
|
||||||
|
PRUint32 appID);
|
||||||
Close(PRUint16 code, nsCString reason);
|
Close(PRUint16 code, nsCString reason);
|
||||||
SendMsg(nsCString aMsg);
|
SendMsg(nsCString aMsg);
|
||||||
SendBinaryMsg(nsCString aMsg);
|
SendBinaryMsg(nsCString aMsg);
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "mozilla/net/NeckoChild.h"
|
#include "mozilla/net/NeckoChild.h"
|
||||||
#include "WebSocketChannelChild.h"
|
#include "WebSocketChannelChild.h"
|
||||||
#include "nsITabChild.h"
|
#include "nsITabChild.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
@ -326,11 +328,31 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
|
||||||
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get info from nsILoadContext, if any
|
||||||
|
bool haveLoadContext = false;
|
||||||
|
bool isContent = false;
|
||||||
|
bool usePrivateBrowsing = false;
|
||||||
|
bool isInBrowserElement = false;
|
||||||
|
PRUint32 appId = 0;
|
||||||
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
|
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
|
||||||
|
NS_GET_IID(nsILoadContext),
|
||||||
|
getter_AddRefs(loadContext));
|
||||||
|
if (loadContext) {
|
||||||
|
haveLoadContext = true;
|
||||||
|
loadContext->GetIsContent(&isContent);
|
||||||
|
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
|
||||||
|
loadContext->GetIsInBrowserElement(&isInBrowserElement);
|
||||||
|
loadContext->GetAppId(&appId);
|
||||||
|
}
|
||||||
|
|
||||||
// Corresponding release in DeallocPWebSocket
|
// Corresponding release in DeallocPWebSocket
|
||||||
AddIPDLReference();
|
AddIPDLReference();
|
||||||
|
|
||||||
gNeckoChild->SendPWebSocketConstructor(this, tabChild);
|
gNeckoChild->SendPWebSocketConstructor(this, tabChild);
|
||||||
if (!SendAsyncOpen(aURI, nsCString(aOrigin), mProtocol, mEncrypted))
|
if (!SendAsyncOpen(aURI, nsCString(aOrigin), mProtocol, mEncrypted,
|
||||||
|
haveLoadContext, isContent, usePrivateBrowsing,
|
||||||
|
isInBrowserElement, appId))
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
mOriginalURI = aURI;
|
mOriginalURI = aURI;
|
||||||
|
|
|
@ -11,13 +11,19 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
NS_IMPL_THREADSAFE_ISUPPORTS2(WebSocketChannelParent,
|
NS_IMPL_THREADSAFE_ISUPPORTS3(WebSocketChannelParent,
|
||||||
nsIWebSocketListener,
|
nsIWebSocketListener,
|
||||||
|
nsILoadContext,
|
||||||
nsIInterfaceRequestor)
|
nsIInterfaceRequestor)
|
||||||
|
|
||||||
WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider)
|
WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider)
|
||||||
: mAuthProvider(aAuthProvider)
|
: mAuthProvider(aAuthProvider)
|
||||||
, mIPCOpen(true)
|
, mIPCOpen(true)
|
||||||
|
, mHaveLoadContext(false)
|
||||||
|
, mIsContent(false)
|
||||||
|
, mUsePrivateBrowsing(false)
|
||||||
|
, mIsInBrowserElement(false)
|
||||||
|
, mAppId(0)
|
||||||
{
|
{
|
||||||
#if defined(PR_LOGGING)
|
#if defined(PR_LOGGING)
|
||||||
if (!webSocketLog)
|
if (!webSocketLog)
|
||||||
|
@ -25,6 +31,10 @@ WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvi
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// WebSocketChannelParent::PWebSocketChannelParent
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebSocketChannelParent::RecvDeleteSelf()
|
WebSocketChannelParent::RecvDeleteSelf()
|
||||||
{
|
{
|
||||||
|
@ -38,7 +48,12 @@ bool
|
||||||
WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
const nsCString& aOrigin,
|
const nsCString& aOrigin,
|
||||||
const nsCString& aProtocol,
|
const nsCString& aProtocol,
|
||||||
const bool& aSecure)
|
const bool& aSecure,
|
||||||
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usePrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId)
|
||||||
{
|
{
|
||||||
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
|
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
@ -52,6 +67,12 @@ WebSocketChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
// fields needed to impersonate nsILoadContext
|
||||||
|
mHaveLoadContext = haveLoadContext;
|
||||||
|
mIsContent = isContent;
|
||||||
|
mUsePrivateBrowsing = usePrivateBrowsing;
|
||||||
|
mIsInBrowserElement = isInBrowserElement;
|
||||||
|
mAppId = appId;
|
||||||
rv = mChannel->SetNotificationCallbacks(this);
|
rv = mChannel->SetNotificationCallbacks(this);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -116,16 +137,9 @@ WebSocketChannelParent::RecvSendBinaryStream(const InputStream& aStream,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
//-----------------------------------------------------------------------------
|
||||||
WebSocketChannelParent::GetInterface(const nsIID & iid, void **result NS_OUTPARAM)
|
// WebSocketChannelParent::nsIRequestObserver
|
||||||
{
|
//-----------------------------------------------------------------------------
|
||||||
LOG(("WebSocketChannelParent::GetInterface() %p\n", this));
|
|
||||||
if (mAuthProvider && iid.Equals(NS_GET_IID(nsIAuthPromptProvider)))
|
|
||||||
return mAuthProvider->GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL,
|
|
||||||
iid, result);
|
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WebSocketChannelParent::OnStart(nsISupports *aContext)
|
WebSocketChannelParent::OnStart(nsISupports *aContext)
|
||||||
|
@ -200,5 +214,94 @@ WebSocketChannelParent::ActorDestroy(ActorDestroyReason why)
|
||||||
mIPCOpen = false;
|
mIPCOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// WebSocketChannelParent::nsIInterfaceRequestor
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetInterface(const nsIID & iid, void **result NS_OUTPARAM)
|
||||||
|
{
|
||||||
|
LOG(("WebSocketChannelParent::GetInterface() %p\n", this));
|
||||||
|
if (mAuthProvider && iid.Equals(NS_GET_IID(nsIAuthPromptProvider)))
|
||||||
|
return mAuthProvider->GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL,
|
||||||
|
iid, result);
|
||||||
|
|
||||||
|
// Only support nsILoadContext if child channel's callbacks did too
|
||||||
|
if (iid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
|
||||||
|
return NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QueryInterface(iid, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// WebSocketChannelParent::nsILoadContext
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetAssociatedWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetTopWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::IsAppOfType(PRUint32, bool*)
|
||||||
|
{
|
||||||
|
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetIsContent(bool *aIsContent)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsContent);
|
||||||
|
|
||||||
|
*aIsContent = mIsContent;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
|
||||||
|
|
||||||
|
*aUsePrivateBrowsing = mUsePrivateBrowsing;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
// We shouldn't need this on parent...
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
|
||||||
|
|
||||||
|
*aIsInBrowserElement = mIsInBrowserElement;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WebSocketChannelParent::GetAppId(PRUint32* aAppId)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aAppId);
|
||||||
|
|
||||||
|
*aAppId = mAppId;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "mozilla/net/PWebSocketParent.h"
|
#include "mozilla/net/PWebSocketParent.h"
|
||||||
#include "nsIWebSocketListener.h"
|
#include "nsIWebSocketListener.h"
|
||||||
#include "nsIWebSocketChannel.h"
|
#include "nsIWebSocketChannel.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
||||||
|
@ -20,12 +21,14 @@ namespace net {
|
||||||
|
|
||||||
class WebSocketChannelParent : public PWebSocketParent,
|
class WebSocketChannelParent : public PWebSocketParent,
|
||||||
public nsIWebSocketListener,
|
public nsIWebSocketListener,
|
||||||
public nsIInterfaceRequestor
|
public nsIInterfaceRequestor,
|
||||||
|
public nsILoadContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIWEBSOCKETLISTENER
|
NS_DECL_NSIWEBSOCKETLISTENER
|
||||||
NS_DECL_NSIINTERFACEREQUESTOR
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
|
NS_DECL_NSILOADCONTEXT
|
||||||
|
|
||||||
WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider);
|
WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvider);
|
||||||
|
|
||||||
|
@ -33,7 +36,12 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||||
bool RecvAsyncOpen(const IPC::URI& aURI,
|
bool RecvAsyncOpen(const IPC::URI& aURI,
|
||||||
const nsCString& aOrigin,
|
const nsCString& aOrigin,
|
||||||
const nsCString& aProtocol,
|
const nsCString& aProtocol,
|
||||||
const bool& aSecure);
|
const bool& aSecure,
|
||||||
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usingPrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId);
|
||||||
bool RecvClose(const PRUint16 & code, const nsCString & reason);
|
bool RecvClose(const PRUint16 & code, const nsCString & reason);
|
||||||
bool RecvSendMsg(const nsCString& aMsg);
|
bool RecvSendMsg(const nsCString& aMsg);
|
||||||
bool RecvSendBinaryMsg(const nsCString& aMsg);
|
bool RecvSendBinaryMsg(const nsCString& aMsg);
|
||||||
|
@ -46,6 +54,14 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||||
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
|
nsCOMPtr<nsIAuthPromptProvider> mAuthProvider;
|
||||||
nsCOMPtr<nsIWebSocketChannel> mChannel;
|
nsCOMPtr<nsIWebSocketChannel> mChannel;
|
||||||
bool mIPCOpen;
|
bool mIPCOpen;
|
||||||
|
|
||||||
|
// fields for impersonating nsILoadContext
|
||||||
|
bool mHaveLoadContext : 1;
|
||||||
|
bool mIsContent : 1;
|
||||||
|
bool mUsePrivateBrowsing : 1;
|
||||||
|
bool mIsInBrowserElement : 1;
|
||||||
|
|
||||||
|
PRUint32 mAppId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|
|
@ -22,7 +22,11 @@ parent:
|
||||||
Init(URI uri);
|
Init(URI uri);
|
||||||
AsyncOpen(URI originalURI,
|
AsyncOpen(URI originalURI,
|
||||||
PRUint32 loadFlags,
|
PRUint32 loadFlags,
|
||||||
bool usingPrivateBrowsing);
|
bool haveLoadContext,
|
||||||
|
bool isContent,
|
||||||
|
bool usePrivateBrowsing,
|
||||||
|
bool isInBrowserElement,
|
||||||
|
PRUint32 appID);
|
||||||
|
|
||||||
// methods corresponding to those of nsIWyciwygChannel
|
// methods corresponding to those of nsIWyciwygChannel
|
||||||
WriteToCacheEntry(nsString data);
|
WriteToCacheEntry(nsString data);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
#include "nsISerializable.h"
|
#include "nsISerializable.h"
|
||||||
#include "nsSerializationHelper.h"
|
#include "nsSerializationHelper.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
@ -24,8 +25,7 @@ NS_IMPL_ISUPPORTS3(WyciwygChannelChild,
|
||||||
|
|
||||||
|
|
||||||
WyciwygChannelChild::WyciwygChannelChild()
|
WyciwygChannelChild::WyciwygChannelChild()
|
||||||
: PrivateBrowsingConsumer(this)
|
: mStatus(NS_OK)
|
||||||
, mStatus(NS_OK)
|
|
||||||
, mIsPending(false)
|
, mIsPending(false)
|
||||||
, mCanceled(false)
|
, mCanceled(false)
|
||||||
, mLoadFlags(LOAD_NORMAL)
|
, mLoadFlags(LOAD_NORMAL)
|
||||||
|
@ -562,7 +562,26 @@ WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aConte
|
||||||
if (mLoadGroup)
|
if (mLoadGroup)
|
||||||
mLoadGroup->AddRequest(this, nsnull);
|
mLoadGroup->AddRequest(this, nsnull);
|
||||||
|
|
||||||
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, UsePrivateBrowsing());
|
// Get info from nsILoadContext, if any
|
||||||
|
bool haveLoadContext = false;
|
||||||
|
bool isContent = false;
|
||||||
|
bool usePrivateBrowsing = false;
|
||||||
|
bool isInBrowserElement = false;
|
||||||
|
PRUint32 appId = 0;
|
||||||
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
|
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
|
||||||
|
NS_GET_IID(nsILoadContext),
|
||||||
|
getter_AddRefs(loadContext));
|
||||||
|
if (loadContext) {
|
||||||
|
haveLoadContext = true;
|
||||||
|
loadContext->GetIsContent(&isContent);
|
||||||
|
loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
|
||||||
|
loadContext->GetIsInBrowserElement(&isInBrowserElement);
|
||||||
|
loadContext->GetAppId(&appId);
|
||||||
|
}
|
||||||
|
|
||||||
|
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, haveLoadContext, isContent,
|
||||||
|
usePrivateBrowsing, isInBrowserElement, appId);
|
||||||
|
|
||||||
mState = WCC_OPENED;
|
mState = WCC_OPENED;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "nsIWyciwygChannel.h"
|
#include "nsIWyciwygChannel.h"
|
||||||
#include "nsIChannel.h"
|
#include "nsIChannel.h"
|
||||||
#include "nsIProgressEventSink.h"
|
#include "nsIProgressEventSink.h"
|
||||||
#include "PrivateBrowsingConsumer.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
@ -35,7 +34,6 @@ enum WyciwygChannelChildState {
|
||||||
// Header file contents
|
// Header file contents
|
||||||
class WyciwygChannelChild : public PWyciwygChannelChild
|
class WyciwygChannelChild : public PWyciwygChannelChild
|
||||||
, public nsIWyciwygChannel
|
, public nsIWyciwygChannel
|
||||||
, public PrivateBrowsingConsumer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
|
@ -17,6 +17,11 @@ namespace net {
|
||||||
|
|
||||||
WyciwygChannelParent::WyciwygChannelParent()
|
WyciwygChannelParent::WyciwygChannelParent()
|
||||||
: mIPCClosed(false)
|
: mIPCClosed(false)
|
||||||
|
, mHaveLoadContext(false)
|
||||||
|
, mIsContent(false)
|
||||||
|
, mUsePrivateBrowsing(false)
|
||||||
|
, mIsInBrowserElement(false)
|
||||||
|
, mAppId(0)
|
||||||
{
|
{
|
||||||
#if defined(PR_LOGGING)
|
#if defined(PR_LOGGING)
|
||||||
if (!gWyciwygLog)
|
if (!gWyciwygLog)
|
||||||
|
@ -40,8 +45,10 @@ WyciwygChannelParent::ActorDestroy(ActorDestroyReason why)
|
||||||
// WyciwygChannelParent::nsISupports
|
// WyciwygChannelParent::nsISupports
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(WyciwygChannelParent,
|
NS_IMPL_ISUPPORTS4(WyciwygChannelParent,
|
||||||
nsIStreamListener,
|
nsIStreamListener,
|
||||||
|
nsIInterfaceRequestor,
|
||||||
|
nsILoadContext,
|
||||||
nsIRequestObserver);
|
nsIRequestObserver);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -79,7 +86,11 @@ WyciwygChannelParent::RecvInit(const IPC::URI& aURI)
|
||||||
bool
|
bool
|
||||||
WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
|
WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
|
||||||
const PRUint32& aLoadFlags,
|
const PRUint32& aLoadFlags,
|
||||||
const bool& aUsingPrivateBrowsing)
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usePrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> original(aOriginal);
|
nsCOMPtr<nsIURI> original(aOriginal);
|
||||||
|
|
||||||
|
@ -98,8 +109,13 @@ WyciwygChannelParent::RecvAsyncOpen(const IPC::URI& aOriginal,
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return SendCancelEarly(rv);
|
return SendCancelEarly(rv);
|
||||||
|
|
||||||
static_cast<nsWyciwygChannel*>(mChannel.get())->
|
// fields needed to impersonate nsILoadContext
|
||||||
OverridePrivateBrowsing(aUsingPrivateBrowsing);
|
mHaveLoadContext = haveLoadContext;
|
||||||
|
mIsContent = isContent;
|
||||||
|
mUsePrivateBrowsing = usePrivateBrowsing;
|
||||||
|
mIsInBrowserElement = isInBrowserElement;
|
||||||
|
mAppId = appId;
|
||||||
|
mChannel->SetNotificationCallbacks(this);
|
||||||
|
|
||||||
rv = mChannel->AsyncOpen(this, nsnull);
|
rv = mChannel->AsyncOpen(this, nsnull);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
|
@ -241,4 +257,87 @@ WyciwygChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// WyciwygChannelParent::nsIInterfaceRequestor
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetInterface(const nsIID& uuid, void** result)
|
||||||
|
{
|
||||||
|
// Only support nsILoadContext if child channel's callbacks did too
|
||||||
|
if (uuid.Equals(NS_GET_IID(nsILoadContext)) && !mHaveLoadContext) {
|
||||||
|
return NS_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QueryInterface(uuid, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// WyciwygChannelParent::nsILoadContext
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetAssociatedWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetTopWindow(nsIDOMWindow**)
|
||||||
|
{
|
||||||
|
// can't support this in the parent process
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::IsAppOfType(PRUint32, bool*)
|
||||||
|
{
|
||||||
|
// don't expect we need this in parent (Thunderbird/SeaMonkey specific?)
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetIsContent(bool *aIsContent)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsContent);
|
||||||
|
|
||||||
|
*aIsContent = mIsContent;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
|
||||||
|
|
||||||
|
*aUsePrivateBrowsing = mUsePrivateBrowsing;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||||
|
{
|
||||||
|
// We shouldn't need this on parent...
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aIsInBrowserElement);
|
||||||
|
|
||||||
|
*aIsInBrowserElement = mIsInBrowserElement;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
WyciwygChannelParent::GetAppId(PRUint32* aAppId)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aAppId);
|
||||||
|
|
||||||
|
*aAppId = mAppId;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
}} // mozilla::net
|
}} // mozilla::net
|
||||||
|
|
|
@ -10,17 +10,23 @@
|
||||||
#include "nsIStreamListener.h"
|
#include "nsIStreamListener.h"
|
||||||
|
|
||||||
#include "nsIWyciwygChannel.h"
|
#include "nsIWyciwygChannel.h"
|
||||||
|
#include "nsIInterfaceRequestor.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
class WyciwygChannelParent : public PWyciwygChannelParent
|
class WyciwygChannelParent : public PWyciwygChannelParent
|
||||||
, public nsIStreamListener
|
, public nsIStreamListener
|
||||||
|
, public nsIInterfaceRequestor
|
||||||
|
, public nsILoadContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIREQUESTOBSERVER
|
NS_DECL_NSIREQUESTOBSERVER
|
||||||
NS_DECL_NSISTREAMLISTENER
|
NS_DECL_NSISTREAMLISTENER
|
||||||
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
|
NS_DECL_NSILOADCONTEXT
|
||||||
|
|
||||||
WyciwygChannelParent();
|
WyciwygChannelParent();
|
||||||
virtual ~WyciwygChannelParent();
|
virtual ~WyciwygChannelParent();
|
||||||
|
@ -29,7 +35,11 @@ protected:
|
||||||
virtual bool RecvInit(const IPC::URI& uri);
|
virtual bool RecvInit(const IPC::URI& uri);
|
||||||
virtual bool RecvAsyncOpen(const IPC::URI& original,
|
virtual bool RecvAsyncOpen(const IPC::URI& original,
|
||||||
const PRUint32& loadFlags,
|
const PRUint32& loadFlags,
|
||||||
const bool& usingPrivateBrowsing);
|
const bool& haveLoadContext,
|
||||||
|
const bool& isContent,
|
||||||
|
const bool& usingPrivateBrowsing,
|
||||||
|
const bool& isInBrowserElement,
|
||||||
|
const PRUint32& appId);
|
||||||
virtual bool RecvWriteToCacheEntry(const nsString& data);
|
virtual bool RecvWriteToCacheEntry(const nsString& data);
|
||||||
virtual bool RecvCloseCacheEntry(const nsresult& reason);
|
virtual bool RecvCloseCacheEntry(const nsresult& reason);
|
||||||
virtual bool RecvSetCharsetAndSource(const PRInt32& source,
|
virtual bool RecvSetCharsetAndSource(const PRInt32& source,
|
||||||
|
@ -41,6 +51,14 @@ protected:
|
||||||
|
|
||||||
nsCOMPtr<nsIWyciwygChannel> mChannel;
|
nsCOMPtr<nsIWyciwygChannel> mChannel;
|
||||||
bool mIPCClosed;
|
bool mIPCClosed;
|
||||||
|
|
||||||
|
// fields for impersonating nsILoadContext
|
||||||
|
bool mHaveLoadContext : 1;
|
||||||
|
bool mIsContent : 1;
|
||||||
|
bool mUsePrivateBrowsing : 1;
|
||||||
|
bool mIsInBrowserElement : 1;
|
||||||
|
|
||||||
|
PRUint32 mAppId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|
|
@ -79,12 +79,11 @@ private:
|
||||||
|
|
||||||
// nsWyciwygChannel methods
|
// nsWyciwygChannel methods
|
||||||
nsWyciwygChannel::nsWyciwygChannel()
|
nsWyciwygChannel::nsWyciwygChannel()
|
||||||
: PrivateBrowsingConsumer(this),
|
: mStatus(NS_OK),
|
||||||
mStatus(NS_OK),
|
|
||||||
mIsPending(false),
|
mIsPending(false),
|
||||||
mCharsetAndSourceSet(false),
|
mCharsetAndSourceSet(false),
|
||||||
mNeedToWriteCharset(false),
|
mNeedToWriteCharset(false),
|
||||||
mPrivate(false),
|
mPrivateBrowsing(false),
|
||||||
mCharsetSource(kCharsetUninitialized),
|
mCharsetSource(kCharsetUninitialized),
|
||||||
mContentLength(-1),
|
mContentLength(-1),
|
||||||
mLoadFlags(LOAD_NORMAL)
|
mLoadFlags(LOAD_NORMAL)
|
||||||
|
@ -272,6 +271,10 @@ nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationC
|
||||||
mLoadGroup,
|
mLoadGroup,
|
||||||
NS_GET_IID(nsIProgressEventSink),
|
NS_GET_IID(nsIProgressEventSink),
|
||||||
getter_AddRefs(mProgressSink));
|
getter_AddRefs(mProgressSink));
|
||||||
|
|
||||||
|
// Will never change unless SetNotificationCallbacks called again, so cache
|
||||||
|
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,9 +399,6 @@ nsWyciwygChannel::WriteToCacheEntry(const nsAString &aData)
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
// UsePrivateBrowsing deals with non-threadsafe objects
|
|
||||||
mPrivate = UsePrivateBrowsing();
|
|
||||||
|
|
||||||
return mCacheIOTarget->Dispatch(new nsWyciwygWriteEvent(this, aData, spec),
|
return mCacheIOTarget->Dispatch(new nsWyciwygWriteEvent(this, aData, spec),
|
||||||
NS_DISPATCH_NORMAL);
|
NS_DISPATCH_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -668,20 +668,20 @@ nsWyciwygChannel::OpenCacheEntry(const nsACString & aCacheKey,
|
||||||
|
|
||||||
// honor security settings
|
// honor security settings
|
||||||
nsCacheStoragePolicy storagePolicy;
|
nsCacheStoragePolicy storagePolicy;
|
||||||
if (mPrivate || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
|
if (mPrivateBrowsing || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
|
||||||
storagePolicy = nsICache::STORE_IN_MEMORY;
|
storagePolicy = nsICache::STORE_IN_MEMORY;
|
||||||
else
|
else
|
||||||
storagePolicy = nsICache::STORE_ANYWHERE;
|
storagePolicy = nsICache::STORE_ANYWHERE;
|
||||||
|
|
||||||
nsCOMPtr<nsICacheSession> cacheSession;
|
nsCOMPtr<nsICacheSession> cacheSession;
|
||||||
// Open a stream based cache session.
|
// Open a stream based cache session.
|
||||||
const char* sessionName = mPrivate ? "wyciwyg-private" : "wyciwyg";
|
const char* sessionName = mPrivateBrowsing ? "wyciwyg-private" : "wyciwyg";
|
||||||
rv = cacheService->CreateSession(sessionName, storagePolicy, true,
|
rv = cacheService->CreateSession(sessionName, storagePolicy, true,
|
||||||
getter_AddRefs(cacheSession));
|
getter_AddRefs(cacheSession));
|
||||||
if (!cacheSession)
|
if (!cacheSession)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
cacheSession->SetIsPrivate(mPrivate);
|
cacheSession->SetIsPrivate(mPrivateBrowsing);
|
||||||
|
|
||||||
if (aAccessMode == nsICache::ACCESS_WRITE)
|
if (aAccessMode == nsICache::ACCESS_WRITE)
|
||||||
rv = cacheSession->OpenCacheEntry(aCacheKey, aAccessMode, false,
|
rv = cacheSession->OpenCacheEntry(aCacheKey, aAccessMode, false,
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
#include "nsICacheEntryDescriptor.h"
|
#include "nsICacheEntryDescriptor.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsIEventTarget.h"
|
#include "nsIEventTarget.h"
|
||||||
#include "PrivateBrowsingConsumer.h"
|
#include "nsILoadContext.h"
|
||||||
|
#include "nsNetUtil.h"
|
||||||
|
|
||||||
extern PRLogModuleInfo * gWyciwygLog;
|
extern PRLogModuleInfo * gWyciwygLog;
|
||||||
|
|
||||||
|
@ -32,8 +33,7 @@ extern PRLogModuleInfo * gWyciwygLog;
|
||||||
|
|
||||||
class nsWyciwygChannel: public nsIWyciwygChannel,
|
class nsWyciwygChannel: public nsIWyciwygChannel,
|
||||||
public nsIStreamListener,
|
public nsIStreamListener,
|
||||||
public nsICacheListener,
|
public nsICacheListener
|
||||||
public mozilla::net::PrivateBrowsingConsumer
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
@ -72,7 +72,7 @@ protected:
|
||||||
bool mIsPending;
|
bool mIsPending;
|
||||||
bool mCharsetAndSourceSet;
|
bool mCharsetAndSourceSet;
|
||||||
bool mNeedToWriteCharset;
|
bool mNeedToWriteCharset;
|
||||||
bool mPrivate;
|
bool mPrivateBrowsing;
|
||||||
PRInt32 mCharsetSource;
|
PRInt32 mCharsetSource;
|
||||||
nsCString mCharset;
|
nsCString mCharset;
|
||||||
PRInt32 mContentLength;
|
PRInt32 mContentLength;
|
||||||
|
|
|
@ -11,20 +11,49 @@ var longexpPath = "/longexp" + suffix;
|
||||||
var nocachePath = "/nocache" + suffix;
|
var nocachePath = "/nocache" + suffix;
|
||||||
var nostorePath = "/nostore" + suffix;
|
var nostorePath = "/nostore" + suffix;
|
||||||
|
|
||||||
function make_channel(url, flags) {
|
// We attach this to channel when we want to test Private Browsing mode
|
||||||
|
function LoadContext(usePrivateBrowsing) {
|
||||||
|
this.usePrivateBrowsing = usePrivateBrowsing;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadContext.prototype = {
|
||||||
|
usePrivateBrowsing: false,
|
||||||
|
// don't bother defining rest of nsILoadContext fields: don't need 'em
|
||||||
|
|
||||||
|
QueryInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsILoadContext))
|
||||||
|
return this;
|
||||||
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
},
|
||||||
|
|
||||||
|
getInterface: function(iid) {
|
||||||
|
if (iid.equals(Ci.nsILoadContext))
|
||||||
|
return this;
|
||||||
|
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PrivateBrowsingLoadContext = new LoadContext(true);
|
||||||
|
|
||||||
|
function make_channel(url, flags, usePrivateBrowsing) {
|
||||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||||
getService(Ci.nsIIOService);
|
getService(Ci.nsIIOService);
|
||||||
var req = ios.newChannel(url, null, null);
|
var req = ios.newChannel(url, null, null);
|
||||||
req.loadFlags = flags;
|
req.loadFlags = flags;
|
||||||
|
if (usePrivateBrowsing) {
|
||||||
|
req.notificationCallbacks = PrivateBrowsingLoadContext;
|
||||||
|
}
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Test(path, flags, expectSuccess, readFromCache, hitServer) {
|
function Test(path, flags, expectSuccess, readFromCache, hitServer,
|
||||||
|
usePrivateBrowsing /* defaults to false */) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
this.expectSuccess = expectSuccess;
|
this.expectSuccess = expectSuccess;
|
||||||
this.readFromCache = readFromCache;
|
this.readFromCache = readFromCache;
|
||||||
this.hitServer = hitServer;
|
this.hitServer = hitServer;
|
||||||
|
this.usePrivateBrowsing = usePrivateBrowsing;
|
||||||
}
|
}
|
||||||
|
|
||||||
Test.prototype = {
|
Test.prototype = {
|
||||||
|
@ -32,6 +61,7 @@ Test.prototype = {
|
||||||
expectSuccess: true,
|
expectSuccess: true,
|
||||||
readFromCache: false,
|
readFromCache: false,
|
||||||
hitServer: true,
|
hitServer: true,
|
||||||
|
usePrivateBrowsing: false,
|
||||||
_buffer: "",
|
_buffer: "",
|
||||||
_isFromCache: false,
|
_isFromCache: false,
|
||||||
|
|
||||||
|
@ -44,7 +74,7 @@ Test.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onStartRequest: function(request, context) {
|
onStartRequest: function(request, context) {
|
||||||
var cachingChannel = request.QueryInterface(Ci.nsICachingChannel);
|
var cachingChannel = request.QueryInterface(Ci.nsICacheInfoChannel);
|
||||||
this._isFromCache = request.isPending() && cachingChannel.isFromCache();
|
this._isFromCache = request.isPending() && cachingChannel.isFromCache();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -68,7 +98,7 @@ Test.prototype = {
|
||||||
"\n " + this.readFromCache +
|
"\n " + this.readFromCache +
|
||||||
"\n " + this.hitServer + "\n");
|
"\n " + this.hitServer + "\n");
|
||||||
gHitServer = false;
|
gHitServer = false;
|
||||||
var channel = make_channel(this.path, this.flags);
|
var channel = make_channel(this.path, this.flags, this.usePrivateBrowsing);
|
||||||
channel.asyncOpen(this, null);
|
channel.asyncOpen(this, null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -76,6 +106,12 @@ Test.prototype = {
|
||||||
var gHitServer = false;
|
var gHitServer = false;
|
||||||
|
|
||||||
var gTests = [
|
var gTests = [
|
||||||
|
|
||||||
|
new Test(httpBase + shortexpPath, 0,
|
||||||
|
true, // expect success
|
||||||
|
false, // read from cache
|
||||||
|
true, // hit server
|
||||||
|
true), // USE PRIVATE BROWSING, so not cached for later requests
|
||||||
new Test(httpBase + shortexpPath, 0,
|
new Test(httpBase + shortexpPath, 0,
|
||||||
true, // expect success
|
true, // expect success
|
||||||
false, // read from cache
|
false, // read from cache
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
//
|
||||||
|
// Run test script in content process instead of chrome (xpcshell's default)
|
||||||
|
//
|
||||||
|
|
||||||
|
function run_test() {
|
||||||
|
run_test_in_child("../unit/test_cacheflags.js");
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
head = head_channels_clone.js
|
head = head_channels_clone.js
|
||||||
tail =
|
tail =
|
||||||
|
|
||||||
|
[test_cacheflags_wrap.js]
|
||||||
[test_channel_close_wrap.js]
|
[test_channel_close_wrap.js]
|
||||||
[test_cookie_wrap.js]
|
[test_cookie_wrap.js]
|
||||||
[test_duplicate_headers_wrap.js]
|
[test_duplicate_headers_wrap.js]
|
||||||
|
|
|
@ -106,7 +106,6 @@
|
||||||
#include "nsIDocShellTreeOwner.h"
|
#include "nsIDocShellTreeOwner.h"
|
||||||
#include "nsIDocShellTreeItem.h"
|
#include "nsIDocShellTreeItem.h"
|
||||||
#include "ExternalHelperAppChild.h"
|
#include "ExternalHelperAppChild.h"
|
||||||
#include "nsIPrivateBrowsingConsumer.h"
|
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
@ -2181,8 +2180,8 @@ nsresult nsExternalAppHandler::OpenWithApplication()
|
||||||
|
|
||||||
// See whether the channel has been opened in private browsing mode
|
// See whether the channel has been opened in private browsing mode
|
||||||
NS_ASSERTION(mRequest, "This should never be called with a null request");
|
NS_ASSERTION(mRequest, "This should never be called with a null request");
|
||||||
nsCOMPtr<nsIPrivateBrowsingConsumer> pbConsumer = do_QueryInterface(mRequest);
|
nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
|
||||||
bool inPrivateBrowsing = pbConsumer && pbConsumer->UsePrivateBrowsing();
|
bool inPrivateBrowsing = channel && NS_UsePrivateBrowsing(channel);
|
||||||
|
|
||||||
// make the tmp file readonly so users won't edit it and lose the changes
|
// make the tmp file readonly so users won't edit it and lose the changes
|
||||||
// only if we're going to delete the file
|
// only if we're going to delete the file
|
||||||
|
|
Загрузка…
Ссылка в новой задаче