1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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 "nsILoadContext.h"
11 #include "nsIPrivateBrowsingChannel.h"
12 #include "nsIWebSocketChannel.h"
16 SerializedLoadContext::SerializedLoadContext(nsILoadContext
* aLoadContext
)
18 mUseRemoteTabs(false),
19 mUseRemoteSubframes(false),
20 mUseTrackingProtection(false) {
24 SerializedLoadContext::SerializedLoadContext(nsIChannel
* aChannel
)
26 mUseRemoteTabs(false),
27 mUseRemoteSubframes(false),
28 mUseTrackingProtection(false) {
34 nsCOMPtr
<nsILoadContext
> loadContext
;
35 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
39 // Attempt to retrieve the private bit from the channel if it has been
41 bool isPrivate
= false;
42 bool isOverriden
= false;
43 nsCOMPtr
<nsIPrivateBrowsingChannel
> pbChannel
= do_QueryInterface(aChannel
);
46 pbChannel
->IsPrivateModeOverriden(&isPrivate
, &isOverriden
)) &&
48 mIsPrivateBitValid
= true;
50 mOriginAttributes
.SyncAttributesWithPrivateBrowsing(isPrivate
);
54 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel
* aChannel
)
56 mUseRemoteTabs(false),
57 mUseRemoteSubframes(false),
58 mUseTrackingProtection(false) {
59 nsCOMPtr
<nsILoadContext
> loadContext
;
61 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
66 void SerializedLoadContext::Init(nsILoadContext
* aLoadContext
) {
69 mIsPrivateBitValid
= true;
70 aLoadContext
->GetIsContent(&mIsContent
);
71 aLoadContext
->GetUseRemoteTabs(&mUseRemoteTabs
);
72 aLoadContext
->GetUseRemoteSubframes(&mUseRemoteSubframes
);
73 aLoadContext
->GetUseTrackingProtection(&mUseTrackingProtection
);
74 aLoadContext
->GetOriginAttributes(mOriginAttributes
);
77 mIsPrivateBitValid
= false;
78 // none of below values really matter when mIsNotNull == false:
79 // we won't be GetInterfaced to nsILoadContext
81 mUseRemoteTabs
= false;
82 mUseRemoteSubframes
= false;
83 mUseTrackingProtection
= false;