mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 1646582 - Remove RemoteWebProgressManager. r=nika,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D80129
This commit is contained in:
parent
00dc8d3d73
commit
ea21b3dd8e
@ -462,20 +462,6 @@ function addXULBrowserDecorations(browser) {
|
||||
swapBrowser() {},
|
||||
};
|
||||
}
|
||||
if (browser._remoteWebProgressManager == undefined) {
|
||||
browser._remoteWebProgressManager = {
|
||||
swapBrowser() {},
|
||||
get progressListeners() {
|
||||
return [];
|
||||
},
|
||||
};
|
||||
}
|
||||
if (browser._remoteWebProgress == undefined) {
|
||||
browser._remoteWebProgress = {
|
||||
addProgressListener() {},
|
||||
removeProgressListener() {},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function tabLoaded(tab) {
|
||||
|
@ -68,14 +68,6 @@ interface nsIBrowser : nsISupports
|
||||
*/
|
||||
readonly attribute boolean isRemoteBrowser;
|
||||
|
||||
/**
|
||||
* The nsIWebProgress instance responsible for handling progress events
|
||||
* from the content process.
|
||||
*
|
||||
* Will always be non-null when isRemoteBrowser is true.
|
||||
*/
|
||||
readonly attribute nsIWebProgress remoteWebProgressManager;
|
||||
|
||||
readonly attribute nsIPrincipal contentPrincipal;
|
||||
readonly attribute nsIPrincipal contentPartitionedPrincipal;
|
||||
readonly attribute nsIPrincipal contentBlockingAllowListPrincipal;
|
||||
|
@ -2581,17 +2581,14 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnStateChange(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
nsCOMPtr<nsIBrowser> browser = GetBrowser();
|
||||
if (!GetBrowsingContext()->GetWebProgress() || !browser) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
|
||||
ReconstructWebProgressAndRequest(aWebProgressData, aRequestData,
|
||||
getter_AddRefs(webProgress),
|
||||
getter_AddRefs(request));
|
||||
|
||||
@ -2611,14 +2608,8 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnStateChange(
|
||||
"Unexpected WebProgressStateChangeData for non-top-level WebProgress");
|
||||
}
|
||||
|
||||
Unused << managerAsListener->OnStateChange(webProgress, request, aStateFlags,
|
||||
aStatus);
|
||||
|
||||
if (GetBrowsingContext()->Top()->GetWebProgress()) {
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnStateChange(
|
||||
webProgress, request, aStateFlags, aStatus);
|
||||
}
|
||||
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnStateChange(
|
||||
webProgress, request, aStateFlags, aStatus);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -2631,30 +2622,20 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnProgressChange(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
if (!GetBrowsingContext()->GetWebProgress()) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
|
||||
ReconstructWebProgressAndRequest(aWebProgressData, aRequestData,
|
||||
getter_AddRefs(webProgress),
|
||||
getter_AddRefs(request));
|
||||
|
||||
Unused << managerAsListener->OnProgressChange(
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnProgressChange(
|
||||
webProgress, request, aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
|
||||
if (GetBrowsingContext()->Top()->GetWebProgress()) {
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnProgressChange(
|
||||
webProgress, request, aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@ -2667,17 +2648,14 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
nsCOMPtr<nsIBrowser> browser = GetBrowser();
|
||||
if (!GetBrowsingContext()->GetWebProgress() || !browser) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
|
||||
ReconstructWebProgressAndRequest(aWebProgressData, aRequestData,
|
||||
getter_AddRefs(webProgress),
|
||||
getter_AddRefs(request));
|
||||
|
||||
@ -2703,12 +2681,8 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnLocationChange(
|
||||
aLocationChangeData->contentType());
|
||||
}
|
||||
|
||||
Unused << managerAsListener->OnLocationChange(webProgress, request, aLocation,
|
||||
aFlags);
|
||||
if (GetBrowsingContext()->Top()->GetWebProgress()) {
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnLocationChange(
|
||||
webProgress, request, aLocation, aFlags);
|
||||
}
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnLocationChange(
|
||||
webProgress, request, aLocation, aFlags);
|
||||
|
||||
// Since we've now changed Documents, notify the BrowsingContext that we've
|
||||
// changed. Ideally we'd just let the BrowsingContext do this when it changes
|
||||
@ -2728,27 +2702,18 @@ mozilla::ipc::IPCResult BrowserParent::RecvOnStatusChange(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
if (!GetBrowsingContext()->GetWebProgress()) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
|
||||
ReconstructWebProgressAndRequest(aWebProgressData, aRequestData,
|
||||
getter_AddRefs(webProgress),
|
||||
getter_AddRefs(request));
|
||||
|
||||
Unused << managerAsListener->OnStatusChange(webProgress, request, aStatus,
|
||||
aMessage.get());
|
||||
|
||||
if (GetBrowsingContext()->Top()->GetWebProgress()) {
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnStatusChange(
|
||||
webProgress, request, aStatus, aMessage.get());
|
||||
}
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnStatusChange(
|
||||
webProgress, request, aStatus, aMessage.get());
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
@ -2811,13 +2776,7 @@ BrowserParent::RecvReportBlockedEmbedderNodeByClassifier() {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
bool BrowserParent::GetWebProgressListener(
|
||||
nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
|
||||
nsIWebProgressListener** aOutListener) {
|
||||
MOZ_ASSERT(aOutBrowser);
|
||||
MOZ_ASSERT(aOutManager);
|
||||
MOZ_ASSERT(aOutListener);
|
||||
|
||||
already_AddRefed<nsIBrowser> BrowserParent::GetBrowser() {
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
RefPtr<Element> currentElement = mFrameElement;
|
||||
|
||||
@ -2835,31 +2794,11 @@ bool BrowserParent::GetWebProgressListener(
|
||||
browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
|
||||
}
|
||||
|
||||
if (!browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(manager);
|
||||
if (!listener) {
|
||||
// We are no longer remote so we cannot forward this event.
|
||||
return false;
|
||||
}
|
||||
|
||||
browser.forget(aOutBrowser);
|
||||
manager.forget(aOutManager);
|
||||
listener.forget(aOutListener);
|
||||
|
||||
return true;
|
||||
return browser.forget();
|
||||
}
|
||||
|
||||
void BrowserParent::ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, nsIWebProgress** aOutWebProgress,
|
||||
nsIRequest** aOutRequest) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aOutWebProgress,
|
||||
@ -2868,11 +2807,11 @@ void BrowserParent::ReconstructWebProgressAndRequest(
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
if (aWebProgressData) {
|
||||
webProgress = new RemoteWebProgress(aManager, aWebProgressData->loadType(),
|
||||
webProgress = new RemoteWebProgress(aWebProgressData->loadType(),
|
||||
aWebProgressData->isLoadingDocument(),
|
||||
aWebProgressData->isTopLevel());
|
||||
} else {
|
||||
webProgress = new RemoteWebProgress(aManager, 0, false, false);
|
||||
webProgress = new RemoteWebProgress(0, false, false);
|
||||
}
|
||||
webProgress.forget(aOutWebProgress);
|
||||
|
||||
|
@ -318,12 +318,10 @@ class BrowserParent final : public PBrowserParent,
|
||||
|
||||
mozilla::ipc::IPCResult RecvNavigationFinished();
|
||||
|
||||
bool GetWebProgressListener(nsIBrowser** aOutBrowser,
|
||||
nsIWebProgress** aOutManager,
|
||||
nsIWebProgressListener** aOutListener);
|
||||
already_AddRefed<nsIBrowser> GetBrowser();
|
||||
|
||||
void ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, nsIWebProgress** aOutWebProgress,
|
||||
nsIRequest** aOutRequest);
|
||||
|
||||
|
@ -7,45 +7,22 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION(RemoteWebProgress, mManager)
|
||||
NS_IMPL_ADDREF(RemoteWebProgress)
|
||||
NS_IMPL_RELEASE(RemoteWebProgress)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(RemoteWebProgress)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(RemoteWebProgress)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RemoteWebProgress)
|
||||
NS_INTERFACE_MAP_BEGIN(RemoteWebProgress)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgress)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRemoteWebProgress)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP RemoteWebProgress::Init(nsIWebProgress* aManager,
|
||||
bool aIsTopLevel) {
|
||||
mManager = aManager;
|
||||
mIsTopLevel = aIsTopLevel;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RemoteWebProgress::AddProgressListener(
|
||||
nsIWebProgressListener* aListener, uint32_t aNotifyMask) {
|
||||
if (mManager) {
|
||||
return mManager->AddProgressListener(aListener, aNotifyMask);
|
||||
} else {
|
||||
NS_WARNING("RemoteWebProgres::mManager should not be null!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RemoteWebProgress::RemoveProgressListener(
|
||||
nsIWebProgressListener* aListener) {
|
||||
if (mManager) {
|
||||
return mManager->RemoveProgressListener(aListener);
|
||||
} else {
|
||||
NS_WARNING("RemoteWebProgres::mManager should not be null!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RemoteWebProgress::GetDOMWindow(mozIDOMWindowProxy** aDOMWindow) {
|
||||
|
@ -5,39 +5,29 @@
|
||||
#ifndef mozilla_dom_RemoteWebProgress_h
|
||||
#define mozilla_dom_RemoteWebProgress_h
|
||||
|
||||
#include "nsIRemoteWebProgress.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class RemoteWebProgress final : public nsIRemoteWebProgress {
|
||||
class RemoteWebProgress final : public nsIWebProgress {
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(RemoteWebProgress)
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBPROGRESS
|
||||
NS_DECL_NSIREMOTEWEBPROGRESS
|
||||
|
||||
RemoteWebProgress()
|
||||
: mManager(nullptr),
|
||||
mLoadType(0),
|
||||
mIsLoadingDocument(false),
|
||||
mIsTopLevel(false) {}
|
||||
: mLoadType(0), mIsLoadingDocument(false), mIsTopLevel(false) {}
|
||||
|
||||
RemoteWebProgress(nsIWebProgress* aManager, uint32_t aLoadType,
|
||||
bool aIsLoadingDocument, bool aIsTopLevel)
|
||||
: mManager(aManager),
|
||||
mLoadType(aLoadType),
|
||||
RemoteWebProgress(uint32_t aLoadType, bool aIsLoadingDocument,
|
||||
bool aIsTopLevel)
|
||||
: mLoadType(aLoadType),
|
||||
mIsLoadingDocument(aIsLoadingDocument),
|
||||
mIsTopLevel(aIsTopLevel) {}
|
||||
|
||||
private:
|
||||
virtual ~RemoteWebProgress() = default;
|
||||
|
||||
nsCOMPtr<nsIWebProgress> mManager;
|
||||
|
||||
uint32_t mLoadType;
|
||||
bool mIsLoadingDocument;
|
||||
bool mIsTopLevel;
|
||||
|
@ -472,36 +472,14 @@ void WindowGlobalParent::NotifyContentBlockingEvent(
|
||||
|
||||
// Notify the OnContentBlockingEvent if necessary.
|
||||
if (event) {
|
||||
// Get the browser parent from the manager directly since the content
|
||||
// blocking event could happen in the early stage of loading, i.e.
|
||||
// accessing cookies for the http header. At this stage, the actor is
|
||||
// not ready, so we would get a nullptr from GetBrowserParent(). But,
|
||||
// we can actually get it from the manager.
|
||||
RefPtr<BrowserParent> browserParent =
|
||||
static_cast<BrowserParent*>(Manager());
|
||||
if (NS_WARN_IF(!browserParent)) {
|
||||
if (!GetBrowsingContext()->GetWebProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
|
||||
if (!browserParent->GetWebProgressListener(
|
||||
getter_AddRefs(browser), getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress = new RemoteWebProgress(
|
||||
manager, 0, false, BrowsingContext()->IsTopContent());
|
||||
|
||||
Unused << managerAsListener->OnContentBlockingEvent(webProgress, aRequest,
|
||||
event.value());
|
||||
if (GetBrowsingContext()->Top()->GetWebProgress()) {
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnContentBlockingEvent(
|
||||
webProgress, aRequest, event.value());
|
||||
}
|
||||
nsCOMPtr<nsIWebProgress> webProgress =
|
||||
new RemoteWebProgress(0, false, BrowsingContext()->IsTopContent());
|
||||
GetBrowsingContext()->Top()->GetWebProgress()->OnContentBlockingEvent(
|
||||
webProgress, aRequest, event.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
# 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/.
|
||||
|
||||
Classes = [
|
||||
{
|
||||
'name': 'RemoteWebProgress',
|
||||
'cid': 'a87eb91c-2a5c-11e9-ac91-d027ecb1fb94',
|
||||
'contract_ids': ['@mozilla.org/dom/remote-web-progress;1'],
|
||||
'type': 'mozilla::dom::RemoteWebProgress',
|
||||
'headers': ['mozilla/dom/RemoteWebProgress.h'],
|
||||
},
|
||||
]
|
@ -11,15 +11,10 @@ XPIDL_SOURCES += [
|
||||
'nsIContentChild.idl',
|
||||
'nsIContentParent.idl',
|
||||
'nsIHangReport.idl',
|
||||
'nsIRemoteWebProgress.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom'
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
'components.conf',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'ManifestMessagesChild.jsm',
|
||||
]
|
||||
|
@ -1,17 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
#include "nsIWebProgress.idl"
|
||||
|
||||
[scriptable, uuid(2104bfce-bbbe-4111-aa29-cd7c91d1023b)]
|
||||
interface nsIRemoteWebProgress : nsIWebProgress {
|
||||
/**
|
||||
* Initialize the web progress.
|
||||
*
|
||||
* @param aManager The RemoteWebProgressManager for this remote nsIWebProgress.
|
||||
* @param aIsTopLevel Whether or not this is a top-level web progress.
|
||||
*/
|
||||
void init(in nsIWebProgress aManager,
|
||||
in boolean aIsTopLevel);
|
||||
};
|
@ -1930,70 +1930,6 @@ auto DocumentLoadListener::AttachStreamFilter(base::ProcessId aChildProcessId)
|
||||
return request->mPromise;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIBrowser> DocumentLoadListener::GetBrowser() {
|
||||
CanonicalBrowsingContext* bc = GetBrowsingContext();
|
||||
if (!bc || !bc->IsTopContent()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
RefPtr<Element> currentElement = bc->GetEmbedderElement();
|
||||
|
||||
// In Responsive Design Mode, mFrameElement will be the <iframe mozbrowser>,
|
||||
// but we want the <xul:browser> that it is embedded in.
|
||||
while (currentElement) {
|
||||
browser = currentElement->AsBrowser();
|
||||
if (browser) {
|
||||
break;
|
||||
}
|
||||
|
||||
BrowsingContext* browsingContext =
|
||||
currentElement->OwnerDoc()->GetBrowsingContext();
|
||||
currentElement =
|
||||
browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
|
||||
}
|
||||
|
||||
return browser.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIWebProgressListener>
|
||||
DocumentLoadListener::GetRemoteWebProgressListener(
|
||||
nsIWebProgress** aWebProgress, nsIRequest** aRequest) {
|
||||
nsCOMPtr<nsIBrowser> browser = GetBrowser();
|
||||
if (!browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(manager);
|
||||
if (!listener) {
|
||||
// We are no longer remote so we cannot forward this event.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
|
||||
nsCOMPtr<nsIWebProgress> webProgress = new RemoteWebProgress(
|
||||
manager, loadInfo->GetOuterWindowID(),
|
||||
/* aInnerDOMWindowID = */ 0, mLoadStateLoadType, true, true);
|
||||
|
||||
nsCOMPtr<nsIURI> uri, originalUri;
|
||||
mChannel->GetURI(getter_AddRefs(uri));
|
||||
mChannel->GetOriginalURI(getter_AddRefs(originalUri));
|
||||
nsCString matchedList;
|
||||
|
||||
nsCOMPtr<nsIRequest> request = MakeAndAddRef<RemoteWebProgressRequest>(
|
||||
uri, originalUri, matchedList, Nothing());
|
||||
|
||||
webProgress.forget(aWebProgress);
|
||||
request.forget(aRequest);
|
||||
return listener.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoadListener::OnProgress(nsIRequest* aRequest,
|
||||
int64_t aProgress,
|
||||
int64_t aProgressMax) {
|
||||
@ -2003,25 +1939,17 @@ NS_IMETHODIMP DocumentLoadListener::OnProgress(nsIRequest* aRequest,
|
||||
NS_IMETHODIMP DocumentLoadListener::OnStatus(nsIRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
const char16_t* aStatusArg) {
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
nsCOMPtr<nsIWebProgressListener> listener = GetRemoteWebProgressListener(
|
||||
getter_AddRefs(webProgress), getter_AddRefs(request));
|
||||
if (!listener) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> channel = mChannel;
|
||||
nsCOMPtr<nsIWebProgress> webProgress =
|
||||
new RemoteWebProgress(mLoadStateLoadType, true, true);
|
||||
|
||||
RefPtr<CanonicalBrowsingContext> ctx = GetBrowsingContext();
|
||||
|
||||
const nsString message(aStatusArg);
|
||||
|
||||
NS_DispatchToMainThread(
|
||||
NS_NewRunnableFunction("DocumentLoadListener::FireStateChange", [=]() {
|
||||
Unused << listener->OnStatusChange(webProgress, request, aStatus,
|
||||
message.get());
|
||||
|
||||
if (ctx && ctx->Top()->GetWebProgress()) {
|
||||
ctx->Top()->GetWebProgress()->OnStatusChange(webProgress, request,
|
||||
ctx->Top()->GetWebProgress()->OnStatusChange(webProgress, channel,
|
||||
aStatus, message.get());
|
||||
}
|
||||
}));
|
||||
|
@ -177,10 +177,6 @@ class DocumentLoadListener : public nsIInterfaceRequestor,
|
||||
|
||||
nsIChannel* GetChannel() const { return mChannel; }
|
||||
|
||||
already_AddRefed<nsIBrowser> GetBrowser();
|
||||
already_AddRefed<nsIWebProgressListener> GetRemoteWebProgressListener(
|
||||
nsIWebProgress** aWebProgress, nsIRequest** aRequest);
|
||||
|
||||
uint32_t GetRedirectChannelId() const { return mRedirectChannelId; }
|
||||
|
||||
nsresult ReportSecurityMessage(const nsAString& aMessageTag,
|
||||
|
@ -51,57 +51,6 @@ nsSecureBrowserUI::GetState(uint32_t* aState) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool GetWebProgressListener(CanonicalBrowsingContext* aBrowsingContext,
|
||||
nsIBrowser** aOutBrowser,
|
||||
nsIWebProgress** aOutManager,
|
||||
nsIWebProgressListener** aOutListener) {
|
||||
MOZ_ASSERT(aOutBrowser);
|
||||
MOZ_ASSERT(aOutManager);
|
||||
MOZ_ASSERT(aOutListener);
|
||||
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
RefPtr<Element> currentElement = aBrowsingContext->GetEmbedderElement();
|
||||
|
||||
// In Responsive Design Mode, mFrameElement will be the <iframe mozbrowser>,
|
||||
// but we want the <xul:browser> that it is embedded in.
|
||||
while (currentElement) {
|
||||
browser = currentElement->AsBrowser();
|
||||
if (browser) {
|
||||
break;
|
||||
}
|
||||
|
||||
BrowsingContext* browsingContext =
|
||||
currentElement->OwnerDoc()->GetBrowsingContext();
|
||||
currentElement =
|
||||
browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
|
||||
}
|
||||
|
||||
if (!browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
if (NS_FAILED(rv)) {
|
||||
browser.forget(aOutBrowser);
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(manager);
|
||||
if (!listener) {
|
||||
// We are no longer remote so we cannot forward this event.
|
||||
browser.forget(aOutBrowser);
|
||||
manager.forget(aOutManager);
|
||||
return true;
|
||||
}
|
||||
|
||||
browser.forget(aOutBrowser);
|
||||
manager.forget(aOutManager);
|
||||
listener.forget(aOutListener);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void nsSecureBrowserUI::UpdateForLocationOrMixedContentChange() {
|
||||
// Our BrowsingContext either has a new WindowGlobalParent, or the
|
||||
// existing one has mutated its security state.
|
||||
@ -161,26 +110,6 @@ void nsSecureBrowserUI::UpdateForLocationOrMixedContentChange() {
|
||||
return;
|
||||
}
|
||||
|
||||
// This is a bit painful, as we need to do different things for
|
||||
// in-process docshells vs OOP ones.
|
||||
// Ideally we'd just call a function on 'browser' which would
|
||||
// handle sending an event to all listeners, and we wouldn't
|
||||
// need to bother with onSecurityChange.
|
||||
nsCOMPtr<nsIBrowser> browser;
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener;
|
||||
if (!GetWebProgressListener(ctx, getter_AddRefs(browser),
|
||||
getter_AddRefs(manager),
|
||||
getter_AddRefs(managerAsListener))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do we need to construct a fake webprogress and request instance?
|
||||
// Should we split this API out of nsIWebProgressListener to avoid
|
||||
// that?
|
||||
if (managerAsListener) {
|
||||
Unused << managerAsListener->OnSecurityChange(nullptr, nullptr, mState);
|
||||
}
|
||||
if (ctx->GetDocShell()) {
|
||||
nsDocShell* nativeDocShell = nsDocShell::Cast(ctx->GetDocShell());
|
||||
nativeDocShell->nsDocLoader::OnSecurityChange(nullptr, mState);
|
||||
|
@ -234,10 +234,6 @@
|
||||
|
||||
this._lastSearchString = null;
|
||||
|
||||
this._remoteWebNavigation = null;
|
||||
|
||||
this._remoteWebProgress = null;
|
||||
|
||||
this._characterSet = "";
|
||||
|
||||
this._mayEnableCharacterEncodingMenu = null;
|
||||
@ -1084,6 +1080,7 @@
|
||||
* the <browser> element may not be initialized yet.
|
||||
*/
|
||||
|
||||
let oldNavigation = this._remoteWebNavigation;
|
||||
this._remoteWebNavigation = new LazyModules.RemoteWebNavigation(this);
|
||||
|
||||
// Initialize contentPrincipal to the about:blank principal for this loadcontext
|
||||
@ -1097,22 +1094,8 @@
|
||||
// we should re-evaluate the CSP here.
|
||||
this._csp = null;
|
||||
|
||||
let jsm = "resource://gre/modules/RemoteWebProgress.jsm";
|
||||
let { RemoteWebProgressManager } = ChromeUtils.import(jsm, {});
|
||||
|
||||
let oldManager = this._remoteWebProgressManager;
|
||||
this._remoteWebProgressManager = new RemoteWebProgressManager(this);
|
||||
if (oldManager) {
|
||||
// We're transitioning from one remote type to another. This means that
|
||||
// the RemoteWebProgress listener is listening to the old message manager,
|
||||
// and needs to be pointed at the new one.
|
||||
this._remoteWebProgressManager.swapListeners(oldManager);
|
||||
}
|
||||
|
||||
this._remoteWebProgress = this._remoteWebProgressManager.topLevelWebProgress;
|
||||
|
||||
if (!oldManager) {
|
||||
// If we didn't have a manager, then we're transitioning from local to
|
||||
if (!oldNavigation) {
|
||||
// If we weren't remote, then we're transitioning from local to
|
||||
// remote. Add all listeners from the previous <browser> to the new
|
||||
// RemoteWebProgress.
|
||||
this.restoreProgressListeners();
|
||||
@ -1165,13 +1148,8 @@
|
||||
} catch (e) {}
|
||||
|
||||
if (!this.isRemoteBrowser) {
|
||||
// If we've transitioned from remote to non-remote, we no longer need
|
||||
// our RemoteWebProgress or its associated manager, but we'll need to
|
||||
// add the progress listeners to the new non-remote WebProgress.
|
||||
this._remoteWebProgressManager = null;
|
||||
this._remoteWebProgress = null;
|
||||
this._remoteWebNavigation = null;
|
||||
this.restoreProgressListeners();
|
||||
|
||||
this.addEventListener("pagehide", this.onPageHide, true);
|
||||
}
|
||||
}
|
||||
@ -1209,10 +1187,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
get remoteWebProgressManager() {
|
||||
return this._remoteWebProgressManager;
|
||||
}
|
||||
|
||||
updateForStateChange(aCharset, aDocumentURI, aContentType) {
|
||||
if (this.isRemoteBrowser && this.messageManager) {
|
||||
if (aCharset != null) {
|
||||
@ -1652,10 +1626,7 @@
|
||||
fieldsToSwap.push(
|
||||
...[
|
||||
"_remoteWebNavigation",
|
||||
"_remoteWebProgressManager",
|
||||
"_remoteWebProgress",
|
||||
"_remoteFinder",
|
||||
"_securityUI",
|
||||
"_documentURI",
|
||||
"_documentContentType",
|
||||
"_characterSet",
|
||||
@ -1702,14 +1673,6 @@
|
||||
this._remoteWebNavigation.swapBrowser(this);
|
||||
aOtherBrowser._remoteWebNavigation.swapBrowser(aOtherBrowser);
|
||||
|
||||
if (
|
||||
this._remoteWebProgressManager &&
|
||||
aOtherBrowser._remoteWebProgressManager
|
||||
) {
|
||||
this._remoteWebProgressManager.swapBrowser(this);
|
||||
aOtherBrowser._remoteWebProgressManager.swapBrowser(aOtherBrowser);
|
||||
}
|
||||
|
||||
if (this._remoteFinder) {
|
||||
this._remoteFinder.swapBrowser(this);
|
||||
}
|
||||
|
@ -1,164 +0,0 @@
|
||||
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||
// 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/.
|
||||
|
||||
var EXPORTED_SYMBOLS = ["RemoteWebProgressManager"];
|
||||
|
||||
const RemoteWebProgress = Components.Constructor(
|
||||
"@mozilla.org/dom/remote-web-progress;1",
|
||||
"nsIRemoteWebProgress",
|
||||
"init"
|
||||
);
|
||||
|
||||
class RemoteWebProgressManager {
|
||||
constructor(aBrowser) {
|
||||
this._topLevelWebProgress = new RemoteWebProgress(
|
||||
this.QueryInterface(Ci.nsIWebProgress),
|
||||
/* aIsTopLevel = */ true
|
||||
);
|
||||
this._progressListeners = [];
|
||||
|
||||
this.swapBrowser(aBrowser);
|
||||
}
|
||||
|
||||
swapBrowser(aBrowser) {
|
||||
this._browser = aBrowser;
|
||||
}
|
||||
|
||||
swapListeners(aOtherRemoteWebProgressManager) {
|
||||
let temp = aOtherRemoteWebProgressManager.progressListeners;
|
||||
aOtherRemoteWebProgressManager._progressListeners = this._progressListeners;
|
||||
this._progressListeners = temp;
|
||||
}
|
||||
|
||||
get progressListeners() {
|
||||
return this._progressListeners;
|
||||
}
|
||||
|
||||
get topLevelWebProgress() {
|
||||
return this._topLevelWebProgress;
|
||||
}
|
||||
|
||||
addProgressListener(aListener, aNotifyMask) {
|
||||
let listener = aListener.QueryInterface(Ci.nsIWebProgressListener);
|
||||
this._progressListeners.push({
|
||||
listener,
|
||||
mask: aNotifyMask || Ci.nsIWebProgress.NOTIFY_ALL,
|
||||
});
|
||||
}
|
||||
|
||||
removeProgressListener(aListener) {
|
||||
this._progressListeners = this._progressListeners.filter(
|
||||
l => l.listener != aListener
|
||||
);
|
||||
}
|
||||
|
||||
setCurrentURI(aURI) {
|
||||
// This function is simpler than nsDocShell::SetCurrentURI since
|
||||
// it doesn't have to deal with child docshells.
|
||||
let remoteWebNav = this._browser._remoteWebNavigationImpl;
|
||||
remoteWebNav._currentURI = aURI;
|
||||
|
||||
let webProgress = this.topLevelWebProgress;
|
||||
for (let { listener, mask } of this._progressListeners) {
|
||||
if (mask & Ci.nsIWebProgress.NOTIFY_LOCATION) {
|
||||
listener.onLocationChange(webProgress, null, aURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_callProgressListeners(type, methodName, ...args) {
|
||||
for (let { listener, mask } of this._progressListeners) {
|
||||
if (mask & type && listener[methodName]) {
|
||||
try {
|
||||
listener[methodName](...args);
|
||||
} catch (ex) {
|
||||
if (ex.result != Cr.NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED) {
|
||||
Cu.reportError(
|
||||
`RemoteWebProgress failed to call ${methodName}: ${ex}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL,
|
||||
"onStateChange",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aStateFlags,
|
||||
aStatus
|
||||
);
|
||||
}
|
||||
|
||||
onProgressChange(
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress
|
||||
) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_PROGRESS,
|
||||
"onProgressChange",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aCurSelfProgress,
|
||||
aMaxSelfProgress,
|
||||
aCurTotalProgress,
|
||||
aMaxTotalProgress
|
||||
);
|
||||
}
|
||||
|
||||
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION,
|
||||
"onLocationChange",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aLocation,
|
||||
aFlags
|
||||
);
|
||||
}
|
||||
|
||||
onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_STATUS,
|
||||
"onStatusChange",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aStatus,
|
||||
aMessage
|
||||
);
|
||||
}
|
||||
|
||||
onSecurityChange(aWebProgress, aRequest, aState) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_SECURITY,
|
||||
"onSecurityChange",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aState
|
||||
);
|
||||
}
|
||||
|
||||
onContentBlockingEvent(aWebProgress, aRequest, aEvent) {
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING,
|
||||
"onContentBlockingEvent",
|
||||
aWebProgress,
|
||||
aRequest,
|
||||
aEvent
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RemoteWebProgressManager.prototype.QueryInterface = ChromeUtils.generateQI([
|
||||
"nsIWebProgress",
|
||||
"nsIWebProgressListener",
|
||||
]);
|
@ -117,9 +117,6 @@ with Files('PrivateBrowsingUtils.jsm'):
|
||||
with Files('Promise*.jsm'):
|
||||
BUG_COMPONENT = ('Toolkit', 'Async Tooling')
|
||||
|
||||
with Files('RemoteWebProgress.jsm'):
|
||||
BUG_COMPONENT = ('Core', 'DOM: Navigation')
|
||||
|
||||
with Files('ResponsivenessMonitor.jsm'):
|
||||
BUG_COMPONENT = ('Firefox', 'Migration')
|
||||
|
||||
@ -209,7 +206,6 @@ EXTRA_JS_MODULES += [
|
||||
'PromiseUtils.jsm',
|
||||
'Region.jsm',
|
||||
'RemotePageAccessManager.jsm',
|
||||
'RemoteWebProgress.jsm',
|
||||
'ResetProfile.jsm',
|
||||
'ResponsivenessMonitor.jsm',
|
||||
'ServiceRequest.jsm',
|
||||
|
@ -175,7 +175,6 @@
|
||||
"remote-settings.js": ["RemoteSettings", "jexlFilterFunc", "remoteSettingsBroadcastHandler"],
|
||||
"RemotePageManagerChild.jsm": ["ChildMessagePort"],
|
||||
"RemotePageManagerParent.jsm": ["RemotePages", "RemotePageManager"],
|
||||
"RemoteWebProgress.jsm": ["RemoteWebProgressManager"],
|
||||
"resource.js": ["AsyncResource", "Resource"],
|
||||
"resource://services-common/utils.js": ["CommonUtils"],
|
||||
"resource://services-crypto/utils.js": ["CryptoUtils"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user