зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1510569 - Reconstruct nsIWebProgress and nsIRequest for onContentBlockingEvent in TabParent r=Ehsan
Now that we have access to the RemoteWebProgress from the TabParent and can construct RemoteWebProgress and RemoteWebProgressRequests in C++, we can reconstruct the RemoteWebProgress and RemoteWebProgressRequest in the TabParent instead of RemoteWebProgressManager. This improves the API for nsIBrowser and RemoteWebProgressManager, removing the need for the `callWebProgressContentBlockingEventListeners` method in both. It also means we won't need to implement `callWebProgress*Listeners` for methods on nsIBrowser and RemoteWebProgressManager for all other nsIWebProgress events. Differential Revision: https://phabricator.services.mozilla.com/D24942 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d4a4ddb2fc
Коммит
779f6e3bbf
|
@ -5,7 +5,7 @@
|
|||
|
||||
interface nsIContentSecurityPolicy;
|
||||
interface nsIPrincipal;
|
||||
interface nsIURI;
|
||||
interface nsIWebProgress;
|
||||
|
||||
webidl FrameLoader;
|
||||
|
||||
|
@ -60,6 +60,14 @@ 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;
|
||||
|
||||
/**
|
||||
* Called by the child to inform the parent that a command update has occurred
|
||||
* and the supplied set of commands are now enabled and disabled.
|
||||
|
@ -78,29 +86,4 @@ interface nsIBrowser : nsISupports
|
|||
|
||||
readonly attribute nsIPrincipal contentPrincipal;
|
||||
readonly attribute nsIContentSecurityPolicy csp;
|
||||
|
||||
/**
|
||||
* Called by Gecko when we need to call the web progress listeners on our
|
||||
* browser element in order to notify them about a content blocking event
|
||||
* which happened in the content process.
|
||||
* @param isWebProgressPassed whether we're passed a webProgress argument
|
||||
* @param isTopLevel whether we're in the top-level document
|
||||
* @param isLoadingDocument whether we're in the process of loading a document
|
||||
* @param loadType the type of load in progress
|
||||
* @param DOMWindowID the ID of the window receiving the notification
|
||||
* @param requestURI the current URI of the request
|
||||
* @param originalRequestURI the original URI of the request
|
||||
* @param matchedList the matched list for the content blocking event
|
||||
* @param eventType one of the content blocking event codes defined in
|
||||
* nsIWebProgressListener.idl.
|
||||
*/
|
||||
void callWebProgressContentBlockingEventListeners(in boolean isWebProgressPassed,
|
||||
in boolean isTopLevel,
|
||||
in boolean isLoadingDocument,
|
||||
in unsigned long loadType,
|
||||
in uint64_t DOMWindowID,
|
||||
in nsIURI requestURI,
|
||||
in nsIURI originalRequestURI,
|
||||
in ACString matchedList,
|
||||
in unsigned long eventType);
|
||||
};
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "mozilla/dom/IPCBlobUtils.h"
|
||||
#include "mozilla/dom/PaymentRequestParent.h"
|
||||
#include "mozilla/dom/BrowserBridgeParent.h"
|
||||
#include "mozilla/dom/RemoteWebProgress.h"
|
||||
#include "mozilla/dom/RemoteWebProgressRequest.h"
|
||||
#include "mozilla/EventStateManager.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||
|
@ -2215,24 +2217,48 @@ mozilla::ipc::IPCResult TabParent::RecvOnContentBlockingEvent(
|
|||
nsCOMPtr<nsIBrowser> browser =
|
||||
mFrameElement ? mFrameElement->AsBrowser() : nullptr;
|
||||
if (browser) {
|
||||
if (aWebProgressData) {
|
||||
Unused << browser->CallWebProgressContentBlockingEventListeners(
|
||||
true, aWebProgressData->isTopLevel(),
|
||||
aWebProgressData->isLoadingDocument(), aWebProgressData->loadType(),
|
||||
aWebProgressData->outerDOMWindowID(), aRequestData.requestURI(),
|
||||
aRequestData.originalRequestURI(), aRequestData.matchedList(),
|
||||
aEvent);
|
||||
} else {
|
||||
Unused << browser->CallWebProgressContentBlockingEventListeners(
|
||||
false, false, false, 0, 0, aRequestData.requestURI(),
|
||||
aRequestData.originalRequestURI(), aRequestData.matchedList(),
|
||||
aEvent);
|
||||
nsCOMPtr<nsIWebProgress> manager;
|
||||
nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
|
||||
nsCOMPtr<nsIWebProgressListener> managerAsListener =
|
||||
do_QueryInterface(manager);
|
||||
if (!managerAsListener) {
|
||||
// We are no longer remote, so we cannot propagate this message.
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress;
|
||||
nsCOMPtr<nsIRequest> request;
|
||||
ReconstructWebProgressAndRequest(manager, aWebProgressData, aRequestData,
|
||||
webProgress, request);
|
||||
|
||||
Unused << managerAsListener->OnContentBlockingEvent(webProgress, request,
|
||||
aEvent);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void TabParent::ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, nsCOMPtr<nsIWebProgress>& aOutWebProgress,
|
||||
nsCOMPtr<nsIRequest>& aOutRequest) {
|
||||
if (aWebProgressData) {
|
||||
aOutWebProgress = MakeAndAddRef<RemoteWebProgress>(
|
||||
aManager, aWebProgressData->outerDOMWindowID(),
|
||||
aWebProgressData->innerDOMWindowID(), aWebProgressData->loadType(),
|
||||
aWebProgressData->isLoadingDocument(), aWebProgressData->isTopLevel());
|
||||
} else {
|
||||
aOutWebProgress =
|
||||
MakeAndAddRef<RemoteWebProgress>(aManager, 0, 0, 0, false, false);
|
||||
}
|
||||
|
||||
aOutRequest = MakeAndAddRef<RemoteWebProgressRequest>(
|
||||
aRequestData.requestURI(), aRequestData.originalRequestURI(),
|
||||
aRequestData.matchedList());
|
||||
}
|
||||
|
||||
bool TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent) {
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (!widget) {
|
||||
|
|
|
@ -173,6 +173,12 @@ class TabParent final : public PBrowserParent,
|
|||
const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData, const uint32_t& aEvent);
|
||||
|
||||
void ReconstructWebProgressAndRequest(
|
||||
nsIWebProgress* aManager, const Maybe<WebProgressData>& aWebProgressData,
|
||||
const RequestData& aRequestData,
|
||||
nsCOMPtr<nsIWebProgress>& aOutWebProgress,
|
||||
nsCOMPtr<nsIRequest>& aOutRequest);
|
||||
|
||||
mozilla::ipc::IPCResult RecvBrowserFrameOpenWindow(
|
||||
PBrowserParent* aOpener, const nsString& aURL, const nsString& aName,
|
||||
const nsString& aFeatures, BrowserFrameOpenWindowResolver&& aResolve);
|
||||
|
|
|
@ -1387,27 +1387,8 @@ class MozBrowser extends MozElements.MozElementMixin(XULFrameElement) {
|
|||
}
|
||||
}
|
||||
|
||||
callWebProgressContentBlockingEventListeners(aIsWebProgressPassed,
|
||||
aIsTopLevel,
|
||||
aIsLoadingDocument,
|
||||
aLoadType,
|
||||
aDOMWindowID,
|
||||
aRequestURI,
|
||||
aOriginalRequestURI,
|
||||
aMatchedList,
|
||||
aEvent) {
|
||||
if (this._remoteWebProgressManager) {
|
||||
this._remoteWebProgressManager
|
||||
.callWebProgressContentBlockingEventListeners(aIsWebProgressPassed,
|
||||
aIsTopLevel,
|
||||
aIsLoadingDocument,
|
||||
aLoadType,
|
||||
aDOMWindowID,
|
||||
aRequestURI,
|
||||
aOriginalRequestURI,
|
||||
aMatchedList,
|
||||
aEvent);
|
||||
}
|
||||
get remoteWebProgressManager() {
|
||||
return this._remoteWebProgressManager;
|
||||
}
|
||||
|
||||
purgeSessionHistory() {
|
||||
|
|
|
@ -156,59 +156,6 @@ class RemoteWebProgressManager {
|
|||
);
|
||||
}
|
||||
|
||||
callWebProgressContentBlockingEventListeners(aIsWebProgressPassed,
|
||||
aIsTopLevel,
|
||||
aIsLoadingDocument,
|
||||
aLoadType,
|
||||
aDOMWindowID,
|
||||
aRequestURI,
|
||||
aOriginalRequestURI,
|
||||
aMatchedList,
|
||||
aEvent) {
|
||||
let [webProgress, request] =
|
||||
this.getWebProgressAndRequest(aIsWebProgressPassed, aIsTopLevel,
|
||||
aIsLoadingDocument, aLoadType,
|
||||
aDOMWindowID, aRequestURI,
|
||||
aOriginalRequestURI, aMatchedList);
|
||||
this._callProgressListeners(
|
||||
Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING, "onContentBlockingEvent",
|
||||
webProgress, request, aEvent
|
||||
);
|
||||
}
|
||||
|
||||
getWebProgressAndRequest(aIsWebProgressPassed,
|
||||
aIsTopLevel,
|
||||
aIsLoadingDocument,
|
||||
aLoadType,
|
||||
aDOMWindowID,
|
||||
aRequestURI,
|
||||
aOriginalRequestURI,
|
||||
aMatchedList) {
|
||||
let webProgress = null;
|
||||
if (aIsWebProgressPassed) {
|
||||
// The top-level WebProgress is always the same, but because we don't
|
||||
// really have a concept of subframes/content we always create a new object
|
||||
// for those.
|
||||
webProgress = aIsTopLevel ? this._topLevelWebProgress
|
||||
: new RemoteWebProgress(this, aIsTopLevel);
|
||||
webProgress.update(aDOMWindowID,
|
||||
0,
|
||||
aLoadType,
|
||||
aIsLoadingDocument);
|
||||
webProgress.QueryInterface(Ci.nsIWebProgress);
|
||||
}
|
||||
|
||||
let request = null;
|
||||
if (aRequestURI) {
|
||||
request = new RemoteWebProgressRequest(aRequestURI,
|
||||
aOriginalRequestURI,
|
||||
aMatchedList);
|
||||
request = request.QueryInterface(Ci.nsIRequest);
|
||||
}
|
||||
|
||||
return [webProgress, request];
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
let json = aMessage.json;
|
||||
// This message is a custom one we send as a result of a loadURI call.
|
||||
|
|
Загрузка…
Ссылка в новой задаче