Line data Source code
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/. */
6 :
7 : #include "nsOpenURIInFrameParams.h"
8 : #include "mozilla/BasePrincipal.h"
9 : #include "mozilla/dom/ToJSValue.h"
10 :
11 0 : NS_IMPL_ISUPPORTS(nsOpenURIInFrameParams, nsIOpenURIInFrameParams)
12 :
13 0 : nsOpenURIInFrameParams::nsOpenURIInFrameParams(const mozilla::OriginAttributes& aOriginAttributes)
14 0 : : mOpenerOriginAttributes(aOriginAttributes)
15 : {
16 0 : }
17 :
18 0 : nsOpenURIInFrameParams::~nsOpenURIInFrameParams() {
19 0 : }
20 :
21 : NS_IMETHODIMP
22 0 : nsOpenURIInFrameParams::GetReferrer(nsAString& aReferrer)
23 : {
24 0 : aReferrer = mReferrer;
25 0 : return NS_OK;
26 : }
27 :
28 : NS_IMETHODIMP
29 0 : nsOpenURIInFrameParams::SetReferrer(const nsAString& aReferrer)
30 : {
31 0 : mReferrer = aReferrer;
32 0 : return NS_OK;
33 : }
34 :
35 : NS_IMETHODIMP
36 0 : nsOpenURIInFrameParams::GetIsPrivate(bool* aIsPrivate)
37 : {
38 0 : NS_ENSURE_ARG_POINTER(aIsPrivate);
39 0 : *aIsPrivate = mOpenerOriginAttributes.mPrivateBrowsingId > 0;
40 0 : return NS_OK;
41 : }
42 :
43 : NS_IMETHODIMP
44 0 : nsOpenURIInFrameParams::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal)
45 : {
46 0 : NS_ADDREF(*aTriggeringPrincipal = mTriggeringPrincipal);
47 0 : return NS_OK;
48 : }
49 :
50 : NS_IMETHODIMP
51 0 : nsOpenURIInFrameParams::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
52 : {
53 0 : NS_ENSURE_TRUE(aTriggeringPrincipal, NS_ERROR_INVALID_ARG);
54 0 : mTriggeringPrincipal = aTriggeringPrincipal;
55 0 : return NS_OK;
56 : }
57 :
58 : NS_IMETHODIMP
59 0 : nsOpenURIInFrameParams::GetOpenerOriginAttributes(JSContext* aCx,
60 : JS::MutableHandle<JS::Value> aValue)
61 : {
62 0 : bool ok = ToJSValue(aCx, mOpenerOriginAttributes, aValue);
63 0 : NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
64 0 : return NS_OK;
65 : }
|