mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 800193 - Print a warning when setting nsILoadContext.usePrivateBrowsing in per-window private browsing builds; r=bzbarsky
This commit is contained in:
parent
a4ce179e40
commit
cbe0e3a4d1
@ -751,6 +751,31 @@ public:
|
||||
return sXPConnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a non-localized error message to the error console.
|
||||
* @param aErrorText the error message
|
||||
* @param aErrorFlags See nsIScriptError.
|
||||
* @param aCategory Name of module reporting error.
|
||||
* @param aDocument Reference to the document which triggered the message.
|
||||
* @param [aURI=nullptr] (Optional) URI of resource containing error.
|
||||
* @param [aSourceLine=EmptyString()] (Optional) The text of the line that
|
||||
contains the error (may be empty).
|
||||
* @param [aLineNumber=0] (Optional) Line number within resource
|
||||
containing error.
|
||||
* @param [aColumnNumber=0] (Optional) Column number within resource
|
||||
containing error.
|
||||
If aURI is null, then aDocument->GetDocumentURI() is used.
|
||||
*/
|
||||
static nsresult ReportToConsoleNonLocalized(const nsAString& aErrorText,
|
||||
uint32_t aErrorFlags,
|
||||
const char *aCategory,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aURI = nullptr,
|
||||
const nsAFlatString& aSourceLine
|
||||
= EmptyString(),
|
||||
uint32_t aLineNumber = 0,
|
||||
uint32_t aColumnNumber = 0);
|
||||
|
||||
/**
|
||||
* Report a localized error message to the error console.
|
||||
* @param aErrorFlags See nsIScriptError.
|
||||
|
@ -3214,6 +3214,33 @@ nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
|
||||
"Supply either both parameters and their number or no"
|
||||
"parameters and 0.");
|
||||
|
||||
nsresult rv;
|
||||
nsXPIDLString errorText;
|
||||
if (aParams) {
|
||||
rv = FormatLocalizedString(aFile, aMessageName, aParams, aParamsLength,
|
||||
errorText);
|
||||
}
|
||||
else {
|
||||
rv = GetLocalizedString(aFile, aMessageName, errorText);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return ReportToConsoleNonLocalized(errorText, aErrorFlags, aCategory,
|
||||
aDocument, aURI, aSourceLine,
|
||||
aLineNumber, aColumnNumber);
|
||||
}
|
||||
|
||||
|
||||
/* static */ nsresult
|
||||
nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
|
||||
uint32_t aErrorFlags,
|
||||
const char *aCategory,
|
||||
nsIDocument* aDocument,
|
||||
nsIURI* aURI,
|
||||
const nsAFlatString& aSourceLine,
|
||||
uint32_t aLineNumber,
|
||||
uint32_t aColumnNumber)
|
||||
{
|
||||
uint64_t innerWindowID = 0;
|
||||
if (aDocument) {
|
||||
if (!aURI) {
|
||||
@ -3228,16 +3255,6 @@ nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsXPIDLString errorText;
|
||||
if (aParams) {
|
||||
rv = FormatLocalizedString(aFile, aMessageName, aParams, aParamsLength,
|
||||
errorText);
|
||||
}
|
||||
else {
|
||||
rv = GetLocalizedString(aFile, aMessageName, errorText);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString spec;
|
||||
if (!aLineNumber) {
|
||||
JSContext *cx = nullptr;
|
||||
@ -3258,7 +3275,7 @@ nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = errorObject->InitWithWindowID(errorText,
|
||||
rv = errorObject->InitWithWindowID(aErrorText,
|
||||
NS_ConvertUTF8toUTF16(spec), // file name
|
||||
aSourceLine,
|
||||
aLineNumber, aColumnNumber,
|
||||
|
@ -94,6 +94,15 @@ LoadContext::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::SetPrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
{
|
||||
MOZ_ASSERT(mIsNotNull);
|
||||
|
||||
// We shouldn't need this on parent...
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetIsInBrowserElement(bool* aIsInBrowserElement)
|
||||
{
|
||||
|
@ -146,7 +146,6 @@
|
||||
|
||||
// For reporting errors with the console service.
|
||||
// These can go away if error reporting is propagated up past nsDocShell.
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
|
||||
// used to dispatch urls to default protocol handlers
|
||||
@ -2014,6 +2013,20 @@ nsDocShell::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
{
|
||||
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
nsContentUtils::ReportToConsoleNonLocalized(
|
||||
NS_LITERAL_STRING("Only internal code is allowed to set the usePrivateBrowsing attribute"),
|
||||
nsIScriptError::warningFlag,
|
||||
"Internal API Used",
|
||||
mContentViewer ? mContentViewer->GetDocument() : nullptr);
|
||||
#endif
|
||||
|
||||
return SetPrivateBrowsing(aUsePrivateBrowsing);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetPrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
{
|
||||
bool changed = aUsePrivateBrowsing != mInPrivateBrowsing;
|
||||
if (changed) {
|
||||
@ -2024,12 +2037,12 @@ nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
DecreasePrivateDocShellCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t count = mChildList.Count();
|
||||
for (int32_t i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsILoadContext> shell = do_QueryInterface(ChildAt(i));
|
||||
if (shell) {
|
||||
shell->SetUsePrivateBrowsing(aUsePrivateBrowsing);
|
||||
shell->SetPrivateBrowsing(aUsePrivateBrowsing);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2769,7 +2782,7 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
|
||||
if (parentAsLoadContext &&
|
||||
NS_SUCCEEDED(parentAsLoadContext->GetUsePrivateBrowsing(&value)))
|
||||
{
|
||||
SetUsePrivateBrowsing(value);
|
||||
SetPrivateBrowsing(value);
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
// Belt and suspenders - we want to catch any instances where the flag
|
||||
// we're propagating doesn't match the global state.
|
||||
|
@ -227,6 +227,7 @@ public:
|
||||
NS_IMETHOD GetIsContent(bool*);
|
||||
NS_IMETHOD GetUsePrivateBrowsing(bool*);
|
||||
NS_IMETHOD SetUsePrivateBrowsing(bool);
|
||||
NS_IMETHOD SetPrivateBrowsing(bool);
|
||||
|
||||
// Restores a cached presentation from history (mLSHE).
|
||||
// This method swaps out the content viewer and simulates loads for
|
||||
|
@ -14,7 +14,7 @@ interface nsIDOMElement;
|
||||
* can be queried for various information about where the load is
|
||||
* happening.
|
||||
*/
|
||||
[scriptable, uuid(17f6a38a-3f4b-4c94-8252-9d9f7dbf4960)]
|
||||
[scriptable, uuid(d0029474-0cc4-42fd-bb21-d9ff22f5293c)]
|
||||
interface nsILoadContext : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -77,6 +77,11 @@ interface nsILoadContext : nsISupports
|
||||
}
|
||||
%}
|
||||
|
||||
/**
|
||||
* Set the private browsing state of the load context, meant to be used internally.
|
||||
*/
|
||||
[noscript] void SetPrivateBrowsing(in boolean aInPrivateBrowsing);
|
||||
|
||||
/**
|
||||
* Returns true iif the load is occurring inside a browser element.
|
||||
*/
|
||||
|
@ -919,7 +919,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
||||
newDocShellItem->GetRootTreeItem(getter_AddRefs(childRoot));
|
||||
nsCOMPtr<nsILoadContext> childContext = do_QueryInterface(childRoot);
|
||||
if (childContext) {
|
||||
childContext->SetUsePrivateBrowsing(isPrivateBrowsingWindow);
|
||||
childContext->SetPrivateBrowsing(isPrivateBrowsingWindow);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,12 @@ OfflineCacheUpdateParent::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateParent::SetPrivateBrowsing(bool aUsePrivateBrowsing)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
OfflineCacheUpdateParent::GetIsInBrowserElement(bool *aIsInBrowserElement)
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
||||
nsCOMPtr<nsIWebNavigation> newWebNav = do_GetInterface(newDomWin);
|
||||
nsCOMPtr<nsILoadContext> thisContext = do_GetInterface(newWebNav);
|
||||
if (thisContext) {
|
||||
thisContext->SetUsePrivateBrowsing(isPrivateBrowsingWindow);
|
||||
thisContext->SetPrivateBrowsing(isPrivateBrowsingWindow);
|
||||
}
|
||||
|
||||
window.swap(*aResult); // transfer reference
|
||||
|
Loading…
Reference in New Issue
Block a user