зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1212129 - e10s support for disabling site notifications. r=wchen
--HG-- extra : commitid : DPxANWhtVhu extra : rebase_source : ba1b2c4cc9a93f7acbc4b68936b808dfc3552294
This commit is contained in:
Родитель
acfff056be
Коммит
ec05a62f84
|
@ -5,6 +5,6 @@ support-files =
|
|||
[browser_notification_do_not_disturb.js]
|
||||
[browser_notification_open_settings.js]
|
||||
[browser_notification_remove_permission.js]
|
||||
skip-if = e10s
|
||||
|
||||
[browser_notification_tab_switching.js]
|
||||
skip-if = buildapp == 'mulet' || e10s # Bug 1100662 - content access causing uncaught exception - Error: cannot ipc non-cpow object at chrome://mochitests/content/browser/browser/base/content/test/general/browser_notification_tab_switching.js:32 (or in RemoteAddonsChild.jsm)
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#ifdef MOZ_EME
|
||||
#include "mozilla/dom/MediaKeySystemAccess.h"
|
||||
#endif
|
||||
#include "mozilla/dom/Notification.h"
|
||||
#include "mozilla/dom/NuwaParent.h"
|
||||
#include "mozilla/dom/PContentBridgeParent.h"
|
||||
#include "mozilla/dom/PContentPermissionRequestParent.h"
|
||||
|
@ -3181,7 +3182,8 @@ ContentParent::Observe(nsISupports* aSubject,
|
|||
// listening for alert notifications
|
||||
else if (!strcmp(aTopic, "alertfinished") ||
|
||||
!strcmp(aTopic, "alertclickcallback") ||
|
||||
!strcmp(aTopic, "alertshow") ) {
|
||||
!strcmp(aTopic, "alertshow") ||
|
||||
!strcmp(aTopic, "alertdisablecallback")) {
|
||||
if (!SendNotifyAlertsObserver(nsDependentCString(aTopic),
|
||||
nsDependentString(aData)))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -4316,6 +4318,21 @@ ContentParent::RecvCloseAlert(const nsString& aName,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvDisableNotifications(const IPC::Principal& aPrincipal)
|
||||
{
|
||||
#ifdef MOZ_CHILD_PERMISSIONS
|
||||
uint32_t permission = mozilla::CheckPermission(this, aPrincipal,
|
||||
"desktop-notification");
|
||||
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
unused << Notification::RemovePermission(aPrincipal);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvSyncMessage(const nsString& aMsg,
|
||||
const ClonedMessageData& aData,
|
||||
|
|
|
@ -767,6 +767,8 @@ private:
|
|||
virtual bool RecvCloseAlert(const nsString& aName,
|
||||
const IPC::Principal& aPrincipal) override;
|
||||
|
||||
virtual bool RecvDisableNotifications(const IPC::Principal& aPrincipal) override;
|
||||
|
||||
virtual bool RecvLoadURIExternal(const URIParams& uri) override;
|
||||
|
||||
virtual bool RecvSyncMessage(const nsString& aMsg,
|
||||
|
|
|
@ -842,6 +842,8 @@ parent:
|
|||
|
||||
CloseAlert(nsString name, Principal principal);
|
||||
|
||||
DisableNotifications(Principal principal);
|
||||
|
||||
PPSMContentDownloader(uint32_t aCertType);
|
||||
|
||||
PExternalHelperApp(OptionalURIParams uri,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "nsIMutable.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
|
@ -81,7 +82,7 @@ StructuredCloneData::Write(JSContext* aCx,
|
|||
}
|
||||
|
||||
void
|
||||
StructuredCloneData::WriteIPCParams(Message* aMsg) const
|
||||
StructuredCloneData::WriteIPCParams(IPC::Message* aMsg) const
|
||||
{
|
||||
WriteParam(aMsg, DataLength());
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
#include "nsAccessibilityService.h"
|
||||
#endif
|
||||
#include "mozilla/BrowserElementParent.h"
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/DataTransfer.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/indexedDB/ActorsParent.h"
|
||||
#include "mozilla/plugins/PluginWidgetParent.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/unused.h"
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "xpcpublic.h"
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/NotificationEvent.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
@ -40,6 +41,7 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStructuredCloneContainer.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "ServiceWorkerManager.h"
|
||||
#include "WorkerPrivate.h"
|
||||
#include "WorkerRunnable.h"
|
||||
|
@ -1154,12 +1156,14 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
AssertIsOnMainThread();
|
||||
|
||||
if (!strcmp("alertdisablecallback", aTopic)) {
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
mozilla::services::GetPermissionManager();
|
||||
if (!permissionManager) {
|
||||
return NS_ERROR_FAILURE;
|
||||
if (XRE_IsParentProcess()) {
|
||||
return Notification::RemovePermission(mPrincipal);
|
||||
}
|
||||
permissionManager->RemoveFromPrincipal(mPrincipal, "desktop-notification");
|
||||
// Permissions can't be removed from the content process. Send a message
|
||||
// to the parent; `ContentParent::RecvDisableNotifications` will call
|
||||
// `RemovePermission`.
|
||||
ContentChild::GetSingleton()->SendDisableNotifications(
|
||||
IPC::Principal(mPrincipal));
|
||||
return NS_OK;
|
||||
} else if (!strcmp("alertsettingscallback", aTopic)) {
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
|
@ -2411,6 +2415,19 @@ Notification::CreateAndShow(nsIGlobalObject* aGlobal,
|
|||
return notification.forget();
|
||||
}
|
||||
|
||||
/* static */ nsresult
|
||||
Notification::RemovePermission(nsIPrincipal* aPrincipal)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
mozilla::services::GetPermissionManager();
|
||||
if (!permissionManager) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
permissionManager->RemoveFromPrincipal(aPrincipal, "desktop-notification");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -275,6 +275,8 @@ public:
|
|||
|
||||
bool DispatchClickEvent();
|
||||
bool DispatchNotificationClickEvent();
|
||||
|
||||
static nsresult RemovePermission(nsIPrincipal* aPrincipal);
|
||||
protected:
|
||||
Notification(nsIGlobalObject* aGlobal, const nsAString& aID,
|
||||
const nsAString& aTitle, const nsAString& aBody,
|
||||
|
|
Загрузка…
Ссылка в новой задаче