1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/base/LoadContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set sw=2 ts=8 et tw=80 : */ 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 LoadContext_h 1.11 +#define LoadContext_h 1.12 + 1.13 +#include "SerializedLoadContext.h" 1.14 +#include "mozilla/Attributes.h" 1.15 +#include "nsIWeakReferenceUtils.h" 1.16 +#include "mozilla/dom/Element.h" 1.17 +#include "nsIInterfaceRequestor.h" 1.18 +#include "nsILoadContext.h" 1.19 + 1.20 +class mozIApplication; 1.21 + 1.22 +namespace mozilla { 1.23 + 1.24 +/** 1.25 + * Class that provides nsILoadContext info in Parent process. Typically copied 1.26 + * from Child via SerializedLoadContext. 1.27 + * 1.28 + * Note: this is not the "normal" or "original" nsILoadContext. That is 1.29 + * typically provided by nsDocShell. This is only used when the original 1.30 + * docshell is in a different process and we need to copy certain values from 1.31 + * it. 1.32 + * 1.33 + * Note: we also generate a new nsILoadContext using LoadContext(uint32_t aAppId) 1.34 + * to separate the safebrowsing cookie. 1.35 + */ 1.36 + 1.37 +class LoadContext MOZ_FINAL : public nsILoadContext, 1.38 + public nsIInterfaceRequestor 1.39 +{ 1.40 +public: 1.41 + NS_DECL_ISUPPORTS 1.42 + NS_DECL_NSILOADCONTEXT 1.43 + NS_DECL_NSIINTERFACEREQUESTOR 1.44 + 1.45 + // AppId/inBrowser arguments override those in SerializedLoadContext provided 1.46 + // by child process. 1.47 + LoadContext(const IPC::SerializedLoadContext& aToCopy, 1.48 + dom::Element* aTopFrameElement, 1.49 + uint32_t aAppId, bool aInBrowser) 1.50 + : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) 1.51 + , mAppId(aAppId) 1.52 + , mIsContent(aToCopy.mIsContent) 1.53 + , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing) 1.54 + , mUseRemoteTabs(aToCopy.mUseRemoteTabs) 1.55 + , mIsInBrowserElement(aInBrowser) 1.56 +#ifdef DEBUG 1.57 + , mIsNotNull(aToCopy.mIsNotNull) 1.58 +#endif 1.59 + {} 1.60 + 1.61 + LoadContext(dom::Element* aTopFrameElement, 1.62 + uint32_t aAppId, 1.63 + bool aIsContent, 1.64 + bool aUsePrivateBrowsing, 1.65 + bool aUseRemoteTabs, 1.66 + bool aIsInBrowserElement) 1.67 + : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) 1.68 + , mAppId(aAppId) 1.69 + , mIsContent(aIsContent) 1.70 + , mUsePrivateBrowsing(aUsePrivateBrowsing) 1.71 + , mUseRemoteTabs(aUseRemoteTabs) 1.72 + , mIsInBrowserElement(aIsInBrowserElement) 1.73 +#ifdef DEBUG 1.74 + , mIsNotNull(true) 1.75 +#endif 1.76 + {} 1.77 + 1.78 + // Constructor taking reserved appId for the safebrowsing cookie. 1.79 + LoadContext(uint32_t aAppId) 1.80 + : mTopFrameElement(nullptr) 1.81 + , mAppId(aAppId) 1.82 + , mIsContent(false) 1.83 + , mUsePrivateBrowsing(false) 1.84 + , mUseRemoteTabs(false) 1.85 + , mIsInBrowserElement(false) 1.86 +#ifdef DEBUG 1.87 + , mIsNotNull(true) 1.88 +#endif 1.89 + {} 1.90 + 1.91 +private: 1.92 + nsWeakPtr mTopFrameElement; 1.93 + uint32_t mAppId; 1.94 + bool mIsContent; 1.95 + bool mUsePrivateBrowsing; 1.96 + bool mUseRemoteTabs; 1.97 + bool mIsInBrowserElement; 1.98 +#ifdef DEBUG 1.99 + bool mIsNotNull; 1.100 +#endif 1.101 +}; 1.102 + 1.103 +} // namespace mozilla 1.104 + 1.105 +#endif // LoadContext_h 1.106 +