|
|
|
Lines 727-742
nsDocShell::nsDocShell():
|
Link Here
|
|---|
|
| 727 |
mBusyFlags(BUSY_FLAGS_NONE), |
727 |
mBusyFlags(BUSY_FLAGS_NONE), |
| 728 |
mAppType(nsIDocShell::APP_TYPE_UNKNOWN), |
728 |
mAppType(nsIDocShell::APP_TYPE_UNKNOWN), |
| 729 |
mLoadType(0), |
729 |
mLoadType(0), |
| 730 |
mMarginWidth(-1), |
730 |
mMarginWidth(-1), |
| 731 |
mMarginHeight(-1), |
731 |
mMarginHeight(-1), |
| 732 |
mItemType(typeContent), |
732 |
mItemType(typeContent), |
| 733 |
mPreviousTransIndex(-1), |
733 |
mPreviousTransIndex(-1), |
| 734 |
mLoadedTransIndex(-1), |
734 |
mLoadedTransIndex(-1), |
|
|
735 |
mSandboxFlags(0), |
| 735 |
mCreated(false), |
736 |
mCreated(false), |
| 736 |
mAllowSubframes(true), |
737 |
mAllowSubframes(true), |
| 737 |
mAllowPlugins(true), |
738 |
mAllowPlugins(true), |
| 738 |
mAllowJavascript(true), |
739 |
mAllowJavascript(true), |
| 739 |
mAllowMetaRedirects(true), |
740 |
mAllowMetaRedirects(true), |
| 740 |
mAllowImages(true), |
741 |
mAllowImages(true), |
| 741 |
mAllowDNSPrefetch(true), |
742 |
mAllowDNSPrefetch(true), |
| 742 |
mAllowWindowControl(true), |
743 |
mAllowWindowControl(true), |
|
Lines 2922-2937
nsDocShell::FindItemWithName(const PRUni
|
Link Here
|
|---|
|
| 2922 |
foundItem = nsnull; |
2923 |
foundItem = nsnull; |
| 2923 |
} |
2924 |
} |
| 2924 |
|
2925 |
|
| 2925 |
if (foundItem) { |
2926 |
if (foundItem) { |
| 2926 |
// We return foundItem here even if it's not an active |
2927 |
// We return foundItem here even if it's not an active |
| 2927 |
// item since all the names we've dealt with so far are |
2928 |
// item since all the names we've dealt with so far are |
| 2928 |
// special cases that we won't bother looking for further. |
2929 |
// special cases that we won't bother looking for further. |
| 2929 |
|
2930 |
|
|
|
2931 |
// If our document is sandboxed, we need to do some extra checks. |
| 2932 |
PRUint32 sandboxFlags = 0; |
| 2933 |
|
| 2934 |
nsCOMPtr<nsIDocument> doc = do_GetInterface(aOriginalRequestor); |
| 2935 |
|
| 2936 |
if (doc) { |
| 2937 |
sandboxFlags = doc->SandboxFlags(); |
| 2938 |
} |
| 2939 |
|
| 2940 |
if (sandboxFlags) { |
| 2941 |
nsCOMPtr<nsIDocShellTreeItem> root; |
| 2942 |
GetSameTypeRootTreeItem(getter_AddRefs(root)); |
| 2943 |
|
| 2944 |
// Is the found item not a top level browsing context and not ourself ? |
| 2945 |
nsCOMPtr<nsIDocShellTreeItem> selfAsItem = static_cast<nsIDocShellTreeItem *>(this); |
| 2946 |
if (foundItem != root && foundItem != selfAsItem) { |
| 2947 |
// Are we an ancestor of the foundItem ? |
| 2948 |
bool isAncestor = false; |
| 2949 |
|
| 2950 |
nsCOMPtr<nsIDocShellTreeItem> parentAsItem; |
| 2951 |
GetSameTypeParent(getter_AddRefs(parentAsItem)); |
| 2952 |
|
| 2953 |
while (parentAsItem) { |
| 2954 |
nsCOMPtr<nsIDocShellTreeItem> tmp; |
| 2955 |
parentAsItem->GetParent(getter_AddRefs(tmp)); |
| 2956 |
|
| 2957 |
if (tmp && tmp == selfAsItem) { |
| 2958 |
isAncestor = true; |
| 2959 |
break; |
| 2960 |
} |
| 2961 |
parentAsItem = tmp; |
| 2962 |
} |
| 2963 |
|
| 2964 |
if (!isAncestor) { |
| 2965 |
// No, we are not an ancestor and our document is |
| 2966 |
// sandboxed, we can't allow this. |
| 2967 |
foundItem = nsnull; |
| 2968 |
} |
| 2969 |
} else { |
| 2970 |
// Top level browsing context - is it an ancestor of ours ? |
| 2971 |
nsCOMPtr<nsIDocShellTreeItem> tmp; |
| 2972 |
GetSameTypeParent(getter_AddRefs(tmp)); |
| 2973 |
|
| 2974 |
while (tmp) { |
| 2975 |
if (tmp && tmp == foundItem) { |
| 2976 |
// This is an ancestor, and we are sandboxed. |
| 2977 |
// Unless allow-top-navigation is set, we can't allow this. |
| 2978 |
if (sandboxFlags & nsIDocShell::SANDBOXED_TOPLEVEL_NAVIGATION) { |
| 2979 |
foundItem = nsnull; |
| 2980 |
} |
| 2981 |
break; |
| 2982 |
} |
| 2983 |
tmp->GetParent(getter_AddRefs(tmp)); |
| 2984 |
} |
| 2985 |
} |
| 2986 |
} |
| 2987 |
|
| 2930 |
foundItem.swap(*_retval); |
2988 |
foundItem.swap(*_retval); |
| 2931 |
return NS_OK; |
2989 |
return NS_OK; |
| 2932 |
} |
2990 |
} |
| 2933 |
} |
2991 |
} |
| 2934 |
|
2992 |
|
| 2935 |
// Keep looking |
2993 |
// Keep looking |
| 2936 |
|
2994 |
|
| 2937 |
// First we check our name. |
2995 |
// First we check our name. |
|
Lines 4958-4973
nsDocShell::SetIsAppTab(bool aIsAppTab)
|
Link Here
|
|---|
|
| 4958 |
NS_IMETHODIMP |
5016 |
NS_IMETHODIMP |
| 4959 |
nsDocShell::GetIsAppTab(bool *aIsAppTab) |
5017 |
nsDocShell::GetIsAppTab(bool *aIsAppTab) |
| 4960 |
{ |
5018 |
{ |
| 4961 |
*aIsAppTab = mIsAppTab; |
5019 |
*aIsAppTab = mIsAppTab; |
| 4962 |
return NS_OK; |
5020 |
return NS_OK; |
| 4963 |
} |
5021 |
} |
| 4964 |
|
5022 |
|
| 4965 |
NS_IMETHODIMP |
5023 |
NS_IMETHODIMP |
|
|
5024 |
nsDocShell::SetSandboxFlags(PRUint32 aSandboxFlags) |
| 5025 |
{ |
| 5026 |
mSandboxFlags = aSandboxFlags; |
| 5027 |
return NS_OK; |
| 5028 |
} |
| 5029 |
|
| 5030 |
NS_IMETHODIMP |
| 5031 |
nsDocShell::GetSandboxFlags(PRUint32 *aSandboxFlags) |
| 5032 |
{ |
| 5033 |
*aSandboxFlags = mSandboxFlags; |
| 5034 |
return NS_OK; |
| 5035 |
} |
| 5036 |
|
| 5037 |
NS_IMETHODIMP |
| 4966 |
nsDocShell::SetVisibility(bool aVisibility) |
5038 |
nsDocShell::SetVisibility(bool aVisibility) |
| 4967 |
{ |
5039 |
{ |
| 4968 |
if (!mContentViewer) |
5040 |
if (!mContentViewer) |
| 4969 |
return NS_OK; |
5041 |
return NS_OK; |
| 4970 |
if (aVisibility) { |
5042 |
if (aVisibility) { |
| 4971 |
mContentViewer->Show(); |
5043 |
mContentViewer->Show(); |
| 4972 |
} |
5044 |
} |
| 4973 |
else { |
5045 |
else { |
|
Lines 8147-8162
nsDocShell::InternalLoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 8147 |
nsCOMPtr<nsIDocShellTreeItem> targetItem; |
8219 |
nsCOMPtr<nsIDocShellTreeItem> targetItem; |
| 8148 |
FindItemWithName(aWindowTarget, nsnull, this, |
8220 |
FindItemWithName(aWindowTarget, nsnull, this, |
| 8149 |
getter_AddRefs(targetItem)); |
8221 |
getter_AddRefs(targetItem)); |
| 8150 |
|
8222 |
|
| 8151 |
nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem); |
8223 |
nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem); |
| 8152 |
|
8224 |
|
| 8153 |
bool isNewWindow = false; |
8225 |
bool isNewWindow = false; |
| 8154 |
if (!targetDocShell) { |
8226 |
if (!targetDocShell) { |
|
|
8227 |
// If the docshell's document is sandboxed and was trying to |
| 8228 |
// navigate/load a frame it wasn't allowed to access, the |
| 8229 |
// FindItemWithName above will have returned null for the target |
| 8230 |
// item - we don't want to actually open a new window in this case |
| 8231 |
// though. Check if we are sandboxed and bail out here if so. |
| 8232 |
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE); |
| 8233 |
nsIDocument* doc = mContentViewer->GetDocument(); |
| 8234 |
PRUint32 sandboxFlags = 0; |
| 8235 |
sandboxFlags = doc->SandboxFlags(); |
| 8236 |
if (sandboxFlags & nsIDocShell::SANDBOXED_NAVIGATION) { |
| 8237 |
return NS_ERROR_FAILURE; |
| 8238 |
} |
| 8239 |
|
| 8155 |
nsCOMPtr<nsIDOMWindow> win = |
8240 |
nsCOMPtr<nsIDOMWindow> win = |
| 8156 |
do_GetInterface(GetAsSupports(this)); |
8241 |
do_GetInterface(GetAsSupports(this)); |
| 8157 |
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); |
8242 |
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); |
| 8158 |
|
8243 |
|
| 8159 |
nsDependentString name(aWindowTarget); |
8244 |
nsDependentString name(aWindowTarget); |
| 8160 |
nsCOMPtr<nsIDOMWindow> newWin; |
8245 |
nsCOMPtr<nsIDOMWindow> newWin; |
| 8161 |
rv = win->Open(EmptyString(), // URL to load |
8246 |
rv = win->Open(EmptyString(), // URL to load |
| 8162 |
name, // window name |
8247 |
name, // window name |
|
Lines 8940-8957
nsDocShell::DoURILoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 8940 |
} |
9025 |
} |
| 8941 |
// Set the referrer explicitly |
9026 |
// Set the referrer explicitly |
| 8942 |
if (aReferrerURI && aSendReferrer) { |
9027 |
if (aReferrerURI && aSendReferrer) { |
| 8943 |
// Referrer is currenly only set for link clicks here. |
9028 |
// Referrer is currenly only set for link clicks here. |
| 8944 |
httpChannel->SetReferrer(aReferrerURI); |
9029 |
httpChannel->SetReferrer(aReferrerURI); |
| 8945 |
} |
9030 |
} |
| 8946 |
} |
9031 |
} |
| 8947 |
|
9032 |
|
| 8948 |
nsCOMPtr<nsIPrincipal> ownerPrincipal(do_QueryInterface(aOwner)); |
9033 |
nsCOMPtr<nsIPrincipal> ownerPrincipal; |
| 8949 |
nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true); |
9034 |
|
|
|
9035 |
// If the content being loaded should be sandboxed with respect to origin |
| 9036 |
// we need to create a new null principal here, and then tell |
| 9037 |
// nsContentUtils::SetUpChannelOwner to force it to be set as the |
| 9038 |
// channel owner. |
| 9039 |
if (mSandboxFlags & nsIDocShell::SANDBOXED_ORIGIN) { |
| 9040 |
ownerPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1"); |
| 9041 |
} else { |
| 9042 |
// Not sandboxed - we allow the content to assume its natural owner. |
| 9043 |
ownerPrincipal = do_QueryInterface(aOwner); |
| 9044 |
} |
| 9045 |
|
| 9046 |
nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true, |
| 9047 |
(mSandboxFlags & |
| 9048 |
nsIDocShell::SANDBOXED_ORIGIN)); |
| 8950 |
|
9049 |
|
| 8951 |
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel); |
9050 |
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel); |
| 8952 |
if (scriptChannel) { |
9051 |
if (scriptChannel) { |
| 8953 |
// Allow execution against our context if the principals match |
9052 |
// Allow execution against our context if the principals match |
| 8954 |
scriptChannel-> |
9053 |
scriptChannel-> |
| 8955 |
SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL); |
9054 |
SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL); |
| 8956 |
} |
9055 |
} |
| 8957 |
|
9056 |
|