mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1106116 - Load images for notifications triggered from private browsing windows as private; r=jdm
This commit is contained in:
parent
586c42c3a9
commit
278bbb319d
@ -270,7 +270,7 @@ let AlertsHelper = {
|
||||
this.registerListener(data.name, data.cookie, data.alertListener);
|
||||
this.showNotification(data.imageURL, data.title, data.text,
|
||||
data.textClickable, data.cookie, data.name, data.bidi,
|
||||
data.lang, dataObj, null);
|
||||
data.lang, dataObj, null, data.inPrivateBrowsing);
|
||||
},
|
||||
|
||||
showAppNotification: function(aMessage) {
|
||||
|
@ -68,7 +68,8 @@ AlertsService.prototype = {
|
||||
// nsIAlertsService
|
||||
showAlertNotification: function(aImageUrl, aTitle, aText, aTextClickable,
|
||||
aCookie, aAlertListener, aName, aBidi,
|
||||
aLang, aDataStr) {
|
||||
aLang, aDataStr, aPrincipal,
|
||||
aInPrivateBrowsing) {
|
||||
cpmm.sendAsyncMessage(kMessageAlertNotificationSend, {
|
||||
imageURL: aImageUrl,
|
||||
title: aTitle,
|
||||
@ -79,7 +80,8 @@ AlertsService.prototype = {
|
||||
id: aName,
|
||||
dir: aBidi,
|
||||
lang: aLang,
|
||||
dataStr: aDataStr
|
||||
dataStr: aDataStr,
|
||||
inPrivateBrowsing: aInPrivateBrowsing
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -14,6 +14,7 @@ Cu.import("resource://gre/modules/Webapps.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NativeApp",
|
||||
"resource://gre/modules/NativeApp.jsm");
|
||||
@ -150,7 +151,8 @@ this.WebappManager = {
|
||||
|
||||
this.installations[manifestURL] = Promise.defer();
|
||||
this.installations[manifestURL].promise.then(() => {
|
||||
notifyInstallSuccess(aData.app, nativeApp, bundle);
|
||||
notifyInstallSuccess(aData.app, nativeApp, bundle,
|
||||
PrivateBrowsingUtils.isWindowPrivate(aWindow));
|
||||
}, (error) => {
|
||||
Cu.reportError("Error installing webapp: " + error);
|
||||
}).then(() => {
|
||||
@ -248,7 +250,7 @@ this.WebappManager = {
|
||||
}
|
||||
}
|
||||
|
||||
function notifyInstallSuccess(aApp, aNativeApp, aBundle) {
|
||||
function notifyInstallSuccess(aApp, aNativeApp, aBundle, aInPrivateBrowsing) {
|
||||
let launcher = {
|
||||
observe: function(aSubject, aTopic) {
|
||||
if (aTopic == "alertclickcallback") {
|
||||
@ -264,6 +266,7 @@ function notifyInstallSuccess(aApp, aNativeApp, aBundle) {
|
||||
notifier.showAlertNotification(aNativeApp.iconURI.spec,
|
||||
aBundle.getString("webapps.install.success"),
|
||||
aNativeApp.appNameAsFilename,
|
||||
true, null, launcher);
|
||||
true, null, launcher, "", "", "", "", null,
|
||||
aInPrivateBrowsing);
|
||||
} catch (ex) {}
|
||||
}
|
||||
|
@ -3657,7 +3657,8 @@ ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsStri
|
||||
const nsString& aCookie, const nsString& aName,
|
||||
const nsString& aBidi, const nsString& aLang,
|
||||
const nsString& aData,
|
||||
const IPC::Principal& aPrincipal)
|
||||
const IPC::Principal& aPrincipal,
|
||||
const bool& aInPrivateBrowsing)
|
||||
{
|
||||
#ifdef MOZ_CHILD_PERMISSIONS
|
||||
uint32_t permission = mozilla::CheckPermission(this, aPrincipal,
|
||||
@ -3671,7 +3672,7 @@ ContentParent::RecvShowAlertNotification(const nsString& aImageUrl, const nsStri
|
||||
if (sysAlerts) {
|
||||
sysAlerts->ShowAlertNotification(aImageUrl, aTitle, aText, aTextClickable,
|
||||
aCookie, this, aName, aBidi, aLang,
|
||||
aData, aPrincipal);
|
||||
aData, aPrincipal, aInPrivateBrowsing);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -602,7 +602,8 @@ private:
|
||||
const nsString& aCookie, const nsString& aName,
|
||||
const nsString& aBidi, const nsString& aLang,
|
||||
const nsString& aData,
|
||||
const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
|
||||
const IPC::Principal& aPrincipal,
|
||||
const bool& aInPrivateBrowsing) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool RecvCloseAlert(const nsString& aName,
|
||||
const IPC::Principal& aPrincipal) MOZ_OVERRIDE;
|
||||
|
@ -653,7 +653,8 @@ parent:
|
||||
nsString bidi,
|
||||
nsString lang,
|
||||
nsString data,
|
||||
Principal principal);
|
||||
Principal principal,
|
||||
bool inPrivateBrowsing);
|
||||
|
||||
CloseAlert(nsString name, Principal principal);
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "PermissionMessageUtils.h"
|
||||
#include "nsILoadContext.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -103,7 +104,10 @@ DesktopNotification::PostDesktopNotification()
|
||||
// to nsIObservers, thus cookies must be unique to differentiate observers.
|
||||
nsString uniqueName = NS_LITERAL_STRING("desktop-notification:");
|
||||
uniqueName.AppendInt(sCount++);
|
||||
nsIPrincipal* principal = GetOwner()->GetDoc()->NodePrincipal();
|
||||
nsCOMPtr<nsIDocument> doc = GetOwner()->GetDoc();
|
||||
nsIPrincipal* principal = doc->NodePrincipal();
|
||||
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
|
||||
bool inPrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
return alerts->ShowAlertNotification(mIconURL, mTitle, mDescription,
|
||||
true,
|
||||
uniqueName,
|
||||
@ -112,7 +116,8 @@ DesktopNotification::PostDesktopNotification()
|
||||
NS_LITERAL_STRING("auto"),
|
||||
EmptyString(),
|
||||
EmptyString(),
|
||||
principal);
|
||||
principal,
|
||||
inPrivateBrowsing);
|
||||
}
|
||||
|
||||
DesktopNotification::DesktopNotification(const nsAString & title,
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsILoadContext.h"
|
||||
#ifdef MOZ_B2G
|
||||
#include "nsIDOMDesktopNotification.h"
|
||||
#endif
|
||||
@ -677,10 +678,16 @@ Notification::ShowInternal()
|
||||
// nsIObserver. Thus the cookie must be unique to differentiate observers.
|
||||
nsString uniqueCookie = NS_LITERAL_STRING("notification:");
|
||||
uniqueCookie.AppendInt(sCount++);
|
||||
bool inPrivateBrowsing = false;
|
||||
if (doc) {
|
||||
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
|
||||
inPrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
alertService->ShowAlertNotification(absoluteUrl, mTitle, mBody, true,
|
||||
uniqueCookie, observer, mAlertName,
|
||||
DirectionToString(mDir), mLang,
|
||||
dataStr, GetPrincipal());
|
||||
dataStr, GetPrincipal(),
|
||||
inPrivateBrowsing);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -70,7 +70,8 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl
|
||||
const nsAString & aBidi,
|
||||
const nsAString & aLang,
|
||||
const nsAString & aData,
|
||||
nsIPrincipal * aPrincipal)
|
||||
nsIPrincipal * aPrincipal,
|
||||
bool aInPrivateBrowsing)
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
ContentChild* cpc = ContentChild::GetSingleton();
|
||||
@ -87,7 +88,8 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl
|
||||
PromiseFlatString(aBidi),
|
||||
PromiseFlatString(aLang),
|
||||
PromiseFlatString(aData),
|
||||
IPC::Principal(aPrincipal));
|
||||
IPC::Principal(aPrincipal),
|
||||
aInPrivateBrowsing);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -103,7 +105,8 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl
|
||||
rv = sysAlerts->ShowAlertNotification(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
|
||||
aAlertCookie, aAlertListener, aAlertName,
|
||||
aBidi, aLang, aData,
|
||||
IPC::Principal(aPrincipal));
|
||||
IPC::Principal(aPrincipal),
|
||||
aInPrivateBrowsing);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return NS_OK;
|
||||
}
|
||||
@ -118,7 +121,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl
|
||||
// Use XUL notifications as a fallback if above methods have failed.
|
||||
rv = mXULAlerts.ShowAlertNotification(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
|
||||
aAlertCookie, aAlertListener, aAlertName,
|
||||
aBidi, aLang);
|
||||
aBidi, aLang, aInPrivateBrowsing);
|
||||
return rv;
|
||||
#endif // !MOZ_WIDGET_ANDROID
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
interface nsIPrincipal;
|
||||
|
||||
[scriptable, uuid(d446bede-fcf7-403d-b6b6-5fd67b19ba58)]
|
||||
[scriptable, uuid(9d0284bf-db40-42da-8f0d-c2769dbde7aa)]
|
||||
interface nsIAlertsService : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -37,6 +37,8 @@ interface nsIAlertsService : nsISupports
|
||||
* platforms.
|
||||
* @param lang Language of title and text of the alert. Only available
|
||||
* on supported platforms.
|
||||
* @param inPrivateBrowsing If set to true, imageUrl will be loaded in private
|
||||
* browsing mode.
|
||||
* @throws NS_ERROR_NOT_AVAILABLE If the notification cannot be displayed.
|
||||
*
|
||||
* The following arguments will be passed to the alertListener's observe()
|
||||
@ -62,7 +64,8 @@ interface nsIAlertsService : nsISupports
|
||||
[optional] in AString dir,
|
||||
[optional] in AString lang,
|
||||
[optional] in AString data,
|
||||
[optional] in nsIPrincipal principal);
|
||||
[optional] in nsIPrincipal principal,
|
||||
[optional] in boolean inPrivateBrowsing);
|
||||
|
||||
/**
|
||||
* Close alerts created by the service.
|
||||
|
@ -44,7 +44,7 @@ nsXULAlerts::ShowAlertNotification(const nsAString& aImageUrl, const nsAString&
|
||||
const nsAString& aAlertText, bool aAlertTextClickable,
|
||||
const nsAString& aAlertCookie, nsIObserver* aAlertListener,
|
||||
const nsAString& aAlertName, const nsAString& aBidi,
|
||||
const nsAString& aLang)
|
||||
const nsAString& aLang, bool aInPrivateBrowsing)
|
||||
{
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
|
||||
@ -135,9 +135,12 @@ nsXULAlerts::ShowAlertNotification(const nsAString& aImageUrl, const nsAString&
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
|
||||
"chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
|
||||
getter_AddRefs(newWindow));
|
||||
nsAutoCString features("chrome,dialog=yes,titlebar=no,popup=yes");
|
||||
if (aInPrivateBrowsing) {
|
||||
features.AppendLiteral(",private");
|
||||
}
|
||||
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank", features.get(),
|
||||
argsArray, getter_AddRefs(newWindow));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mNamedWindows.Put(aAlertName, newWindow);
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
const nsAString& aAlertText, bool aAlertTextClickable,
|
||||
const nsAString& aAlertCookie, nsIObserver* aAlertListener,
|
||||
const nsAString& aAlertName, const nsAString& aBidi,
|
||||
const nsAString& aLang);
|
||||
const nsAString& aLang, bool aInPrivateBrowsing);
|
||||
|
||||
nsresult CloseAlert(const nsAString& aAlertName);
|
||||
protected:
|
||||
|
@ -2756,7 +2756,7 @@ nsDownload::SetState(DownloadState aState)
|
||||
message, !removeWhenDone,
|
||||
mPrivate ? NS_LITERAL_STRING("private") : NS_LITERAL_STRING("non-private"),
|
||||
mDownloadManager, EmptyString(), NS_LITERAL_STRING("auto"),
|
||||
EmptyString(), EmptyString(), nullptr);
|
||||
EmptyString(), EmptyString(), nullptr, mPrivate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ nsAlertsIconListener::ShowAlert(GdkPixbuf* aPixbuf)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAlertsIconListener::StartRequest(const nsAString & aImageUrl)
|
||||
nsAlertsIconListener::StartRequest(const nsAString & aImageUrl, bool aInPrivateBrowsing)
|
||||
{
|
||||
if (mIconRequest) {
|
||||
// Another icon request is already in flight. Kill it.
|
||||
@ -219,8 +219,11 @@ nsAlertsIconListener::StartRequest(const nsAString & aImageUrl)
|
||||
|
||||
nsresult rv = il->LoadImageXPCOM(imageUri, nullptr, nullptr,
|
||||
NS_LITERAL_STRING("default"), nullptr, nullptr,
|
||||
this, nullptr, nsIRequest::LOAD_NORMAL, nullptr,
|
||||
0 /* use default */, getter_AddRefs(mIconRequest));
|
||||
this, nullptr,
|
||||
aInPrivateBrowsing ? nsIRequest::LOAD_ANONYMOUS :
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
nullptr, 0 /* use default */,
|
||||
getter_AddRefs(mIconRequest));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -267,7 +270,8 @@ nsAlertsIconListener::InitAlertAsync(const nsAString & aImageUrl,
|
||||
const nsAString & aAlertText,
|
||||
bool aAlertTextClickable,
|
||||
const nsAString & aAlertCookie,
|
||||
nsIObserver * aAlertListener)
|
||||
nsIObserver * aAlertListener,
|
||||
bool aInPrivateBrowsing)
|
||||
{
|
||||
if (!libNotifyHandle)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -341,5 +345,5 @@ nsAlertsIconListener::InitAlertAsync(const nsAString & aImageUrl,
|
||||
mAlertListener = aAlertListener;
|
||||
mAlertCookie = aAlertCookie;
|
||||
|
||||
return StartRequest(aImageUrl);
|
||||
return StartRequest(aImageUrl, aInPrivateBrowsing);
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ public:
|
||||
const nsAString & aAlertText,
|
||||
bool aAlertTextClickable,
|
||||
const nsAString & aAlertCookie,
|
||||
nsIObserver * aAlertListener);
|
||||
nsIObserver * aAlertListener,
|
||||
bool aInPrivateBrowsing);
|
||||
|
||||
void SendCallback();
|
||||
void SendClosed();
|
||||
@ -82,7 +83,7 @@ protected:
|
||||
NotifyNotification* mNotification;
|
||||
gulong mClosureHandler;
|
||||
|
||||
nsresult StartRequest(const nsAString & aImageUrl);
|
||||
nsresult StartRequest(const nsAString & aImageUrl, bool aInPrivateBrowsing);
|
||||
nsresult ShowAlert(GdkPixbuf* aPixbuf);
|
||||
};
|
||||
|
||||
|
@ -37,14 +37,15 @@ NS_IMETHODIMP nsSystemAlertsService::ShowAlertNotification(const nsAString & aIm
|
||||
const nsAString & aBidi,
|
||||
const nsAString & aLang,
|
||||
const nsAString & aData,
|
||||
nsIPrincipal * aPrincipal)
|
||||
nsIPrincipal * aPrincipal,
|
||||
bool aInPrivateBrowsing)
|
||||
{
|
||||
nsRefPtr<nsAlertsIconListener> alertListener = new nsAlertsIconListener();
|
||||
if (!alertListener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return alertListener->InitAlertAsync(aImageUrl, aAlertTitle, aAlertText, aAlertTextClickable,
|
||||
aAlertCookie, aAlertListener);
|
||||
aAlertCookie, aAlertListener, aInPrivateBrowsing);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSystemAlertsService::CloseAlert(const nsAString& aAlertName,
|
||||
|
@ -204,7 +204,8 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
const nsAString & aBidi,
|
||||
const nsAString & aLang,
|
||||
const nsAString & aData,
|
||||
nsIPrincipal * aPrincipal)
|
||||
nsIPrincipal * aPrincipal,
|
||||
bool aInPrivateBrowsing)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
@ -246,8 +247,11 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
nsresult rv = il->LoadImage(imageUri, nullptr, nullptr,
|
||||
mozilla::net::RP_Default,
|
||||
aPrincipal, nullptr,
|
||||
this, nullptr, nsIRequest::LOAD_NORMAL, nullptr,
|
||||
nsIContentPolicy::TYPE_IMAGE, EmptyString(),
|
||||
this, nullptr,
|
||||
aInPrivateBrowsing ? nsIRequest::LOAD_ANONYMOUS :
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
nullptr, nsIContentPolicy::TYPE_IMAGE,
|
||||
EmptyString(),
|
||||
getter_AddRefs(osxni->mIconRequest));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Set a timer for six seconds. If we don't have an icon by the time this
|
||||
|
Loading…
Reference in New Issue
Block a user