Bug 1586228 - Don't always disable file downloads when parental controls are on in Windows 10. r=aklotz, a=RyanVM
authorMatt Howell <mhowell@mozilla.com>
Fri, 04 Oct 2019 21:03:26 +0000
changeset 555531 2508214f49547072dbfb13b5f273b8800f52324d
parent 555530 fb691468a82d54d188cd19c296ea33cafc84bdea
child 555532 0d15569b45f0c7f1929030ee2c2c2db2d4e0e0f1
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, RyanVM
bugs1586228
milestone70.0
Bug 1586228 - Don't always disable file downloads when parental controls are on in Windows 10. r=aklotz, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D48202
toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
--- a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
+++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
@@ -139,38 +139,51 @@ nsParentalControlsService::GetParentalCo
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsParentalControlsService::GetBlockFileDownloadsEnabled(bool* aResult) {
   *aResult = false;
 
-  if (!mEnabled || !mPC) {
+  if (!mEnabled) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // If we're on Windows 10 and we don't have the whole API available, then
+  // we can't tell if file downloads are allowed, so assume they are to avoid
+  // breaking downloads for every single user with parental controls.
+  if (!mPC) {
+    return NS_OK;
+  }
+
   RefPtr<IWPCWebSettings> wpcws;
   if (SUCCEEDED(mPC->GetWebSettings(nullptr, getter_AddRefs(wpcws)))) {
     DWORD settings = 0;
     wpcws->GetSettings(&settings);
     if (settings == WPCFLAG_WEB_SETTING_DOWNLOADSBLOCKED) *aResult = true;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsParentalControlsService::GetLoggingEnabled(bool* aResult) {
   *aResult = false;
 
-  if (!mEnabled || !mPC) {
+  if (!mEnabled) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // If we're on Windows 10 and we don't have the whole API available, then
+  // we don't know how logging should be done, so report that it's disabled.
+  if (!mPC) {
+    return NS_OK;
+  }
+
   // Check the general purpose logging flag
   RefPtr<IWPCSettings> wpcs;
   if (SUCCEEDED(mPC->GetUserSettings(nullptr, getter_AddRefs(wpcs)))) {
     BOOL enabled = FALSE;
     wpcs->IsLoggingRequired(&enabled);
     if (enabled) *aResult = true;
   }
 
@@ -212,20 +225,25 @@ nsParentalControlsService::Log(int16_t a
 }
 
 // Override a single URI
 NS_IMETHODIMP
 nsParentalControlsService::RequestURIOverride(
     nsIURI* aTarget, nsIInterfaceRequestor* aWindowContext, bool* _retval) {
   *_retval = false;
 
-  if (!mEnabled || !mPC) {
+  if (!mEnabled) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // We don't know how to get the overrides unless the PC API exists.
+  if (!mPC) {
+    return NS_OK;
+  }
+
   NS_ENSURE_ARG_POINTER(aTarget);
 
   nsAutoCString spec;
   aTarget->GetSpec(spec);
   if (spec.IsEmpty()) return NS_ERROR_INVALID_ARG;
 
   HWND hWnd = nullptr;
   // If we have a native window, use its handle instead
@@ -245,20 +263,25 @@ nsParentalControlsService::RequestURIOve
 }
 
 // Override a web page
 NS_IMETHODIMP
 nsParentalControlsService::RequestURIOverrides(
     nsIArray* aTargets, nsIInterfaceRequestor* aWindowContext, bool* _retval) {
   *_retval = false;
 
-  if (!mEnabled || !mPC) {
+  if (!mEnabled) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  // We don't know how to get the overrides unless the PC API exists.
+  if (!mPC) {
+    return NS_OK;
+  }
+
   NS_ENSURE_ARG_POINTER(aTargets);
 
   uint32_t arrayLength = 0;
   aTargets->GetLength(&arrayLength);
   if (!arrayLength) return NS_ERROR_INVALID_ARG;
 
   if (arrayLength == 1) {
     nsCOMPtr<nsIURI> uri = do_QueryElementAt(aTargets, 0);