docshell/base/SerializedLoadContext.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set sw=2 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "SerializedLoadContext.h"
michael@0 8 #include "nsNetUtil.h"
michael@0 9 #include "nsIChannel.h"
michael@0 10 #include "nsIWebSocketChannel.h"
michael@0 11
michael@0 12 namespace IPC {
michael@0 13
michael@0 14 SerializedLoadContext::SerializedLoadContext(nsILoadContext* aLoadContext)
michael@0 15 {
michael@0 16 Init(aLoadContext);
michael@0 17 }
michael@0 18
michael@0 19 SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
michael@0 20 {
michael@0 21 if (!aChannel) {
michael@0 22 Init(nullptr);
michael@0 23 return;
michael@0 24 }
michael@0 25
michael@0 26 nsCOMPtr<nsILoadContext> loadContext;
michael@0 27 NS_QueryNotificationCallbacks(aChannel, loadContext);
michael@0 28 Init(loadContext);
michael@0 29
michael@0 30 if (!loadContext) {
michael@0 31 // Attempt to retrieve the private bit from the channel if it has been
michael@0 32 // overriden.
michael@0 33 bool isPrivate = false;
michael@0 34 bool isOverriden = false;
michael@0 35 nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
michael@0 36 if (pbChannel &&
michael@0 37 NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) &&
michael@0 38 isOverriden) {
michael@0 39 mUsePrivateBrowsing = isPrivate;
michael@0 40 mIsPrivateBitValid = true;
michael@0 41 }
michael@0 42 }
michael@0 43 }
michael@0 44
michael@0 45 SerializedLoadContext::SerializedLoadContext(nsIWebSocketChannel* aChannel)
michael@0 46 {
michael@0 47 nsCOMPtr<nsILoadContext> loadContext;
michael@0 48 if (aChannel) {
michael@0 49 NS_QueryNotificationCallbacks(aChannel, loadContext);
michael@0 50 }
michael@0 51 Init(loadContext);
michael@0 52 }
michael@0 53
michael@0 54 void
michael@0 55 SerializedLoadContext::Init(nsILoadContext* aLoadContext)
michael@0 56 {
michael@0 57 if (aLoadContext) {
michael@0 58 mIsNotNull = true;
michael@0 59 mIsPrivateBitValid = true;
michael@0 60 aLoadContext->GetIsContent(&mIsContent);
michael@0 61 aLoadContext->GetUsePrivateBrowsing(&mUsePrivateBrowsing);
michael@0 62 aLoadContext->GetUseRemoteTabs(&mUseRemoteTabs);
michael@0 63 aLoadContext->GetAppId(&mAppId);
michael@0 64 aLoadContext->GetIsInBrowserElement(&mIsInBrowserElement);
michael@0 65 } else {
michael@0 66 mIsNotNull = false;
michael@0 67 mIsPrivateBitValid = false;
michael@0 68 // none of below values really matter when mIsNotNull == false:
michael@0 69 // we won't be GetInterfaced to nsILoadContext
michael@0 70 mIsContent = true;
michael@0 71 mUsePrivateBrowsing = false;
michael@0 72 mUseRemoteTabs = false;
michael@0 73 mAppId = 0;
michael@0 74 mIsInBrowserElement = false;
michael@0 75 }
michael@0 76 }
michael@0 77
michael@0 78 } // namespace IPC
michael@0 79

mercurial