Bug 1590908 - Part 1: Move parent-only LoadURI method to CanonicalBrowsingContext, r=kmag
These methods are only callable from the parent process, so it doesn't make sense to have the method available driectly on BrowsingContext. Differential Revision: https://phabricator.services.mozilla.com/D50854
This commit is contained in:
@@ -845,37 +845,6 @@ void BrowsingContext::Location(JSContext* aCx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowsingContext::LoadURI(const nsAString& aURI,
|
|
||||||
const LoadURIOptions& aOptions,
|
|
||||||
ErrorResult& aError) {
|
|
||||||
nsCOMPtr<nsIURIFixup> uriFixup = components::URIFixup::Service();
|
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> consumer = mDocShell.get();
|
|
||||||
if (!consumer) {
|
|
||||||
consumer = mEmbedderElement;
|
|
||||||
}
|
|
||||||
if (!consumer) {
|
|
||||||
aError.Throw(NS_ERROR_UNEXPECTED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<nsDocShellLoadState> loadState;
|
|
||||||
nsresult rv = nsDocShellLoadState::CreateFromLoadURIOptions(
|
|
||||||
consumer, uriFixup, aURI, aOptions, getter_AddRefs(loadState));
|
|
||||||
|
|
||||||
if (rv == NS_ERROR_MALFORMED_URI) {
|
|
||||||
DisplayLoadError(aURI);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
aError.Throw(rv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadURI(nullptr, loadState, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor,
|
nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor,
|
||||||
nsDocShellLoadState* aLoadState,
|
nsDocShellLoadState* aLoadState,
|
||||||
bool aSetNavigating) {
|
bool aSetNavigating) {
|
||||||
|
|||||||
@@ -192,9 +192,6 @@ class BrowsingContext : public nsISupports,
|
|||||||
nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState,
|
nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState,
|
||||||
bool aSetNavigating = false);
|
bool aSetNavigating = false);
|
||||||
|
|
||||||
void LoadURI(const nsAString& aURI, const LoadURIOptions& aOptions,
|
|
||||||
ErrorResult& aError);
|
|
||||||
|
|
||||||
void DisplayLoadError(const nsAString& aURI);
|
void DisplayLoadError(const nsAString& aURI);
|
||||||
|
|
||||||
// Determine if the current BrowsingContext was 'cached' by the logic in
|
// Determine if the current BrowsingContext was 'cached' by the logic in
|
||||||
|
|||||||
@@ -198,6 +198,39 @@ void CanonicalBrowsingContext::UpdateMediaAction(MediaControlActions aAction) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanonicalBrowsingContext::LoadURI(const nsAString& aURI,
|
||||||
|
const LoadURIOptions& aOptions,
|
||||||
|
ErrorResult& aError) {
|
||||||
|
nsCOMPtr<nsIURIFixup> uriFixup = components::URIFixup::Service();
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> consumer = GetDocShell();
|
||||||
|
if (!consumer) {
|
||||||
|
consumer = GetEmbedderElement();
|
||||||
|
}
|
||||||
|
if (!consumer) {
|
||||||
|
aError.Throw(NS_ERROR_UNEXPECTED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<nsDocShellLoadState> loadState;
|
||||||
|
nsresult rv = nsDocShellLoadState::CreateFromLoadURIOptions(
|
||||||
|
consumer, uriFixup, aURI, aOptions, getter_AddRefs(loadState));
|
||||||
|
|
||||||
|
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||||
|
DisplayLoadError(aURI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
aError.Throw(rv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: It's safe to call `LoadURI` without an accessor from the parent
|
||||||
|
// process. The load will be performed with ambient "chrome" authority.
|
||||||
|
LoadURI(nullptr, loadState, true);
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using NewOrUsedPromise = MozPromise<RefPtr<ContentParent>, nsresult, false>;
|
using NewOrUsedPromise = MozPromise<RefPtr<ContentParent>, nsresult, false>;
|
||||||
|
|||||||
@@ -78,6 +78,11 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
|||||||
// and propogate the action to other browsing contexts in content processes.
|
// and propogate the action to other browsing contexts in content processes.
|
||||||
void UpdateMediaAction(MediaControlActions aAction);
|
void UpdateMediaAction(MediaControlActions aAction);
|
||||||
|
|
||||||
|
// Triggers a load in the process
|
||||||
|
using BrowsingContext::LoadURI;
|
||||||
|
void LoadURI(const nsAString& aURI, const LoadURIOptions& aOptions,
|
||||||
|
ErrorResult& aError);
|
||||||
|
|
||||||
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
|
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
|
||||||
RefPtr<RemotenessPromise> ChangeFrameRemoteness(const nsAString& aRemoteType,
|
RefPtr<RemotenessPromise> ChangeFrameRemoteness(const nsAString& aRemoteType,
|
||||||
uint64_t aPendingSwitchId);
|
uint64_t aPendingSwitchId);
|
||||||
|
|||||||
@@ -47,23 +47,6 @@ interface BrowsingContext {
|
|||||||
* See nsSandboxFlags.h for the possible flags.
|
* See nsSandboxFlags.h for the possible flags.
|
||||||
*/
|
*/
|
||||||
attribute unsigned long sandboxFlags;
|
attribute unsigned long sandboxFlags;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 aLoadURIOptions
|
|
||||||
* A JSObject defined in LoadURIOptions.webidl holding info like e.g.
|
|
||||||
* the triggeringPrincipal, the referrer info.
|
|
||||||
*/
|
|
||||||
[Throws]
|
|
||||||
void loadURI(DOMString aURI, optional LoadURIOptions aOptions = {});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
[Exposed=Window, ChromeOnly]
|
[Exposed=Window, ChromeOnly]
|
||||||
@@ -83,6 +66,23 @@ interface CanonicalBrowsingContext : BrowsingContext {
|
|||||||
void notifyStartDelayedAutoplayMedia();
|
void notifyStartDelayedAutoplayMedia();
|
||||||
void notifyMediaMutedChanged(boolean muted);
|
void notifyMediaMutedChanged(boolean muted);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 aLoadURIOptions
|
||||||
|
* A JSObject defined in LoadURIOptions.webidl holding info like e.g.
|
||||||
|
* the triggeringPrincipal, the referrer info.
|
||||||
|
*/
|
||||||
|
[Throws]
|
||||||
|
void loadURI(DOMString aURI, optional LoadURIOptions aOptions = {});
|
||||||
|
|
||||||
[Throws]
|
[Throws]
|
||||||
Promise<unsigned long long> changeFrameRemoteness(
|
Promise<unsigned long long> changeFrameRemoteness(
|
||||||
DOMString remoteType, unsigned long long pendingSwitchId);
|
DOMString remoteType, unsigned long long pendingSwitchId);
|
||||||
|
|||||||
Reference in New Issue
Block a user