content/xul/templates/src/nsXULContentUtils.h

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 /*
     8   A package of routines shared by the XUL content code.
    10  */
    12 #ifndef nsXULContentUtils_h__
    13 #define nsXULContentUtils_h__
    15 #include "nsISupports.h"
    17 class nsIAtom;
    18 class nsIContent;
    19 class nsIDocument;
    20 class nsIDOMNodeList;
    21 class nsIRDFNode;
    22 class nsCString;
    23 class nsString;
    24 class nsIRDFResource;
    25 class nsIRDFLiteral;
    26 class nsIRDFService;
    27 class nsIDateTimeFormat;
    28 class nsICollation;
    30 // errors to pass to LogTemplateError
    31 #define ERROR_TEMPLATE_INVALID_QUERYPROCESSOR                           \
    32         "querytype attribute doesn't specify a valid query processor"
    33 #define ERROR_TEMPLATE_INVALID_QUERYSET                                 \
    34         "unexpected <queryset> element"
    35 #define ERROR_TEMPLATE_NO_MEMBERVAR                                     \
    36         "no member variable found. Action body should have an element with uri attribute"
    37 #define ERROR_TEMPLATE_WHERE_NO_SUBJECT                                 \
    38         "<where> element is missing a subject attribute"
    39 #define ERROR_TEMPLATE_WHERE_NO_RELATION                                \
    40         "<where> element is missing a rel attribute"
    41 #define ERROR_TEMPLATE_WHERE_NO_VALUE                                   \
    42         "<where> element is missing a value attribute"
    43 #define ERROR_TEMPLATE_WHERE_NO_VAR                                     \
    44         "<where> element must have at least one variable as a subject or value"
    45 #define ERROR_TEMPLATE_BINDING_BAD_SUBJECT                              \
    46         "<binding> requires a variable for its subject attribute"
    47 #define ERROR_TEMPLATE_BINDING_BAD_PREDICATE                            \
    48         "<binding> element is missing a predicate attribute"
    49 #define ERROR_TEMPLATE_BINDING_BAD_OBJECT                               \
    50         "<binding> requires a variable for its object attribute"
    51 #define ERROR_TEMPLATE_CONTENT_NOT_FIRST                                \
    52         "expected <content> to be first"
    53 #define ERROR_TEMPLATE_MEMBER_NOCONTAINERVAR                            \
    54         "<member> requires a variable for its container attribute"
    55 #define ERROR_TEMPLATE_MEMBER_NOCHILDVAR                                \
    56         "<member> requires a variable for its child attribute"
    57 #define ERROR_TEMPLATE_TRIPLE_NO_VAR                                    \
    58         "<triple> should have at least one variable as a subject or object"
    59 #define ERROR_TEMPLATE_TRIPLE_BAD_SUBJECT                               \
    60         "<triple> requires a variable for its subject attribute"
    61 #define ERROR_TEMPLATE_TRIPLE_BAD_PREDICATE                             \
    62         "<triple> should have a non-variable value as a predicate"
    63 #define ERROR_TEMPLATE_TRIPLE_BAD_OBJECT                                \
    64         "<triple> requires a variable for its object attribute"
    65 #define ERROR_TEMPLATE_MEMBER_UNBOUND                                   \
    66         "neither container or child variables of <member> has a value"
    67 #define ERROR_TEMPLATE_TRIPLE_UNBOUND                                   \
    68         "neither subject or object variables of <triple> has a value"
    69 #define ERROR_TEMPLATE_BAD_XPATH                                        \
    70         "XPath expression in query could not be parsed"
    71 #define ERROR_TEMPLATE_BAD_ASSIGN_XPATH                                 \
    72         "XPath expression in <assign> could not be parsed"
    73 #define ERROR_TEMPLATE_BAD_BINDING_XPATH                                \
    74         "XPath expression in <binding> could not be parsed"
    75 #define ERROR_TEMPLATE_STORAGE_BAD_URI                                  \
    76         "only profile: or file URI are allowed"
    77 #define ERROR_TEMPLATE_STORAGE_CANNOT_OPEN_DATABASE                     \
    78         "cannot open given database"
    79 #define ERROR_TEMPLATE_STORAGE_BAD_QUERY                                \
    80         "syntax error in the SQL query"
    81 #define ERROR_TEMPLATE_STORAGE_UNKNOWN_QUERY_PARAMETER                   \
    82         "the given named parameter is unknown in the SQL query"
    83 #define ERROR_TEMPLATE_STORAGE_WRONG_TYPE_QUERY_PARAMETER               \
    84         "the type of a query parameter is wrong"
    85 #define ERROR_TEMPLATE_STORAGE_QUERY_PARAMETER_NOT_BOUND                \
    86         "a query parameter cannot be bound to the SQL query"
    88 class nsXULContentUtils
    89 {
    90 protected:
    91     static nsIRDFService* gRDF;
    92     static nsIDateTimeFormat* gFormat;
    93     static nsICollation *gCollation;
    95     static bool gDisableXULCache;
    97     static int
    98     DisableXULCacheChangedCallback(const char* aPrefName, void* aClosure);
   100 public:
   101     static nsresult
   102     Init();
   104     static nsresult
   105     Finish();
   107     static nsresult
   108     FindChildByTag(nsIContent *aElement,
   109                    int32_t aNameSpaceID,
   110                    nsIAtom* aTag,
   111                    nsIContent **aResult);
   113     static nsresult
   114     FindChildByResource(nsIContent* aElement,
   115                         nsIRDFResource* aResource,
   116                         nsIContent** aResult);
   118     static nsresult
   119     GetElementResource(nsIContent* aElement, nsIRDFResource** aResult);
   121     static nsresult
   122     GetTextForNode(nsIRDFNode* aNode, nsAString& aResult);
   124     /**
   125      * Construct a URI from the element ID given.  This uses aElement as the
   126      * ref and aDocument's document URI as the base.  If aDocument's document
   127      * URI does not support refs, this will throw NS_ERROR_NOT_AVAILABLE.
   128      */
   129     static nsresult
   130     MakeElementURI(nsIDocument* aDocument, const nsAString& aElementID, nsCString& aURI);
   132     static nsresult
   133     MakeElementResource(nsIDocument* aDocument, const nsAString& aElementID, nsIRDFResource** aResult);
   135     /**
   136      * Extract the element ID from aURI.  Note that aURI must be an absolute
   137      * URI string in UTF8; the element ID is the ref from the URI.  If the
   138      * scheme does not support refs, then the ID will be empty.
   139      */
   140     static nsresult
   141     MakeElementID(nsIDocument* aDocument, const nsACString& aURI, nsAString& aElementID);
   143     static nsresult
   144     GetResource(int32_t aNameSpaceID, nsIAtom* aAttribute, nsIRDFResource** aResult);
   146     static nsresult
   147     GetResource(int32_t aNameSpaceID, const nsAString& aAttribute, nsIRDFResource** aResult);
   149     static nsresult
   150     SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElement);
   152     /**
   153      * Log a message to the error console
   154      */
   155     static void
   156     LogTemplateError(const char* aMsg);
   158     static nsIRDFService*
   159     RDFService()
   160     {
   161         return gRDF;
   162     }
   164     static nsICollation*
   165     GetCollation();
   167 #define XUL_RESOURCE(ident, uri) static nsIRDFResource* ident
   168 #define XUL_LITERAL(ident, val)  static nsIRDFLiteral*  ident
   169 #include "nsXULResourceList.h"
   170 #undef XUL_RESOURCE
   171 #undef XUL_LITERAL
   172 };
   174 #endif // nsXULContentUtils_h__

mercurial