Bug 995430 - send header when user is signed into a children\'s account. r=mcmanus, a=gal
authorDoug Turner <doug.turner@gmail.com>
Mon, 05 May 2014 14:30:42 -0700
changeset 199365 765e85a7f2916b42b899eef4ec9dadb66a65d084
parent 199364 a31a77cd7951716f592bb165a44c19de91ae5d44
child 199366 9cf15aa7756f6be485a5af66534c0c4971f76a7f
push idunknown
push userunknown
push dateunknown
reviewersmcmanus, gal
bugs995430
milestone31.0a2
Bug 995430 - send header when user is signed into a children\'s account. r=mcmanus, a=gal
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -42,16 +42,17 @@
 #include "nsICookieService.h"
 #include "nsIObserverService.h"
 #include "nsISiteSecurityService.h"
 #include "nsIStreamConverterService.h"
 #include "nsITimer.h"
 #include "nsCRT.h"
 #include "SpdyZlibReporter.h"
 #include "nsIMemoryReporter.h"
+#include "nsIParentalControlsService.h"
 
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/Telemetry.h"
 
 #if defined(XP_UNIX)
 #include <sys/utsname.h>
 #endif
 
@@ -169,16 +170,17 @@ nsHttpHandler::nsHttpHandler()
     , mUserAgentIsDirty(true)
     , mUseCache(true)
     , mPromptTempRedirect(true)
     , mSendSecureXSiteReferrer(true)
     , mEnablePersistentHttpsCaching(false)
     , mDoNotTrackEnabled(false)
     , mDoNotTrackValue(1)
     , mSafeHintEnabled(false)
+    , mParentalControlEnabled(false)
     , mTelemetryEnabled(false)
     , mAllowExperiments(true)
     , mHandlerActive(false)
     , mEnableSpdy(false)
     , mSpdyV3(true)
     , mSpdyV31(true)
     , mHttp2DraftEnabled(true)
     , mEnforceHttp2TlsProfile(true)
@@ -347,16 +349,20 @@ nsHttpHandler::Init()
         mObserverService->AddObserver(this, "last-pb-context-exited", true);
     }
 
     MakeNewRequestTokenBucket();
     mWifiTickler = new Tickler();
     if (NS_FAILED(mWifiTickler->Init()))
         mWifiTickler = nullptr;
 
+    nsCOMPtr<nsIParentalControlsService> pc = do_CreateInstance("@mozilla.org/parental-controls-service;1");
+    if (pc) {
+        pc->GetParentalControlsEnabled(&mParentalControlEnabled);
+    }
     return NS_OK;
 }
 
 void
 nsHttpHandler::MakeNewRequestTokenBucket()
 {
     if (!mConnMgr)
         return;
@@ -416,17 +422,17 @@ nsHttpHandler::AddStandardRequestHeaders
     // Add the "Do-Not-Track" header
     if (mDoNotTrackEnabled) {
       rv = request->SetHeader(nsHttp::DoNotTrack,
                               nsPrintfCString("%d", mDoNotTrackValue));
       if (NS_FAILED(rv)) return rv;
     }
 
     // add the "Send Hint" header
-    if (mSafeHintEnabled) {
+    if (mSafeHintEnabled || mParentalControlEnabled) {
       rv = request->SetHeader(nsHttp::Prefer, NS_LITERAL_CSTRING("safe"));
       if (NS_FAILED(rv)) return rv;
     }
     return NS_OK;
 }
 
 nsresult
 nsHttpHandler::AddConnectionHeader(nsHttpHeaderArray *request,
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -431,16 +431,17 @@ private:
     bool           mEnablePersistentHttpsCaching;
 
     // For broadcasting tracking preference
     bool           mDoNotTrackEnabled;
     uint8_t        mDoNotTrackValue;
 
     // for broadcasting safe hint;
     bool           mSafeHintEnabled;
+    bool           mParentalControlEnabled;
 
     // Whether telemetry is reported or not
     uint32_t           mTelemetryEnabled : 1;
 
     // The value of network.allow-experiments
     uint32_t           mAllowExperiments : 1;
 
     // true in between init and shutdown states