mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 862395 - Part 3: Add preference for web notification requireInteraction flag. r=baku
--HG-- extra : rebase_source : 751db25819dbd441d549721757d9bcb0bc67ec8e extra : histedit_source : 10337b25798cc73cce0b2779fab4e01076cd0423
This commit is contained in:
parent
47ed3011e6
commit
f208316cdd
@ -928,6 +928,21 @@ NotificationTask::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
Notification::RequireInteractionEnabled(JSContext* aCx, JSObject* aOjb)
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
return Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false);
|
||||
}
|
||||
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return workerPrivate->DOMWorkerNotificationRIEnabled();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
Notification::PrefEnabled(JSContext* aCx, JSObject* aObj)
|
||||
@ -1821,6 +1836,11 @@ Notification::ShowInternal()
|
||||
uniqueCookie.AppendInt(sCount++);
|
||||
bool inPrivateBrowsing = IsInPrivateBrowsing();
|
||||
|
||||
bool requireInteraction = mRequireInteraction;
|
||||
if (!Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false)) {
|
||||
requireInteraction = false;
|
||||
}
|
||||
|
||||
nsAutoString alertName;
|
||||
GetAlertName(alertName);
|
||||
nsCOMPtr<nsIAlertNotification> alert =
|
||||
@ -1835,7 +1855,7 @@ Notification::ShowInternal()
|
||||
mDataAsBase64,
|
||||
GetPrincipal(),
|
||||
inPrivateBrowsing,
|
||||
mRequireInteraction);
|
||||
requireInteraction);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (isPersistent) {
|
||||
@ -2702,7 +2722,7 @@ Notification::ShowPersistentNotification(JSContext* aCx,
|
||||
// which leads to uglier code.
|
||||
NotificationPermission permission = GetPermission(aGlobal, aRv);
|
||||
|
||||
// "If permission for notification’s origin is not "granted", reject promise with a TypeError exception, and terminate these substeps."
|
||||
// "If permission for notification's origin is not "granted", reject promise with a TypeError exception, and terminate these substeps."
|
||||
if (NS_WARN_IF(aRv.Failed()) || permission == NotificationPermission::Denied) {
|
||||
ErrorResult result;
|
||||
result.ThrowTypeError<MSG_NOTIFICATION_PERMISSION_DENIED>();
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper)
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static bool RequireInteractionEnabled(JSContext* aCx, JSObject* aObj);
|
||||
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
|
||||
// Returns if Notification.get() is allowed for the current global.
|
||||
static bool IsGetEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
@ -51,7 +51,7 @@ interface Notification : EventTarget {
|
||||
[Pure]
|
||||
readonly attribute DOMString? icon;
|
||||
|
||||
[Constant]
|
||||
[Constant, Func="mozilla::dom::Notification::RequireInteractionEnabled"]
|
||||
readonly attribute boolean requireInteraction;
|
||||
|
||||
[Constant]
|
||||
|
@ -30,6 +30,7 @@ WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CA
|
||||
WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
|
||||
WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
|
||||
WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
|
||||
WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.serviceWorkers.openWindow.enabled", OpenWindowEnabled, OPEN_WINDOW_ENABLED)
|
||||
|
@ -4690,6 +4690,11 @@ pref("notification.feature.enabled", false);
|
||||
// Web Notification
|
||||
pref("dom.webnotifications.enabled", true);
|
||||
pref("dom.webnotifications.serviceworker.enabled", true);
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("dom.webnotifications.requireinteraction.enabled", true);
|
||||
#else
|
||||
pref("dom.webnotifications.requireinteraction.enabled", false);
|
||||
#endif
|
||||
|
||||
// Alert animation effect, name is disableSlidingEffect for backwards-compat.
|
||||
pref("alerts.disableSlidingEffect", false);
|
||||
|
Loading…
Reference in New Issue
Block a user