diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index d997337049e9..707c09ae12a3 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -443,18 +443,6 @@ void nsContentPermissionUtils::NotifyRemoveContentPermissionRequestChild( ContentPermissionRequestChildMap().erase(it); } -NS_IMPL_ISUPPORTS(nsContentPermissionRequester, nsIContentPermissionRequester) - -nsContentPermissionRequester::nsContentPermissionRequester( - nsPIDOMWindowInner* aWindow) - : mWindow(do_GetWeakReference(aWindow)), - mListener(new VisibilityChangeListener(aWindow)) {} - -nsContentPermissionRequester::~nsContentPermissionRequester() { - mListener->RemoveListener(); - mListener = nullptr; -} - static nsIPrincipal* GetTopLevelPrincipal(nsPIDOMWindowInner* aWindow) { MOZ_ASSERT(aWindow); @@ -491,7 +479,6 @@ ContentPermissionRequestBase::ContentPermissionRequestBase( : mPrincipal(aPrincipal), mTopLevelPrincipal(aWindow ? ::GetTopLevelPrincipal(aWindow) : nullptr), mWindow(aWindow), - mRequester(aWindow ? new nsContentPermissionRequester(aWindow) : nullptr), mPrefName(aPrefName), mType(aType), mIsHandlingUserInput(false), @@ -569,16 +556,6 @@ ContentPermissionRequestBase::GetIsHandlingUserInput( return NS_OK; } -NS_IMETHODIMP -ContentPermissionRequestBase::GetRequester( - nsIContentPermissionRequester** aRequester) { - NS_ENSURE_ARG_POINTER(aRequester); - - nsCOMPtr requester = mRequester; - requester.forget(aRequester); - return NS_OK; -} - NS_IMETHODIMP ContentPermissionRequestBase::GetTypes(nsIArray** aTypes) { nsTArray emptyOptions; @@ -743,24 +720,6 @@ nsresult TranslateChoices( } // namespace mozilla::dom -NS_IMPL_ISUPPORTS( - nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy, - nsIContentPermissionRequester) - -void nsContentPermissionRequestProxy::nsContentPermissionRequesterProxy :: - NotifyVisibilityResult(const bool& aIsVisible) { - if (mWaitGettingResult) { - MOZ_ASSERT(mGetCallback); - mWaitGettingResult = false; - mGetCallback->NotifyVisibility(aIsVisible); - return; - } - - if (mOnChangeCallback) { - mOnChangeCallback->NotifyVisibility(aIsVisible); - } -} - nsContentPermissionRequestProxy::nsContentPermissionRequestProxy( ContentPermissionRequestParent* parent) : mParent(parent) { @@ -772,7 +731,6 @@ nsContentPermissionRequestProxy::~nsContentPermissionRequestProxy() = default; nsresult nsContentPermissionRequestProxy::Init( const nsTArray& requests) { mPermissionRequests = requests.Clone(); - mRequester = new nsContentPermissionRequesterProxy(); nsCOMPtr prompt = do_GetService(NS_CONTENT_PERMISSION_PROMPT_CONTRACTID); @@ -785,7 +743,6 @@ nsresult nsContentPermissionRequestProxy::Init( } void nsContentPermissionRequestProxy::OnParentDestroyed() { - mRequester = nullptr; mParent = nullptr; } @@ -924,22 +881,6 @@ nsContentPermissionRequestProxy::Allow(JS::HandleValue aChoices) { return NS_OK; } -void nsContentPermissionRequestProxy::NotifyVisibility(const bool& aIsVisible) { - MOZ_ASSERT(mRequester); - - mRequester->NotifyVisibilityResult(aIsVisible); -} - -NS_IMETHODIMP -nsContentPermissionRequestProxy::GetRequester( - nsIContentPermissionRequester** aRequester) { - NS_ENSURE_ARG_POINTER(aRequester); - - RefPtr requester = mRequester; - requester.forget(aRequester); - return NS_OK; -} - // RemotePermissionRequest NS_IMPL_ISUPPORTS(RemotePermissionRequest, nsIContentPermissionRequestCallback); diff --git a/dom/base/nsContentPermissionHelper.h b/dom/base/nsContentPermissionHelper.h index 053d40c01b28..f00256720385 100644 --- a/dom/base/nsContentPermissionHelper.h +++ b/dom/base/nsContentPermissionHelper.h @@ -90,21 +90,6 @@ class nsContentPermissionUtils { PContentPermissionRequestChild* aChild); }; -class nsContentPermissionRequester final - : public nsIContentPermissionRequester { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSICONTENTPERMISSIONREQUESTER - - explicit nsContentPermissionRequester(nsPIDOMWindowInner* aWindow); - - private: - virtual ~nsContentPermissionRequester(); - - nsWeakPtr mWindow; - RefPtr mListener; -}; - nsresult TranslateChoices( JS::HandleValue aChoices, const nsTArray& aPermissionRequests, @@ -125,7 +110,6 @@ class ContentPermissionRequestBase : public nsIContentPermissionRequest { NS_IMETHOD GetIsHandlingUserInput(bool* aIsHandlingUserInput) override; NS_IMETHOD GetMaybeUnsafePermissionDelegate( bool* aMaybeUnsafePermissionDelegate) override; - NS_IMETHOD GetRequester(nsIContentPermissionRequester** aRequester) override; // Overrides for Allow() and Cancel() aren't provided by this class. // That is the responsibility of the subclasses. @@ -158,7 +142,6 @@ class ContentPermissionRequestBase : public nsIContentPermissionRequest { nsCOMPtr mPrincipal; nsCOMPtr mTopLevelPrincipal; nsCOMPtr mWindow; - nsCOMPtr mRequester; RefPtr mPermissionHandler; nsCString mPrefName; nsCString mType; @@ -186,23 +169,6 @@ class nsContentPermissionRequestProxy : public nsIContentPermissionRequest { void NotifyVisibility(const bool& aIsVisible); private: - class nsContentPermissionRequesterProxy final - : public nsIContentPermissionRequester { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSICONTENTPERMISSIONREQUESTER - - explicit nsContentPermissionRequesterProxy() : mWaitGettingResult(false) {} - - void NotifyVisibilityResult(const bool& aIsVisible); - - private: - virtual ~nsContentPermissionRequesterProxy() = default; - - bool mWaitGettingResult; - nsCOMPtr mGetCallback; - nsCOMPtr mOnChangeCallback; - }; virtual ~nsContentPermissionRequestProxy(); @@ -210,7 +176,6 @@ class nsContentPermissionRequestProxy : public nsIContentPermissionRequest { // this proxy. ContentPermissionRequestParent* mParent; nsTArray mPermissionRequests; - RefPtr mRequester; }; /** diff --git a/dom/geolocation/Geolocation.cpp b/dom/geolocation/Geolocation.cpp index e1b1075e6318..f523be1a6f4b 100644 --- a/dom/geolocation/Geolocation.cpp +++ b/dom/geolocation/Geolocation.cpp @@ -77,7 +77,7 @@ class nsGeolocationRequest final : public ContentPermissionRequestBase, nsGeolocationRequest(Geolocation* aLocator, GeoPositionCallback aCallback, GeoPositionErrorCallback aErrorCallback, UniquePtr&& aOptions, - uint8_t aProtocolType, nsIEventTarget* aMainThreadTarget, + nsIEventTarget* aMainThreadTarget, bool aWatchPositionRequest = false, int32_t aWatchId = 0); @@ -140,8 +140,6 @@ class nsGeolocationRequest final : public ContentPermissionRequestBase, int32_t mWatchId; bool mShutdown; - nsCOMPtr mRequester; - uint8_t mProtocolType; nsCOMPtr mMainThreadTarget; }; @@ -192,7 +190,7 @@ static nsPIDOMWindowInner* ConvertWeakReferenceToWindow( nsGeolocationRequest::nsGeolocationRequest( Geolocation* aLocator, GeoPositionCallback aCallback, GeoPositionErrorCallback aErrorCallback, - UniquePtr&& aOptions, uint8_t aProtocolType, + UniquePtr&& aOptions, nsIEventTarget* aMainThreadTarget, bool aWatchPositionRequest, int32_t aWatchId) : ContentPermissionRequestBase( @@ -206,7 +204,6 @@ nsGeolocationRequest::nsGeolocationRequest( mLocator(aLocator), mWatchId(aWatchId), mShutdown(false), - mProtocolType(aProtocolType), mMainThreadTarget(aMainThreadTarget) { if (nsCOMPtr win = do_QueryReferent(mLocator->GetOwner())) { @@ -242,14 +239,6 @@ void nsGeolocationRequest::NotifyErrorAndShutdown(uint16_t aErrorCode) { NS_IMETHODIMP nsGeolocationRequest::Cancel() { - if (mRequester) { - // Record the number of denied requests for regular web content. - // This method is only called when the user explicitly denies the request, - // and is not called when the page is simply unloaded, or similar. - Telemetry::Accumulate(Telemetry::GEOLOCATION_REQUEST_GRANTED, - mProtocolType); - } - if (mLocator->ClearPendingRequest(this)) { return NS_OK; } @@ -262,31 +251,6 @@ NS_IMETHODIMP nsGeolocationRequest::Allow(JS::HandleValue aChoices) { MOZ_ASSERT(aChoices.isUndefined()); - if (mRequester) { - // Record the number of granted requests for regular web content. - Telemetry::Accumulate(Telemetry::GEOLOCATION_REQUEST_GRANTED, - mProtocolType + 10); - - // Record whether a location callback is fulfilled while the owner window - // is not visible. - bool isVisible = false; - nsCOMPtr window = mLocator->GetParentObject(); - - if (window) { - nsCOMPtr doc = window->GetDoc(); - isVisible = doc && !doc->Hidden(); - } - - if (IsWatch()) { - mozilla::Telemetry::Accumulate( - mozilla::Telemetry::GEOLOCATION_WATCHPOSITION_VISIBLE, isVisible); - } else { - mozilla::Telemetry::Accumulate( - mozilla::Telemetry::GEOLOCATION_GETCURRENTPOSITION_VISIBLE, - isVisible); - } - } - if (mLocator->ClearPendingRequest(this)) { return NS_OK; } @@ -1025,14 +989,10 @@ nsresult Geolocation::GetCurrentPosition(GeoPositionCallback callback, // After this we hand over ownership of options to our nsGeolocationRequest. - // Count the number of requests per protocol/scheme. - Telemetry::Accumulate(Telemetry::GEOLOCATION_GETCURRENTPOSITION_SECURE_ORIGIN, - static_cast(mProtocolType)); - nsIEventTarget* target = MainThreadTarget(this); RefPtr request = new nsGeolocationRequest( this, std::move(callback), std::move(errorCallback), std::move(options), - static_cast(mProtocolType), target); + target); if (!StaticPrefs::geo_enabled() || ShouldBlockInsecureRequests() || !request->CheckPermissionDelegate()) { @@ -1094,18 +1054,13 @@ int32_t Geolocation::WatchPosition(GeoPositionCallback aCallback, return -1; } - // Count the number of requests per protocol/scheme. - Telemetry::Accumulate(Telemetry::GEOLOCATION_WATCHPOSITION_SECURE_ORIGIN, - static_cast(mProtocolType)); - // The watch ID: int32_t watchId = mLastWatchId++; nsIEventTarget* target = MainThreadTarget(this); RefPtr request = new nsGeolocationRequest( this, std::move(aCallback), std::move(aErrorCallback), - std::move(aOptions), static_cast(mProtocolType), target, true, - watchId); + std::move(aOptions), target, true, watchId); if (!StaticPrefs::geo_enabled() || ShouldBlockInsecureRequests() || !request->CheckPermissionDelegate()) { diff --git a/dom/interfaces/base/nsIContentPermissionPrompt.idl b/dom/interfaces/base/nsIContentPermissionPrompt.idl index 39d01840cb6e..381e0d695e4a 100644 --- a/dom/interfaces/base/nsIContentPermissionPrompt.idl +++ b/dom/interfaces/base/nsIContentPermissionPrompt.idl @@ -38,14 +38,6 @@ interface nsIContentPermissionRequestCallback : nsISupports { void notifyVisibility(in boolean isVisible); }; -/** - * Interface provides the way to get the visibility and - * the notification. - */ -[scriptable, uuid(f8577124-6a5f-486f-ae04-c5bcae911eb5)] -interface nsIContentPermissionRequester : nsISupports { -}; - /** * Interface allows access to a content to request * permission to perform a privileged operation such as @@ -81,11 +73,6 @@ interface nsIContentPermissionRequest : nsISupports { readonly attribute boolean isHandlingUserInput; readonly attribute boolean maybeUnsafePermissionDelegate; - /** - * The requester to get the required information of - * the window. - */ - readonly attribute nsIContentPermissionRequester requester; /* * Get delegate principal of the permission request. This will return nullptr, diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 6b9f9fb29649..5b205d87abdb 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1032,37 +1032,6 @@ "kind": "flag", "description": "Has seen location error" }, - "GEOLOCATION_GETCURRENTPOSITION_SECURE_ORIGIN" : { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["mds@mozilla.com"], - "expires_in_version": "60", - "kind": "enumerated", - "n_values": 10, - "bug_numbers": [1230209], - "description" : "Number of navigator.geolocation.getCurrentPosition() calls (0=other, 1=http, 2=https)" - }, - "GEOLOCATION_REQUEST_GRANTED": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["tdsmith@mozilla.com"], - "expires_in_version": "72", - "kind": "enumerated", - "n_values": 20, - "releaseChannelCollection": "opt-out", - "bug_numbers": [1230209, 1494496, 1519170, 1544539], - "description": "Geolocation requests either granted or denied (0=denied/other, 1=denied/http, 2=denied/https, ..., 10=granted/other, 11=granted/http, 12=granted/https)" - }, - "GEOLOCATION_WATCHPOSITION_SECURE_ORIGIN" : { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["mds@mozilla.com"], - "expires_in_version": "60", - "kind": "enumerated", - "n_values": 10, - "bug_numbers": [1230209], - "description" : "Number of navigator.geolocation.watchPosition() calls (0=other, 1=http, 2=https)" - }, "GEOLOCATION_WIN8_SOURCE_IS_MLS": { "record_in_processes": ["main", "content"], "products": ["firefox", "fennec"], @@ -1077,24 +1046,6 @@ "kind": "boolean", "description": "Geolocation on OS X is either MLS or CoreLocation" }, - "GEOLOCATION_GETCURRENTPOSITION_VISIBLE": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["mds@mozilla.com"], - "expires_in_version": "60", - "kind": "boolean", - "bug_numbers": [1255198], - "description": "This metric is recorded every time a navigator.geolocation.getCurrentPosition() request gets allowed/fulfilled. A false value is recorded if the owner is not visible according to document.isVisible." - }, - "GEOLOCATION_WATCHPOSITION_VISIBLE": { - "record_in_processes": ["main", "content"], - "products": ["firefox", "fennec"], - "alert_emails": ["mds@mozilla.com"], - "expires_in_version": "60", - "kind": "boolean", - "bug_numbers": [1255198], - "description": "This metric is recorded every time a navigator.geolocation.watchPosition() request gets allowed/fulfilled. A false value is recorded if the owner is not visible according to document.isVisible." - }, "GPU_PROCESS_LAUNCH_TIME_MS_2" : { "record_in_processes": ["main", "content"], "products": ["firefox", "fennec"],