Bug 995430 - send header when user is signed into a children\'s account. r=mcmanus
authorDoug Turner <doug.turner@gmail.com>
Mon, 05 May 2014 14:30:42 -0700
changeset 204847 9d0c1f1037e37465eeafb4466fb3ad2973b1755b
parent 204846 083b9fb75e9a8fff9eab3dddfed568a88d4a2bcf
child 204848 5b455e3d326142b3eaf4feae108d7e183d300f88
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs995430
milestone32.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 995430 - send header when user is signed into a children\'s account. r=mcmanus
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
@@ -432,16 +432,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