docshell/base/nsDSURIContentListener.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/base/nsDSURIContentListener.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsDSURIContentListener_h__
    1.11 +#define nsDSURIContentListener_h__
    1.12 +
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsIURIContentListener.h"
    1.15 +#include "nsWeakReference.h"
    1.16 +
    1.17 +class nsDocShell;
    1.18 +class nsIWebNavigationInfo;
    1.19 +class nsIHttpChannel;
    1.20 +class nsAString;
    1.21 +
    1.22 +class nsDSURIContentListener :
    1.23 +    public nsIURIContentListener,
    1.24 +    public nsSupportsWeakReference
    1.25 +
    1.26 +{
    1.27 +friend class nsDocShell;
    1.28 +public:
    1.29 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.30 +    NS_DECL_NSIURICONTENTLISTENER
    1.31 +
    1.32 +    nsresult Init();
    1.33 +
    1.34 +protected:
    1.35 +    nsDSURIContentListener(nsDocShell* aDocShell);
    1.36 +    virtual ~nsDSURIContentListener();
    1.37 +
    1.38 +    void DropDocShellreference() {
    1.39 +        mDocShell = nullptr;
    1.40 +    }
    1.41 +
    1.42 +    // Determine if X-Frame-Options allows content to be framed
    1.43 +    // as a subdocument
    1.44 +    bool CheckFrameOptions(nsIRequest* request);
    1.45 +    bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel,
    1.46 +                                    const nsAString& policy);
    1.47 +
    1.48 +    enum XFOHeader {
    1.49 +      eDENY,
    1.50 +      eSAMEORIGIN,
    1.51 +      eALLOWFROM
    1.52 +    };
    1.53 +
    1.54 +    void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
    1.55 +                            nsIURI* aThisURI,
    1.56 +                            XFOHeader aHeader);
    1.57 +protected:
    1.58 +    nsDocShell*                      mDocShell;
    1.59 +
    1.60 +    // Store the parent listener in either of these depending on
    1.61 +    // if supports weak references or not. Proper weak refs are
    1.62 +    // preferred and encouraged!
    1.63 +    nsWeakPtr                        mWeakParentContentListener;
    1.64 +    nsIURIContentListener*           mParentContentListener;
    1.65 +
    1.66 +    nsCOMPtr<nsIWebNavigationInfo>   mNavInfo;
    1.67 +};
    1.68 +
    1.69 +#endif /* nsDSURIContentListener_h__ */

mercurial