本文整理汇总了C++中NS_QueryNotificationCallbacks函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_QueryNotificationCallbacks函数的具体用法?C++ NS_QueryNotificationCallbacks怎么用?C++ NS_QueryNotificationCallbacks使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_QueryNotificationCallbacks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
{
if (!aChannel) {
Init(nullptr);
return;
}
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(aChannel, loadContext);
Init(loadContext);
if (!loadContext) {
// Attempt to retrieve the private bit from the channel if it has been
// overriden.
bool isPrivate = false;
bool isOverriden = false;
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
if (pbChannel &&
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
&isOverriden)) &&
isOverriden) {
mUsePrivateBrowsing = isPrivate;
mIsPrivateBitValid = true;
}
mOriginAttributes.SyncAttributesWithPrivateBrowsing(mUsePrivateBrowsing);
}
}
示例2: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsMsgCookiePolicy::CanAccess(nsIURI *aURI,
nsIChannel *aChannel,
nsCookieAccess *aResult)
{
// by default we deny all cookies in mail
*aResult = ACCESS_DENY;
NS_ENSURE_ARG_POINTER(aChannel);
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem;
NS_QueryNotificationCallbacks(aChannel, docShellTreeItem);
NS_ENSURE_TRUE(docShellTreeItem, NS_OK);
PRInt32 itemType;
docShellTreeItem->GetItemType(&itemType);
// allow chrome docshells to set cookies
if (itemType == nsIDocShellTreeItem::typeChrome)
*aResult = ACCESS_DEFAULT;
else // allow RSS articles in content to access cookies
{
NS_ENSURE_TRUE(aURI, NS_OK);
PRBool isRSS = PR_FALSE;
IsRSSArticle(aURI, &isRSS);
if (isRSS)
*aResult = ACCESS_DEFAULT;
}
return NS_OK;
}
示例3: LOG
NS_IMETHODIMP
FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
{
LOG(("FTPChannelChild::AsyncOpen [this=%x]\n", this));
NS_ENSURE_TRUE((gNeckoChild), NS_ERROR_FAILURE);
NS_ENSURE_ARG_POINTER(listener);
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
// Port checked in parent, but duplicate here so we can return with error
// immediately, as we've done since before e10s.
nsresult rv;
rv = NS_CheckPortSafety(nsBaseChannel::URI()); // Need to disambiguate,
// because in the child ipdl,
// a typedef URI is defined...
if (NS_FAILED(rv))
return rv;
// FIXME: like bug 558623, merge constructor+SendAsyncOpen into 1 IPC msg
gNeckoChild->SendPFTPChannelConstructor(this);
mListener = listener;
mListenerContext = aContext;
// add ourselves to the load group.
if (mLoadGroup)
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,
IPC::InputStream(mUploadStream), haveLoadContext, isContent,
usePrivateBrowsing, isInBrowserElement, appId);
// The socket transport layer in the chrome process now has a logical ref to
// us until OnStopRequest is called.
AddIPDLReference();
mIsPending = true;
mWasOpened = true;
return rv;
}
示例4: NS_QueryNotificationCallbacks
SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
{
nsCOMPtr<nsILoadContext> loadContext;
if (aChannel) {
NS_QueryNotificationCallbacks(aChannel, loadContext);
}
Init(loadContext);
}
示例5: mIsContent
SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
: mIsContent(false),
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
mUseTrackingProtection(false) {
nsCOMPtr<nsILoadContext> loadContext;
if (aChannel) {
NS_QueryNotificationCallbacks(aChannel, loadContext);
}
Init(loadContext);
}
示例6: NS_QueryNotificationCallbacks
NS_IMETHODIMP
nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
{
mCallbacks = aNotificationCallbacks;
NS_QueryNotificationCallbacks(mCallbacks,
mLoadGroup,
NS_GET_IID(nsIProgressEventSink),
getter_AddRefs(mProgressSink));
// Will never change unless SetNotificationCallbacks called again, so cache
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
return NS_OK;
}
示例7: GetAppIdAndBrowserStatus
static void
GetAppIdAndBrowserStatus(nsIChannel* aChan, uint32_t* aAppId, bool* aInBrowserElem)
{
nsCOMPtr<nsILoadContext> loadContext;
if (aChan) {
NS_QueryNotificationCallbacks(aChan, loadContext);
}
if (!loadContext) {
*aAppId = NECKO_NO_APP_ID;
*aInBrowserElem = false;
} else {
loadContext->GetAppId(aAppId);
loadContext->GetIsInBrowserElement(aInBrowserElem);
}
}
示例8: LOG
/* void asyncOpen (in nsIStreamListener aListener, in nsISupports aContext); */
NS_IMETHODIMP
WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aContext)
{
LOG(("WyciwygChannelChild::AsyncOpen [this=%x]\n", this));
// The only places creating wyciwyg: channels should be
// HTMLDocument::OpenCommon and session history. Both should be setting an
// owner.
NS_PRECONDITION(mOwner, "Must have a principal");
NS_ENSURE_STATE(mOwner);
NS_ENSURE_ARG_POINTER(aListener);
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
mListener = aListener;
mListenerContext = aContext;
mIsPending = true;
if (mLoadGroup)
mLoadGroup->AddRequest(this, nullptr);
// Get info from nsILoadContext, if any
bool haveLoadContext = false;
bool isContent = false;
bool usePrivateBrowsing = false;
bool isInBrowserElement = false;
PRUint32 appId = 0;
nsCAutoString extendedOrigin;
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);
loadContext->GetExtendedOrigin(mURI, extendedOrigin);
}
SendAsyncOpen(IPC::URI(mOriginalURI), mLoadFlags, haveLoadContext, isContent,
usePrivateBrowsing, isInBrowserElement, appId, extendedOrigin);
mState = WCC_OPENED;
return NS_OK;
}
示例9: NS_QueryNotificationCallbacks
NS_IMETHODIMP
nsWyciwygChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
{
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}
mLoadGroup = aLoadGroup;
NS_QueryNotificationCallbacks(mCallbacks,
mLoadGroup,
NS_GET_IID(nsIProgressEventSink),
getter_AddRefs(mProgressSink));
mPrivateBrowsing = NS_UsePrivateBrowsing(this);
NS_GetAppInfo(this, &mAppId, &mInBrowser);
return NS_OK;
}
示例10: NS_QueryNotificationCallbacks
NS_IMETHODIMP
nsWyciwygChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
{
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}
mLoadGroup = aLoadGroup;
NS_QueryNotificationCallbacks(mCallbacks,
mLoadGroup,
NS_GET_IID(nsIProgressEventSink),
getter_AddRefs(mProgressSink));
UpdatePrivateBrowsing();
NS_GetOriginAttributes(this, mOriginAttributes);
return NS_OK;
}
示例11: LOG
NS_IMETHODIMP
nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
{
LOG(("nsJARChannel::AsyncOpen [this=%x]\n", this));
NS_ENSURE_ARG_POINTER(listener);
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
mJarFile = nsnull;
mIsUnsafe = PR_TRUE;
// Initialize mProgressSink
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink);
nsresult rv = EnsureJarInput(PR_FALSE);
if (NS_FAILED(rv)) return rv;
// These variables must only be set if we're going to trigger an
// OnStartRequest, either from AsyncRead or OnDownloadComplete.
mListener = listener;
mListenerContext = ctx;
mIsPending = PR_TRUE;
if (mJarInput) {
// create input stream pump and call AsyncRead as a block
rv = NS_NewInputStreamPump(getter_AddRefs(mPump), mJarInput);
if (NS_SUCCEEDED(rv))
rv = mPump->AsyncRead(this, nsnull);
// If we failed to create the pump or initiate the AsyncRead,
// then we need to clear these variables.
if (NS_FAILED(rv)) {
mIsPending = PR_FALSE;
mListenerContext = nsnull;
mListener = nsnull;
return rv;
}
}
if (mLoadGroup)
mLoadGroup->AddRequest(this, nsnull);
return NS_OK;
}
示例12: NS_QueryNotificationCallbacks
NS_IMETHODIMP
nsGopherChannel::OnTransportStatus(nsITransport *trans, nsresult status,
PRUint64 progress, PRUint64 progressMax)
{
if (!mProgressSink)
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup, mProgressSink);
// suppress status notification if channel is no longer pending!
if (mProgressSink && NS_SUCCEEDED(mStatus) && mPump && !(mLoadFlags & LOAD_BACKGROUND)) {
NS_ConvertUTF8toUTF16 host(mHost);
mProgressSink->OnStatus(this, nsnull, status, host.get());
if (status == nsISocketTransport::STATUS_RECEIVING_FROM ||
status == nsISocketTransport::STATUS_SENDING_TO) {
mProgressSink->OnProgress(this, nsnull, progress, progressMax);
}
}
return NS_OK;
}
示例13: NS_ENSURE_ARG
NS_IMETHODIMP
ThirdPartyUtil::GetTopWindowForChannel(nsIChannel* aChannel, nsIDOMWindow** aWin)
{
NS_ENSURE_ARG(aWin);
nsresult rv;
// Find the associated window and its parent window.
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(aChannel, ctx);
if (!ctx) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIDOMWindow> window;
rv = ctx->GetAssociatedWindow(getter_AddRefs(window));
if (!window) {
return NS_ERROR_INVALID_ARG;
}
rv = window->GetTop(aWin);
return rv;
}
示例14: NS_ENSURE_ARG
NS_IMETHODIMP
ThirdPartyUtil::GetTopWindowForChannel(nsIChannel* aChannel, nsIDOMWindow** aWin)
{
NS_ENSURE_ARG(aWin);
// Find the associated window and its parent window.
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(aChannel, ctx);
if (!ctx) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIDOMWindow> window;
ctx->GetAssociatedWindow(getter_AddRefs(window));
nsCOMPtr<nsPIDOMWindow> top = do_QueryInterface(window);
if (!top) {
return NS_ERROR_INVALID_ARG;
}
top = top->GetTop();
top.forget(aWin);
return NS_OK;
}
示例15: ExplicitCallback
NS_IMETHODIMP
nsAsyncRedirectVerifyHelper::Run()
{
/* If the channel got canceled after it fired AsyncOnChannelRedirect
* and before we got here, mostly because docloader load has been canceled,
* we must completely ignore this notification and prevent any further
* notification.
*/
if (IsOldChannelCanceled()) {
ExplicitCallback(NS_BINDING_ABORTED);
return NS_OK;
}
// First, the global observer
NS_ASSERTION(gIOService, "Must have an IO service at this point");
LOG(("nsAsyncRedirectVerifyHelper::Run() calling gIOService..."));
nsresult rv = gIOService->AsyncOnChannelRedirect(mOldChan, mNewChan,
mFlags, this);
if (NS_FAILED(rv)) {
ExplicitCallback(rv);
return NS_OK;
}
// Now, the per-channel observers
nsCOMPtr<nsIChannelEventSink> sink;
NS_QueryNotificationCallbacks(mOldChan, sink);
if (sink) {
LOG(("nsAsyncRedirectVerifyHelper::Run() calling sink..."));
rv = DelegateOnChannelRedirect(sink, mOldChan, mNewChan, mFlags);
}
// All invocations to AsyncOnChannelRedirect has been done - call
// InitCallback() to flag this
InitCallback();
return NS_OK;
}