2003-11-27 03:54:33 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2003-11-27 03:54:33 +03:00
|
|
|
|
2010-09-15 20:44:57 +04:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2013-11-12 03:56:21 +04:00
|
|
|
#include "mozilla/dom/PermissionMessageUtils.h"
|
2016-02-23 00:16:27 +03:00
|
|
|
#include "mozilla/Preferences.h"
|
2015-11-14 08:22:59 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2010-09-15 20:44:57 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
|
2003-11-27 03:54:33 +03:00
|
|
|
#include "nsAlertsService.h"
|
2010-06-15 06:17:37 +04:00
|
|
|
|
2003-11-27 03:54:33 +03:00
|
|
|
#include "nsXPCOM.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2011-07-15 14:31:34 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2011-08-09 14:11:48 +04:00
|
|
|
#include "nsPromiseFlatString.h"
|
2009-01-08 11:12:16 +03:00
|
|
|
#include "nsToolkitCompsCID.h"
|
2003-11-27 03:54:33 +03:00
|
|
|
|
2016-01-07 23:15:55 +03:00
|
|
|
#ifdef MOZ_PLACES
|
|
|
|
#include "mozIAsyncFavicons.h"
|
|
|
|
#include "nsIFaviconService.h"
|
|
|
|
#endif // MOZ_PLACES
|
|
|
|
|
2017-03-17 05:04:33 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
#include <shellapi.h>
|
|
|
|
#endif
|
|
|
|
|
2011-09-09 06:27:13 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2011-07-15 14:31:34 +04:00
|
|
|
using mozilla::dom::ContentChild;
|
|
|
|
|
2016-01-07 23:15:55 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#ifdef MOZ_PLACES
|
|
|
|
|
|
|
|
class IconCallback final : public nsIFaviconDataCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
IconCallback(nsIAlertsService* aBackend,
|
|
|
|
nsIAlertNotification* aAlert,
|
|
|
|
nsIObserver* aAlertListener)
|
|
|
|
: mBackend(aBackend)
|
|
|
|
, mAlert(aAlert)
|
|
|
|
, mAlertListener(aAlertListener)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
OnComplete(nsIURI *aIconURI, uint32_t aIconSize, const uint8_t *aIconData,
|
Bug 977177 - Update favicons API consumers. r=adw
Updates consumers to the new behavior.
Some consumers are changed to use the "page-icon:" protocol, since it's not
trivial to join the icons table and get a single result out of it. In most cases
the join would return multiple results since a page can have multiple icon payloads.
These consumers for now will return the biggest payload, bug 1347532 will fix
some of them to properly pass a #size=NN fragment.
Note that, even before, these were just "moz-anno:favicon:" uris, and the
payload had to be fetched from the database.
Some other consumers for now just fallback to the largest payload, by passing 0
to GetFaviconURLForPage.
The favicon optimization still happens on the main-thread, bug 1346139 will
handle that problem.
Most of the changes involve handling the modified IconData objects, that now
retain an array of payloads, rather than just one. But note that .ico files are
not yet split into single frames, due to imagelib missing APIs that will be handled
in bug 1337402.
The other changes involve fixing queries to properly join with the new tables.
Finally, note that thanks to the FOREIGN KEYS support, removing from moz_icons or
moz_pages_w_icons will also remove relations from moz_icons_to_pages.
The system only supports square icons, so icons are resized based on their larger side.
This doesn't include new tests, those will be in a following changeset.
MozReview-Commit-ID: JUkpquhpS8y
--HG--
rename : toolkit/components/places/tests/unit/test_svg_favicon.js => toolkit/components/places/tests/favicons/test_svg_favicon.js
extra : rebase_source : fa49c4a81d6ab6b34a2f19ee4175e889a6e9d734
2016-09-28 17:14:30 +03:00
|
|
|
const nsACString &aMimeType, uint16_t aWidth) override
|
2016-01-07 23:15:55 +03:00
|
|
|
{
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
if (aIconSize > 0) {
|
|
|
|
nsCOMPtr<nsIAlertsIconData> alertsIconData(do_QueryInterface(mBackend));
|
|
|
|
if (alertsIconData) {
|
|
|
|
rv = alertsIconData->ShowAlertWithIconData(mAlert, mAlertListener,
|
|
|
|
aIconSize, aIconData);
|
|
|
|
}
|
|
|
|
} else if (aIconURI) {
|
|
|
|
nsCOMPtr<nsIAlertsIconURI> alertsIconURI(do_QueryInterface(mBackend));
|
|
|
|
if (alertsIconURI) {
|
|
|
|
rv = alertsIconURI->ShowAlertWithIconURI(mAlert, mAlertListener,
|
|
|
|
aIconURI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
rv = mBackend->ShowAlert(mAlert, mAlertListener);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~IconCallback() {}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAlertsService> mBackend;
|
|
|
|
nsCOMPtr<nsIAlertNotification> mAlert;
|
|
|
|
nsCOMPtr<nsIObserver> mAlertListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(IconCallback, nsIFaviconDataCallback)
|
|
|
|
|
|
|
|
#endif // MOZ_PLACES
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ShowWithIconBackend(nsIAlertsService* aBackend, nsIAlertNotification* aAlert,
|
|
|
|
nsIObserver* aAlertListener)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_PLACES
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
nsresult rv = aAlert->GetURI(getter_AddRefs(uri));
|
|
|
|
if (NS_FAILED(rv) || !uri) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure the backend supports favicons.
|
|
|
|
nsCOMPtr<nsIAlertsIconData> alertsIconData(do_QueryInterface(aBackend));
|
|
|
|
nsCOMPtr<nsIAlertsIconURI> alertsIconURI;
|
|
|
|
if (!alertsIconData) {
|
|
|
|
alertsIconURI = do_QueryInterface(aBackend);
|
|
|
|
}
|
|
|
|
if (!alertsIconData && !alertsIconURI) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozIAsyncFavicons> favicons(do_GetService(
|
|
|
|
"@mozilla.org/browser/favicon-service;1"));
|
|
|
|
NS_ENSURE_TRUE(favicons, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFaviconDataCallback> callback =
|
|
|
|
new IconCallback(aBackend, aAlert, aAlertListener);
|
|
|
|
if (alertsIconData) {
|
Bug 977177 - Update favicons API consumers. r=adw
Updates consumers to the new behavior.
Some consumers are changed to use the "page-icon:" protocol, since it's not
trivial to join the icons table and get a single result out of it. In most cases
the join would return multiple results since a page can have multiple icon payloads.
These consumers for now will return the biggest payload, bug 1347532 will fix
some of them to properly pass a #size=NN fragment.
Note that, even before, these were just "moz-anno:favicon:" uris, and the
payload had to be fetched from the database.
Some other consumers for now just fallback to the largest payload, by passing 0
to GetFaviconURLForPage.
The favicon optimization still happens on the main-thread, bug 1346139 will
handle that problem.
Most of the changes involve handling the modified IconData objects, that now
retain an array of payloads, rather than just one. But note that .ico files are
not yet split into single frames, due to imagelib missing APIs that will be handled
in bug 1337402.
The other changes involve fixing queries to properly join with the new tables.
Finally, note that thanks to the FOREIGN KEYS support, removing from moz_icons or
moz_pages_w_icons will also remove relations from moz_icons_to_pages.
The system only supports square icons, so icons are resized based on their larger side.
This doesn't include new tests, those will be in a following changeset.
MozReview-Commit-ID: JUkpquhpS8y
--HG--
rename : toolkit/components/places/tests/unit/test_svg_favicon.js => toolkit/components/places/tests/favicons/test_svg_favicon.js
extra : rebase_source : fa49c4a81d6ab6b34a2f19ee4175e889a6e9d734
2016-09-28 17:14:30 +03:00
|
|
|
return favicons->GetFaviconDataForPage(uri, callback, 0);
|
2016-01-07 23:15:55 +03:00
|
|
|
}
|
Bug 977177 - Update favicons API consumers. r=adw
Updates consumers to the new behavior.
Some consumers are changed to use the "page-icon:" protocol, since it's not
trivial to join the icons table and get a single result out of it. In most cases
the join would return multiple results since a page can have multiple icon payloads.
These consumers for now will return the biggest payload, bug 1347532 will fix
some of them to properly pass a #size=NN fragment.
Note that, even before, these were just "moz-anno:favicon:" uris, and the
payload had to be fetched from the database.
Some other consumers for now just fallback to the largest payload, by passing 0
to GetFaviconURLForPage.
The favicon optimization still happens on the main-thread, bug 1346139 will
handle that problem.
Most of the changes involve handling the modified IconData objects, that now
retain an array of payloads, rather than just one. But note that .ico files are
not yet split into single frames, due to imagelib missing APIs that will be handled
in bug 1337402.
The other changes involve fixing queries to properly join with the new tables.
Finally, note that thanks to the FOREIGN KEYS support, removing from moz_icons or
moz_pages_w_icons will also remove relations from moz_icons_to_pages.
The system only supports square icons, so icons are resized based on their larger side.
This doesn't include new tests, those will be in a following changeset.
MozReview-Commit-ID: JUkpquhpS8y
--HG--
rename : toolkit/components/places/tests/unit/test_svg_favicon.js => toolkit/components/places/tests/favicons/test_svg_favicon.js
extra : rebase_source : fa49c4a81d6ab6b34a2f19ee4175e889a6e9d734
2016-09-28 17:14:30 +03:00
|
|
|
return favicons->GetFaviconURLForPage(uri, callback, 0);
|
2016-01-07 23:15:55 +03:00
|
|
|
#else
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#endif // !MOZ_PLACES
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
ShowWithBackend(nsIAlertsService* aBackend, nsIAlertNotification* aAlert,
|
2016-08-04 16:17:54 +03:00
|
|
|
nsIObserver* aAlertListener, const nsAString& aPersistentData)
|
2016-01-07 23:15:55 +03:00
|
|
|
{
|
2016-08-04 16:17:54 +03:00
|
|
|
if (!aPersistentData.IsEmpty()) {
|
|
|
|
return aBackend->ShowPersistentNotification(
|
|
|
|
aPersistentData, aAlert, aAlertListener);
|
|
|
|
}
|
|
|
|
|
2016-02-23 00:16:27 +03:00
|
|
|
if (Preferences::GetBool("alerts.showFavicons")) {
|
|
|
|
nsresult rv = ShowWithIconBackend(aBackend, aAlert, aAlertListener);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2016-01-07 23:15:55 +03:00
|
|
|
}
|
2016-08-04 16:17:54 +03:00
|
|
|
|
2016-02-23 00:16:27 +03:00
|
|
|
// If favicons are disabled, or the backend doesn't support them, show the
|
|
|
|
// alert without one.
|
2016-01-07 23:15:55 +03:00
|
|
|
return aBackend->ShowAlert(aAlert, aAlertListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2016-08-04 16:17:54 +03:00
|
|
|
NS_IMPL_ISUPPORTS(nsAlertsService, nsIAlertsService, nsIAlertsDoNotDisturb)
|
2003-11-27 03:54:33 +03:00
|
|
|
|
2015-12-31 23:27:09 +03:00
|
|
|
nsAlertsService::nsAlertsService() :
|
2016-01-05 22:20:38 +03:00
|
|
|
mBackend(nullptr)
|
2003-11-27 03:54:33 +03:00
|
|
|
{
|
2016-01-05 22:20:38 +03:00
|
|
|
mBackend = do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID);
|
2003-11-27 03:54:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAlertsService::~nsAlertsService()
|
|
|
|
{}
|
|
|
|
|
2012-03-08 01:09:04 +04:00
|
|
|
bool nsAlertsService::ShouldShowAlert()
|
|
|
|
{
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2017-03-17 05:04:33 +03:00
|
|
|
QUERY_USER_NOTIFICATION_STATE qstate;
|
|
|
|
if (SUCCEEDED(SHQueryUserNotificationState(&qstate))) {
|
|
|
|
if (qstate != QUNS_ACCEPTS_NOTIFICATIONS) {
|
|
|
|
result = false;
|
2012-03-08 01:09:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-01-07 23:15:55 +03:00
|
|
|
NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl, const nsAString & aAlertTitle,
|
2011-09-29 10:19:26 +04:00
|
|
|
const nsAString & aAlertText, bool aAlertTextClickable,
|
2005-03-15 22:41:41 +03:00
|
|
|
const nsAString & aAlertCookie,
|
2007-09-22 06:08:28 +04:00
|
|
|
nsIObserver * aAlertListener,
|
2013-03-18 17:24:53 +04:00
|
|
|
const nsAString & aAlertName,
|
|
|
|
const nsAString & aBidi,
|
2013-11-12 03:56:21 +04:00
|
|
|
const nsAString & aLang,
|
2014-08-21 04:56:12 +04:00
|
|
|
const nsAString & aData,
|
2014-11-28 22:08:29 +03:00
|
|
|
nsIPrincipal * aPrincipal,
|
2016-10-13 03:27:40 +03:00
|
|
|
bool aInPrivateBrowsing,
|
|
|
|
bool aRequireInteraction)
|
2003-11-27 03:54:33 +03:00
|
|
|
{
|
2015-12-31 22:04:24 +03:00
|
|
|
nsCOMPtr<nsIAlertNotification> alert =
|
|
|
|
do_CreateInstance(ALERT_NOTIFICATION_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(alert, NS_ERROR_FAILURE);
|
|
|
|
nsresult rv = alert->Init(aAlertName, aImageUrl, aAlertTitle,
|
|
|
|
aAlertText, aAlertTextClickable,
|
|
|
|
aAlertCookie, aBidi, aLang, aData,
|
2016-10-13 03:27:40 +03:00
|
|
|
aPrincipal, aInPrivateBrowsing,
|
|
|
|
aRequireInteraction);
|
2015-12-31 22:04:24 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
return ShowAlert(alert, aAlertListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsAlertsService::ShowAlert(nsIAlertNotification * aAlert,
|
|
|
|
nsIObserver * aAlertListener)
|
2016-05-12 18:58:18 +03:00
|
|
|
{
|
|
|
|
return ShowPersistentNotification(EmptyString(), aAlert, aAlertListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsAlertsService::ShowPersistentNotification(const nsAString & aPersistentData,
|
|
|
|
nsIAlertNotification * aAlert,
|
|
|
|
nsIObserver * aAlertListener)
|
2015-12-31 22:04:24 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aAlert);
|
|
|
|
|
|
|
|
nsAutoString cookie;
|
|
|
|
nsresult rv = aAlert->GetCookie(cookie);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2010-09-15 20:44:57 +04:00
|
|
|
ContentChild* cpc = ContentChild::GetSingleton();
|
|
|
|
|
|
|
|
if (aAlertListener)
|
2015-12-31 22:04:24 +03:00
|
|
|
cpc->AddRemoteAlertObserver(cookie, aAlertListener);
|
|
|
|
|
|
|
|
cpc->SendShowAlert(aAlert);
|
2010-09-15 20:44:57 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-08 11:12:16 +03:00
|
|
|
// Check if there is an optional service that handles system-level notifications
|
2016-01-05 22:20:38 +03:00
|
|
|
if (mBackend) {
|
2016-08-04 16:17:54 +03:00
|
|
|
rv = ShowWithBackend(mBackend, aAlert, aAlertListener, aPersistentData);
|
2016-01-05 22:20:38 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
// If the system backend failed to show the alert, clear the backend and
|
|
|
|
// retry with XUL notifications. Future alerts will always use XUL.
|
|
|
|
mBackend = nullptr;
|
2009-05-04 12:11:11 +04:00
|
|
|
}
|
2009-01-08 11:12:16 +03:00
|
|
|
|
2012-03-08 01:09:04 +04:00
|
|
|
if (!ShouldShowAlert()) {
|
|
|
|
// Do not display the alert. Instead call alertfinished and get out.
|
|
|
|
if (aAlertListener)
|
2015-12-31 22:04:24 +03:00
|
|
|
aAlertListener->Observe(nullptr, "alertfinished", cookie.get());
|
2012-03-08 01:09:04 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-03-18 17:24:54 +04:00
|
|
|
// Use XUL notifications as a fallback if above methods have failed.
|
2016-01-05 22:20:38 +03:00
|
|
|
nsCOMPtr<nsIAlertsService> xulBackend(nsXULAlerts::GetInstance());
|
|
|
|
NS_ENSURE_TRUE(xulBackend, NS_ERROR_FAILURE);
|
2016-08-04 16:17:54 +03:00
|
|
|
return ShowWithBackend(xulBackend, aAlert, aAlertListener, aPersistentData);
|
2003-11-27 03:54:33 +03:00
|
|
|
}
|
2010-10-02 01:21:21 +04:00
|
|
|
|
2013-11-12 03:56:21 +04:00
|
|
|
NS_IMETHODIMP nsAlertsService::CloseAlert(const nsAString& aAlertName,
|
|
|
|
nsIPrincipal* aPrincipal)
|
2013-03-18 17:24:53 +04:00
|
|
|
{
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2013-03-18 17:24:53 +04:00
|
|
|
ContentChild* cpc = ContentChild::GetSingleton();
|
2013-11-12 03:56:21 +04:00
|
|
|
cpc->SendCloseAlert(nsAutoString(aAlertName), IPC::Principal(aPrincipal));
|
2013-03-18 17:24:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-01-05 22:20:38 +03:00
|
|
|
nsresult rv;
|
2013-03-18 17:24:53 +04:00
|
|
|
// Try the system notification service.
|
2016-01-05 22:20:38 +03:00
|
|
|
if (mBackend) {
|
|
|
|
rv = mBackend->CloseAlert(aAlertName, aPrincipal);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
// If the system backend failed to close the alert, fall back to XUL for
|
|
|
|
// future alerts.
|
|
|
|
mBackend = nullptr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIAlertsService> xulBackend(nsXULAlerts::GetInstance());
|
|
|
|
NS_ENSURE_TRUE(xulBackend, NS_ERROR_FAILURE);
|
|
|
|
rv = xulBackend->CloseAlert(aAlertName, aPrincipal);
|
2013-03-18 17:24:53 +04:00
|
|
|
}
|
2016-01-05 22:20:38 +03:00
|
|
|
return rv;
|
2013-03-18 17:24:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-19 06:04:56 +03:00
|
|
|
// nsIAlertsDoNotDisturb
|
|
|
|
NS_IMETHODIMP nsAlertsService::GetManualDoNotDisturb(bool* aRetVal)
|
|
|
|
{
|
2015-10-19 06:39:35 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
2016-01-05 22:20:38 +03:00
|
|
|
nsCOMPtr<nsIAlertsDoNotDisturb> alertsDND(GetDNDBackend());
|
|
|
|
NS_ENSURE_TRUE(alertsDND, NS_ERROR_NOT_IMPLEMENTED);
|
|
|
|
return alertsDND->GetManualDoNotDisturb(aRetVal);
|
2015-10-19 06:39:35 +03:00
|
|
|
#endif
|
2015-10-19 06:04:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsAlertsService::SetManualDoNotDisturb(bool aDoNotDisturb)
|
|
|
|
{
|
2015-10-19 06:39:35 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
#else
|
2016-01-05 22:20:38 +03:00
|
|
|
nsCOMPtr<nsIAlertsDoNotDisturb> alertsDND(GetDNDBackend());
|
|
|
|
NS_ENSURE_TRUE(alertsDND, NS_ERROR_NOT_IMPLEMENTED);
|
2015-10-19 06:04:56 +03:00
|
|
|
|
2016-01-05 22:20:38 +03:00
|
|
|
nsresult rv = alertsDND->SetManualDoNotDisturb(aDoNotDisturb);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
Telemetry::Accumulate(Telemetry::ALERTS_SERVICE_DND_ENABLED, 1);
|
|
|
|
}
|
2015-11-14 08:22:59 +03:00
|
|
|
return rv;
|
2015-10-19 06:39:35 +03:00
|
|
|
#endif
|
2015-10-19 06:04:56 +03:00
|
|
|
}
|
|
|
|
|
2016-01-05 22:20:38 +03:00
|
|
|
already_AddRefed<nsIAlertsDoNotDisturb>
|
|
|
|
nsAlertsService::GetDNDBackend()
|
|
|
|
{
|
|
|
|
// Try the system notification service.
|
|
|
|
nsCOMPtr<nsIAlertsService> backend = mBackend;
|
|
|
|
if (!backend) {
|
|
|
|
backend = nsXULAlerts::GetInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAlertsDoNotDisturb> alertsDND(do_QueryInterface(backend));
|
|
|
|
return alertsDND.forget();
|
|
|
|
}
|