Bug 1087182 - Only send Prefer:Safe header if Web Filtering is on (Windows-only) r=dougt
authorJason Duell <jduell.mcbugs@gmail.com>
Tue, 11 Nov 2014 15:17:37 -0800
changeset 215136 60b2d69d81ca42c2b7d7defab33012ea67b5fb41
parent 215135 5cf41ab7e2f93eccfa705a900bf3ef66be2b6866
child 215137 04b8193b4b4990eb9f5bf1038c4e35d3829e72ee
push id27810
push usercbook@mozilla.com
push dateWed, 12 Nov 2014 15:03:31 +0000
treeherdermozilla-central@cf9eafef4ffa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs1087182
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1087182 - Only send Prefer:Safe header if Web Filtering is on (Windows-only) r=dougt
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;