Bug 1250288 - Add a pref for showing favicons in web notifications. r?MattN
MozReview-Commit-ID: 9hxv7Ts8L8u
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4510,16 +4510,18 @@ pref("notification.feature.enabled", fal
// Web Notification
pref("dom.webnotifications.enabled", true);
#if !defined(RELEASE_BUILD)
pref("dom.webnotifications.serviceworker.enabled", true);
#endif
// Alert animation effect, name is disableSlidingEffect for backwards-compat.
pref("alerts.disableSlidingEffect", false);
+// Show favicons in web notifications.
+pref("alerts.showFavicons", false);
// DOM full-screen API.
pref("full-screen-api.enabled", false);
pref("full-screen-api.allow-trusted-requests-only", true);
pref("full-screen-api.pointer-lock.enabled", true);
// transition duration of fade-to-black and fade-from-black, unit: ms
pref("full-screen-api.transition-duration.enter", "200 200");
pref("full-screen-api.transition-duration.leave", "200 200");
--- a/toolkit/components/alerts/nsAlertsService.cpp
+++ b/toolkit/components/alerts/nsAlertsService.cpp
@@ -1,15 +1,16 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/PermissionMessageUtils.h"
+#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "nsXULAppAPI.h"
#include "nsAlertsService.h"
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#else
@@ -121,17 +122,20 @@ ShowWithIconBackend(nsIAlertsService* aB
return NS_ERROR_NOT_IMPLEMENTED;
#endif // !MOZ_PLACES
}
nsresult
ShowWithBackend(nsIAlertsService* aBackend, nsIAlertNotification* aAlert,
nsIObserver* aAlertListener)
{
- nsresult rv = ShowWithIconBackend(aBackend, aAlert, aAlertListener);
+ nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
+ if (Preferences::GetBool("alerts.showFavicons")) {
+ rv = ShowWithIconBackend(aBackend, aAlert, aAlertListener);
+ }
if (NS_SUCCEEDED(rv)) {
return rv;
}
// If the backend doesn't support favicons, show the alert without one.
return aBackend->ShowAlert(aAlert, aAlertListener);
}
#endif // MOZ_WIDGET_ANDROID