Bug 1005225 - CSP in C++: SImplify shouldProcess for CSP (r=sstamm)
☠☠ backed out by 28dfed913436 ☠ ☠
authorChristoph Kerschbaumer <mozilla@christophkerschbaumer.com>
Mon, 07 Jul 2014 10:15:36 -0700
changeset 216173 61d41b381f30647351387bdbbd77066d546e45cd
parent 216172 e5e366ed6cf4e800d77804a9f20d61c7ef243882
child 216174 32a1fa1b28d5bb9b43bd745af6cbcb485ef4fb9e
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstamm
bugs1005225
milestone33.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 1005225 - CSP in C++: SImplify shouldProcess for CSP (r=sstamm)
content/base/public/nsIContentPolicy.idl
content/base/public/nsIContentSecurityPolicy.idl
content/base/src/nsCSPContext.cpp
content/base/src/nsCSPService.cpp
--- a/content/base/public/nsIContentPolicy.idl
+++ b/content/base/public/nsIContentPolicy.idl
@@ -19,17 +19,17 @@ typedef unsigned long nsContentPolicyTyp
  * Interface for content policy mechanism.  Implementations of this
  * interface can be used to control loading of various types of out-of-line
  * content, or processing of certain types of in-line content.
  *
  * WARNING: do not block the caller from shouldLoad or shouldProcess (e.g.,
  * by launching a dialog to prompt the user for something).
  */
 
-[scriptable,uuid(b6a71698-c117-441d-86b9-480cf06e3952)]
+[scriptable,uuid(3e923bf6-a974-4f3b-91c4-b4fd48b37732)]
 interface nsIContentPolicy : nsISupports
 {
   /**
    * Gecko/Firefox developers: Do not use TYPE_OTHER under any circumstances.
    *
    * Extension developers: Whenever it is reasonable, use one of the existing
    * content types. If none of the existing content types are right for
    * something you are doing, file a bug in the Core/DOM component that
--- a/content/base/public/nsIContentSecurityPolicy.idl
+++ b/content/base/public/nsIContentSecurityPolicy.idl
@@ -216,26 +216,14 @@ interface nsIContentSecurityPolicy : nsI
    */
   short shouldLoad(in nsContentPolicyType aContentType,
                    in nsIURI          aContentLocation,
                    in nsIURI          aRequestOrigin,
                    in nsISupports     aContext,
                    in ACString        aMimeTypeGuess,
                    in nsISupports     aExtra);
 
-  /**
-   * Delegate method called by the service when sub-elements of the protected
-   * document are being processed.  Given a bit of information about the request,
-   * decides whether or not the policy is satisfied.
-   */
-  short shouldProcess(in nsContentPolicyType   aContentType,
-                      in nsIURI          aContentLocation,
-                      in nsIURI          aRequestOrigin,
-                      in nsISupports     aContext,
-                      in ACString        aMimeType,
-                      in nsISupports     aExtra);
-
 %{ C++
 // nsIObserver topic to fire when the policy encounters a violation.
 #define CSP_VIOLATION_TOPIC "csp-on-violate-policy"
 %}
 
 };
--- a/content/base/src/nsCSPContext.cpp
+++ b/content/base/src/nsCSPContext.cpp
@@ -204,29 +204,16 @@ nsCSPContext::ShouldLoad(nsContentPolicy
   nsAutoCString spec;
   aContentLocation->GetSpec(spec);
   CSPCONTEXTLOG(("nsCSPContext::ShouldLoad, decision: %s, aContentLocation: %s", *outDecision ? "load" : "deny", spec.get()));
   }
 #endif
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsCSPContext::ShouldProcess(nsContentPolicyType aContentType,
-                            nsIURI*             aContentLocation,
-                            nsIURI*             aRequestOrigin,
-                            nsISupports*        aRequestContext,
-                            const nsACString&   aMimeType,
-                            nsISupports*        aExtra,
-                            int16_t*            outDecision)
-{
-  *outDecision = nsIContentPolicy::ACCEPT;
-  return NS_OK;
-}
-
 /* ===== nsISupports implementation ========== */
 
 NS_IMPL_CLASSINFO(nsCSPContext,
                   nullptr,
                   nsIClassInfo::MAIN_THREAD_ONLY,
                   NS_CSPCONTEXT_CID)
 
 NS_IMPL_ISUPPORTS_CI(nsCSPContext,
--- a/content/base/src/nsCSPService.cpp
+++ b/content/base/src/nsCSPService.cpp
@@ -213,66 +213,17 @@ CSPService::ShouldProcess(uint32_t      
                           const nsACString &aMimeTypeGuess,
                           nsISupports      *aExtra,
                           nsIPrincipal     *aRequestPrincipal,
                           int16_t          *aDecision)
 {
   if (!aContentLocation)
     return NS_ERROR_FAILURE;
 
-  // default decision is to accept the item
   *aDecision = nsIContentPolicy::ACCEPT;
-
-  // No need to continue processing if CSP is disabled
-  if (!sCSPEnabled)
-    return NS_OK;
-
-  // find the nsDocument that initiated this request and see if it has a
-  // CSP policy object
-  nsCOMPtr<nsINode> node(do_QueryInterface(aRequestContext));
-  nsCOMPtr<nsIPrincipal> principal;
-  nsCOMPtr<nsIContentSecurityPolicy> csp;
-  if (node) {
-    principal = node->NodePrincipal();
-    principal->GetCsp(getter_AddRefs(csp));
-
-    if (csp) {
-#ifdef PR_LOGGING
-      {
-        uint32_t numPolicies = 0;
-        nsresult rv = csp->GetPolicyCount(&numPolicies);
-        if (NS_SUCCEEDED(rv)) {
-          for (uint32_t i=0; i<numPolicies; i++) {
-            nsAutoString policy;
-            csp->GetPolicy(i, policy);
-            PR_LOG(gCspPRLog, PR_LOG_DEBUG,
-                   ("shouldProcess - document has policy[%d]: %s", i,
-                   NS_ConvertUTF16toUTF8(policy).get()));
-          }
-        }
-      }
-#endif
-      // obtain the enforcement decision
-      csp->ShouldProcess(aContentType,
-                         aContentLocation,
-                         aRequestOrigin,
-                         aRequestContext,
-                         aMimeTypeGuess,
-                         aExtra,
-                         aDecision);
-    }
-  }
-#ifdef PR_LOGGING
-  else {
-    nsAutoCString uriSpec;
-    aContentLocation->GetSpec(uriSpec);
-    PR_LOG(gCspPRLog, PR_LOG_DEBUG,
-           ("COULD NOT get nsINode for location: %s", uriSpec.get()));
-  }
-#endif
   return NS_OK;
 }
 
 /* nsIChannelEventSink implementation */
 NS_IMETHODIMP
 CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
                                    nsIChannel *newChannel,
                                    uint32_t flags,