Bug 965413 part 6. Create an implementation of nsILoadInfo. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 10 Jul 2014 02:56:37 -0400
changeset 193203 c6791b67b3813d004a6e9adc62351b5a0ddc0228
parent 193202 970e43b1fab9ba798a9a72f0adac80be5f8515b4
child 193204 b53f72363f2c56b33356424f7a496e8595b72b82
push id46053
push userbzbarsky@mozilla.com
push dateThu, 10 Jul 2014 06:57:10 +0000
treeherdermozilla-inbound@99b306c69791 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs965413
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 965413 part 6. Create an implementation of nsILoadInfo. r=smaug
docshell/base/LoadInfo.cpp
docshell/base/LoadInfo.h
docshell/base/moz.build
new file mode 100644
--- /dev/null
+++ b/docshell/base/LoadInfo.cpp
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et tw=80 : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/LoadInfo.h"
+
+#include "mozilla/Assertions.h"
+#include "nsISupportsImpl.h"
+#include "nsISupportsUtils.h"
+
+namespace mozilla {
+
+LoadInfo::LoadInfo(nsIPrincipal* aPrincipal,
+                   InheritType aInheritPrincipal,
+                   SandboxType aSandboxed)
+  : mPrincipal(aPrincipal)
+  , mInheritPrincipal(aInheritPrincipal == eInheritPrincipal &&
+                      aSandboxed != eSandboxed)
+  , mSandboxed(aSandboxed == eSandboxed)
+{
+  MOZ_ASSERT(aPrincipal);
+}
+
+LoadInfo::~LoadInfo()
+{
+}
+
+NS_IMPL_ISUPPORTS(LoadInfo, nsILoadInfo)
+
+NS_IMETHODIMP
+LoadInfo::GetLoadingPrincipal(nsIPrincipal** aPrincipal)
+{
+  NS_ADDREF(*aPrincipal = mPrincipal);
+  return NS_OK;
+}
+
+nsIPrincipal*
+LoadInfo::LoadingPrincipal()
+{
+  return mPrincipal;
+}
+
+NS_IMETHODIMP
+LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
+{
+  *aInheritPrincipal = mInheritPrincipal;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
+{
+  *aLoadingSandboxed = mSandboxed;
+  return NS_OK;
+}
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/docshell/base/LoadInfo.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=8 et tw=80 : */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_LoadInfo_h
+#define mozilla_LoadInfo_h
+
+#include "nsIPrincipal.h"
+#include "nsILoadInfo.h"
+
+namespace mozilla {
+
+/**
+ * Class that provides an nsILoadInfo implementation.
+ */
+class LoadInfo MOZ_FINAL : public nsILoadInfo
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSILOADINFO
+
+  enum InheritType
+  {
+    eInheritPrincipal,
+    eDontInheritPrincipal
+  };
+
+  enum SandboxType
+  {
+    eSandboxed,
+    eNotSandboxed
+  };
+
+  // aPrincipal MUST NOT BE NULL.  If aSandboxed is eSandboxed, the
+  // value passed for aInheritPrincipal will be ignored and
+  // eDontInheritPrincipal will be used instead.
+  LoadInfo(nsIPrincipal* aPrincipal,
+           InheritType aInheritPrincipal,
+           SandboxType aSandboxed);
+
+private:
+  ~LoadInfo();
+
+  nsCOMPtr<nsIPrincipal> mPrincipal;
+  bool mInheritPrincipal;
+  bool mSandboxed;
+};
+
+} // namespace mozilla
+
+#endif // mozilla_LoadInfo_h
+
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -41,20 +41,22 @@ EXPORTS += [
     'nsIScrollObserver.h',
     'nsIWebShellServices.h',
     'SerializedLoadContext.h',
 ]
 
 EXPORTS.mozilla += [
     'IHistory.h',
     'LoadContext.h',
+    'LoadInfo.h',
 ]
 
 UNIFIED_SOURCES += [
     'LoadContext.cpp',
+    'LoadInfo.cpp',
     'nsAboutRedirector.cpp',
     'nsDefaultURIFixup.cpp',
     'nsDocShellEditorData.cpp',
     'nsDocShellEnumerator.cpp',
     'nsDocShellLoadInfo.cpp',
     'nsDocShellTransferableHooks.cpp',
     'nsDownloadHistory.cpp',
     'nsDSURIContentListener.cpp',