/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=4 sts=2 sw=2 et cin: */ /* 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/. */
template <class Channel> class PrivateBrowsingChannel : public nsIPrivateBrowsingChannel { public:
PrivateBrowsingChannel()
: mPrivateBrowsingOverriden(false), mPrivateBrowsing(false) {}
NS_IMETHOD SetPrivate(bool aPrivate) override { // Make sure that we don't have a load context // This is a fatal error in debug builds, and a runtime error in release // builds.
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(static_cast<Channel*>(this), loadContext);
MOZ_ASSERT(!loadContext); if (loadContext) { return NS_ERROR_FAILURE;
}
// Must be called every time the channel's callbacks or loadGroup is updated void UpdatePrivateBrowsing() { // once marked as private we never go un-private if (mPrivateBrowsing) { return;
}
bool CanSetCallbacks(nsIInterfaceRequestor* aCallbacks) const { // Make sure that the private bit override flag is not set. // This is a fatal error in debug builds, and a runtime error in release // builds. if (!aCallbacks) { returntrue;
}
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks); if (!loadContext) { returntrue;
}
MOZ_ASSERT(!mPrivateBrowsingOverriden); return !mPrivateBrowsingOverriden;
}
bool CanSetLoadGroup(nsILoadGroup* aLoadGroup) const { // Make sure that the private bit override flag is not set. // This is a fatal error in debug builds, and a runtime error in release // builds. if (!aLoadGroup) { returntrue;
}
nsCOMPtr<nsIInterfaceRequestor> callbacks;
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks)); // From this point on, we just hand off the work to CanSetCallbacks, // because the logic is exactly the same. return CanSetCallbacks(callbacks);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.