本文整理汇总了C++中NS_QueryNotificationCallbacks函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_QueryNotificationCallbacks函数的具体用法?C++ NS_QueryNotificationCallbacks怎么用?C++ NS_QueryNotificationCallbacks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_QueryNotificationCallbacks函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:Neil511,项目名称:gecko-dev,代码行数:27,代码来源:SerializedLoadContext.cpp
示例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;
}
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:29,代码来源:nsMsgContentPolicy.cpp
示例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;
}
开发者ID:TheTypoMaster,项目名称:fennec-777045,代码行数:59,代码来源:FTPChannelChild.cpp
示例4: NS_QueryNotificationCallbacks
SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
{
nsCOMPtr<nsILoadContext> loadContext;
if (aChannel) {
NS_QueryNotificationCallbacks(aChannel, loadContext);
}
Init(loadContext);
}
开发者ID:Neil511,项目名称:gecko-dev,代码行数:8,代码来源:SerializedLoadContext.cpp
示例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);
}
开发者ID:jld,项目名称:gecko-dev,代码行数:11,代码来源:SerializedLoadContext.cpp
示例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;
}
开发者ID:mdevils,项目名称:services-central-legacy,代码行数:14,代码来源:nsWyciwygChannel.cpp
示例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);
}
}
开发者ID:RickEyre,项目名称:mozilla-central,代码行数:15,代码来源:nsHttpChannelAuthProvider.cpp
示例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;
}
开发者ID:mbuttu,项目名称:mozilla-central,代码行数:49,代码来源:WyciwygChannelChild.cpp
示例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;
}
开发者ID:haasn,项目名称:gecko-dev,代码行数:16,代码来源:nsWyciwygChannel.cpp
示例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;
}
开发者ID:brendandahl,项目名称:positron,代码行数:17,代码来源:nsWyciwygChannel.cpp
示例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;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:43,代码来源:nsJARChannel.cpp
示例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;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:19,代码来源:nsGopherChannel.cpp
示例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;
}
开发者ID:Acidburn0zzz,项目名称:tor-browser,代码行数:22,代码来源:ThirdPartyUtil.cpp
示例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;
}
开发者ID:70599,项目名称:Waterfox,代码行数:23,代码来源:ThirdPartyUtil.cpp
示例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;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:36,代码来源:nsAsyncRedirectVerifyHelper.cpp
示例16: mount_operation_ask_password
/**
* This function is called when username or password are requested from user.
* This function is called in main thread as async request from dbus.
* @param mount_op mount operation
* @param message message to show to user
* @param default_user preffered user
* @param default_domain domain name
* @param flags what type of information is required
* @param user_data nsIChannel
*/
static void
mount_operation_ask_password (GMountOperation *mount_op,
const char *message,
const char *default_user,
const char *default_domain,
GAskPasswordFlags flags,
gpointer user_data)
{
nsIChannel *channel = (nsIChannel *) user_data;
if (!channel) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
// We can't handle request for domain
if (flags & G_ASK_PASSWORD_NEED_DOMAIN) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
nsCOMPtr<nsIAuthPrompt> prompt;
NS_QueryNotificationCallbacks(channel, prompt);
// If no auth prompt, then give up. We could failover to using the
// WindowWatcher service, but that might defeat a consumer's purposeful
// attempt to disable authentication (for whatever reason).
if (!prompt) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
// Parse out the host and port...
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
if (!uri) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
nsAutoCString scheme, hostPort;
uri->GetScheme(scheme);
uri->GetHostPort(hostPort);
// It doesn't make sense for either of these strings to be empty. What kind
// of funky URI is this?
if (scheme.IsEmpty() || hostPort.IsEmpty()) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
// Construct the single signon key. Altering the value of this key will
// cause people's remembered passwords to be forgotten. Think carefully
// before changing the way this key is constructed.
nsAutoString key, realm;
NS_ConvertUTF8toUTF16 dispHost(scheme);
dispHost.AppendLiteral("://");
dispHost.Append(NS_ConvertUTF8toUTF16(hostPort));
key = dispHost;
if (*default_domain != '\0')
{
// We assume the realm string is ASCII. That might be a bogus assumption,
// but we have no idea what encoding GnomeVFS is using, so for now we'll
// limit ourselves to ISO-Latin-1. XXX What is a better solution?
realm.Append('"');
realm.Append(NS_ConvertASCIItoUTF16(default_domain));
realm.Append('"');
key.Append(' ');
key.Append(realm);
}
// Construct the message string...
//
// We use Necko's string bundle here. This code really should be encapsulated
// behind some Necko API, after all this code is based closely on the code in
// nsHttpChannel.cpp.
nsCOMPtr<nsIStringBundleService> bundleSvc =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
if (!bundleSvc) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
nsCOMPtr<nsIStringBundle> bundle;
bundleSvc->CreateBundle("chrome://global/locale/commonDialogs.properties",
getter_AddRefs(bundle));
if (!bundle) {
g_mount_operation_reply(mount_op, G_MOUNT_OPERATION_ABORTED);
return;
}
nsAutoString nsmessage;
if (flags & G_ASK_PASSWORD_NEED_PASSWORD) {
if (flags & G_ASK_PASSWORD_NEED_USERNAME) {
//.........这里部分代码省略.........
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:101,代码来源:nsGIOProtocolHandler.cpp
示例17: do_GetService
bool
nsHttpChannelAuthProvider::ConfirmAuth(const nsString &bundleKey,
bool doYesNoPrompt)
{
// skip prompting the user if
// 1) we've already prompted the user
// 2) we're not a toplevel channel
// 3) the userpass length is less than the "phishy" threshold
uint32_t loadFlags;
nsresult rv = mAuthChannel->GetLoadFlags(&loadFlags);
if (NS_FAILED(rv))
return true;
if (mSuppressDefensiveAuth ||
!(loadFlags & nsIChannel::LOAD_INITIAL_DOCUMENT_URI))
return true;
nsCAutoString userPass;
rv = mURI->GetUserPass(userPass);
if (NS_FAILED(rv) ||
(userPass.Length() < gHttpHandler->PhishyUserPassLength()))
return true;
// we try to confirm by prompting the user. if we cannot do so, then
// assume the user said ok. this is done to keep things working in
// embedded builds, where the string bundle might not be present, etc.
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
if (!bundleService)
return true;
nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
if (!bundle)
return true;
nsCAutoString host;
rv = mURI->GetHost(host);
if (NS_FAILED(rv))
return true;
nsCAutoString user;
rv = mURI->GetUsername(user);
if (NS_FAILED(rv))
return true;
NS_ConvertUTF8toUTF16 ucsHost(host), ucsUser(user);
const PRUnichar *strs[2] = { ucsHost.get(), ucsUser.get() };
nsXPIDLString msg;
bundle->FormatStringFromName(bundleKey.get(), strs, 2, getter_Copies(msg));
if (!msg)
return true;
nsCOMPtr<nsIInterfaceRequestor> callbacks;
rv = mAuthChannel->GetNotificationCallbacks(getter_AddRefs(callbacks));
if (NS_FAILED(rv))
return true;
nsCOMPtr<nsILoadGroup> loadGroup;
rv = mAuthChannel->GetLoadGroup(getter_AddRefs(loadGroup));
if (NS_FAILED(rv))
return true;
nsCOMPtr<nsIPrompt> prompt;
NS_QueryNotificationCallbacks(callbacks, loadGroup, NS_GET_IID(nsIPrompt),
getter_AddRefs(prompt));
if (!prompt)
return true;
// do not prompt again
mSuppressDefensiveAuth = true;
bool confirmed;
if (doYesNoPrompt) {
int32_t choice;
// The actual value is irrelevant but we shouldn't be handing out
// malformed JSBools to XPConnect.
bool checkState = false;
rv = prompt->ConfirmEx(nullptr, msg,
nsIPrompt::BUTTON_POS_1_DEFAULT +
nsIPrompt::STD_YES_NO_BUTTONS,
nullptr, nullptr, nullptr, nullptr,
&checkState, &choice);
if (NS_FAILED(rv))
return true;
confirmed = choice == 0;
}
else {
rv = prompt->Confirm(nullptr, msg, &confirmed);
if (NS_FAILED(rv))
return true;
}
return confirmed;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:99,代码来源:nsHttpChannelAuthProvider.cpp
示例18: NS_QueryNotificationCallbacks
// static
nsresult
nsChannelClassifier::SetBlockedTrackingContent(nsIChannel *channel)
{
// Can be called in EITHER the parent or child process.
nsCOMPtr<nsIParentChannel> parentChannel;
NS_QueryNotificationCallbacks(channel, parentChannel);
if (parentChannel) {
// This channel is a parent-process proxy for a child process request. The
// actual channel will be notified via the status passed to
// nsIRequest::Cancel and do this for us.
return NS_OK;
}
nsresult rv;
nsCOMPtr<mozIDOMWindowProxy> win;
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
do_GetService(THIRDPARTYUTIL_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
rv = thirdPartyUtil->GetTopWindowForChannel(channel, getter_AddRefs(win));
NS_ENSURE_SUCCESS(rv, NS_OK);
auto* pwin = nsPIDOMWindowOuter::From(win);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
if (!docShell) {
return NS_OK;
}
nsCOMPtr<nsIDocument> doc = docShell->GetDocument();
NS_ENSURE_TRUE(doc, NS_OK);
// This event might come after the user has navigated to another page.
// To prevent showing the TrackingProtection UI on the wrong page, we need to
// check that the loading URI for the channel is the same as the URI currently
// loaded in the document.
if (!SameLoadingURI(doc, channel)) {
return NS_OK;
}
// Notify nsIWebProgressListeners of this security event.
// Can be used to change the UI state.
nsCOMPtr<nsISecurityEventSink> eventSink = do_QueryInterface(docShell, &rv);
NS_ENSURE_SUCCESS(rv, NS_OK);
uint32_t state = 0;
nsCOMPtr<nsISecureBrowserUI> securityUI;
docShell->GetSecurityUI(getter_AddRefs(securityUI));
if (!securityUI) {
return NS_OK;
}
doc->SetHasTrackingContentBlocked(true);
securityUI->GetState(&state);
state |= nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT;
eventSink->OnSecurityChange(nullptr, state);
// Log a warning to the web console.
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
NS_ConvertUTF8toUTF16 spec(uri->GetSpecOrDefault());
const char16_t* params[] = { spec.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Tracking Protection"),
doc,
nsContentUtils::eNECKO_PROPERTIES,
"TrackingUriBlocked",
params, ArrayLength(params));
return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:66,代码来源:nsChannelClassifier.cpp
示例19: ProxiedAuthCallback
static void
ProxiedAuthCallback(gconstpointer in,
gsize in_size,
gpointer out,
gsize out_size,
gpointer callback_data)
{
GnomeVFSModuleCallbackAuthenticationIn *authIn =
(GnomeVFSModuleCallbackAuthenticationIn *) in;
GnomeVFSModuleCallbackAuthenticationOut *authOut =
(GnomeVFSModuleCallbackAuthenticationOut *) out;
LOG(("gnomevfs: ProxiedAuthCallback [uri=%s]\n", authIn->uri));
// Without a channel, we have no way of getting a prompter.
nsIChannel *channel = (nsIChannel *) callback_data;
if (!channel)
return;
nsCOMPtr<nsIAuthPrompt> prompt;
NS_QueryNotificationCallbacks(channel, prompt);
// If no auth prompt, then give up. We could failover to using the
// WindowWatcher service, but that might defeat a consumer's purposeful
// attempt to disable authentication (for whatever reason).
if (!prompt)
return;
// Parse out the host and port...
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
if (!uri)
return;
#ifdef DEBUG
{
//
// Make sure authIn->uri is consistent with the channel's URI.
//
// XXX This check is probably not IDN safe, and it might incorrectly
// fire as a result of escaping differences. It's unclear what
// kind of transforms GnomeVFS might have applied to the URI spec
// that we originally gave to it. In spite of the likelihood of
// false hits, this check is probably still valuable.
//
nsAutoCString spec;
uri->GetSpec(spec);
int uriLen = strlen(authIn->uri);
if (!StringHead(spec, uriLen).Equals(nsDependentCString(authIn->uri, uriLen)))
{
LOG(("gnomevfs: [spec=%s authIn->uri=%s]\n", spec.get(), authIn->uri));
NS_ERROR("URI mismatch");
}
}
#endif
nsAutoCString scheme, hostPort;
uri->GetScheme(scheme);
uri->GetHostPort(hostPort);
// It doesn't make sense for either of these strings to be empty. What kind
// of funky URI is this?
if (scheme.IsEmpty() || hostPort.IsEmpty())
return;
// Construct the single signon key. Altering the value of this key will
// cause people's remembered passwords to be forgotten. Think carefully
// before changing the way this key is constructed.
nsAutoString key, realm;
NS_ConvertUTF8toUTF16 dispHost(scheme);
dispHost.AppendLiteral("://");
dispHost.Append(NS_ConvertUTF8toUTF16(hostPort));
key = dispHost;
if (authIn->realm)
{
// We assume the realm string is ASCII. That might be a bogus assumption,
// but we have no idea what encoding GnomeVFS is using, so for now we'll
// limit ourselves to ISO-Latin-1. XXX What is a better solution?
realm.Append('"');
realm.Append(NS_ConvertASCIItoUTF16(authIn->realm));
realm.Append('"');
key.Append(' ');
key.Append(realm);
}
// Construct the message string...
//
// We use Necko's string bundle here. This code really should be encapsulated
// behind some Necko API, after all this code is based closely on the code in
// nsHttpChannel.cpp.
nsCOMPtr<nsIStringBundleService> bundleSvc =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
if (!bundleSvc)
return;
nsCOMPtr<nsIStringBundle> bundle;
bundleSvc->CreateBundle("chrome://global/locale/commonDialogs.properties",
//.........这里部分代码省略.........
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:101,代码来源:nsGnomeVFSProtocolHandler.cpp
示例20: NS_ASSERTION
NS_IMETHODIMP
nsCookiePermission::CanSetCookie(nsIURI *aURI,
nsIChannel *aChannel,
nsICookie2 *aCookie,
bool *aIsSession,
PRInt64 *aExpiry,
bool *aResult)
{
NS_ASSERTION(aURI, "null uri");
*aResult = kDefaultPolicy;
// Lazily initialize ourselves
if (!EnsureInitialized())
return NS_ERROR_UNEXPECTED;
PRUint32 perm;
mPermMgr->TestPermission(aURI, kPermissionType, &perm);
switch (perm) {
case nsICookiePermission::ACCESS_SESSION:
*aIsSession = true;
case nsIPermissionManager::ALLOW_ACTION: // ACCESS_ALLOW
*aResult = true;
break;
case nsIPermissionManager::DENY_ACTION: // ACCESS_DENY
*aResult = false;
break;
default:
// the permission manager has nothing to say about this cookie -
// so, we apply the default prefs to it.
NS_ASSERTION(perm == nsIPermissionManager::UNKNOWN_ACTION, "unknown permission");
// now we need to figure out what type of accept policy we're dealing with
// if we accept cookies normally, just bail and return
if (mCookiesLifetimePolicy == ACCEPT_NORMALLY) {
*aResult = true;
return NS_OK;
}
// declare this here since it'll be used in all of the remaining cases
PRInt64 currentTime = PR_Now() / PR_USEC_PER_SEC;
PRInt64 delta = *aExpiry - currentTime;
// check whether the user wants to be prompted
if (mCookiesLifetimePolicy == ASK_BEFORE_ACCEPT) {
// if it's a session cookie and the user wants to accept these
// without asking, or if we are in private browsing mode, just
// accept the cookie and return
if ((*aIsSession && mCookiesAlwaysAcceptSession) ||
InPrivateBrowsing()) {
*aResult = true;
return NS_OK;
}
// default to rejecting, in case the prompting process fails
*aResult = false;
nsCAutoString hostPort;
aURI->GetHostPort(hostPort);
if (!aCookie) {
return NS_ERROR_UNEXPECTED;
}
// If there is no host, use the scheme, and append "://",
// to make sure it isn't a host or something.
// This is done to make the dialog appear for javascript cookies from
// file:// urls, and make the text on it not too weird. (bug 209689)
if (hostPort.IsEmpty()) {
aURI->GetScheme(hostPort);
if (hostPort.IsEmpty()) {
// still empty. Just return the default.
return NS_OK;
}
hostPort = hostPort + NS_LITERAL_CSTRING("://");
}
// we don't cache the cookiePromptService - it's not used often, so not
// worth the memory.
nsresult rv;
nsCOMPtr<nsICookiePromptService> cookiePromptService =
do_GetService(NS_COOKIEPROMPTSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
// try to get a nsIDOMWindow from the channel...
nsCOMPtr<nsIDOMWindow> parent;
if (aChannel) {
nsCOMPtr<nsILoadContext> ctx;
NS_QueryNotificationCallbacks(aChannel, ctx);
if (ctx) {
ctx->GetAssociatedWindow(getter_AddRefs(parent));
}
}
// get some useful information to present to the user:
// whether a previous cookie already exists, and how many cookies this host
// has set
bool foundCookie = false;
//.........这里部分代码省略.........
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:101,代码来源:nsCookiePermission.cpp
注:本文中的NS_QueryNotificationCallbacks函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论