Bug 1087182 - Only send Prefer:Safe header if Web Filtering is on (Windows-only). r=dougt, a=lsblakk
authorJason Duell <jduell.mcbugs@gmail.com>
Tue, 11 Nov 2014 15:17:37 -0800
changeset 233866 9c775c8888ef57d344cc18cb0a857148ebc54d0a
parent 233865 3d78aaf8a9c7ac0b82b35617362fee16d7b85a88
child 233867 5b7d7f3c8cc75c29643169daff36b47067a73d89
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt, lsblakk
bugs1087182
milestone35.0a2
Bug 1087182 - Only send Prefer:Safe header if Web Filtering is on (Windows-only). r=dougt, a=lsblakk
toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
--- a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
+++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
@@ -8,16 +8,19 @@
 #include "nsIArray.h"
 #include "nsIWidget.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIFile.h"
 #include "nsILocalFileWin.h"
 #include "nsArrayUtils.h"
 #include "nsIXULAppInfo.h"
+#include "mozilla/WindowsVersion.h"
+
+using namespace mozilla;
 
 static const CLSID CLSID_WinParentalControls = {0xE77CC89B,0x7401,0x4C04,{0x8C,0xED,0x14,0x9D,0xB3,0x5A,0xDD,0x04}};
 static const IID IID_IWinParentalControls  = {0x28B4D88B,0xE072,0x49E6,{0x80,0x4D,0x26,0xED,0xBE,0x21,0xA7,0xB9}};
 
 NS_IMPL_ISUPPORTS(nsParentalControlsService, nsIParentalControlsService)
 
 static HINSTANCE gAdvAPIDLLInst = nullptr;
 
@@ -42,18 +45,23 @@ nsParentalControlsService::nsParentalCon
     // Not available on this os or not enabled for this user account or we're running as admin
     mPC->Release();
     mPC = nullptr;
     return;
   }
 
   DWORD settings = 0;
   wpcs->GetRestrictions(&settings);
-  
-  if (settings) { // WPCFLAG_NO_RESTRICTION = 0
+
+  // If we can't determine specifically whether Web Filtering is on/off (i.e.
+  // we're on Windows < 8), then assume it's on unless no restrictions are set.
+  bool enable = IsWin8OrLater() ? settings & WPCFLAG_WEB_FILTERED
+                                : settings != WPCFLAG_NO_RESTRICTION;
+
+  if (enable) {
     gAdvAPIDLLInst = ::LoadLibrary("Advapi32.dll");
     if(gAdvAPIDLLInst)
     {
       gEventWrite = (decltype(EventWrite)*) GetProcAddress(gAdvAPIDLLInst, "EventWrite");
       gEventRegister = (decltype(EventRegister)*) GetProcAddress(gAdvAPIDLLInst, "EventRegister");
       gEventUnregister = (decltype(EventUnregister)*) GetProcAddress(gAdvAPIDLLInst, "EventUnregister");
     }
     mEnabled = true;