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 #include "SerializedLoadContext.h"
9 #include "nsIChannel.h"
10 #include "nsIWebSocketChannel.h"
14 SerializedLoadContext::SerializedLoadContext(nsILoadContext
* aLoadContext
)
19 SerializedLoadContext::SerializedLoadContext(nsIChannel
* aChannel
)
26 nsCOMPtr
<nsILoadContext
> loadContext
;
27 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
31 // Attempt to retrieve the private bit from the channel if it has been
33 bool isPrivate
= false;
34 bool isOverriden
= false;
35 nsCOMPtr
<nsIPrivateBrowsingChannel
> pbChannel
= do_QueryInterface(aChannel
);
37 NS_SUCCEEDED(pbChannel
->IsPrivateModeOverriden(&isPrivate
, &isOverriden
)) &&
39 mUsePrivateBrowsing
= isPrivate
;
40 mIsPrivateBitValid
= true;
45 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel
* aChannel
)
47 nsCOMPtr
<nsILoadContext
> loadContext
;
49 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
55 SerializedLoadContext::Init(nsILoadContext
* aLoadContext
)
59 mIsPrivateBitValid
= true;
60 aLoadContext
->GetIsContent(&mIsContent
);
61 aLoadContext
->GetUsePrivateBrowsing(&mUsePrivateBrowsing
);
62 aLoadContext
->GetUseRemoteTabs(&mUseRemoteTabs
);
63 aLoadContext
->GetAppId(&mAppId
);
64 aLoadContext
->GetIsInBrowserElement(&mIsInBrowserElement
);
67 mIsPrivateBitValid
= false;
68 // none of below values really matter when mIsNotNull == false:
69 // we won't be GetInterfaced to nsILoadContext
71 mUsePrivateBrowsing
= false;
72 mUseRemoteTabs
= false;
74 mIsInBrowserElement
= false;