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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-11-04 15:05:47 +00:00
Родитель fa9fb525b5
Коммит 89c099a0fe
5 изменённых файлов: 55 добавлений и 51 удалений

Просмотреть файл

@ -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,
nsDocShellLoadState* aLoadState,
bool aSetNavigating) {

Просмотреть файл

@ -192,9 +192,6 @@ class BrowsingContext : public nsISupports,
nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState,
bool aSetNavigating = false);
void LoadURI(const nsAString& aURI, const LoadURIOptions& aOptions,
ErrorResult& aError);
void DisplayLoadError(const nsAString& aURI);
// 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 {
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.
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>;
RefPtr<RemotenessPromise> ChangeFrameRemoteness(const nsAString& aRemoteType,
uint64_t aPendingSwitchId);

Просмотреть файл

@ -47,23 +47,6 @@ interface BrowsingContext {
* See nsSandboxFlags.h for the possible flags.
*/
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]
@ -83,6 +66,23 @@ interface CanonicalBrowsingContext : BrowsingContext {
void notifyStartDelayedAutoplayMedia();
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]
Promise<unsigned long long> changeFrameRemoteness(
DOMString remoteType, unsigned long long pendingSwitchId);