|
|
|
|
| 177 |
#include "nsIWebBrowserPrint.h" |
177 |
#include "nsIWebBrowserPrint.h" |
| 178 |
#endif |
178 |
#endif |
| 179 |
|
179 |
|
| 180 |
#include "nsPluginError.h" |
180 |
#include "nsPluginError.h" |
| 181 |
#include "nsContentUtils.h" |
181 |
#include "nsContentUtils.h" |
| 182 |
#include "nsContentErrors.h" |
182 |
#include "nsContentErrors.h" |
| 183 |
#include "nsIChannelPolicy.h" |
183 |
#include "nsIChannelPolicy.h" |
| 184 |
#include "nsIContentSecurityPolicy.h" |
184 |
#include "nsIContentSecurityPolicy.h" |
|
|
185 |
#include "nsSandboxFlags.h" |
| 185 |
|
186 |
|
| 186 |
#include "nsXULAppAPI.h" |
187 |
#include "nsXULAppAPI.h" |
| 187 |
|
188 |
|
| 188 |
#include "nsDOMNavigationTiming.h" |
189 |
#include "nsDOMNavigationTiming.h" |
| 189 |
#include "nsITimedChannel.h" |
190 |
#include "nsITimedChannel.h" |
| 190 |
#include "mozilla/StartupTimeline.h" |
191 |
#include "mozilla/StartupTimeline.h" |
| 191 |
#include "nsIFrameMessageManager.h" |
192 |
#include "nsIFrameMessageManager.h" |
| 192 |
|
193 |
|
|
Lines 728-743
nsDocShell::nsDocShell():
|
Link Here
|
|---|
|
| 728 |
mBusyFlags(BUSY_FLAGS_NONE), |
729 |
mBusyFlags(BUSY_FLAGS_NONE), |
| 729 |
mAppType(nsIDocShell::APP_TYPE_UNKNOWN), |
730 |
mAppType(nsIDocShell::APP_TYPE_UNKNOWN), |
| 730 |
mLoadType(0), |
731 |
mLoadType(0), |
| 731 |
mMarginWidth(-1), |
732 |
mMarginWidth(-1), |
| 732 |
mMarginHeight(-1), |
733 |
mMarginHeight(-1), |
| 733 |
mItemType(typeContent), |
734 |
mItemType(typeContent), |
| 734 |
mPreviousTransIndex(-1), |
735 |
mPreviousTransIndex(-1), |
| 735 |
mLoadedTransIndex(-1), |
736 |
mLoadedTransIndex(-1), |
|
|
737 |
mSandboxFlags(0), |
| 736 |
mCreated(false), |
738 |
mCreated(false), |
| 737 |
mAllowSubframes(true), |
739 |
mAllowSubframes(true), |
| 738 |
mAllowPlugins(true), |
740 |
mAllowPlugins(true), |
| 739 |
mAllowJavascript(true), |
741 |
mAllowJavascript(true), |
| 740 |
mAllowMetaRedirects(true), |
742 |
mAllowMetaRedirects(true), |
| 741 |
mAllowImages(true), |
743 |
mAllowImages(true), |
| 742 |
mAllowDNSPrefetch(true), |
744 |
mAllowDNSPrefetch(true), |
| 743 |
mAllowWindowControl(true), |
745 |
mAllowWindowControl(true), |
|
Lines 2972-2987
nsDocShell::FindItemWithName(const PRUni
|
Link Here
|
|---|
|
| 2972 |
foundItem = nsnull; |
2974 |
foundItem = nsnull; |
| 2973 |
} |
2975 |
} |
| 2974 |
|
2976 |
|
| 2975 |
if (foundItem) { |
2977 |
if (foundItem) { |
| 2976 |
// We return foundItem here even if it's not an active |
2978 |
// We return foundItem here even if it's not an active |
| 2977 |
// item since all the names we've dealt with so far are |
2979 |
// item since all the names we've dealt with so far are |
| 2978 |
// special cases that we won't bother looking for further. |
2980 |
// special cases that we won't bother looking for further. |
| 2979 |
|
2981 |
|
|
|
2982 |
// If our document is sandboxed, we need to do some extra checks. |
| 2983 |
PRUint32 sandboxFlags = 0; |
| 2984 |
|
| 2985 |
nsCOMPtr<nsIDocument> doc = do_GetInterface(aOriginalRequestor); |
| 2986 |
|
| 2987 |
if (doc) { |
| 2988 |
sandboxFlags = doc->SandboxFlags(); |
| 2989 |
} |
| 2990 |
|
| 2991 |
if (sandboxFlags) { |
| 2992 |
nsCOMPtr<nsIDocShellTreeItem> root; |
| 2993 |
GetSameTypeRootTreeItem(getter_AddRefs(root)); |
| 2994 |
|
| 2995 |
// Is the found item not a top level browsing context and not ourself ? |
| 2996 |
nsCOMPtr<nsIDocShellTreeItem> selfAsItem = static_cast<nsIDocShellTreeItem *>(this); |
| 2997 |
if (foundItem != root && foundItem != selfAsItem) { |
| 2998 |
// Are we an ancestor of the foundItem ? |
| 2999 |
bool isAncestor = false; |
| 3000 |
|
| 3001 |
nsCOMPtr<nsIDocShellTreeItem> parentAsItem; |
| 3002 |
GetSameTypeParent(getter_AddRefs(parentAsItem)); |
| 3003 |
|
| 3004 |
while (parentAsItem) { |
| 3005 |
nsCOMPtr<nsIDocShellTreeItem> tmp; |
| 3006 |
parentAsItem->GetParent(getter_AddRefs(tmp)); |
| 3007 |
|
| 3008 |
if (tmp && tmp == selfAsItem) { |
| 3009 |
isAncestor = true; |
| 3010 |
break; |
| 3011 |
} |
| 3012 |
parentAsItem = tmp; |
| 3013 |
} |
| 3014 |
|
| 3015 |
if (!isAncestor) { |
| 3016 |
// No, we are not an ancestor and our document is |
| 3017 |
// sandboxed, we can't allow this. |
| 3018 |
foundItem = nsnull; |
| 3019 |
} |
| 3020 |
} else { |
| 3021 |
// Top level browsing context - is it an ancestor of ours ? |
| 3022 |
nsCOMPtr<nsIDocShellTreeItem> tmp; |
| 3023 |
GetSameTypeParent(getter_AddRefs(tmp)); |
| 3024 |
|
| 3025 |
while (tmp) { |
| 3026 |
if (tmp && tmp == foundItem) { |
| 3027 |
// This is an ancestor, and we are sandboxed. |
| 3028 |
// Unless allow-top-navigation is set, we can't allow this. |
| 3029 |
if (sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION) { |
| 3030 |
foundItem = nsnull; |
| 3031 |
} |
| 3032 |
break; |
| 3033 |
} |
| 3034 |
tmp->GetParent(getter_AddRefs(tmp)); |
| 3035 |
} |
| 3036 |
} |
| 3037 |
} |
| 3038 |
|
| 2980 |
foundItem.swap(*_retval); |
3039 |
foundItem.swap(*_retval); |
| 2981 |
return NS_OK; |
3040 |
return NS_OK; |
| 2982 |
} |
3041 |
} |
| 2983 |
} |
3042 |
} |
| 2984 |
|
3043 |
|
| 2985 |
// Keep looking |
3044 |
// Keep looking |
| 2986 |
|
3045 |
|
| 2987 |
// First we check our name. |
3046 |
// First we check our name. |
|
Lines 5012-5027
nsDocShell::SetIsAppTab(bool aIsAppTab)
|
Link Here
|
|---|
|
| 5012 |
NS_IMETHODIMP |
5071 |
NS_IMETHODIMP |
| 5013 |
nsDocShell::GetIsAppTab(bool *aIsAppTab) |
5072 |
nsDocShell::GetIsAppTab(bool *aIsAppTab) |
| 5014 |
{ |
5073 |
{ |
| 5015 |
*aIsAppTab = mIsAppTab; |
5074 |
*aIsAppTab = mIsAppTab; |
| 5016 |
return NS_OK; |
5075 |
return NS_OK; |
| 5017 |
} |
5076 |
} |
| 5018 |
|
5077 |
|
| 5019 |
NS_IMETHODIMP |
5078 |
NS_IMETHODIMP |
|
|
5079 |
nsDocShell::SetSandboxFlags(PRUint32 aSandboxFlags) |
| 5080 |
{ |
| 5081 |
mSandboxFlags = aSandboxFlags; |
| 5082 |
return NS_OK; |
| 5083 |
} |
| 5084 |
|
| 5085 |
NS_IMETHODIMP |
| 5086 |
nsDocShell::GetSandboxFlags(PRUint32 *aSandboxFlags) |
| 5087 |
{ |
| 5088 |
*aSandboxFlags = mSandboxFlags; |
| 5089 |
return NS_OK; |
| 5090 |
} |
| 5091 |
|
| 5092 |
NS_IMETHODIMP |
| 5020 |
nsDocShell::SetVisibility(bool aVisibility) |
5093 |
nsDocShell::SetVisibility(bool aVisibility) |
| 5021 |
{ |
5094 |
{ |
| 5022 |
if (!mContentViewer) |
5095 |
if (!mContentViewer) |
| 5023 |
return NS_OK; |
5096 |
return NS_OK; |
| 5024 |
if (aVisibility) { |
5097 |
if (aVisibility) { |
| 5025 |
mContentViewer->Show(); |
5098 |
mContentViewer->Show(); |
| 5026 |
} |
5099 |
} |
| 5027 |
else { |
5100 |
else { |
|
Lines 8250-8265
nsDocShell::InternalLoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 8250 |
nsCOMPtr<nsIDocShellTreeItem> targetItem; |
8323 |
nsCOMPtr<nsIDocShellTreeItem> targetItem; |
| 8251 |
FindItemWithName(aWindowTarget, nsnull, this, |
8324 |
FindItemWithName(aWindowTarget, nsnull, this, |
| 8252 |
getter_AddRefs(targetItem)); |
8325 |
getter_AddRefs(targetItem)); |
| 8253 |
|
8326 |
|
| 8254 |
nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem); |
8327 |
nsCOMPtr<nsIDocShell> targetDocShell = do_QueryInterface(targetItem); |
| 8255 |
|
8328 |
|
| 8256 |
bool isNewWindow = false; |
8329 |
bool isNewWindow = false; |
| 8257 |
if (!targetDocShell) { |
8330 |
if (!targetDocShell) { |
|
|
8331 |
// If the docshell's document is sandboxed and was trying to |
| 8332 |
// navigate/load a frame it wasn't allowed to access, the |
| 8333 |
// FindItemWithName above will have returned null for the target |
| 8334 |
// item - we don't want to actually open a new window in this case |
| 8335 |
// though. Check if we are sandboxed and bail out here if so. |
| 8336 |
NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE); |
| 8337 |
nsIDocument* doc = mContentViewer->GetDocument(); |
| 8338 |
PRUint32 sandboxFlags = 0; |
| 8339 |
sandboxFlags = doc->SandboxFlags(); |
| 8340 |
if (sandboxFlags & SANDBOXED_NAVIGATION) { |
| 8341 |
return NS_ERROR_FAILURE; |
| 8342 |
} |
| 8343 |
|
| 8258 |
nsCOMPtr<nsIDOMWindow> win = |
8344 |
nsCOMPtr<nsIDOMWindow> win = |
| 8259 |
do_GetInterface(GetAsSupports(this)); |
8345 |
do_GetInterface(GetAsSupports(this)); |
| 8260 |
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); |
8346 |
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); |
| 8261 |
|
8347 |
|
| 8262 |
nsDependentString name(aWindowTarget); |
8348 |
nsDependentString name(aWindowTarget); |
| 8263 |
nsCOMPtr<nsIDOMWindow> newWin; |
8349 |
nsCOMPtr<nsIDOMWindow> newWin; |
| 8264 |
rv = win->Open(EmptyString(), // URL to load |
8350 |
rv = win->Open(EmptyString(), // URL to load |
| 8265 |
name, // window name |
8351 |
name, // window name |
|
Lines 9061-9078
nsDocShell::DoURILoad(nsIURI * aURI,
|
Link Here
|
|---|
|
| 9061 |
} |
9147 |
} |
| 9062 |
// Set the referrer explicitly |
9148 |
// Set the referrer explicitly |
| 9063 |
if (aReferrerURI && aSendReferrer) { |
9149 |
if (aReferrerURI && aSendReferrer) { |
| 9064 |
// Referrer is currenly only set for link clicks here. |
9150 |
// Referrer is currenly only set for link clicks here. |
| 9065 |
httpChannel->SetReferrer(aReferrerURI); |
9151 |
httpChannel->SetReferrer(aReferrerURI); |
| 9066 |
} |
9152 |
} |
| 9067 |
} |
9153 |
} |
| 9068 |
|
9154 |
|
| 9069 |
nsCOMPtr<nsIPrincipal> ownerPrincipal(do_QueryInterface(aOwner)); |
9155 |
nsCOMPtr<nsIPrincipal> ownerPrincipal; |
| 9070 |
nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true); |
9156 |
|
|
|
9157 |
// If the content being loaded should be sandboxed with respect to origin |
| 9158 |
// we need to create a new null principal here, and then tell |
| 9159 |
// nsContentUtils::SetUpChannelOwner to force it to be set as the |
| 9160 |
// channel owner. |
| 9161 |
if (mSandboxFlags & SANDBOXED_ORIGIN) { |
| 9162 |
ownerPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1"); |
| 9163 |
} else { |
| 9164 |
// Not sandboxed - we allow the content to assume its natural owner. |
| 9165 |
ownerPrincipal = do_QueryInterface(aOwner); |
| 9166 |
} |
| 9167 |
|
| 9168 |
nsContentUtils::SetUpChannelOwner(ownerPrincipal, channel, aURI, true, |
| 9169 |
(mSandboxFlags & SANDBOXED_ORIGIN)); |
| 9071 |
|
9170 |
|
| 9072 |
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel); |
9171 |
nsCOMPtr<nsIScriptChannel> scriptChannel = do_QueryInterface(channel); |
| 9073 |
if (scriptChannel) { |
9172 |
if (scriptChannel) { |
| 9074 |
// Allow execution against our context if the principals match |
9173 |
// Allow execution against our context if the principals match |
| 9075 |
scriptChannel-> |
9174 |
scriptChannel-> |
| 9076 |
SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL); |
9175 |
SetExecutionPolicy(nsIScriptChannel::EXECUTE_NORMAL); |
| 9077 |
} |
9176 |
} |
| 9078 |
|
9177 |
|