forked from mirrors/gecko-dev
Bug 1513241: Update loadURI interface and pass a loadURIOptions dictionary from frontend to docshell loads. r=bz
This commit is contained in:
parent
76512d9aef
commit
fbb4bafd5c
10 changed files with 173 additions and 177 deletions
|
|
@ -58,6 +58,7 @@
|
|||
#include "mozilla/dom/TabGroup.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/ChildSHistory.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
|
||||
|
|
@ -3802,37 +3803,22 @@ nsDocShell::GotoIndex(int32_t aIndex) {
|
|||
return rootSH->LegacySHistory()->GotoIndex(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURI(const nsAString& aURI, uint32_t aLoadFlags,
|
||||
nsIURI* aReferringURI, nsIInputStream* aPostStream,
|
||||
nsIInputStream* aHeaderStream,
|
||||
nsIPrincipal* aTriggeringPrincipal) {
|
||||
if (mUseStrictSecurityChecks && !aTriggeringPrincipal) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return LoadURIWithOptions(aURI, aLoadFlags, aReferringURI, RP_Unset,
|
||||
aPostStream, aHeaderStream, nullptr,
|
||||
aTriggeringPrincipal);
|
||||
}
|
||||
nsresult nsDocShell::LoadURI(const nsAString& aURI,
|
||||
const LoadURIOptions& aLoadURIOptions) {
|
||||
uint32_t loadFlags = aLoadURIOptions.mLoadFlags;
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
||||
nsIURI* aReferringURI, uint32_t aReferrerPolicy,
|
||||
nsIInputStream* aPostStream,
|
||||
nsIInputStream* aHeaderStream, nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal) {
|
||||
NS_ASSERTION((aLoadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0,
|
||||
NS_ASSERTION((loadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0,
|
||||
"Unexpected flags");
|
||||
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIInputStream> postStream(aPostStream);
|
||||
nsCOMPtr<nsIInputStream> postData(aLoadURIOptions.mPostData);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Create a URI from our string; if that succeeds, we want to
|
||||
// change aLoadFlags to not include the ALLOW_THIRD_PARTY_FIXUP
|
||||
// change loadFlags to not include the ALLOW_THIRD_PARTY_FIXUP
|
||||
// flag.
|
||||
|
||||
NS_ConvertUTF16toUTF8 uriString(aURI);
|
||||
|
|
@ -3842,13 +3828,13 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
uriString.StripCRLF();
|
||||
NS_ENSURE_TRUE(!uriString.IsEmpty(), NS_ERROR_FAILURE);
|
||||
|
||||
if (mUseStrictSecurityChecks && !aTriggeringPrincipal) {
|
||||
if (mUseStrictSecurityChecks && !aLoadURIOptions.mTriggeringPrincipal) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(uri), uriString);
|
||||
if (uri) {
|
||||
aLoadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
loadFlags &= ~LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURIFixupInfo> fixupInfo;
|
||||
|
|
@ -3858,10 +3844,10 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
// if NS_NewURI returned a URI, because fixup handles nested URIs, etc
|
||||
// (things like view-source:mozilla.org for example).
|
||||
uint32_t fixupFlags = 0;
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
if (loadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
fixupFlags |= nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
|
||||
}
|
||||
if (aLoadFlags & LOAD_FLAGS_FIXUP_SCHEME_TYPOS) {
|
||||
if (loadFlags & LOAD_FLAGS_FIXUP_SCHEME_TYPOS) {
|
||||
fixupFlags |= nsIURIFixup::FIXUP_FLAG_FIX_SCHEME_TYPOS;
|
||||
}
|
||||
nsCOMPtr<nsIInputStream> fixupStream;
|
||||
|
|
@ -3878,10 +3864,10 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
// GetFixupURIInfo only returns a post data stream if it succeeded
|
||||
// and changed the URI, in which case we should override the
|
||||
// passed-in post data.
|
||||
postStream = fixupStream;
|
||||
postData = fixupStream;
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
if (loadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
|
||||
if (serv) {
|
||||
serv->NotifyObservers(fixupInfo, "keyword-uri-fixup",
|
||||
|
|
@ -3894,7 +3880,7 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
|
||||
if (NS_ERROR_MALFORMED_URI == rv) {
|
||||
if (DisplayLoadError(rv, uri, PromiseFlatString(aURI).get(), nullptr) &&
|
||||
(aLoadFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) {
|
||||
(loadFlags & LOAD_FLAGS_ERROR_LOAD_CHANGES_RV) != 0) {
|
||||
return NS_ERROR_LOAD_SHOWED_ERRORPAGE;
|
||||
}
|
||||
}
|
||||
|
|
@ -3904,21 +3890,21 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
}
|
||||
|
||||
PopupBlocker::PopupControlState popupState;
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_POPUPS) {
|
||||
if (loadFlags & LOAD_FLAGS_ALLOW_POPUPS) {
|
||||
popupState = PopupBlocker::openAllowed;
|
||||
aLoadFlags &= ~LOAD_FLAGS_ALLOW_POPUPS;
|
||||
loadFlags &= ~LOAD_FLAGS_ALLOW_POPUPS;
|
||||
} else {
|
||||
popupState = PopupBlocker::openOverridden;
|
||||
}
|
||||
nsAutoPopupStatePusher statePusher(popupState);
|
||||
|
||||
bool forceAllowDataURI = aLoadFlags & LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
bool forceAllowDataURI = loadFlags & LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
|
||||
// Don't pass certain flags that aren't needed and end up confusing
|
||||
// ConvertLoadTypeToDocShellInfoLoadType. We do need to ensure that they are
|
||||
// passed to LoadURI though, since it uses them.
|
||||
uint32_t extraFlags = (aLoadFlags & EXTRA_LOAD_FLAGS);
|
||||
aLoadFlags &= ~EXTRA_LOAD_FLAGS;
|
||||
uint32_t extraFlags = (loadFlags & EXTRA_LOAD_FLAGS);
|
||||
loadFlags &= ~EXTRA_LOAD_FLAGS;
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(uri);
|
||||
|
||||
|
|
@ -3926,21 +3912,22 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
* If the user "Disables Protection on This Page", we have to make sure to
|
||||
* remember the users decision when opening links in child tabs [Bug 906190]
|
||||
*/
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
|
||||
if (loadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
|
||||
loadState->SetLoadType(
|
||||
MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags));
|
||||
MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, loadFlags));
|
||||
} else {
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags));
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, loadFlags));
|
||||
}
|
||||
|
||||
loadState->SetLoadFlags(extraFlags);
|
||||
loadState->SetFirstParty(true);
|
||||
loadState->SetPostDataStream(postStream);
|
||||
loadState->SetReferrer(aReferringURI);
|
||||
loadState->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadState->SetHeadersStream(aHeaderStream);
|
||||
loadState->SetBaseURI(aBaseURI);
|
||||
loadState->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadState->SetPostDataStream(postData);
|
||||
loadState->SetReferrer(aLoadURIOptions.mReferrerURI);
|
||||
loadState->SetReferrerPolicy(
|
||||
(mozilla::net::ReferrerPolicy)aLoadURIOptions.mReferrerPolicy);
|
||||
loadState->SetHeadersStream(aLoadURIOptions.mHeaders);
|
||||
loadState->SetBaseURI(aLoadURIOptions.mBaseURI);
|
||||
loadState->SetTriggeringPrincipal(aLoadURIOptions.mTriggeringPrincipal);
|
||||
loadState->SetForceAllowDataURI(forceAllowDataURI);
|
||||
|
||||
if (fixupInfo) {
|
||||
|
|
@ -3959,6 +3946,18 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURIFromScript(const nsAString& aURI,
|
||||
JS::Handle<JS::Value> aLoadURIOptions,
|
||||
JSContext* aCx) {
|
||||
// generate dictionary for aLoadURIOptions and forward call
|
||||
LoadURIOptions loadURIOptions;
|
||||
if (!loadURIOptions.Init(aCx, aLoadURIOptions)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return LoadURI(aURI, loadURIOptions);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
|
||||
const char16_t* aURL, nsIChannel* aFailedChannel,
|
||||
|
|
@ -6910,12 +6909,11 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
|
|||
MOZ_ASSERT(loadInfo, "loadInfo is required on all channels");
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
loadInfo->TriggeringPrincipal();
|
||||
return LoadURI(newSpecW, // URI string
|
||||
LOAD_FLAGS_NONE, // Load flags
|
||||
nullptr, // Referring URI
|
||||
newPostData, // Post data stream
|
||||
nullptr, // Headers stream
|
||||
triggeringPrincipal); // TriggeringPrincipal
|
||||
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = triggeringPrincipal;
|
||||
loadURIOptions.mPostData = newPostData;
|
||||
return LoadURI(newSpecW, loadURIOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
#include "mozilla/dom/Event.h" // for Event
|
||||
#include "mozilla/dom/File.h" // for input type=file
|
||||
#include "mozilla/dom/FileList.h" // for input type=file
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
@ -896,8 +897,9 @@ nsDocShellTreeOwner::HandleEvent(Event* aEvent) {
|
|||
"nsDocShellTreeOwner::HandleEvent: Need a valid "
|
||||
"triggeringPrincipal");
|
||||
#endif
|
||||
webnav->LoadURI(url, 0, nullptr, nullptr, nullptr,
|
||||
triggeringPrincipal);
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = triggeringPrincipal;
|
||||
webnav->LoadURI(url, loadURIOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,15 @@ webidl Document;
|
|||
|
||||
%{ C++
|
||||
#include "mozilla/dom/ChildSHistory.h"
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
struct LoadURIOptions;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
%}
|
||||
|
||||
[ref] native LoadURIOptionsRef(const mozilla::dom::LoadURIOptions);
|
||||
|
||||
/**
|
||||
* The nsIWebNavigation interface defines an interface for navigating the web.
|
||||
* It provides methods and attributes to direct an object to navigate to a new
|
||||
|
|
@ -219,103 +226,30 @@ interface nsIWebNavigation : nsISupports
|
|||
*/
|
||||
const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
* however, the URI dispatcher will go through its normal process of content
|
||||
* loading.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI string to load. For HTTP and FTP URLs and possibly others,
|
||||
* characters above U+007F will be converted to UTF-8 and then URL-
|
||||
* escaped per the rules of RFC 2396.
|
||||
* @param aLoadFlags
|
||||
* Flags modifying load behaviour. This parameter is a bitwise
|
||||
* combination of the load flags defined above. (Undefined bits are
|
||||
* reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
|
||||
* for this parameter.
|
||||
* @param aReferrer
|
||||
* The referring URI. If this argument is null, then the referring
|
||||
* URI will be inferred internally.
|
||||
* @param aPostData
|
||||
* If the URI corresponds to a HTTP request, then this stream is
|
||||
* appended directly to the HTTP request headers. It may be prefixed
|
||||
* with additional HTTP headers. This stream must contain a "\r\n"
|
||||
* sequence separating any HTTP headers from the HTTP request body.
|
||||
* This parameter is optional and may be null.
|
||||
* @param aHeaders
|
||||
* If the URI corresponds to a HTTP request, then any HTTP headers
|
||||
* contained in this stream are set on the HTTP request. The HTTP
|
||||
* header stream is formatted as:
|
||||
* ( HEADER "\r\n" )*
|
||||
* This parameter is optional and may be null.
|
||||
* @param aTriggeringPrincipal
|
||||
* The principal that initiated the load of aURI. If omitted docShell
|
||||
* tries to create a codeBasePrincipal from aReferrer if not null. If
|
||||
* aReferrer is also null docShell peforms a load using the
|
||||
* SystemPrincipal as the triggeringPrincipal.
|
||||
*/
|
||||
void loadURI(in AString aURI,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsIURI aReferrer,
|
||||
in nsIInputStream aPostData,
|
||||
in nsIInputStream aHeaders,
|
||||
[optional] in nsIPrincipal aTriggeringPrincipal);
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
* however, the URI dispatcher will go through its normal process of content
|
||||
* loading.
|
||||
*
|
||||
* Behaves like loadURI, but allows passing of additional parameters.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI string to load. For HTTP and FTP URLs and possibly others,
|
||||
* characters above U+007F will be converted to UTF-8 and then URL-
|
||||
* escaped per the rules of RFC 2396.
|
||||
* @param aLoadFlags
|
||||
* Flags modifying load behaviour. This parameter is a bitwise
|
||||
* combination of the load flags defined above. (Undefined bits are
|
||||
* reserved for future use.) Generally you will pass LOAD_FLAGS_NONE
|
||||
* for this parameter.
|
||||
* @param aReferrer
|
||||
* The referring URI. If this argument is null, then the referring
|
||||
* URI will be inferred internally.
|
||||
* @param aReferrerPolicy
|
||||
* One of the REFERRER_POLICY_* constants from nsIHttpChannel.
|
||||
* Normal case is REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE.
|
||||
* @param aPostData
|
||||
* If the URI corresponds to a HTTP request, then this stream is
|
||||
* appended directly to the HTTP request headers. It may be prefixed
|
||||
* with additional HTTP headers. This stream must contain a "\r\n"
|
||||
* sequence separating any HTTP headers from the HTTP request body.
|
||||
* This parameter is optional and may be null.
|
||||
* @param aHeaders
|
||||
* If the URI corresponds to a HTTP request, then any HTTP headers
|
||||
* contained in this stream are set on the HTTP request. The HTTP
|
||||
* header stream is formatted as:
|
||||
* ( HEADER "\r\n" )*
|
||||
* This parameter is optional and may be null.
|
||||
* @param aBaseURI
|
||||
* Set to indicate a base URI to be associated with the load. Note
|
||||
* that at present this argument is only used with view-source aURIs
|
||||
* and cannot be used to resolve aURI.
|
||||
* This parameter is optional and may be null.
|
||||
* @param aTriggeringPrincipal
|
||||
* The principal that initiated the load of aURI. If omitted docShell
|
||||
* tries to create a codeBasePrincipal from aReferrer if not null. If
|
||||
* aReferrer is also null docShell peforms a load using the
|
||||
* SystemPrincipal as the triggeringPrincipal.
|
||||
* @param aLoadURIOptions
|
||||
* A JSObject defined in LoadURIOptions.webidl holding info like e.g.
|
||||
* the triggeringPrincipal, the referrer URI, the referrer policy.
|
||||
*/
|
||||
void loadURIWithOptions(in AString aURI,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsIURI aReferrer,
|
||||
in unsigned long aReferrerPolicy,
|
||||
in nsIInputStream aPostData,
|
||||
in nsIInputStream aHeaders,
|
||||
in nsIURI aBaseURI,
|
||||
[optional] in nsIPrincipal aTriggeringPrincipal);
|
||||
[implicit_jscontext, binaryname(LoadURIFromScript)]
|
||||
void loadURI(in AString aURI,
|
||||
in jsval aLoadURIOptions);
|
||||
|
||||
/**
|
||||
* A C++ friendly version of loadURI
|
||||
*/
|
||||
[nostdcall, binaryname(LoadURI)]
|
||||
void binaryLoadURI(in AString aURI,
|
||||
in LoadURIOptionsRef aLoadURIOptions);
|
||||
|
||||
/**
|
||||
* Tells the Object to reload the current page. There may be cases where the
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "mozilla/dom/DataTransfer.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/MouseEventBinding.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
|
|
@ -1007,11 +1008,14 @@ mozilla::ipc::IPCResult TabChild::RecvLoadURL(const nsCString& aURI,
|
|||
ApplyShowInfo(aInfo);
|
||||
}
|
||||
|
||||
nsresult rv = WebNavigation()->LoadURI(
|
||||
NS_ConvertUTF8toUTF16(aURI),
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
|
||||
loadURIOptions.mLoadFlags =
|
||||
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
||||
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL,
|
||||
nullptr, nullptr, nullptr, nsContentUtils::GetSystemPrincipal());
|
||||
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
|
||||
|
||||
nsresult rv =
|
||||
WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI), loadURIOptions);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING(
|
||||
"WebNavigation()->LoadURI failed. Eating exception, what else can I "
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsQueryObject.h"
|
||||
#include "mozilla/dom/nsCSPUtils.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
@ -257,8 +258,10 @@ static bool ShouldIgnoreFrameOptions(nsIChannel* aChannel,
|
|||
RefPtr<NullPrincipal> principal =
|
||||
NullPrincipal::CreateWithInheritedAttributes(
|
||||
loadInfo->TriggeringPrincipal());
|
||||
webNav->LoadURI(NS_LITERAL_STRING("about:blank"), 0, nullptr, nullptr,
|
||||
nullptr, principal);
|
||||
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = principal;
|
||||
webNav->LoadURI(NS_LITERAL_STRING("about:blank"), loadURIOptions);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
60
dom/webidl/LoadURIOptions.webidl
Normal file
60
dom/webidl/LoadURIOptions.webidl
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* 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/. */
|
||||
|
||||
interface Principal;
|
||||
interface URI;
|
||||
interface InputStream;
|
||||
|
||||
/**
|
||||
* This dictionary holds load arguments for docshell loads.
|
||||
*/
|
||||
|
||||
dictionary LoadURIOptions {
|
||||
/**
|
||||
* The principal that initiated the load.
|
||||
*/
|
||||
Principal? triggeringPrincipal = null;
|
||||
|
||||
/**
|
||||
* Flags modifying load behaviour. This parameter is a bitwise
|
||||
* combination of the load flags defined in nsIWebNavigation.idl.
|
||||
*/
|
||||
long loadFlags = 0;
|
||||
|
||||
/**
|
||||
* The referring URI. If this argument is null, then the referring
|
||||
* URI will be inferred internally.
|
||||
*/
|
||||
URI? referrerURI = null;
|
||||
|
||||
/**
|
||||
* Referrer Policy for the load, defaults to REFERRER_POLICY_UNSET.
|
||||
* Alternatively use one of REFERRER_POLICY_* constants from
|
||||
* nsIHttpChannel.
|
||||
*/
|
||||
long referrerPolicy = 0;
|
||||
|
||||
/**
|
||||
* If the URI to be loaded corresponds to a HTTP request, then this stream is
|
||||
* appended directly to the HTTP request headers. It may be prefixed
|
||||
* with additional HTTP headers. This stream must contain a "\r\n"
|
||||
* sequence separating any HTTP headers from the HTTP request body.
|
||||
*/
|
||||
InputStream? postData = null;
|
||||
|
||||
/**
|
||||
* If the URI corresponds to a HTTP request, then any HTTP headers
|
||||
* contained in this stream are set on the HTTP request. The HTTP
|
||||
* header stream is formatted as:
|
||||
* ( HEADER "\r\n" )*
|
||||
*/
|
||||
InputStream? headers = null;
|
||||
|
||||
/**
|
||||
* Set to indicate a base URI to be associated with the load. Note
|
||||
* that at present this argument is only used with view-source aURIs
|
||||
* and cannot be used to resolve aURI.
|
||||
*/
|
||||
URI? baseURI = null;
|
||||
};
|
||||
|
|
@ -632,6 +632,7 @@ WEBIDL_FILES = [
|
|||
'L10nUtils.webidl',
|
||||
'LegacyQueryInterface.webidl',
|
||||
'LinkStyle.webidl',
|
||||
'LoadURIOptions.webidl',
|
||||
'Location.webidl',
|
||||
'MediaCapabilities.webidl',
|
||||
'MediaDeviceInfo.webidl',
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include "mozilla/dom/Selection.h" // for AutoHideSelectionChanges, etc
|
||||
#include "nsFrameSelection.h" // for nsFrameSelection
|
||||
#include "nsBaseCommandController.h" // for nsBaseCommandController
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
|
||||
class nsISupports;
|
||||
class nsIURI;
|
||||
|
|
@ -940,8 +941,10 @@ void nsEditingSession::TimerCallback(nsITimer* aTimer, void* aClosure) {
|
|||
if (docShell) {
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
if (webNav) {
|
||||
webNav->LoadURI(NS_LITERAL_STRING("about:blank"), 0, nullptr, nullptr,
|
||||
nullptr, nsContentUtils::GetSystemPrincipal());
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal =
|
||||
nsContentUtils::GetSystemPrincipal();
|
||||
webNav->LoadURI(NS_LITERAL_STRING("about:blank"), loadURIOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
|
||||
// for painting the background window
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
|
|
@ -547,24 +548,27 @@ nsWebBrowser::GoForward() {
|
|||
return mDocShellAsNav->GoForward();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::LoadURIWithOptions(const nsAString& aURI, uint32_t aLoadFlags,
|
||||
nsIURI* aReferringURI,
|
||||
uint32_t aReferrerPolicy,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aExtraHeaderStream,
|
||||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal) {
|
||||
nsresult nsWebBrowser::LoadURI(const nsAString& aURI,
|
||||
const dom::LoadURIOptions& aLoadURIOptions) {
|
||||
#ifndef ANDROID
|
||||
MOZ_ASSERT(
|
||||
aTriggeringPrincipal,
|
||||
"nsWebBrowser::LoadURIWithOptions - Need a valid triggeringPrincipal");
|
||||
MOZ_ASSERT(aLoadURIOptions.mTriggeringPrincipal,
|
||||
"nsWebBrowser::LoadURI - Need a valid triggeringPrincipal");
|
||||
#endif
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsNav->LoadURIWithOptions(
|
||||
aURI, aLoadFlags, aReferringURI, aReferrerPolicy, aPostDataStream,
|
||||
aExtraHeaderStream, aBaseURI, aTriggeringPrincipal);
|
||||
return mDocShellAsNav->LoadURI(aURI, aLoadURIOptions);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::LoadURIFromScript(const nsAString& aURI,
|
||||
JS::Handle<JS::Value> aLoadURIOptions,
|
||||
JSContext* aCx) {
|
||||
// generate dictionary for loadURIOptions and forward call
|
||||
dom::LoadURIOptions loadURIOptions;
|
||||
if (!loadURIOptions.Init(aCx, aLoadURIOptions)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
return LoadURI(aURI, loadURIOptions);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
@ -574,22 +578,6 @@ nsWebBrowser::SetOriginAttributesBeforeLoading(
|
|||
aCx);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::LoadURI(const nsAString& aURI, uint32_t aLoadFlags,
|
||||
nsIURI* aReferringURI, nsIInputStream* aPostDataStream,
|
||||
nsIInputStream* aExtraHeaderStream,
|
||||
nsIPrincipal* aTriggeringPrincipal) {
|
||||
#ifndef ANDROID
|
||||
MOZ_ASSERT(aTriggeringPrincipal,
|
||||
"nsWebBrowser::LoadURI - Need a valid triggeringPrincipal");
|
||||
#endif
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
return mDocShellAsNav->LoadURI(aURI, aLoadFlags, aReferringURI,
|
||||
aPostDataStream, aExtraHeaderStream,
|
||||
aTriggeringPrincipal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowser::Reload(uint32_t aReloadFlags) {
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
#include "mozilla/MouseEvents.h"
|
||||
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
|
||||
#include "nsPIWindowRoot.h"
|
||||
|
||||
|
|
@ -245,9 +246,11 @@ nsresult nsWebShellWindow::Initialize(
|
|||
NS_ConvertUTF8toUTF16 urlString(tmpStr);
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
||||
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
||||
rv =
|
||||
webNav->LoadURI(urlString, nsIWebNavigation::LOAD_FLAGS_NONE, nullptr,
|
||||
nullptr, nullptr, nsContentUtils::GetSystemPrincipal());
|
||||
|
||||
LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
|
||||
|
||||
rv = webNav->LoadURI(urlString, loadURIOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue