Bumping manifests a=b2g-bump
[gecko.git] / docshell / base / SerializedLoadContext.cpp
blobff61184b6c2a25ec49542bf1be9856c095bce0d9
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"
8 #include "nsNetUtil.h"
9 #include "nsIChannel.h"
10 #include "nsIWebSocketChannel.h"
12 namespace IPC {
14 SerializedLoadContext::SerializedLoadContext(nsILoadContext* aLoadContext)
16 Init(aLoadContext);
19 SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
21 if (!aChannel) {
22 Init(nullptr);
23 return;
26 nsCOMPtr<nsILoadContext> loadContext;
27 NS_QueryNotificationCallbacks(aChannel, loadContext);
28 Init(loadContext);
30 if (!loadContext) {
31 // Attempt to retrieve the private bit from the channel if it has been
32 // overriden.
33 bool isPrivate = false;
34 bool isOverriden = false;
35 nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
36 if (pbChannel &&
37 NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) &&
38 isOverriden) {
39 mUsePrivateBrowsing = isPrivate;
40 mIsPrivateBitValid = true;
45 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
47 nsCOMPtr<nsILoadContext> loadContext;
48 if (aChannel) {
49 NS_QueryNotificationCallbacks(aChannel, loadContext);
51 Init(loadContext);
54 void
55 SerializedLoadContext::Init(nsILoadContext* aLoadContext)
57 if (aLoadContext) {
58 mIsNotNull = true;
59 mIsPrivateBitValid = true;
60 aLoadContext->GetIsContent(&mIsContent);
61 aLoadContext->GetUsePrivateBrowsing(&mUsePrivateBrowsing);
62 aLoadContext->GetUseRemoteTabs(&mUseRemoteTabs);
63 aLoadContext->GetAppId(&mAppId);
64 aLoadContext->GetIsInBrowserElement(&mIsInBrowserElement);
65 } else {
66 mIsNotNull = false;
67 mIsPrivateBitValid = false;
68 // none of below values really matter when mIsNotNull == false:
69 // we won't be GetInterfaced to nsILoadContext
70 mIsContent = true;
71 mUsePrivateBrowsing = false;
72 mUseRemoteTabs = false;
73 mAppId = 0;
74 mIsInBrowserElement = false;
78 } // namespace IPC