Bug 1250288 - Add a pref for showing favicons in web notifications. r?MattN draft
authorKit Cambridge <kcambridge@mozilla.com>
Mon, 22 Feb 2016 13:16:27 -0800
changeset 333157 aa3ded52cefb97938a21e8e1215437bb15fbdc62
parent 332881 789a12291942763bc1e3a89f97e0b82dc1c9d00b
child 514652 4f1ad4028bb0f36ee47345241ddbff80b7d2bb4e
push id11278
push userkcambridge@mozilla.com
push dateMon, 22 Feb 2016 21:16:52 +0000
reviewersMattN
bugs1250288
milestone47.0a1
Bug 1250288 - Add a pref for showing favicons in web notifications. r?MattN MozReview-Commit-ID: 9hxv7Ts8L8u
modules/libpref/init/all.js
toolkit/components/alerts/nsAlertsService.cpp
--- 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