docshell/base/LoadContext.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set sw=2 ts=8 et tw=80 : */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef LoadContext_h
     8 #define LoadContext_h
    10 #include "SerializedLoadContext.h"
    11 #include "mozilla/Attributes.h"
    12 #include "nsIWeakReferenceUtils.h"
    13 #include "mozilla/dom/Element.h"
    14 #include "nsIInterfaceRequestor.h"
    15 #include "nsILoadContext.h"
    17 class mozIApplication;
    19 namespace mozilla {
    21 /**
    22  * Class that provides nsILoadContext info in Parent process.  Typically copied
    23  * from Child via SerializedLoadContext.
    24  *
    25  * Note: this is not the "normal" or "original" nsILoadContext.  That is
    26  * typically provided by nsDocShell.  This is only used when the original
    27  * docshell is in a different process and we need to copy certain values from
    28  * it.
    29  *
    30  * Note: we also generate a new nsILoadContext using LoadContext(uint32_t aAppId)
    31  * to separate the safebrowsing cookie.
    32  */
    34 class LoadContext MOZ_FINAL : public nsILoadContext,
    35                               public nsIInterfaceRequestor
    36 {
    37 public:
    38   NS_DECL_ISUPPORTS
    39   NS_DECL_NSILOADCONTEXT
    40   NS_DECL_NSIINTERFACEREQUESTOR
    42   // AppId/inBrowser arguments override those in SerializedLoadContext provided
    43   // by child process.
    44   LoadContext(const IPC::SerializedLoadContext& aToCopy,
    45               dom::Element* aTopFrameElement,
    46               uint32_t aAppId, bool aInBrowser)
    47     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
    48     , mAppId(aAppId)
    49     , mIsContent(aToCopy.mIsContent)
    50     , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
    51     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
    52     , mIsInBrowserElement(aInBrowser)
    53 #ifdef DEBUG
    54     , mIsNotNull(aToCopy.mIsNotNull)
    55 #endif
    56   {}
    58   LoadContext(dom::Element* aTopFrameElement,
    59               uint32_t aAppId,
    60               bool aIsContent,
    61               bool aUsePrivateBrowsing,
    62               bool aUseRemoteTabs,
    63               bool aIsInBrowserElement)
    64     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
    65     , mAppId(aAppId)
    66     , mIsContent(aIsContent)
    67     , mUsePrivateBrowsing(aUsePrivateBrowsing)
    68     , mUseRemoteTabs(aUseRemoteTabs)
    69     , mIsInBrowserElement(aIsInBrowserElement)
    70 #ifdef DEBUG
    71     , mIsNotNull(true)
    72 #endif
    73   {}
    75   // Constructor taking reserved appId for the safebrowsing cookie.
    76   LoadContext(uint32_t aAppId)
    77     : mTopFrameElement(nullptr)
    78     , mAppId(aAppId)
    79     , mIsContent(false)
    80     , mUsePrivateBrowsing(false)
    81     , mUseRemoteTabs(false)
    82     , mIsInBrowserElement(false)
    83 #ifdef DEBUG
    84     , mIsNotNull(true)
    85 #endif
    86   {}
    88 private:
    89   nsWeakPtr     mTopFrameElement;
    90   uint32_t      mAppId;
    91   bool          mIsContent;
    92   bool          mUsePrivateBrowsing;
    93   bool          mUseRemoteTabs;
    94   bool          mIsInBrowserElement;
    95 #ifdef DEBUG
    96   bool          mIsNotNull;
    97 #endif
    98 };
   100 } // namespace mozilla
   102 #endif // LoadContext_h

mercurial