Issue #2653 - Part 1: Initial cleanup of AppId and isolated mozbrowser.

This removes a lot of the plumbing for having the platform embed itself
through IPC which was required for B2G running the browser as both
shell and browser application.
This commit is contained in:
Moonchild 2024-11-17 20:39:45 +01:00 • committed by roytam1
commit 7b6e3a2d4a
77 changed files with 295 additions and 1799 deletions

View file

@ -6,7 +6,6 @@
#ifndef mozilla_dom_TabContext_h
#define mozilla_dom_TabContext_h
#include "mozIApplication.h"
#include "nsCOMPtr.h"
#include "mozilla/BasePrincipal.h"
#include "nsPIDOMWindow.h"
@ -18,9 +17,7 @@ namespace dom {
class IPCTabContext;
/**
* TabContext encapsulates information about an iframe that may be a mozbrowser
* or mozapp. You can ask whether a TabContext corresponds to a mozbrowser or
* mozapp, get the app that contains the browser, and so on.
* TabContext encapsulates information about an iframe that may be a mozbrowser.
*
* TabParent and TabChild both inherit from TabContext, and you can also have
* standalone TabContext objects.
@ -37,91 +34,29 @@ public:
/* (The implicit copy-constructor and operator= are fine.) */
/**
* Generates IPCTabContext of type BrowserFrameIPCTabContext or
* AppFrameIPCTabContext from this TabContext's information.
* Generates IPCTabContext of type BrowserFrameIPCTabContext from this
* TabContext's information.
*/
IPCTabContext AsIPCTabContext() const;
/**
* Does this TabContext correspond to a mozbrowser?
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements.
*
* If IsMozBrowserElement() is true, HasOwnApp() and HasAppOwnerApp() are
* guaranteed to be false.
*
* If IsMozBrowserElement() is false, HasBrowserOwnerApp() is guaranteed to be
* false.
* <iframe mozbrowser> is a mozbrowser element, but <xul:browser> is not.
*/
bool IsMozBrowserElement() const;
/**
* Does this TabContext correspond to an isolated mozbrowser?
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* mozbrowser elements. <iframe mozbrowser noisolation> does not count as
* isolated since isolation is disabled. Isolation can only be disabled by
* chrome pages.
* Does this TabContext correspond to a mozbrowser? This is equivalent to
* IsMozBrowserElement(). Returns false for <xul:browser>, which isn't a
* mozbrowser.
*/
bool IsIsolatedMozBrowserElement() const;
/**
* Does this TabContext correspond to a mozbrowser or mozapp? This is
* equivalent to IsMozBrowserElement() || HasOwnApp(). Returns false for
* <xul:browser>, which is neither a mozbrowser nor a mozapp.
*/
bool IsMozBrowserOrApp() const;
/**
* OwnAppId() returns the id of the app which directly corresponds to this
* context's frame. GetOwnApp() returns the corresponding app object, and
* HasOwnApp() returns true iff GetOwnApp() would return a non-null value.
*
* If HasOwnApp() is true, IsMozBrowserElement() is guaranteed to be
* false.
*/
uint32_t OwnAppId() const;
already_AddRefed<mozIApplication> GetOwnApp() const;
bool HasOwnApp() const;
/**
* BrowserOwnerAppId() gets the ID of the app which contains this browser
* frame. If this is not a mozbrowser frame (if !IsMozBrowserElement()), then
* BrowserOwnerAppId() is guaranteed to return NO_APP_ID.
*
* Even if we are a browser frame, BrowserOwnerAppId() may still return
* NO_APP_ID, if this browser frame is not contained inside an app.
*/
uint32_t BrowserOwnerAppId() const;
already_AddRefed<mozIApplication> GetBrowserOwnerApp() const;
bool HasBrowserOwnerApp() const;
/**
* AppOwnerAppId() gets the ID of the app which contains this app frame. If
* this is not an app frame (i.e., if !HasOwnApp()), then AppOwnerAppId() is
* guaranteed to return NO_APP_ID.
*
* Even if we are an app frame, AppOwnerAppId() may still return NO_APP_ID, if
* this app frame is not contained inside an app.
*/
uint32_t AppOwnerAppId() const;
already_AddRefed<mozIApplication> GetAppOwnerApp() const;
bool HasAppOwnerApp() const;
/**
* OwnOrContainingAppId() gets the ID of this frame, if HasOwnApp(). If this
* frame does not have its own app, it gets the ID of the app which contains
* this frame (i.e., the result of {Browser,App}OwnerAppId(), as applicable).
*/
uint32_t OwnOrContainingAppId() const;
already_AddRefed<mozIApplication> GetOwnOrContainingApp() const;
bool HasOwnOrContainingApp() const;
bool IsMozBrowser() const;
/**
* OriginAttributesRef() returns the DocShellOriginAttributes of this frame to
* the caller. This is used to store any attribute associated with the frame's
* docshell, such as the AppId.
* docshell.
*/
const DocShellOriginAttributes& OriginAttributesRef() const;
@ -150,17 +85,8 @@ protected:
*/
void SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing);
/**
* Set the TabContext for this frame. This can either be:
* - an app frame (with the given own app) inside the given owner app. Either
* apps can be null.
* - a browser frame inside the given owner app (which may be null).
* - a non-browser, non-app frame. Both own app and owner app should be null.
*/
bool SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered,
mozIApplication* aOwnApp,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes);
@ -190,29 +116,11 @@ private:
/**
* Whether this TabContext corresponds to a mozbrowser.
*
* <iframe mozbrowser mozapp> and <xul:browser> are not considered to be
* <iframe mozbrowser> and <xul:browser> are not considered to be
* mozbrowser elements.
*/
bool mIsMozBrowserElement;
/**
* This TabContext's own app. If this is non-null, then this
* TabContext corresponds to an app, and mIsMozBrowserElement must be false.
*/
nsCOMPtr<mozIApplication> mOwnApp;
/**
* This TabContext's containing app. If mIsMozBrowserElement, this
* corresponds to the app which contains the browser frame; otherwise, this
* corresponds to the app which contains the app frame.
*/
nsCOMPtr<mozIApplication> mContainingApp;
/*
* Cache of mContainingApp->GetLocalId().
*/
uint32_t mContainingAppId;
/**
* DocShellOriginAttributes of the top level tab docShell
*/
@ -241,16 +149,12 @@ public:
bool
SetTabContext(bool aIsMozBrowserElement,
bool aIsPrerendered,
mozIApplication* aOwnApp,
mozIApplication* aAppFrameOwnerApp,
UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings,
const DocShellOriginAttributes& aOriginAttributes)
{
return TabContext::SetTabContext(aIsMozBrowserElement,
aIsPrerendered,
aOwnApp,
aAppFrameOwnerApp,
aShowAccelerators,
aShowFocusRings,
aOriginAttributes);
@ -261,10 +165,9 @@ public:
* MaybeInvalidTabContext is a simple class that lets you transform an
* IPCTabContext into a TabContext.
*
* The issue is that an IPCTabContext is not necessarily valid; for example, it
* might specify an app-id which doesn't exist. So to convert an IPCTabContext
* into a TabContext, you construct a MaybeInvalidTabContext, check whether it's
* valid, and, if so, read out your TabContext.
* The issue is that an IPCTabContext is not necessarily valid. So to convert
* an IPCTabContext into a TabContext, you construct a MaybeInvalidTabContext,
* check whether it's valid, and, if so, read out your TabContext.
*
* Example usage:
*