diff options
-rw-r--r-- | dom/base/nsContentPolicyUtils.h | 3 | ||||
-rw-r--r-- | dom/base/nsIContentPolicyBase.idl | 5 | ||||
-rw-r--r-- | dom/cache/DBSchema.cpp | 1 | ||||
-rw-r--r-- | dom/fetch/InternalRequest.cpp | 3 | ||||
-rw-r--r-- | dom/fetch/InternalRequest.h | 2 | ||||
-rw-r--r-- | dom/security/nsContentSecurityManager.cpp | 6 | ||||
-rw-r--r-- | dom/security/nsMixedContentBlocker.cpp | 7 |
7 files changed, 25 insertions, 2 deletions
diff --git a/dom/base/nsContentPolicyUtils.h b/dom/base/nsContentPolicyUtils.h index ed0544226..f530f9be9 100644 --- a/dom/base/nsContentPolicyUtils.h +++ b/dom/base/nsContentPolicyUtils.h @@ -115,6 +115,7 @@ NS_CP_ContentTypeName(uint32_t contentType) CASE_RETURN( TYPE_FETCH ); CASE_RETURN( TYPE_IMAGESET ); CASE_RETURN( TYPE_WEB_MANIFEST ); + CASE_RETURN( TYPE_SAVEAS_DOWNLOAD ); CASE_RETURN( TYPE_INTERNAL_SCRIPT ); CASE_RETURN( TYPE_INTERNAL_WORKER ); CASE_RETURN( TYPE_INTERNAL_SHARED_WORKER ); @@ -236,7 +237,7 @@ NS_CheckContentLoadPolicy(uint32_t contentType, CHECK_PRINCIPAL_AND_DATA(ShouldLoad); if (policyService) { CHECK_CONTENT_POLICY_WITH_SERVICE(ShouldLoad, policyService); - } +y CHECK_CONTENT_POLICY(ShouldLoad); } diff --git a/dom/base/nsIContentPolicyBase.idl b/dom/base/nsIContentPolicyBase.idl index 884e3d96d..0520ebacc 100644 --- a/dom/base/nsIContentPolicyBase.idl +++ b/dom/base/nsIContentPolicyBase.idl @@ -182,6 +182,11 @@ interface nsIContentPolicyBase : nsISupports const nsContentPolicyType TYPE_WEB_MANIFEST = 22; /** + * Indicates an save-as link download from the front-end code. + */ + const nsContentPolicyType TYPE_SAVEAS_DOWNLOAD = 43; + + /** * Indicates an internal constant for scripts loaded through script * elements. * diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index d16ba2d6a..975fe8742 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -269,6 +269,7 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 && nsIContentPolicy::TYPE_FETCH == 20 && nsIContentPolicy::TYPE_IMAGESET == 21 && nsIContentPolicy::TYPE_WEB_MANIFEST == 22 && + nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD == 43 && nsIContentPolicy::TYPE_INTERNAL_SCRIPT == 23 && nsIContentPolicy::TYPE_INTERNAL_WORKER == 24 && nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER == 25 && diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp index 85feabde3..b2631da6a 100644 --- a/dom/fetch/InternalRequest.cpp +++ b/dom/fetch/InternalRequest.cpp @@ -320,6 +320,9 @@ InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aConte case nsIContentPolicy::TYPE_WEB_MANIFEST: context = RequestContext::Manifest; break; + case nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD: + context = RequestContext::Internal; + break; default: MOZ_ASSERT(false, "Unhandled nsContentPolicyType value"); break; diff --git a/dom/fetch/InternalRequest.h b/dom/fetch/InternalRequest.h index 84ee0bf69..966490675 100644 --- a/dom/fetch/InternalRequest.h +++ b/dom/fetch/InternalRequest.h @@ -53,7 +53,7 @@ namespace dom { * image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD, TYPE_INTERNAL_IMAGE_FAVICON * imageset | TYPE_IMAGESET * import | Not supported by Gecko - * internal | TYPE_DOCUMENT, TYPE_XBL, TYPE_OTHER + * internal | TYPE_DOCUMENT, TYPE_XBL, TYPE_OTHER, TYPE_SAVEAS_DOWNLOAD * location | * manifest | TYPE_WEB_MANIFEST * object | TYPE_INTERNAL_OBJECT diff --git a/dom/security/nsContentSecurityManager.cpp b/dom/security/nsContentSecurityManager.cpp index f329aa723..4ee9b4877 100644 --- a/dom/security/nsContentSecurityManager.cpp +++ b/dom/security/nsContentSecurityManager.cpp @@ -471,6 +471,12 @@ DoContentSecurityChecks(nsIChannel* aChannel, nsILoadInfo* aLoadInfo) break; } + case nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD: { + mimeTypeGuess = EmptyCString(); + requestingContext = aLoadInfo->LoadingNode(); + break; + } + default: // nsIContentPolicy::TYPE_INVALID MOZ_ASSERT(false, "can not perform security check without a valid contentType"); diff --git a/dom/security/nsMixedContentBlocker.cpp b/dom/security/nsMixedContentBlocker.cpp index 7d50a43a3..c03628da0 100644 --- a/dom/security/nsMixedContentBlocker.cpp +++ b/dom/security/nsMixedContentBlocker.cpp @@ -468,6 +468,13 @@ nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect, *aDecision = ACCEPT; return NS_OK; + // Creating insecure connections for a save-as link download is acceptable. + // This download is completely disconnected from the docShell, but still + // using the same loading principal. + case TYPE_SAVEAS_DOWNLOAD: + *aDecision = ACCEPT; + return NS_OK; + // Static display content is considered moderate risk for mixed content so // these will be blocked according to the mixed display preference case TYPE_IMAGE: |