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 "nsIPrivateBrowsingChannel.h"
11 #include "nsIWebSocketChannel.h"
15 SerializedLoadContext::SerializedLoadContext(nsILoadContext
* aLoadContext
)
17 , mUseRemoteTabs(false)
18 , mUseTrackingProtection(false)
23 SerializedLoadContext::SerializedLoadContext(nsIChannel
* aChannel
)
25 , mUseRemoteTabs(false)
26 , mUseTrackingProtection(false)
33 nsCOMPtr
<nsILoadContext
> loadContext
;
34 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
38 // Attempt to retrieve the private bit from the channel if it has been
40 bool isPrivate
= false;
41 bool isOverriden
= false;
42 nsCOMPtr
<nsIPrivateBrowsingChannel
> pbChannel
= do_QueryInterface(aChannel
);
44 NS_SUCCEEDED(pbChannel
->IsPrivateModeOverriden(&isPrivate
,
47 mIsPrivateBitValid
= true;
49 mOriginAttributes
.SyncAttributesWithPrivateBrowsing(isPrivate
);
53 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel
* aChannel
)
55 , mUseRemoteTabs(false)
56 , mUseTrackingProtection(false)
58 nsCOMPtr
<nsILoadContext
> loadContext
;
60 NS_QueryNotificationCallbacks(aChannel
, loadContext
);
66 SerializedLoadContext::Init(nsILoadContext
* aLoadContext
)
70 mIsPrivateBitValid
= true;
71 aLoadContext
->GetIsContent(&mIsContent
);
72 aLoadContext
->GetUseRemoteTabs(&mUseRemoteTabs
);
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 mUseTrackingProtection
= false;