dom/xslt/xml/txXMLParser.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "txXMLParser.h"
     7 #include "txURIUtils.h"
     8 #include "txXPathTreeWalker.h"
    10 #include "nsIDocument.h"
    11 #include "nsIDOMDocument.h"
    12 #include "nsSyncLoadService.h"
    13 #include "nsNetUtil.h"
    14 #include "nsIPrincipal.h"
    16 nsresult
    17 txParseDocumentFromURI(const nsAString& aHref, const txXPathNode& aLoader,
    18                        nsAString& aErrMsg, txXPathNode** aResult)
    19 {
    20     NS_ENSURE_ARG_POINTER(aResult);
    21     *aResult = nullptr;
    22     nsCOMPtr<nsIURI> documentURI;
    23     nsresult rv = NS_NewURI(getter_AddRefs(documentURI), aHref);
    24     NS_ENSURE_SUCCESS(rv, rv);
    26     nsIDocument* loaderDocument = txXPathNativeNode::getDocument(aLoader);
    28     nsCOMPtr<nsILoadGroup> loadGroup = loaderDocument->GetDocumentLoadGroup();
    30     // For the system principal loaderUri will be null here, which is good
    31     // since that means that chrome documents can load any uri.
    33     // Raw pointer, we want the resulting txXPathNode to hold a reference to
    34     // the document.
    35     nsIDOMDocument* theDocument = nullptr;
    36     nsAutoSyncOperation sync(loaderDocument);
    37     rv = nsSyncLoadService::LoadDocument(documentURI,
    38                                          loaderDocument->NodePrincipal(),
    39                                          loadGroup, true, &theDocument);
    41     if (NS_FAILED(rv)) {
    42         aErrMsg.Append(NS_LITERAL_STRING("Document load of ") + 
    43                        aHref + NS_LITERAL_STRING(" failed."));
    44         return NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;
    45     }
    47     *aResult = txXPathNativeNode::createXPathNode(theDocument);
    48     if (!*aResult) {
    49         NS_RELEASE(theDocument);
    50         return NS_ERROR_FAILURE;
    51     }
    53     return NS_OK;
    54 }

mercurial