summaryrefslogtreecommitdiffstats
path: root/dom/notification
diff options
context:
space:
mode:
authoradeshkp <adeshkp@users.noreply.github.com>2019-01-12 06:20:31 -0500
committeradeshkp <adeshkp@users.noreply.github.com>2019-01-12 06:20:31 -0500
commit5335681cd2ab05ad47e81be7722c9eee19d54065 (patch)
treeeced0f22032c4f01229ac0a18b9ffb6219cea309 /dom/notification
parentf38edc94a31de3bae839cf63ed57c3851908ac46 (diff)
downloadUXP-5335681cd2ab05ad47e81be7722c9eee19d54065.tar
UXP-5335681cd2ab05ad47e81be7722c9eee19d54065.tar.gz
UXP-5335681cd2ab05ad47e81be7722c9eee19d54065.tar.lz
UXP-5335681cd2ab05ad47e81be7722c9eee19d54065.tar.xz
UXP-5335681cd2ab05ad47e81be7722c9eee19d54065.zip
Telemetry: Remove stubs and related code
Diffstat (limited to 'dom/notification')
-rw-r--r--dom/notification/Notification.cpp169
-rw-r--r--dom/notification/Notification.h34
2 files changed, 0 insertions, 203 deletions
diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
index 71c4916b9..a5aa48b00 100644
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -11,7 +11,6 @@
#include "mozilla/OwningNonNull.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
-#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
@@ -656,172 +655,6 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
aTypes);
}
-NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
-
-NotificationTelemetryService::NotificationTelemetryService()
- : mDNDRecorded(false)
-{}
-
-NotificationTelemetryService::~NotificationTelemetryService()
-{
- Unused << NS_WARN_IF(NS_FAILED(RemovePermissionChangeObserver()));
-}
-
-/* static */ already_AddRefed<NotificationTelemetryService>
-NotificationTelemetryService::GetInstance()
-{
- nsCOMPtr<nsISupports> telemetrySupports =
- do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID);
- if (!telemetrySupports) {
- return nullptr;
- }
- RefPtr<NotificationTelemetryService> telemetry =
- static_cast<NotificationTelemetryService*>(telemetrySupports.get());
- return telemetry.forget();
-}
-
-nsresult
-NotificationTelemetryService::Init()
-{
- nsresult rv = AddPermissionChangeObserver();
- NS_ENSURE_SUCCESS(rv, rv);
-
- RecordPermissions();
-
- return NS_OK;
-}
-
-nsresult
-NotificationTelemetryService::RemovePermissionChangeObserver()
-{
- nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
- if (!obs) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- return obs->RemoveObserver(this, "perm-changed");
-}
-
-nsresult
-NotificationTelemetryService::AddPermissionChangeObserver()
-{
- nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
- if (!obs) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
- return obs->AddObserver(this, "perm-changed", false);
-}
-
-void
-NotificationTelemetryService::RecordPermissions()
-{
- if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) {
- return;
- }
-
- nsCOMPtr<nsIPermissionManager> permissionManager =
- services::GetPermissionManager();
- if (!permissionManager) {
- return;
- }
-
- nsCOMPtr<nsISimpleEnumerator> enumerator;
- nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return;
- }
-
- for (;;) {
- bool hasMoreElements;
- nsresult rv = enumerator->HasMoreElements(&hasMoreElements);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return;
- }
- if (!hasMoreElements) {
- break;
- }
- nsCOMPtr<nsISupports> supportsPermission;
- rv = enumerator->GetNext(getter_AddRefs(supportsPermission));
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return;
- }
- uint32_t capability;
- if (!GetNotificationPermission(supportsPermission, &capability)) {
- continue;
- }
- }
-}
-
-bool
-NotificationTelemetryService::GetNotificationPermission(nsISupports* aSupports,
- uint32_t* aCapability)
-{
- nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
- if (!permission) {
- return false;
- }
- nsAutoCString type;
- permission->GetType(type);
- if (!type.Equals("desktop-notification")) {
- return false;
- }
- permission->GetCapability(aCapability);
- return true;
-}
-
-void
-NotificationTelemetryService::RecordDNDSupported()
-{
- if (mDNDRecorded) {
- return;
- }
-
- nsCOMPtr<nsIAlertsService> alertService =
- do_GetService(NS_ALERTSERVICE_CONTRACTID);
- if (!alertService) {
- return;
- }
-
- nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND =
- do_QueryInterface(alertService);
- if (!alertServiceDND) {
- return;
- }
-
- mDNDRecorded = true;
- bool isEnabled;
- nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled);
- if (NS_FAILED(rv)) {
- return;
- }
-}
-
-nsresult
-NotificationTelemetryService::RecordSender(nsIPrincipal* aPrincipal)
-{
- if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended() ||
- !nsAlertsUtils::IsActionablePrincipal(aPrincipal)) {
- return NS_OK;
- }
- nsAutoString origin;
- nsresult rv = Notification::GetOrigin(aPrincipal, origin);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (!mOrigins.Contains(origin)) {
- mOrigins.PutEntry(origin);
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-NotificationTelemetryService::Observe(nsISupports* aSubject,
- const char* aTopic,
- const char16_t* aData)
-{
- /* STUB */
- return NS_OK;
-}
-
// Observer that the alert service calls to do common tasks and/or dispatch to the
// specific observer for the context e.g. main thread, worker, or service worker.
class NotificationObserver final : public nsIObserver
@@ -1402,8 +1235,6 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK;
} else if (!strcmp("alertshow", aTopic) ||
!strcmp("alertfinished", aTopic)) {
- RefPtr<NotificationTelemetryService> telemetry =
- NotificationTelemetryService::GetInstance();
Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
}
diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h
index a2c4b5c68..11958f6ad 100644
--- a/dom/notification/Notification.h
+++ b/dom/notification/Notification.h
@@ -18,9 +18,6 @@
#include "nsTHashtable.h"
#include "nsWeakReference.h"
-#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
- "@mozilla.org/notificationTelemetryService;1"
-
class nsIPrincipal;
class nsIVariant;
@@ -49,36 +46,6 @@ public:
Notify(workers::Status aStatus) override;
};
-// Records telemetry probes at application startup, when a notification is
-// shown, and when the notification permission is revoked for a site.
-class NotificationTelemetryService final : public nsIObserver
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIOBSERVER
-
- NotificationTelemetryService();
-
- static already_AddRefed<NotificationTelemetryService> GetInstance();
-
- nsresult Init();
- void RecordDNDSupported();
- void RecordPermissions();
- nsresult RecordSender(nsIPrincipal* aPrincipal);
-
-private:
- virtual ~NotificationTelemetryService();
-
- nsresult AddPermissionChangeObserver();
- nsresult RemovePermissionChangeObserver();
-
- bool GetNotificationPermission(nsISupports* aSupports,
- uint32_t* aCapability);
-
- bool mDNDRecorded;
- nsTHashtable<nsStringHashKey> mOrigins;
-};
-
/*
* Notifications on workers introduce some lifetime issues. The property we
* are trying to satisfy is:
@@ -143,7 +110,6 @@ class Notification : public DOMEventTargetHelper
friend class ServiceWorkerNotificationObserver;
friend class WorkerGetRunnable;
friend class WorkerNotificationObserver;
- friend class NotificationTelemetryService;
public:
IMPL_EVENT_HANDLER(click)