mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 05:38:39 +00:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
@@ -340,9 +340,9 @@ this.AccessFu = { // jshint ignore:line
|
||||
case 'remote-browser-shown':
|
||||
case 'inprocess-browser-shown':
|
||||
{
|
||||
// Ignore notifications that aren't from a BrowserOrApp
|
||||
// Ignore notifications that aren't from a Browser
|
||||
let frameLoader = aSubject.QueryInterface(Ci.nsIFrameLoader);
|
||||
if (!frameLoader.ownerIsMozBrowserOrAppFrame) {
|
||||
if (!frameLoader.ownerIsMozBrowserFrame) {
|
||||
return;
|
||||
}
|
||||
this._handleMessageManager(frameLoader.messageManager);
|
||||
|
||||
@@ -624,13 +624,8 @@ BasePrincipal::GetOriginSuffix(nsACString& aOriginAttributes)
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetAppStatus(uint16_t* aAppStatus)
|
||||
{
|
||||
if (AppId() == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
NS_WARNING("Asking for app status on a principal with an unknown app id");
|
||||
*aAppStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aAppStatus = nsScriptSecurityManager::AppStatusForPrincipal(this);
|
||||
// TODO: Remove GetAppStatus.
|
||||
*aAppStatus = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -303,15 +303,6 @@ interface nsIPrincipal : nsISerializable
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long privateBrowsingId;
|
||||
|
||||
/**
|
||||
* Returns true iff the principal is inside an isolated mozbrowser element.
|
||||
* <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 if
|
||||
* the containing document is chrome.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
|
||||
|
||||
/**
|
||||
* Returns true if this principal has an unknown appId. This shouldn't
|
||||
* generally be used. We only expose it due to not providing the correct
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
|
||||
#include "nsIAppsService.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
static bool gCodeBasePrincipalSupport = false;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "xpcpublic.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIInputStreamChannel.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@@ -55,7 +54,6 @@
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
@@ -240,68 +238,6 @@ nsScriptSecurityManager::SecurityHashURI(nsIURI* aURI)
|
||||
return NS_SecurityHashURI(aURI);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
nsScriptSecurityManager::AppStatusForPrincipal(nsIPrincipal *aPrin)
|
||||
{
|
||||
uint32_t appId = aPrin->GetAppId();
|
||||
|
||||
// After bug 1238160, the principal no longer knows how to answer "is this a
|
||||
// browser element", which is really what this code path wants. Currently,
|
||||
// desktop is the only platform where we intend to disable isolation on a
|
||||
// browser frame, so non-desktop should be able to assume that
|
||||
// inIsolatedMozBrowser is true for all mozbrowser frames. Additionally,
|
||||
// apps are no longer used on desktop, so appId is always NO_APP_ID. We use
|
||||
// a release assertion in nsFrameLoader::OwnerIsIsolatedMozBrowserFrame so
|
||||
// that platforms with apps can assume inIsolatedMozBrowser is true for all
|
||||
// mozbrowser frames.
|
||||
bool inIsolatedMozBrowser = aPrin->GetIsInIsolatedMozBrowserElement();
|
||||
|
||||
NS_WARNING_ASSERTION(
|
||||
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
|
||||
"Asking for app status on a principal with an unknown app id");
|
||||
|
||||
// Installed apps have a valid app id (not NO_APP_ID or UNKNOWN_APP_ID)
|
||||
// and they are not inside a mozbrowser.
|
||||
if (appId == nsIScriptSecurityManager::NO_APP_ID ||
|
||||
appId == nsIScriptSecurityManager::UNKNOWN_APP_ID ||
|
||||
inIsolatedMozBrowser)
|
||||
{
|
||||
return nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(appsService, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByLocalId(appId, getter_AddRefs(app));
|
||||
NS_ENSURE_TRUE(app, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
uint16_t status = nsIPrincipal::APP_STATUS_INSTALLED;
|
||||
NS_ENSURE_SUCCESS(app->GetAppStatus(&status),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
nsString appOrigin;
|
||||
NS_ENSURE_SUCCESS(app->GetOrigin(appOrigin),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
nsCOMPtr<nsIURI> appURI;
|
||||
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(appURI), appOrigin),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
|
||||
// The app could contain a cross-origin iframe - make sure that the content
|
||||
// is actually same-origin with the app.
|
||||
MOZ_ASSERT(inIsolatedMozBrowser == false, "Checked this above");
|
||||
nsAutoCString suffix;
|
||||
PrincipalOriginAttributes attrs;
|
||||
NS_ENSURE_TRUE(attrs.PopulateFromOrigin(NS_ConvertUTF16toUTF8(appOrigin), suffix),
|
||||
nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
attrs.mAppId = appId;
|
||||
attrs.mInIsolatedMozBrowser = false;
|
||||
nsCOMPtr<nsIPrincipal> appPrin = BasePrincipal::CreateCodebasePrincipal(appURI, attrs);
|
||||
NS_ENSURE_TRUE(appPrin, nsIPrincipal::APP_STATUS_NOT_INSTALLED);
|
||||
return aPrin->Equals(appPrin) ? status
|
||||
: nsIPrincipal::APP_STATUS_NOT_INSTALLED;
|
||||
}
|
||||
|
||||
/*
|
||||
* GetChannelResultPrincipal will return the principal that the resource
|
||||
* returned by this channel will use. For example, if the resource is in
|
||||
|
||||
@@ -4,7 +4,6 @@ support-files =
|
||||
file_disableScript.html
|
||||
!/js/xpconnect/tests/mochitest/file_empty.html
|
||||
|
||||
[test_app_principal_equality.html]
|
||||
[test_bug246699.html]
|
||||
[test_bug292789.html]
|
||||
[test_bug423375.html]
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=777467
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test app principal's equality</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=777467">Mozilla Bug 777467</a>
|
||||
<p id="display"></p>
|
||||
<script>
|
||||
|
||||
/** Test for app principal's equality **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var permissions = new Promise(resolve => {
|
||||
SpecialPowers.pushPermissions(
|
||||
[{ type: "browser", allow: true, context: document },
|
||||
{ type: "embed-apps", allow: true, context: document }],
|
||||
resolve);
|
||||
});
|
||||
|
||||
permissions.then(() => {
|
||||
$('content').innerHTML =
|
||||
'<iframe src="error404"></iframe>\n' +
|
||||
'<iframe mozbrowser src="error404"></iframe>\n' +
|
||||
'<iframe mozapp="http://example.org/manifest.webapp" mozbrowser src="error404"></iframe>';
|
||||
|
||||
var iframes = document.getElementsByTagName("iframe");
|
||||
var promises = []
|
||||
for (var i = 0; i < promises.length; ++i) {
|
||||
promises.push(new Promise(resolve => {
|
||||
iframes[i].addEventListener("load", resolve);
|
||||
}));
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
var prefs = new Promise(resolve => {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{ set: [[ "dom.mozBrowserFramesEnabled", true ],
|
||||
[ "dom.ipc.browser_frames.oop_by_default", false ]] },
|
||||
resolve);
|
||||
});
|
||||
</script>
|
||||
<div id="content" style="display: none;">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
function canAccessDocument(win) {
|
||||
var result = true;
|
||||
try {
|
||||
win.document;
|
||||
} catch(e) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var loaded = new Promise(resolve => addLoadEvent(resolve));
|
||||
|
||||
Promise.all([ permissions, prefs, loaded ]).then(runTest);
|
||||
|
||||
function runTest() {
|
||||
// Test the witness frame (we can access same-origin frame).
|
||||
is(canAccessDocument(frames[0]), true,
|
||||
"should be able to access the first frame");
|
||||
|
||||
// Test different app/browserElement frames.
|
||||
for (var i=1; i<frames.length; ++i) {
|
||||
is(canAccessDocument(frames[i]), false,
|
||||
"should not be able to access the other frames");
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -569,11 +569,9 @@ WebConsoleActor.prototype =
|
||||
|
||||
let startedListeners = [];
|
||||
let window = !this.parentActor.isRootActor ? this.window : null;
|
||||
let appId = null;
|
||||
let messageManager = null;
|
||||
|
||||
if (this._parentIsContentActor) {
|
||||
appId = this.parentActor.docShell.appId;
|
||||
messageManager = this.parentActor.messageManager;
|
||||
}
|
||||
|
||||
@@ -604,16 +602,16 @@ WebConsoleActor.prototype =
|
||||
// Create a StackTraceCollector that's going to be shared both by the
|
||||
// NetworkMonitorChild (getting messages about requests from parent) and
|
||||
// by the NetworkMonitor that directly watches service workers requests.
|
||||
this.stackTraceCollector = new StackTraceCollector({ window, appId });
|
||||
this.stackTraceCollector = new StackTraceCollector({ window });
|
||||
this.stackTraceCollector.init();
|
||||
|
||||
let processBoundary = Services.appinfo.processType !=
|
||||
Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
if ((appId || messageManager) && processBoundary) {
|
||||
if (messageManager && processBoundary) {
|
||||
// Start a network monitor in the parent process to listen to
|
||||
// most requests than happen in parent
|
||||
this.networkMonitor =
|
||||
new NetworkMonitorChild(appId, this.parentActor.outerWindowID,
|
||||
new NetworkMonitorChild(this.parentActor.outerWindowID,
|
||||
messageManager, this.conn, this);
|
||||
this.networkMonitor.init();
|
||||
// Spawn also one in the child to listen to service workers
|
||||
|
||||
@@ -37,12 +37,12 @@ function getTopWindow(win) {
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
|
||||
if (!docShell.isMozBrowserOrApp) {
|
||||
if (!docShell.isMozBrowser) {
|
||||
return win.top;
|
||||
}
|
||||
|
||||
let topDocShell =
|
||||
docShell.getSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries();
|
||||
docShell.getSameTypeRootTreeItemIgnoreBrowserBoundaries();
|
||||
|
||||
return topDocShell
|
||||
? topDocShell.contentViewer.DOMDocument.defaultView
|
||||
@@ -98,12 +98,12 @@ function getParentWindow(win) {
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShell);
|
||||
|
||||
if (!docShell.isMozBrowserOrApp) {
|
||||
if (!docShell.isMozBrowser) {
|
||||
return win.parent;
|
||||
}
|
||||
|
||||
let parentDocShell =
|
||||
docShell.getSameTypeParentIgnoreBrowserAndAppBoundaries();
|
||||
docShell.getSameTypeParentIgnoreBrowserBoundaries();
|
||||
|
||||
return parentDocShell
|
||||
? parentDocShell.contentViewer.DOMDocument.defaultView
|
||||
|
||||
@@ -1551,8 +1551,6 @@ NetworkMonitor.prototype = {
|
||||
* data to the WebConsoleActor or to a NetworkEventActor.
|
||||
*
|
||||
* @constructor
|
||||
* @param number appId
|
||||
* The web appId of the child process.
|
||||
* @param number outerWindowID
|
||||
* The outerWindowID of the TabActor's main window.
|
||||
* @param nsIMessageManager messageManager
|
||||
@@ -1562,8 +1560,7 @@ NetworkMonitor.prototype = {
|
||||
* @param object owner
|
||||
* The WebConsoleActor that is listening for the network requests.
|
||||
*/
|
||||
function NetworkMonitorChild(appId, outerWindowID, messageManager, conn, owner) {
|
||||
this.appId = appId;
|
||||
function NetworkMonitorChild(outerWindowID, messageManager, conn, owner) {
|
||||
this.outerWindowID = outerWindowID;
|
||||
this.conn = conn;
|
||||
this.owner = owner;
|
||||
@@ -1577,7 +1574,6 @@ function NetworkMonitorChild(appId, outerWindowID, messageManager, conn, owner)
|
||||
exports.NetworkMonitorChild = NetworkMonitorChild;
|
||||
|
||||
NetworkMonitorChild.prototype = {
|
||||
appId: null,
|
||||
owner: null,
|
||||
_netEvents: null,
|
||||
_saveRequestAndResponseBodies: true,
|
||||
@@ -1623,7 +1619,6 @@ NetworkMonitorChild.prototype = {
|
||||
mm.addMessageListener(`${this._msgName}:newEvent`, this._onNewEvent);
|
||||
mm.addMessageListener(`${this._msgName}:updateEvent`, this._onUpdateEvent);
|
||||
mm.sendAsyncMessage(this._msgName, {
|
||||
appId: this.appId,
|
||||
outerWindowID: this.outerWindowID,
|
||||
action: "start",
|
||||
});
|
||||
|
||||
@@ -157,28 +157,6 @@ LoadContext::SetRemoteTabs(bool aUseRemoteTabs)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
|
||||
{
|
||||
MOZ_ASSERT(mIsNotNull);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aIsInIsolatedMozBrowserElement);
|
||||
|
||||
*aIsInIsolatedMozBrowserElement = mOriginAttributes.mInIsolatedMozBrowser;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetAppId(uint32_t* aAppId)
|
||||
{
|
||||
MOZ_ASSERT(mIsNotNull);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aAppId);
|
||||
|
||||
*aAppId = mOriginAttributes.mAppId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadContext::GetOriginAttributes(JS::MutableHandleValue aAttrs)
|
||||
{
|
||||
|
||||
@@ -38,8 +38,6 @@ public:
|
||||
NS_DECL_NSILOADCONTEXT
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
// appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
|
||||
// provided by child process.
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
dom::Element* aTopFrameElement,
|
||||
DocShellOriginAttributes& aAttrs)
|
||||
@@ -54,8 +52,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// appId/inIsolatedMozBrowser arguments override those in SerializedLoadContext
|
||||
// provided by child process.
|
||||
LoadContext(const IPC::SerializedLoadContext& aToCopy,
|
||||
uint64_t aNestedFrameId,
|
||||
DocShellOriginAttributes& aAttrs)
|
||||
|
||||
@@ -334,7 +334,7 @@ nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
|
||||
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
|
||||
parentDocShellItem) {
|
||||
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
|
||||
if (curDocShell && curDocShell->GetIsMozBrowserOrApp()) {
|
||||
if (curDocShell && curDocShell->GetIsMozBrowser()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -427,6 +427,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// log warning to console that xfo is ignored because of CSP
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->GetLoadInfo();
|
||||
uint64_t innerWindowID = loadInfo ? loadInfo->GetInnerWindowID() : 0;
|
||||
@@ -440,7 +441,7 @@ ShouldIgnoreFrameOptions(nsIChannel* aChannel, nsIPrincipal* aPrincipal)
|
||||
0, // no columnnumber
|
||||
nsIScriptError::warningFlag,
|
||||
"CSP", innerWindowID);
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+18
-103
@@ -193,7 +193,6 @@
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsDSURIContentListener.h"
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "nsDocShellTransferableHooks.h"
|
||||
@@ -2569,7 +2568,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetFullscreenAllowed(bool aFullscreenAllowed)
|
||||
{
|
||||
if (!nsIDocShell::GetIsMozBrowserOrApp()) {
|
||||
if (!nsIDocShell::GetIsMozBrowser()) {
|
||||
// Only allow setting of fullscreenAllowed on content/process boundaries.
|
||||
// At non-boundaries the fullscreenAllowed attribute is calculated based on
|
||||
// whether all enclosing frames have the "mozFullscreenAllowed" attribute
|
||||
@@ -3401,7 +3400,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
*aParent = nullptr;
|
||||
|
||||
if (nsIDocShell::GetIsMozBrowserOrApp()) {
|
||||
if (nsIDocShell::GetIsMozBrowser()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -3418,7 +3417,7 @@ nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetSameTypeParentIgnoreBrowserAndAppBoundaries(nsIDocShell** aParent)
|
||||
nsDocShell::GetSameTypeParentIgnoreBrowserBoundaries(nsIDocShell** aParent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
*aParent = nullptr;
|
||||
@@ -3472,18 +3471,18 @@ nsDocShell::GetSameTypeRootTreeItem(nsIDocShellTreeItem** aRootTreeItem)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries(nsIDocShell ** aRootTreeItem)
|
||||
nsDocShell::GetSameTypeRootTreeItemIgnoreBrowserBoundaries(nsIDocShell ** aRootTreeItem)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRootTreeItem);
|
||||
*aRootTreeItem = static_cast<nsIDocShell *>(this);
|
||||
|
||||
nsCOMPtr<nsIDocShell> parent;
|
||||
NS_ENSURE_SUCCESS(GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent)),
|
||||
NS_ENSURE_SUCCESS(GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent)),
|
||||
NS_ERROR_FAILURE);
|
||||
while (parent) {
|
||||
*aRootTreeItem = parent;
|
||||
NS_ENSURE_SUCCESS((*aRootTreeItem)->
|
||||
GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent)),
|
||||
GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent)),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
NS_ADDREF(*aRootTreeItem);
|
||||
@@ -3537,12 +3536,6 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetDS->GetIsInIsolatedMozBrowserElement() !=
|
||||
accessingDS->GetIsInIsolatedMozBrowserElement() ||
|
||||
targetDS->GetAppId() != accessingDS->GetAppId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
|
||||
aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot));
|
||||
nsCOMPtr<nsIDocShell> accessingRootDS = do_QueryInterface(accessingRoot);
|
||||
@@ -3563,7 +3556,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
||||
if (OriginAttributes::IsFirstPartyEnabled()) {
|
||||
if (accessingDS == accessingRootDS &&
|
||||
aAccessingItem->ItemType() == nsIDocShellTreeItem::typeContent &&
|
||||
!accessingDS->GetIsMozBrowserOrApp()) {
|
||||
!accessingDS->GetIsMozBrowser()) {
|
||||
|
||||
nsCOMPtr<nsIDocument> accessingDoc = aAccessingItem->GetDocument();
|
||||
|
||||
@@ -3577,7 +3570,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
||||
|
||||
if (targetDS == targetRootDS &&
|
||||
aTargetItem->ItemType() == nsIDocShellTreeItem::typeContent &&
|
||||
!targetDS->GetIsMozBrowserOrApp()) {
|
||||
!targetDS->GetIsMozBrowser()) {
|
||||
|
||||
nsCOMPtr<nsIDocument> targetDoc = aAccessingItem->GetDocument();
|
||||
|
||||
@@ -3774,7 +3767,7 @@ nsDocShell::DoFindItemWithName(const nsAString& aName,
|
||||
|
||||
// If we have a same-type parent, respecting browser and app boundaries.
|
||||
// NOTE: Could use GetSameTypeParent if the issues described in bug 1310344 are fixed.
|
||||
if (!GetIsMozBrowserOrApp() && parentAsTreeItem->ItemType() == mItemType) {
|
||||
if (!GetIsMozBrowser() && parentAsTreeItem->ItemType() == mItemType) {
|
||||
return parentAsTreeItem->FindItemWithName(
|
||||
aName,
|
||||
static_cast<nsIDocShellTreeItem*>(this),
|
||||
@@ -5312,16 +5305,6 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
|
||||
errorPageUrl.AppendLiteral("&f=");
|
||||
errorPageUrl.AppendASCII(frameType.get());
|
||||
|
||||
// Append the manifest URL if the error comes from an app.
|
||||
nsString manifestURL;
|
||||
nsresult rv = GetAppManifestURL(manifestURL);
|
||||
if (manifestURL.Length() > 0) {
|
||||
nsCString manifestParam;
|
||||
SAFE_ESCAPE(manifestParam, NS_ConvertUTF16toUTF8(manifestURL), url_Path);
|
||||
errorPageUrl.AppendLiteral("&m=");
|
||||
errorPageUrl.AppendASCII(manifestParam.get());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICaptivePortalService> cps = do_GetService(NS_CAPTIVEPORTAL_CID);
|
||||
int32_t cpsState;
|
||||
if (cps && NS_SUCCEEDED(cps->GetState(&cpsState)) &&
|
||||
@@ -5335,7 +5318,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
|
||||
errorPageUrl.AppendASCII(escapedDescription.get());
|
||||
|
||||
nsCOMPtr<nsIURI> errorPageURI;
|
||||
rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return InternalLoad(errorPageURI, nullptr, false, false,
|
||||
@@ -6222,9 +6205,7 @@ nsDocShell::SetIsActive(bool aIsActive)
|
||||
mScriptGlobal->SetIsBackground(!aIsActive);
|
||||
if (nsCOMPtr<nsIDocument> doc = mScriptGlobal->GetExtantDoc()) {
|
||||
// Update orientation when the top-level browsing context becomes active.
|
||||
// We make an exception for apps because they currently rely on
|
||||
// orientation locks persisting across browsing contexts.
|
||||
if (aIsActive && !GetIsApp()) {
|
||||
if (aIsActive) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
GetSameTypeParent(getter_AddRefs(parent));
|
||||
if (!parent) {
|
||||
@@ -6261,7 +6242,7 @@ nsDocShell::SetIsActive(bool aIsActive)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!docshell->GetIsMozBrowserOrApp()) {
|
||||
if (!docshell->GetIsMozBrowser()) {
|
||||
docshell->SetIsActive(aIsActive);
|
||||
}
|
||||
}
|
||||
@@ -10636,9 +10617,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
||||
// lock the orientation of the document to the document's default
|
||||
// orientation. We don't explicitly check for a top-level browsing context
|
||||
// here because orientation is only set on top-level browsing contexts.
|
||||
// We make an exception for apps because they currently rely on
|
||||
// orientation locks persisting across browsing contexts.
|
||||
if (OrientationLock() != eScreenOrientation_None && !GetIsApp()) {
|
||||
if (OrientationLock() != eScreenOrientation_None) {
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
GetSameTypeParent(getter_AddRefs(parent));
|
||||
@@ -11023,7 +11002,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
||||
NeckoOriginAttributes neckoAttrs;
|
||||
bool isTopLevelDoc = aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT &&
|
||||
mItemType == typeContent &&
|
||||
!GetIsMozBrowserOrApp();
|
||||
!GetIsMozBrowser();
|
||||
neckoAttrs.InheritFromDocShellToNecko(GetOriginAttributes(), isTopLevelDoc, aURI);
|
||||
rv = loadInfo->SetOriginAttributes(neckoAttrs);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@@ -14480,16 +14459,9 @@ nsDocShell::GetFrameType(uint32_t* aFrameType)
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetIsApp(bool* aIsApp)
|
||||
nsDocShell::GetIsMozBrowser(bool* aIsMozBrowser)
|
||||
{
|
||||
*aIsApp = (mFrameType == FRAME_TYPE_APP);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetIsMozBrowserOrApp(bool* aIsMozBrowserOrApp)
|
||||
{
|
||||
*aIsMozBrowserOrApp = (mFrameType != FRAME_TYPE_REGULAR);
|
||||
*aIsMozBrowser = (mFrameType == FRAME_TYPE_BROWSER);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -14512,30 +14484,9 @@ nsDocShell::GetInheritedFrameType()
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetIsIsolatedMozBrowserElement(bool* aIsIsolatedMozBrowserElement)
|
||||
nsDocShell::GetIsInMozBrowser(bool* aIsInMozBrowser)
|
||||
{
|
||||
bool result = mFrameType == FRAME_TYPE_BROWSER &&
|
||||
mOriginAttributes.mInIsolatedMozBrowser;
|
||||
*aIsIsolatedMozBrowserElement = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
|
||||
{
|
||||
MOZ_ASSERT(!mOriginAttributes.mInIsolatedMozBrowser ||
|
||||
(GetInheritedFrameType() == FRAME_TYPE_BROWSER),
|
||||
"Isolated mozbrowser should only be true inside browser frames");
|
||||
bool result = (GetInheritedFrameType() == FRAME_TYPE_BROWSER) &&
|
||||
mOriginAttributes.mInIsolatedMozBrowser;
|
||||
*aIsInIsolatedMozBrowserElement = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetIsInMozBrowserOrApp(bool* aIsInMozBrowserOrApp)
|
||||
{
|
||||
*aIsInMozBrowserOrApp = (GetInheritedFrameType() != FRAME_TYPE_REGULAR);
|
||||
*aIsInMozBrowser = (GetInheritedFrameType() == FRAME_TYPE_BROWSER);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -14553,25 +14504,6 @@ nsDocShell::GetIsTopLevelContentDocShell(bool* aIsTopLevelContentDocShell)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsDocShell::GetAppId(uint32_t* aAppId)
|
||||
{
|
||||
if (mOriginAttributes.mAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
*aAppId = mOriginAttributes.mAppId;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> parent;
|
||||
GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
|
||||
|
||||
if (!parent) {
|
||||
*aAppId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return parent->GetAppId(aAppId);
|
||||
}
|
||||
|
||||
// Implements nsILoadContext.originAttributes
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetOriginAttributes(JS::MutableHandle<JS::Value> aVal)
|
||||
@@ -14680,23 +14612,6 @@ nsDocShell::SetOriginAttributes(JS::Handle<JS::Value> aOriginAttributes,
|
||||
return SetOriginAttributes(attrs);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetAppManifestURL(nsAString& aAppManifestURL)
|
||||
{
|
||||
uint32_t appId = nsIDocShell::GetAppId();
|
||||
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
|
||||
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
nsCOMPtr<nsIAppsService> appsService =
|
||||
do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ASSERTION(appsService, "No AppsService available");
|
||||
appsService->GetManifestURLByLocalId(appId, aAppManifestURL);
|
||||
} else {
|
||||
aAppManifestURL.SetLength(0);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetAsyncPanZoomEnabled(bool* aOut)
|
||||
{
|
||||
|
||||
@@ -789,8 +789,6 @@ protected:
|
||||
static const nsCString FrameTypeToString(uint32_t aFrameType)
|
||||
{
|
||||
switch (aFrameType) {
|
||||
case FRAME_TYPE_APP:
|
||||
return NS_LITERAL_CSTRING("app");
|
||||
case FRAME_TYPE_BROWSER:
|
||||
return NS_LITERAL_CSTRING("browser");
|
||||
case FRAME_TYPE_REGULAR:
|
||||
|
||||
@@ -826,109 +826,50 @@ interface nsIDocShell : nsIDocShellTreeItem
|
||||
*/
|
||||
[noscript] void notifyScrollObservers();
|
||||
|
||||
/**
|
||||
* Returns true iff the docshell corresponds to an <iframe mozapp>.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isApp;
|
||||
|
||||
/**
|
||||
* The type of iframe that this docshell lives.
|
||||
*/
|
||||
const unsigned long FRAME_TYPE_REGULAR = 0;
|
||||
const unsigned long FRAME_TYPE_BROWSER = 1;
|
||||
const unsigned long FRAME_TYPE_APP = 2;
|
||||
|
||||
[infallible] attribute unsigned long frameType;
|
||||
|
||||
/**
|
||||
* Returns true if this docshell corresponds to an <iframe mozbrowser> or
|
||||
* <iframe mozapp>. <xul:browser> returns false here.
|
||||
* Returns true if this docshell corresponds to an <iframe mozbrowser>.
|
||||
* <xul:browser> returns false here.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isMozBrowserOrApp;
|
||||
[infallible] readonly attribute boolean isMozBrowser;
|
||||
|
||||
/**
|
||||
* Returns true if this docshell corresponds to an isolated <iframe
|
||||
* 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 if
|
||||
* the containing document is chrome.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isIsolatedMozBrowserElement;
|
||||
|
||||
/**
|
||||
* Returns true if this docshell corresponds to an isolated <iframe
|
||||
* mozbrowser> or if the docshell is contained in an isolated <iframe
|
||||
* 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 if
|
||||
* the containing document is chrome.
|
||||
*
|
||||
* Our notion here of "contained in" means: Walk up the docshell hierarchy in
|
||||
* this process until we hit an <iframe mozapp> or <iframe mozbrowser> (or
|
||||
* until the hierarchy ends). Return true iff the docshell we stopped on has
|
||||
* isIsolatedMozBrowserElement == true.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
|
||||
|
||||
/**
|
||||
* Returns true if this docshell corresponds to an <iframe mozbrowser> or
|
||||
* <iframe mozapp>, or if this docshell is contained in an <iframe mozbrowser>
|
||||
* or <iframe mozapp>. <xul:browser> returns false here.
|
||||
* Returns true if this docshell corresponds to an <iframe mozbrowser>, or
|
||||
* if this docshell is contained in an <iframe mozbrowser>. <xul:browser>
|
||||
* returns false here.
|
||||
*
|
||||
* To compute this value, we walk up the docshell hierarchy. If we encounter
|
||||
* a docshell with isMozBrowserOrApp before we hit the end of the hierarchy,
|
||||
* a docshell with isMozBrowser before we hit the end of the hierarchy,
|
||||
* we return true. Otherwise, we return false.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isInMozBrowserOrApp;
|
||||
[infallible] readonly attribute boolean isInMozBrowser;
|
||||
|
||||
/**
|
||||
* Returns true if this docshell is the top level content docshell.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isTopLevelContentDocShell;
|
||||
|
||||
/**
|
||||
* Returns the id of the app associated with this docshell. If this docshell
|
||||
* is an <iframe mozbrowser> inside an <iframe mozapp>, we return the app's
|
||||
* appId.
|
||||
*
|
||||
* We compute this value by walking up the docshell hierarchy until we find a
|
||||
* docshell on which origin attributes was set. (ignoring those docshells
|
||||
* where x == UNKNOWN_APP_ID). We return the app id x.
|
||||
*
|
||||
* If we don't find a docshell with an associated app id in our hierarchy, we
|
||||
* return NO_APP_ID. We never return UNKNOWN_APP_ID.
|
||||
*
|
||||
* Notice that a docshell may have an associated app even if it returns true
|
||||
* for isBrowserElement!
|
||||
*/
|
||||
[infallible] readonly attribute unsigned long appId;
|
||||
|
||||
/**
|
||||
* Return the manifest URL of the app associated with this docshell.
|
||||
*
|
||||
* If there is no associated app in our hierarchy, we return empty string.
|
||||
*/
|
||||
readonly attribute DOMString appManifestURL;
|
||||
|
||||
/**
|
||||
* Like nsIDocShellTreeItem::GetSameTypeParent, except this ignores <iframe
|
||||
* mozbrowser> and <iframe mozapp> boundaries.
|
||||
* mozbrowser> boundaries.
|
||||
*/
|
||||
nsIDocShell getSameTypeParentIgnoreBrowserAndAppBoundaries();
|
||||
nsIDocShell getSameTypeParentIgnoreBrowserBoundaries();
|
||||
|
||||
/**
|
||||
* Like nsIDocShellTreeItem::GetSameTypeRootTreeItem, except this ignores
|
||||
* <iframe mozbrowser> and <iframe mozapp> boundaries.
|
||||
* <iframe mozbrowser> boundaries.
|
||||
*/
|
||||
nsIDocShell getSameTypeRootTreeItemIgnoreBrowserAndAppBoundaries();
|
||||
nsIDocShell getSameTypeRootTreeItemIgnoreBrowserBoundaries();
|
||||
|
||||
/**
|
||||
* True iff asynchronous panning and zooming is enabled for this
|
||||
* docshell.
|
||||
* True if asynchronous panning and zooming is enabled for this docshell.
|
||||
*/
|
||||
readonly attribute bool asyncPanZoomEnabled;
|
||||
|
||||
|
||||
@@ -57,10 +57,9 @@ interface nsIDocShellTreeItem : nsISupports
|
||||
|
||||
/*
|
||||
This getter returns the same thing parent does however if the parent
|
||||
is of a different itemType, or if the parent is an <iframe mozbrowser>
|
||||
or <iframe mozapp>, it will instead return nullptr. This call is a
|
||||
convience function for those wishing to not cross the boundaries at
|
||||
which item types change.
|
||||
is of a different itemType, or if the parent is an <iframe mozbrowser>.
|
||||
It will instead return nullptr. This call is a convience function for
|
||||
Ithose wishing to not cross the boundaries at which item types change.
|
||||
*/
|
||||
readonly attribute nsIDocShellTreeItem sameTypeParent;
|
||||
|
||||
|
||||
@@ -104,21 +104,6 @@ interface nsILoadContext : nsISupports
|
||||
*/
|
||||
[noscript] void SetRemoteTabs(in boolean aUseRemoteTabs);
|
||||
|
||||
/**
|
||||
* Returns true iff the load is occurring inside an isolated mozbrowser
|
||||
* element. <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 if
|
||||
* the containing document is chrome.
|
||||
*/
|
||||
readonly attribute boolean isInIsolatedMozBrowserElement;
|
||||
|
||||
/**
|
||||
* Returns the app id of the app the load is occurring is in. Returns
|
||||
* nsIScriptSecurityManager::NO_APP_ID if the load is not part of an app.
|
||||
*/
|
||||
readonly attribute unsigned long appId;
|
||||
|
||||
/**
|
||||
* A dictionary of the non-default origin attributes associated with this
|
||||
* nsILoadContext.
|
||||
|
||||
@@ -1,114 +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/. */
|
||||
|
||||
"use strict"
|
||||
|
||||
function debug(s) {
|
||||
//dump("-*- AppsService.js: " + s + "\n");
|
||||
}
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
||||
const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
|
||||
|
||||
function AppsService()
|
||||
{
|
||||
debug("AppsService Constructor");
|
||||
this.inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
debug("inParent: " + this.inParent);
|
||||
if (!this.inParent) {
|
||||
Cu.import("resource://gre/modules/AppsServiceChild.jsm");
|
||||
}
|
||||
}
|
||||
|
||||
AppsService.prototype = {
|
||||
|
||||
isInvalidId: function(localId) {
|
||||
return (localId == Ci.nsIScriptSecurityManager.NO_APP_ID ||
|
||||
localId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID);
|
||||
},
|
||||
|
||||
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
|
||||
debug("GetAppByManifestURL( " + aManifestURL + " )");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getManifestFor: function getManifestFor(aManifestURL) {
|
||||
debug("getManifestFor(" + aManifestURL + ")");
|
||||
if (this.inParent) {
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
} else {
|
||||
return Promise.reject(
|
||||
new Error("Calling getManifestFor() from child is not supported"));
|
||||
}
|
||||
},
|
||||
|
||||
getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
|
||||
debug("getAppLocalIdByManifestURL( " + aManifestURL + " )");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getAppLocalIdByStoreId: function getAppLocalIdByStoreId(aStoreId) {
|
||||
debug("getAppLocalIdByStoreId( " + aStoreId + " )");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getAppByLocalId: function getAppByLocalId(aLocalId) {
|
||||
debug("getAppByLocalId( " + aLocalId + " )");
|
||||
if (this.isInvalidId(aLocalId)) {
|
||||
return null;
|
||||
}
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
|
||||
debug("getManifestURLByLocalId( " + aLocalId + " )");
|
||||
if (this.isInvalidId(aLocalId)) {
|
||||
return null;
|
||||
}
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getCoreAppsBasePath: function getCoreAppsBasePath() {
|
||||
debug("getCoreAppsBasePath()");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getWebAppsBasePath: function getWebAppsBasePath() {
|
||||
debug("getWebAppsBasePath()");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
areAnyAppsInstalled: function() {
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getAppInfo: function getAppInfo(aAppId) {
|
||||
debug("getAppInfo()");
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
getScopeByLocalId: function(aLocalId) {
|
||||
debug("getScopeByLocalId( " + aLocalId + " )");
|
||||
if (this.isInvalidId(aLocalId)) {
|
||||
return null;
|
||||
}
|
||||
// TODO : implement properly!
|
||||
// We just return null for now to not break PushService.jsm
|
||||
return null;
|
||||
},
|
||||
|
||||
classID : APPS_SERVICE_CID,
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppsService])
|
||||
@@ -1,2 +0,0 @@
|
||||
component {05072afa-92fe-45bf-ae22-39b69c117058} AppsService.js
|
||||
contract @mozilla.org/AppsService;1 {05072afa-92fe-45bf-ae22-39b69c117058}
|
||||
@@ -1,408 +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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
// This module exposes a subset of the functionalities of the parent DOM
|
||||
// Registry to content processes, to be used from the AppsService component.
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["DOMApplicationRegistry", "WrappedManifestCache"];
|
||||
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function debug(s) {
|
||||
//dump("-*- AppsServiceChild.jsm: " + s + "\n");
|
||||
}
|
||||
|
||||
const APPS_IPC_MSG_NAMES = [
|
||||
"Webapps:AddApp",
|
||||
"Webapps:RemoveApp",
|
||||
"Webapps:UpdateApp",
|
||||
"Webapps:CheckForUpdate:Return:KO",
|
||||
"Webapps:FireEvent",
|
||||
"Webapps:UpdateState"
|
||||
];
|
||||
|
||||
// A simple cache for the wrapped manifests.
|
||||
this.WrappedManifestCache = {
|
||||
_cache: { },
|
||||
|
||||
// Gets an entry from the cache, and populates the cache if needed.
|
||||
get: function mcache_get(aManifestURL, aManifest, aWindow, aInnerWindowID) {
|
||||
if (!aManifest) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(aManifestURL in this._cache)) {
|
||||
this._cache[aManifestURL] = { };
|
||||
}
|
||||
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (!(aInnerWindowID in winObjs)) {
|
||||
winObjs[aInnerWindowID] = Cu.cloneInto(aManifest, aWindow);
|
||||
}
|
||||
|
||||
return winObjs[aInnerWindowID];
|
||||
},
|
||||
|
||||
// Invalidates an entry in the cache.
|
||||
evict: function mcache_evict(aManifestURL, aInnerWindowID) {
|
||||
debug("Evicting manifest " + aManifestURL + " window ID " +
|
||||
aInnerWindowID);
|
||||
if (aManifestURL in this._cache) {
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (aInnerWindowID in winObjs) {
|
||||
delete winObjs[aInnerWindowID];
|
||||
}
|
||||
|
||||
if (Object.keys(winObjs).length == 0) {
|
||||
delete this._cache[aManifestURL];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// Clear the cache on memory pressure.
|
||||
this._cache = { };
|
||||
Cu.forceGC();
|
||||
},
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, "memory-pressure", false);
|
||||
}
|
||||
};
|
||||
|
||||
this.WrappedManifestCache.init();
|
||||
|
||||
|
||||
// DOMApplicationRegistry keeps a cache containing a list of apps in the device.
|
||||
// This information is updated with the data received from the main process and
|
||||
// it is queried by the DOM objects to set their state.
|
||||
// This module handle all the messages broadcasted from the parent process,
|
||||
// including DOM events, which are dispatched to the corresponding DOM objects.
|
||||
|
||||
this.DOMApplicationRegistry = {
|
||||
// DOMApps will hold a list of arrays of weak references to
|
||||
// mozIDOMApplication objects indexed by manifest URL.
|
||||
DOMApps: {},
|
||||
|
||||
ready: false,
|
||||
webapps: null,
|
||||
|
||||
init: function init() {
|
||||
this.cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsISyncMessageSender);
|
||||
|
||||
APPS_IPC_MSG_NAMES.forEach((function(aMsgName) {
|
||||
this.cpmm.addMessageListener(aMsgName, this);
|
||||
}).bind(this));
|
||||
|
||||
this.webapps = { };
|
||||
// We need a fast mapping from localId -> app, so we add an index.
|
||||
// We also add the manifest to the app object.
|
||||
this.localIdIndex = { };
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
this.localIdIndex[app.localId] = app;
|
||||
app.manifest = list.manifests[id];
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// cpmm.addMessageListener causes the DOMApplicationRegistry object to
|
||||
// live forever if we don't clean up properly.
|
||||
this.webapps = null;
|
||||
this.DOMApps = null;
|
||||
|
||||
APPS_IPC_MSG_NAMES.forEach((aMsgName) => {
|
||||
this.cpmm.removeMessageListener(aMsgName, this);
|
||||
});
|
||||
},
|
||||
|
||||
receiveMessage: function receiveMessage(aMessage) {
|
||||
debug("Received " + aMessage.name + " message.");
|
||||
let msg = aMessage.data;
|
||||
switch (aMessage.name) {
|
||||
case "Webapps:AddApp":
|
||||
this.webapps[msg.id] = msg.app;
|
||||
this.localIdIndex[msg.app.localId] = msg.app;
|
||||
if (msg.manifest) {
|
||||
this.webapps[msg.id].manifest = msg.manifest;
|
||||
}
|
||||
break;
|
||||
case "Webapps:RemoveApp":
|
||||
delete this.DOMApps[this.webapps[msg.id].manifestURL];
|
||||
delete this.localIdIndex[this.webapps[msg.id].localId];
|
||||
delete this.webapps[msg.id];
|
||||
break;
|
||||
case "Webapps:UpdateApp":
|
||||
let app = this.webapps[msg.oldId];
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.app) {
|
||||
for (let prop in msg.app) {
|
||||
app[prop] = msg.app[prop];
|
||||
}
|
||||
}
|
||||
|
||||
this.webapps[msg.newId] = app;
|
||||
this.localIdIndex[app.localId] = app;
|
||||
delete this.webapps[msg.oldId];
|
||||
|
||||
let apps = this.DOMApps[msg.app.manifestURL];
|
||||
if (!apps) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
let domApp = apps[i].get();
|
||||
if (!domApp || domApp._window === null) {
|
||||
apps.splice(i, 1);
|
||||
continue;
|
||||
}
|
||||
domApp._proxy = new Proxy(domApp, {
|
||||
get: function(target, prop) {
|
||||
if (!DOMApplicationRegistry.webapps[msg.newId]) {
|
||||
return;
|
||||
}
|
||||
return DOMApplicationRegistry.webapps[msg.newId][prop];
|
||||
},
|
||||
set: function(target, prop, val) {
|
||||
if (!DOMApplicationRegistry.webapps[msg.newId]) {
|
||||
return;
|
||||
}
|
||||
DOMApplicationRegistry.webapps[msg.newId][prop] = val;
|
||||
return;
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "Webapps:FireEvent":
|
||||
this._fireEvent(aMessage);
|
||||
break;
|
||||
case "Webapps:UpdateState":
|
||||
this._updateState(msg);
|
||||
break;
|
||||
case "Webapps:CheckForUpdate:Return:KO":
|
||||
let DOMApps = this.DOMApps[msg.manifestURL];
|
||||
if (!DOMApps || !msg.requestID) {
|
||||
return;
|
||||
}
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (domApp && msg.requestID) {
|
||||
domApp._fireRequestResult(aMessage, true /* aIsError */);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* mozIDOMApplication management
|
||||
*/
|
||||
|
||||
// Every time a DOM app is created, we save a weak reference to it that will
|
||||
// be used to dispatch events and fire request results.
|
||||
addDOMApp: function(aApp, aManifestURL, aId) {
|
||||
let weakRef = Cu.getWeakReference(aApp);
|
||||
|
||||
if (!this.DOMApps[aManifestURL]) {
|
||||
this.DOMApps[aManifestURL] = [];
|
||||
}
|
||||
|
||||
let apps = this.DOMApps[aManifestURL];
|
||||
|
||||
// Get rid of dead weak references.
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
let app = apps[i].get();
|
||||
if (!app || app._window === null) {
|
||||
apps.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
apps.push(weakRef);
|
||||
|
||||
// Each DOM app contains a proxy object used to build their state. We
|
||||
// return the handler for this proxy object with traps to get and set
|
||||
// app properties kept in the DOMApplicationRegistry app cache.
|
||||
return {
|
||||
get: function(target, prop) {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop in DOMApplicationRegistry.webapps[aId]) {
|
||||
return DOMApplicationRegistry.webapps[aId][prop];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set: function(target, prop, val) {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
return;
|
||||
}
|
||||
DOMApplicationRegistry.webapps[aId][prop] = val;
|
||||
return;
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
_fireEvent: function(aMessage) {
|
||||
let msg = aMessage.data;
|
||||
debug("_fireEvent " + JSON.stringify(msg));
|
||||
if (!this.DOMApps || !msg.manifestURL || !msg.eventType) {
|
||||
return;
|
||||
}
|
||||
|
||||
let DOMApps = this.DOMApps[msg.manifestURL];
|
||||
if (!DOMApps) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The parent might ask childs to trigger more than one event in one
|
||||
// shot, so in order to avoid needless IPC we allow an array for the
|
||||
// 'eventType' IPC message field.
|
||||
if (!Array.isArray(msg.eventType)) {
|
||||
msg.eventType = [msg.eventType];
|
||||
}
|
||||
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (!domApp) {
|
||||
return;
|
||||
}
|
||||
msg.eventType.forEach((aEventType) => {
|
||||
if ('on' + aEventType in domApp) {
|
||||
domApp._fireEvent(aEventType);
|
||||
}
|
||||
});
|
||||
|
||||
if (msg.requestID) {
|
||||
aMessage.data.result = msg.manifestURL;
|
||||
domApp._fireRequestResult(aMessage);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_updateState: function(aMessage) {
|
||||
if (!this.DOMApps || !aMessage.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let app = this.webapps[aMessage.id];
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aMessage.app) {
|
||||
for (let prop in aMessage.app) {
|
||||
app[prop] = aMessage.app[prop];
|
||||
}
|
||||
}
|
||||
|
||||
if ("error" in aMessage) {
|
||||
app.downloadError = aMessage.error;
|
||||
}
|
||||
|
||||
if (aMessage.manifest) {
|
||||
app.manifest = aMessage.manifest;
|
||||
// Evict the wrapped manifest cache for all the affected DOM objects.
|
||||
let DOMApps = this.DOMApps[app.manifestURL];
|
||||
if (!DOMApps) {
|
||||
return;
|
||||
}
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (!domApp) {
|
||||
return;
|
||||
}
|
||||
WrappedManifestCache.evict(app.manifestURL, domApp.innerWindowID);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getAll: function(aCallback) {
|
||||
debug("getAll()\n");
|
||||
if (!aCallback || typeof aCallback !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
let res = [];
|
||||
for (let id in this.webapps) {
|
||||
res.push(this.webapps[id]);
|
||||
}
|
||||
aCallback(res);
|
||||
},
|
||||
|
||||
getAdditionalLanguages: function(aManifestURL) {
|
||||
for (let id in this.webapps) {
|
||||
if (this.webapps[id].manifestURL == aManifestURL) {
|
||||
return this.webapps[id].additionalLanguages || {};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIAppsService API
|
||||
*/
|
||||
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
|
||||
debug("getAppByManifestURL " + aManifestURL);
|
||||
return AppsUtils.getAppByManifestURL(this.webapps, aManifestURL);
|
||||
},
|
||||
|
||||
getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
|
||||
debug("getAppLocalIdByManifestURL " + aManifestURL);
|
||||
return AppsUtils.getAppLocalIdByManifestURL(this.webapps, aManifestURL);
|
||||
},
|
||||
|
||||
getAppLocalIdByStoreId: function(aStoreId) {
|
||||
debug("getAppLocalIdByStoreId:" + aStoreId);
|
||||
return AppsUtils.getAppLocalIdByStoreId(this.webapps, aStoreId);
|
||||
},
|
||||
|
||||
getAppByLocalId: function getAppByLocalId(aLocalId) {
|
||||
debug("getAppByLocalId " + aLocalId + " - ready: " + this.ready);
|
||||
let app = this.localIdIndex[aLocalId];
|
||||
if (!app) {
|
||||
debug("Ouch, No app!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new mozIApplication(app);
|
||||
},
|
||||
|
||||
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
|
||||
debug("getManifestURLByLocalId " + aLocalId);
|
||||
return AppsUtils.getManifestURLByLocalId(this.webapps, aLocalId);
|
||||
},
|
||||
|
||||
getCoreAppsBasePath: function getCoreAppsBasePath() {
|
||||
debug("getCoreAppsBasePath() not yet supported on child!");
|
||||
return null;
|
||||
},
|
||||
|
||||
getWebAppsBasePath: function getWebAppsBasePath() {
|
||||
debug("getWebAppsBasePath() not yet supported on child!");
|
||||
return null;
|
||||
},
|
||||
|
||||
areAnyAppsInstalled: function() {
|
||||
return AppsUtils.areAnyAppsInstalled(this.webapps);
|
||||
},
|
||||
|
||||
getAppInfo: function getAppInfo(aAppId) {
|
||||
return AppsUtils.getAppInfo(this.webapps, aAppId);
|
||||
}
|
||||
}
|
||||
|
||||
DOMApplicationRegistry.init();
|
||||
+2
-81
@@ -19,14 +19,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
"@mozilla.org/AppsService;1",
|
||||
"nsIAppsService");
|
||||
|
||||
// Shared code for AppsServiceChild.jsm, Webapps.jsm and Webapps.js
|
||||
// Shared code for Webapps.jsm and Webapps.js
|
||||
|
||||
this.EXPORTED_SYMBOLS =
|
||||
["AppsUtils", "ManifestHelper", "isAbsoluteURI", "mozIApplication"];
|
||||
["AppsUtils", "ManifestHelper", "isAbsoluteURI"];
|
||||
|
||||
function debug(s) {
|
||||
//dump("-*- AppsUtils.jsm: " + s + "\n");
|
||||
@@ -39,46 +35,6 @@ this.isAbsoluteURI = function(aURI) {
|
||||
Services.io.newURI(aURI, null, bar).prePath != bar.prePath;
|
||||
}
|
||||
|
||||
this.mozIApplication = function(aApp) {
|
||||
_setAppProperties(this, aApp);
|
||||
}
|
||||
|
||||
mozIApplication.prototype = {
|
||||
hasPermission: function(aPermission) {
|
||||
// This helper checks an URI inside |aApp|'s origin and part of |aApp| has a
|
||||
// specific permission. It is not checking if browsers inside |aApp| have such
|
||||
// permission.
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(this.principal,
|
||||
aPermission);
|
||||
return (perm === Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
},
|
||||
|
||||
get principal() {
|
||||
if (this._principal) {
|
||||
return this._principal;
|
||||
}
|
||||
|
||||
this._principal = null;
|
||||
|
||||
try {
|
||||
this._principal = Services.scriptSecurityManager.createCodebasePrincipal(
|
||||
Services.io.newURI(this.origin, null, null),
|
||||
{appId: this.localId});
|
||||
} catch(e) {
|
||||
dump("Could not create app principal " + e + "\n");
|
||||
}
|
||||
|
||||
return this._principal;
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
if (aIID.equals(Ci.mozIApplication) ||
|
||||
aIID.equals(Ci.nsISupports))
|
||||
return this;
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
function _setAppProperties(aObj, aApp) {
|
||||
aObj.name = aApp.name;
|
||||
aObj.csp = aApp.csp;
|
||||
@@ -217,21 +173,6 @@ this.AppsUtils = {
|
||||
return aPagePath.substr(pathPos, pathLen);
|
||||
},
|
||||
|
||||
getAppByManifestURL: function getAppByManifestURL(aApps, aManifestURL) {
|
||||
debug("getAppByManifestURL " + aManifestURL);
|
||||
// This could be O(1) if |webapps| was a dictionary indexed on manifestURL
|
||||
// which should be the unique app identifier.
|
||||
// It's currently O(n).
|
||||
for (let id in aApps) {
|
||||
let app = aApps[id];
|
||||
if (app.manifestURL == aManifestURL) {
|
||||
return new mozIApplication(app);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getManifestFor: function getManifestFor(aManifestURL) {
|
||||
debug("getManifestFor(" + aManifestURL + ")");
|
||||
return DOMApplicationRegistry.getManifestFor(aManifestURL);
|
||||
@@ -259,18 +200,6 @@ this.AppsUtils = {
|
||||
return Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||
},
|
||||
|
||||
getAppByLocalId: function getAppByLocalId(aApps, aLocalId) {
|
||||
debug("getAppByLocalId " + aLocalId);
|
||||
for (let id in aApps) {
|
||||
let app = aApps[id];
|
||||
if (app.localId == aLocalId) {
|
||||
return new mozIApplication(app);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getManifestURLByLocalId: function getManifestURLByLocalId(aApps, aLocalId) {
|
||||
debug("getManifestURLByLocalId " + aLocalId);
|
||||
for (let id in aApps) {
|
||||
@@ -697,14 +626,6 @@ this.AppsUtils = {
|
||||
return this.computeHash(JSON.stringify(aObject));
|
||||
},
|
||||
|
||||
getAppManifestURLFromWindow: function(aWindow) {
|
||||
let appId = aWindow.document.nodePrincipal.appId;
|
||||
if (appId === Ci.nsIScriptSecurityManager.NO_APP_ID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return appsService.getManifestURLByLocalId(appId);
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -233,11 +233,6 @@ this.PermissionsTable = { geolocation: {
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"embed-apps": {
|
||||
app: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
"background-sensors": {
|
||||
app: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
|
||||
@@ -5,13 +5,7 @@
|
||||
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'AppsService.js',
|
||||
'AppsService.manifest',
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'AppsServiceChild.jsm',
|
||||
'AppsUtils.jsm',
|
||||
'PermissionsInstaller.jsm',
|
||||
'PermissionsTable.jsm',
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource:///modules/AppsUtils.jsm");
|
||||
|
||||
add_test(() => {
|
||||
let app = {
|
||||
name: "TestApp",
|
||||
csp: "aCsp",
|
||||
installOrigin: "http://installorigin.com",
|
||||
origin: "http://www.example.com",
|
||||
installTime: Date.now(),
|
||||
manifestURL: "http://www.example.com/manifest.webapp",
|
||||
appStatus: Ci.nsIPrincipal.APP_STATUS_NOT_INSTALLED,
|
||||
removable: false,
|
||||
id: 123,
|
||||
localId: 123,
|
||||
basePath: "/",
|
||||
progress: 1.0,
|
||||
installState: "installed",
|
||||
downloadAvailable: false,
|
||||
downloading: false,
|
||||
lastUpdateCheck: Date.now(),
|
||||
updateTime: Date.now(),
|
||||
etag: "aEtag",
|
||||
packageEtag: "aPackageEtag",
|
||||
manifestHash: "aManifestHash",
|
||||
packageHash: "aPackageHash",
|
||||
staged: false,
|
||||
installerAppId: 345,
|
||||
installerIsBrowser: false,
|
||||
storeId: "aStoreId",
|
||||
storeVersion: 1,
|
||||
role: "aRole",
|
||||
kind: "aKind",
|
||||
enabled: true,
|
||||
sideloaded: false
|
||||
};
|
||||
|
||||
let mozapp = new mozIApplication(app);
|
||||
|
||||
Object.keys(app).forEach((key) => {
|
||||
if (key == "principal") {
|
||||
return;
|
||||
}
|
||||
Assert.equal(app[key], mozapp[key],
|
||||
"app[" + key + "] should be equal to mozapp[" + key + "]");
|
||||
});
|
||||
|
||||
Assert.ok(mozapp.principal, "app principal should exist");
|
||||
let expectedPrincipalOrigin = app.origin + "^appId=" + app.localId;
|
||||
Assert.equal(mozapp.principal.origin, expectedPrincipalOrigin,
|
||||
"app principal origin ok");
|
||||
Assert.equal(mozapp.principal.appId, app.localId, "app principal appId ok");
|
||||
Assert.equal(mozapp.principal.isInIsolatedMozBrowserElement, false,
|
||||
"app principal isInIsolatedMozBrowserElement ok");
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
@@ -2,4 +2,3 @@
|
||||
|
||||
[test_manifestSanitizer.js]
|
||||
[test_manifestHelper.js]
|
||||
[test_moziapplication.js]
|
||||
|
||||
+40
-150
@@ -30,7 +30,6 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIIPCBackgroundChildCreateCallback.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@@ -443,11 +442,9 @@ public:
|
||||
mPrincipalInfo(aPrincipalInfo),
|
||||
mOpenMode(aOpenMode),
|
||||
mWriteParams(aWriteParams),
|
||||
mPersistence(quota::PERSISTENCE_TYPE_INVALID),
|
||||
mState(eInitial),
|
||||
mResult(JS::AsmJSCache_InternalError),
|
||||
mIsApp(false),
|
||||
mEnforcingQuota(true),
|
||||
mDeleteReceived(false),
|
||||
mActorDestroyed(false),
|
||||
mOpened(false)
|
||||
{
|
||||
@@ -488,31 +485,6 @@ private:
|
||||
MOZ_ASSERT(!IsOnOwningThread());
|
||||
}
|
||||
|
||||
// This method is called on the owning thread when no cache entry was found
|
||||
// to open. If we just tried a lookup in persistent storage then we might
|
||||
// still get a hit in temporary storage (for an asm.js module that wasn't
|
||||
// compiled at install-time).
|
||||
void
|
||||
CacheMiss()
|
||||
{
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mState == eFailedToReadMetadata ||
|
||||
mState == eWaitingToOpenCacheFileForRead);
|
||||
MOZ_ASSERT(mOpenMode == eOpenForRead);
|
||||
|
||||
if (mPersistence == quota::PERSISTENCE_TYPE_TEMPORARY) {
|
||||
Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
// Try again with a clean slate. InitOnMainThread will see that mPersistence
|
||||
// is initialized and switch to temporary storage.
|
||||
MOZ_ASSERT(mPersistence == quota::PERSISTENCE_TYPE_PERSISTENT);
|
||||
FinishOnOwningThread();
|
||||
mState = eInitial;
|
||||
NS_DispatchToMainThread(this);
|
||||
}
|
||||
|
||||
// This method is called on the owning thread when the JS engine is finished
|
||||
// reading/writing the cache entry.
|
||||
void
|
||||
@@ -542,7 +514,7 @@ private:
|
||||
|
||||
FinishOnOwningThread();
|
||||
|
||||
if (!mActorDestroyed) {
|
||||
if (!mDeleteReceived && !mActorDestroyed) {
|
||||
Unused << Send__delete__(this, mResult);
|
||||
}
|
||||
}
|
||||
@@ -561,9 +533,6 @@ private:
|
||||
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
|
||||
}
|
||||
|
||||
void
|
||||
InitPersistenceType();
|
||||
|
||||
nsresult
|
||||
InitOnMainThread();
|
||||
|
||||
@@ -615,6 +584,10 @@ private:
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mState != eFinished);
|
||||
|
||||
MOZ_ASSERT(!mDeleteReceived);
|
||||
|
||||
mDeleteReceived = true;
|
||||
|
||||
if (mOpened) {
|
||||
Close();
|
||||
} else {
|
||||
@@ -666,23 +639,12 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
RecvCacheMiss() override
|
||||
{
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
CacheMiss();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventTarget> mOwningThread;
|
||||
const PrincipalInfo mPrincipalInfo;
|
||||
const OpenMode mOpenMode;
|
||||
const WriteParams mWriteParams;
|
||||
|
||||
// State initialized during eInitial:
|
||||
quota::PersistenceType mPersistence;
|
||||
nsCString mSuffix;
|
||||
nsCString mGroup;
|
||||
nsCString mOrigin;
|
||||
@@ -702,7 +664,6 @@ private:
|
||||
eWaitingToOpenDirectory, // Waiting to open directory
|
||||
eWaitingToOpenMetadata, // Waiting to be called back from OpenDirectory
|
||||
eReadyToReadMetadata, // Waiting to read the metadata file on the IO thread
|
||||
eFailedToReadMetadata, // Waiting to be dispatched to owning thread after fail
|
||||
eSendingMetadataForRead, // Waiting to send OnOpenMetadataForRead
|
||||
eWaitingToOpenCacheFileForRead, // Waiting to hear back from child
|
||||
eReadyToOpenCacheFileForRead, // Waiting to open cache file for read
|
||||
@@ -714,58 +675,11 @@ private:
|
||||
State mState;
|
||||
JS::AsmJSCacheResult mResult;
|
||||
|
||||
bool mIsApp;
|
||||
bool mEnforcingQuota;
|
||||
bool mDeleteReceived;
|
||||
bool mActorDestroyed;
|
||||
bool mOpened;
|
||||
};
|
||||
|
||||
void
|
||||
ParentRunnable::InitPersistenceType()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mState == eInitial);
|
||||
|
||||
if (mOpenMode == eOpenForWrite) {
|
||||
MOZ_ASSERT(mPersistence == quota::PERSISTENCE_TYPE_INVALID);
|
||||
|
||||
// If we are performing install-time caching of an app, we'd like to store
|
||||
// the cache entry in persistent storage so the entry is never evicted,
|
||||
// but we need to check that quota is not enforced for the app.
|
||||
// That justifies us in skipping all quota checks when storing the cache
|
||||
// entry and avoids all the issues around the persistent quota prompt.
|
||||
// If quota is enforced for the app, then we can still cache in temporary
|
||||
// for a likely good first-run experience.
|
||||
|
||||
MOZ_ASSERT_IF(mWriteParams.mInstalled, mIsApp);
|
||||
|
||||
if (mWriteParams.mInstalled &&
|
||||
!QuotaManager::IsQuotaEnforced(quota::PERSISTENCE_TYPE_PERSISTENT,
|
||||
mOrigin, mIsApp)) {
|
||||
mPersistence = quota::PERSISTENCE_TYPE_PERSISTENT;
|
||||
} else {
|
||||
mPersistence = quota::PERSISTENCE_TYPE_TEMPORARY;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// For the reasons described above, apps may have cache entries in both
|
||||
// persistent and temporary storage. At lookup time we don't know how and
|
||||
// where the given script was cached, so start the search in persistent
|
||||
// storage and, if that fails, search in temporary storage. (Non-apps can
|
||||
// only be stored in temporary storage.)
|
||||
|
||||
MOZ_ASSERT_IF(mPersistence != quota::PERSISTENCE_TYPE_INVALID,
|
||||
mIsApp && mPersistence == quota::PERSISTENCE_TYPE_PERSISTENT);
|
||||
|
||||
if (mPersistence == quota::PERSISTENCE_TYPE_INVALID && mIsApp) {
|
||||
mPersistence = quota::PERSISTENCE_TYPE_PERSISTENT;
|
||||
} else {
|
||||
mPersistence = quota::PERSISTENCE_TYPE_TEMPORARY;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
ParentRunnable::InitOnMainThread()
|
||||
{
|
||||
@@ -780,15 +694,9 @@ ParentRunnable::InitOnMainThread()
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup,
|
||||
&mOrigin, &mIsApp);
|
||||
rv = QuotaManager::GetInfoFromPrincipal(principal, &mSuffix, &mGroup, &mOrigin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
InitPersistenceType();
|
||||
|
||||
mEnforcingQuota =
|
||||
QuotaManager::IsQuotaEnforced(mPersistence, mOrigin, mIsApp);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -803,10 +711,9 @@ ParentRunnable::OpenDirectory()
|
||||
mState = eWaitingToOpenMetadata;
|
||||
|
||||
// XXX The exclusive lock shouldn't be needed for read operations.
|
||||
QuotaManager::Get()->OpenDirectory(mPersistence,
|
||||
QuotaManager::Get()->OpenDirectory(quota::PERSISTENCE_TYPE_TEMPORARY,
|
||||
mGroup,
|
||||
mOrigin,
|
||||
mIsApp,
|
||||
quota::Client::ASMJS,
|
||||
/* aExclusive */ true,
|
||||
this);
|
||||
@@ -822,8 +729,11 @@ ParentRunnable::ReadMetadata()
|
||||
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
|
||||
|
||||
nsresult rv =
|
||||
qm->EnsureOriginIsInitialized(mPersistence, mSuffix, mGroup, mOrigin,
|
||||
mIsApp, getter_AddRefs(mDirectory));
|
||||
qm->EnsureOriginIsInitialized(quota::PERSISTENCE_TYPE_TEMPORARY,
|
||||
mSuffix,
|
||||
mGroup,
|
||||
mOrigin,
|
||||
getter_AddRefs(mDirectory));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
mResult = JS::AsmJSCache_StorageInitFailure;
|
||||
return rv;
|
||||
@@ -894,25 +804,23 @@ ParentRunnable::OpenCacheFileForWrite()
|
||||
QuotaManager* qm = QuotaManager::Get();
|
||||
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
|
||||
|
||||
if (mEnforcingQuota) {
|
||||
// Create the QuotaObject before all file IO and keep it alive until caching
|
||||
// completes to get maximum assertion coverage in QuotaManager against
|
||||
// concurrent removal, etc.
|
||||
mQuotaObject = qm->GetQuotaObject(mPersistence, mGroup, mOrigin, file);
|
||||
NS_ENSURE_STATE(mQuotaObject);
|
||||
// Create the QuotaObject before all file IO and keep it alive until caching
|
||||
// completes to get maximum assertion coverage in QuotaManager against
|
||||
// concurrent removal, etc.
|
||||
mQuotaObject = qm->GetQuotaObject(quota::PERSISTENCE_TYPE_TEMPORARY, mGroup, mOrigin, file);
|
||||
NS_ENSURE_STATE(mQuotaObject);
|
||||
|
||||
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
|
||||
/* aTruncate */ false)) {
|
||||
// If the request fails, it might be because mOrigin is using too much
|
||||
// space (MaybeUpdateSize will not evict our own origin since it is
|
||||
// active). Try to make some space by evicting LRU entries until there is
|
||||
// enough space.
|
||||
EvictEntries(mDirectory, mGroup, mOrigin, mWriteParams.mSize, mMetadata);
|
||||
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
|
||||
/* aTruncate */ false)) {
|
||||
// If the request fails, it might be because mOrigin is using too much
|
||||
// space (MaybeUpdateSize will not evict our own origin since it is
|
||||
// active). Try to make some space by evicting LRU entries until there is
|
||||
// enough space.
|
||||
EvictEntries(mDirectory, mGroup, mOrigin, mWriteParams.mSize, mMetadata);
|
||||
if (!mQuotaObject->MaybeUpdateSize(mWriteParams.mSize,
|
||||
/* aTruncate */ false)) {
|
||||
mResult = JS::AsmJSCache_QuotaExceeded;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mResult = JS::AsmJSCache_QuotaExceeded;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,13 +856,11 @@ ParentRunnable::OpenCacheFileForRead()
|
||||
QuotaManager* qm = QuotaManager::Get();
|
||||
MOZ_ASSERT(qm, "We are on the QuotaManager's IO thread");
|
||||
|
||||
if (mEnforcingQuota) {
|
||||
// Even though it's not strictly necessary, create the QuotaObject before
|
||||
// all file IO and keep it alive until caching completes to get maximum
|
||||
// assertion coverage in QuotaManager against concurrent removal, etc.
|
||||
mQuotaObject = qm->GetQuotaObject(mPersistence, mGroup, mOrigin, file);
|
||||
NS_ENSURE_STATE(mQuotaObject);
|
||||
}
|
||||
// Even though it's not strictly necessary, create the QuotaObject before
|
||||
// all file IO and keep it alive until caching completes to get maximum
|
||||
// assertion coverage in QuotaManager against concurrent removal, etc.
|
||||
mQuotaObject = qm->GetQuotaObject(quota::PERSISTENCE_TYPE_TEMPORARY, mGroup, mOrigin, file);
|
||||
NS_ENSURE_STATE(mQuotaObject);
|
||||
|
||||
rv = file->GetFileSize(&mFileSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -1058,8 +964,7 @@ ParentRunnable::Run()
|
||||
|
||||
rv = ReadMetadata();
|
||||
if (NS_FAILED(rv)) {
|
||||
mState = eFailedToReadMetadata;
|
||||
MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(this, NS_DISPATCH_NORMAL));
|
||||
FailOnNonOwningThread();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1081,18 +986,6 @@ ParentRunnable::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
case eFailedToReadMetadata: {
|
||||
AssertIsOnOwningThread();
|
||||
|
||||
if (mOpenMode == eOpenForRead) {
|
||||
CacheMiss();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Fail();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
case eSendingMetadataForRead: {
|
||||
AssertIsOnOwningThread();
|
||||
MOZ_ASSERT(mOpenMode == eOpenForRead);
|
||||
@@ -1404,11 +1297,13 @@ private:
|
||||
MOZ_ASSERT(mState == eOpening);
|
||||
|
||||
uint32_t moduleIndex;
|
||||
if (FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
|
||||
return SendSelectCacheFileToRead(moduleIndex);
|
||||
if (!FindHashMatch(aMetadata, mReadParams, &moduleIndex)) {
|
||||
Fail(JS::AsmJSCache_InternalError);
|
||||
Send__delete__(this, JS::AsmJSCache_InternalError);
|
||||
return true;
|
||||
}
|
||||
|
||||
return SendCacheMiss();
|
||||
return SendSelectCacheFileToRead(moduleIndex);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1760,7 +1655,6 @@ CloseEntryForRead(size_t aSize,
|
||||
|
||||
JS::AsmJSCacheResult
|
||||
OpenEntryForWrite(nsIPrincipal* aPrincipal,
|
||||
bool aInstalled,
|
||||
const char16_t* aBegin,
|
||||
const char16_t* aEnd,
|
||||
size_t aSize,
|
||||
@@ -1777,7 +1671,6 @@ OpenEntryForWrite(nsIPrincipal* aPrincipal,
|
||||
static_assert(sNumFastHashChars < sMinCachedModuleLength, "HashString safe");
|
||||
|
||||
WriteParams writeParams;
|
||||
writeParams.mInstalled = aInstalled;
|
||||
writeParams.mSize = aSize;
|
||||
writeParams.mFastHash = HashString(aBegin, sNumFastHashChars);
|
||||
writeParams.mNumChars = aEnd - aBegin;
|
||||
@@ -2043,7 +1936,6 @@ ParamTraits<WriteParams>::Write(Message* aMsg, const paramType& aParam)
|
||||
WriteParam(aMsg, aParam.mFastHash);
|
||||
WriteParam(aMsg, aParam.mNumChars);
|
||||
WriteParam(aMsg, aParam.mFullHash);
|
||||
WriteParam(aMsg, aParam.mInstalled);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -2053,8 +1945,7 @@ ParamTraits<WriteParams>::Read(const Message* aMsg, PickleIterator* aIter,
|
||||
return ReadParam(aMsg, aIter, &aResult->mSize) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFastHash) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mNumChars) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFullHash) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mInstalled);
|
||||
ReadParam(aMsg, aIter, &aResult->mFullHash);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2064,7 +1955,6 @@ ParamTraits<WriteParams>::Log(const paramType& aParam, std::wstring* aLog)
|
||||
LogParam(aParam.mFastHash, aLog);
|
||||
LogParam(aParam.mNumChars, aLog);
|
||||
LogParam(aParam.mFullHash, aLog);
|
||||
LogParam(aParam.mInstalled, aLog);
|
||||
}
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
@@ -72,14 +72,12 @@ struct WriteParams
|
||||
int64_t mFastHash;
|
||||
int64_t mNumChars;
|
||||
int64_t mFullHash;
|
||||
bool mInstalled;
|
||||
|
||||
WriteParams()
|
||||
: mSize(0),
|
||||
mFastHash(0),
|
||||
mNumChars(0),
|
||||
mFullHash(0),
|
||||
mInstalled(false)
|
||||
: mSize(0)
|
||||
, mFastHash(0)
|
||||
, mNumChars(0)
|
||||
, mFullHash(0)
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -90,8 +88,8 @@ struct ReadParams
|
||||
const char16_t* mLimit;
|
||||
|
||||
ReadParams()
|
||||
: mBegin(nullptr),
|
||||
mLimit(nullptr)
|
||||
: mBegin(nullptr)
|
||||
, mLimit(nullptr)
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -120,7 +118,6 @@ CloseEntryForRead(size_t aSize,
|
||||
intptr_t aHandle);
|
||||
JS::AsmJSCacheResult
|
||||
OpenEntryForWrite(nsIPrincipal* aPrincipal,
|
||||
bool aInstalled,
|
||||
const char16_t* aBegin,
|
||||
const char16_t* aEnd,
|
||||
size_t aSize,
|
||||
|
||||
@@ -22,7 +22,6 @@ child:
|
||||
async OnOpenMetadataForRead(Metadata metadata);
|
||||
parent:
|
||||
async SelectCacheFileToRead(uint32_t moduleIndex);
|
||||
async CacheMiss();
|
||||
|
||||
child:
|
||||
// Once the cache file has been opened, the child is notified and sent an
|
||||
|
||||
@@ -62,8 +62,6 @@
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "TimeManager.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "WidgetUtils.h"
|
||||
#include "mozilla/dom/MediaDevices.h"
|
||||
#include "MediaManager.h"
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
|
||||
|
||||
@@ -145,7 +146,7 @@ ThirdPartyUtil::IsThirdPartyWindow(mozIDOMWindowProxy* aWindow,
|
||||
nsCOMPtr<nsIURI> parentURI;
|
||||
do {
|
||||
// We use GetScriptableParent rather than GetParent because we consider
|
||||
// <iframe mozbrowser/mozapp> to be a top-level frame.
|
||||
// <iframe mozbrowser> to be a top-level frame.
|
||||
parent = current->GetScriptableParent();
|
||||
if (SameCOMIdentity(parent, current)) {
|
||||
// We're at the topmost content window. We already know the answer.
|
||||
|
||||
@@ -6616,7 +6616,7 @@ nsContentUtils::IsUserFocusIgnored(nsINode* aNode)
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(aNode);
|
||||
if (browserFrame &&
|
||||
aNode->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::ignoreuserfocus) &&
|
||||
browserFrame->GetReallyIsBrowserOrApp()) {
|
||||
browserFrame->GetReallyIsBrowser()) {
|
||||
return true;
|
||||
}
|
||||
nsPIDOMWindowOuter* win = aNode->OwnerDoc()->GetWindow();
|
||||
|
||||
@@ -3026,8 +3026,7 @@ nsDOMWindowUtils::GetFileReferences(const nsAString& aDatabaseName, int64_t aId,
|
||||
|
||||
nsCString origin;
|
||||
nsresult rv =
|
||||
quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin,
|
||||
nullptr);
|
||||
quota::QuotaManager::GetInfoFromWindow(window, nullptr, nullptr, &origin);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
IDBOpenDBOptions options;
|
||||
|
||||
+23
-164
@@ -12,9 +12,7 @@
|
||||
|
||||
#include "prenv.h"
|
||||
|
||||
#include "mozIApplication.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIDOMHTMLIFrameElement.h"
|
||||
#include "nsIDOMHTMLFrameElement.h"
|
||||
#include "nsIDOMMozBrowserFrame.h"
|
||||
@@ -88,7 +86,6 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "mozilla/layout/RenderFrameParent.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "GeckoProfiler.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
@@ -1071,12 +1068,6 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (mRemoteBrowser->IsIsolatedMozBrowserElement() !=
|
||||
aOther->mRemoteBrowser->IsIsolatedMozBrowserElement() ||
|
||||
mRemoteBrowser->HasOwnApp() != aOther->mRemoteBrowser->HasOwnApp()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// When we swap docShells, maybe we have to deal with a new page created just
|
||||
// for this operation. In this case, the browser code should already have set
|
||||
// the correct userContextId attribute value in the owning XULElement, but our
|
||||
@@ -1145,10 +1136,10 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther,
|
||||
}
|
||||
|
||||
// Destroy browser frame scripts for content leaving a frame with browser API
|
||||
if (OwnerIsMozBrowserOrAppFrame() && !aOther->OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (OwnerIsMozBrowserFrame() && !aOther->OwnerIsMozBrowserFrame()) {
|
||||
DestroyBrowserFrameScripts();
|
||||
}
|
||||
if (!OwnerIsMozBrowserOrAppFrame() && aOther->OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (!OwnerIsMozBrowserFrame() && aOther->OwnerIsMozBrowserFrame()) {
|
||||
aOther->DestroyBrowserFrameScripts();
|
||||
}
|
||||
|
||||
@@ -1320,12 +1311,12 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
|
||||
bool ourFullscreenAllowed =
|
||||
ourContent->IsXULElement() ||
|
||||
(OwnerIsMozBrowserOrAppFrame() &&
|
||||
(OwnerIsMozBrowserFrame() &&
|
||||
(ourContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
|
||||
ourContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)));
|
||||
bool otherFullscreenAllowed =
|
||||
otherContent->IsXULElement() ||
|
||||
(aOther->OwnerIsMozBrowserOrAppFrame() &&
|
||||
(aOther->OwnerIsMozBrowserFrame() &&
|
||||
(otherContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
|
||||
otherContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)));
|
||||
if (ourFullscreenAllowed != otherFullscreenAllowed) {
|
||||
@@ -1470,12 +1461,6 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (ourDocshell->GetIsIsolatedMozBrowserElement() !=
|
||||
otherDocshell->GetIsIsolatedMozBrowserElement() ||
|
||||
ourDocshell->GetIsApp() != otherDocshell->GetIsApp()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// When we swap docShells, maybe we have to deal with a new page created just
|
||||
// for this operation. In this case, the browser code should already have set
|
||||
// the correct userContextId attribute value in the owning XULElement, but our
|
||||
@@ -1522,10 +1507,10 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
||||
}
|
||||
|
||||
// Destroy browser frame scripts for content leaving a frame with browser API
|
||||
if (OwnerIsMozBrowserOrAppFrame() && !aOther->OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (OwnerIsMozBrowserFrame() && !aOther->OwnerIsMozBrowserFrame()) {
|
||||
DestroyBrowserFrameScripts();
|
||||
}
|
||||
if (!OwnerIsMozBrowserOrAppFrame() && aOther->OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (!OwnerIsMozBrowserFrame() && aOther->OwnerIsMozBrowserFrame()) {
|
||||
aOther->DestroyBrowserFrameScripts();
|
||||
}
|
||||
|
||||
@@ -1884,102 +1869,20 @@ nsFrameLoader::SetOwnerContent(Element* aContent)
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsMozBrowserOrAppFrame()
|
||||
nsFrameLoader::OwnerIsMozBrowserFrame()
|
||||
{
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
return browserFrame ? browserFrame->GetReallyIsBrowserOrApp() : false;
|
||||
return browserFrame ? browserFrame->GetReallyIsBrowser() : false;
|
||||
}
|
||||
|
||||
// The xpcom getter version
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetOwnerIsMozBrowserOrAppFrame(bool* aResult)
|
||||
nsFrameLoader::GetOwnerIsMozBrowserFrame(bool* aResult)
|
||||
{
|
||||
*aResult = OwnerIsMozBrowserOrAppFrame();
|
||||
*aResult = OwnerIsMozBrowserFrame();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsAppFrame()
|
||||
{
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
return browserFrame ? browserFrame->GetReallyIsApp() : false;
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsMozBrowserFrame()
|
||||
{
|
||||
return OwnerIsMozBrowserOrAppFrame() && !OwnerIsAppFrame();
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::OwnerIsIsolatedMozBrowserFrame()
|
||||
{
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
if (!browserFrame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OwnerIsMozBrowserFrame()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isolated = browserFrame->GetIsolated();
|
||||
if (isolated) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameLoader::GetOwnerAppManifestURL(nsAString& aOut)
|
||||
{
|
||||
aOut.Truncate();
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
if (browserFrame) {
|
||||
browserFrame->GetAppManifestURL(aOut);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
nsFrameLoader::GetOwnApp()
|
||||
{
|
||||
nsAutoString manifest;
|
||||
GetOwnerAppManifestURL(manifest);
|
||||
if (manifest.IsEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(appsService, nullptr);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByManifestURL(manifest, getter_AddRefs(app));
|
||||
|
||||
return app.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
nsFrameLoader::GetContainingApp()
|
||||
{
|
||||
// See if our owner content's principal has an associated app.
|
||||
uint32_t appId = mOwnerContent->NodePrincipal()->GetAppId();
|
||||
MOZ_ASSERT(appId != nsIScriptSecurityManager::UNKNOWN_APP_ID);
|
||||
|
||||
if (appId == nsIScriptSecurityManager::NO_APP_ID ||
|
||||
appId == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(appsService, nullptr);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByLocalId(appId, getter_AddRefs(app));
|
||||
|
||||
return app.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
nsFrameLoader::ShouldUseRemoteProcess()
|
||||
{
|
||||
@@ -2003,7 +1906,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
|
||||
|
||||
// If we're an <iframe mozbrowser> and we don't have a "remote" attribute,
|
||||
// fall back to the default.
|
||||
if (OwnerIsMozBrowserOrAppFrame() &&
|
||||
if (OwnerIsMozBrowserFrame() &&
|
||||
!mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::Remote)) {
|
||||
|
||||
return Preferences::GetBool("dom.ipc.browser_frames.oop_by_default", false);
|
||||
@@ -2011,7 +1914,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
|
||||
|
||||
// Otherwise, we're remote if we have "remote=true" and we're either a
|
||||
// browser frame or a XUL element.
|
||||
return (OwnerIsMozBrowserOrAppFrame() ||
|
||||
return (OwnerIsMozBrowserFrame() ||
|
||||
mOwnerContent->GetNameSpaceID() == kNameSpaceID_XUL) &&
|
||||
mOwnerContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::Remote,
|
||||
@@ -2189,13 +2092,13 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
// Inherit origin attributes from parent document if
|
||||
// 1. It's in a content docshell.
|
||||
// 2. its nodePrincipal is not a SystemPrincipal.
|
||||
// 3. It's not a mozbrowser nor mozapp frame.
|
||||
// 3. It's not a mozbrowser frame.
|
||||
//
|
||||
// For example, firstPartyDomain is computed from top-level document, it
|
||||
// doesn't exist in the top-level docshell.
|
||||
if (parentType == nsIDocShellTreeItem::typeContent &&
|
||||
!nsContentUtils::IsSystemPrincipal(doc->NodePrincipal()) &&
|
||||
!OwnerIsMozBrowserOrAppFrame()) {
|
||||
!OwnerIsMozBrowserFrame()) {
|
||||
PrincipalOriginAttributes poa = BasePrincipal::Cast(doc->NodePrincipal())->OriginAttributesRef();
|
||||
|
||||
// Assert on the firstPartyDomain from top-level docshell should be empty
|
||||
@@ -2210,42 +2113,14 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
"docshell and document should have the same appId attribute.");
|
||||
MOZ_ASSERT(attrs.mUserContextId == poa.mUserContextId,
|
||||
"docshell and document should have the same userContextId attribute.");
|
||||
MOZ_ASSERT(attrs.mInIsolatedMozBrowser == poa.mInIsolatedMozBrowser,
|
||||
"docshell and document should have the same inIsolatedMozBrowser attribute.");
|
||||
MOZ_ASSERT(attrs.mPrivateBrowsingId == poa.mPrivateBrowsingId,
|
||||
"docshell and document should have the same privateBrowsingId attribute.");
|
||||
|
||||
attrs.InheritFromDocToChildDocShell(poa);
|
||||
}
|
||||
|
||||
if (OwnerIsAppFrame()) {
|
||||
// You can't be both an app and a browser frame.
|
||||
MOZ_ASSERT(!OwnerIsMozBrowserFrame());
|
||||
|
||||
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
|
||||
MOZ_ASSERT(ownApp);
|
||||
uint32_t ownAppId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (ownApp) {
|
||||
NS_ENSURE_SUCCESS(ownApp->GetLocalId(&ownAppId), NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
attrs.mAppId = ownAppId;
|
||||
mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_APP);
|
||||
}
|
||||
|
||||
if (OwnerIsMozBrowserFrame()) {
|
||||
// You can't be both a browser and an app frame.
|
||||
MOZ_ASSERT(!OwnerIsAppFrame());
|
||||
|
||||
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
|
||||
uint32_t containingAppId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (containingApp) {
|
||||
NS_ENSURE_SUCCESS(containingApp->GetLocalId(&containingAppId),
|
||||
NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
attrs.mAppId = containingAppId;
|
||||
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
|
||||
attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
mDocShell->SetFrameType(nsIDocShell::FRAME_TYPE_BROWSER);
|
||||
}
|
||||
|
||||
@@ -2276,7 +2151,7 @@ nsFrameLoader::MaybeCreateDocShell()
|
||||
}
|
||||
attrs.SyncAttributesWithPrivateBrowsing(isPrivate);
|
||||
|
||||
if (OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (OwnerIsMozBrowserFrame()) {
|
||||
// For inproc frames, set the docshell properties.
|
||||
nsAutoString name;
|
||||
if (mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name)) {
|
||||
@@ -2679,7 +2554,7 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
}
|
||||
|
||||
// <iframe mozbrowser> gets to skip these checks.
|
||||
if (!OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (!OwnerIsMozBrowserFrame()) {
|
||||
if (parentDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
|
||||
return false;
|
||||
}
|
||||
@@ -2720,8 +2595,8 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<Element> ownerElement = mOwnerContent;
|
||||
mRemoteBrowser = ContentParent::CreateBrowserOrApp(context, ownerElement,
|
||||
openerContentParent, mFreshProcess);
|
||||
mRemoteBrowser = ContentParent::CreateBrowser(context, ownerElement,
|
||||
openerContentParent, mFreshProcess);
|
||||
if (!mRemoteBrowser) {
|
||||
return false;
|
||||
}
|
||||
@@ -2984,7 +2859,7 @@ nsFrameLoader::EnsureMessageManager()
|
||||
}
|
||||
|
||||
if (!mIsTopLevelContent &&
|
||||
!OwnerIsMozBrowserOrAppFrame() &&
|
||||
!OwnerIsMozBrowserFrame() &&
|
||||
!IsRemoteFrame() &&
|
||||
!(mOwnerContent->IsXULElement() &&
|
||||
mOwnerContent->AttrValueIs(kNameSpaceID_None,
|
||||
@@ -3291,7 +3166,7 @@ nsFrameLoader::GetLoadContext(nsILoadContext** aLoadContext)
|
||||
void
|
||||
nsFrameLoader::InitializeBrowserAPI()
|
||||
{
|
||||
if (!OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (!OwnerIsMozBrowserFrame()) {
|
||||
return;
|
||||
}
|
||||
if (!IsRemoteFrame()) {
|
||||
@@ -3315,7 +3190,7 @@ nsFrameLoader::InitializeBrowserAPI()
|
||||
void
|
||||
nsFrameLoader::DestroyBrowserFrameScripts()
|
||||
{
|
||||
if (!OwnerIsMozBrowserOrAppFrame()) {
|
||||
if (!OwnerIsMozBrowserFrame()) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwnerContent);
|
||||
@@ -3396,24 +3271,10 @@ nsresult
|
||||
nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
nsIURI* aURI)
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
|
||||
nsCOMPtr<mozIApplication> containingApp = GetContainingApp();
|
||||
DocShellOriginAttributes attrs;
|
||||
attrs.mInIsolatedMozBrowser = OwnerIsIsolatedMozBrowserFrame();
|
||||
nsresult rv;
|
||||
|
||||
// Get the AppId from ownApp
|
||||
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (ownApp) {
|
||||
rv = ownApp->GetLocalId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(appId != nsIScriptSecurityManager::NO_APP_ID);
|
||||
} else if (containingApp) {
|
||||
rv = containingApp->GetLocalId(&appId);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_STATE(appId != nsIScriptSecurityManager::NO_APP_ID);
|
||||
}
|
||||
attrs.mAppId = appId;
|
||||
attrs.mAppId = nsIScriptSecurityManager::NO_APP_ID; // No longer used...
|
||||
|
||||
// set the userContextId on the attrs before we pass them into
|
||||
// the tab context
|
||||
@@ -3443,8 +3304,6 @@ nsFrameLoader::GetNewTabContext(MutableTabContext* aTabContext,
|
||||
bool tabContextUpdated =
|
||||
aTabContext->SetTabContext(OwnerIsMozBrowserFrame(),
|
||||
mIsPrerendered,
|
||||
ownApp,
|
||||
containingApp,
|
||||
showAccelerators,
|
||||
showFocusRings,
|
||||
attrs);
|
||||
|
||||
@@ -241,53 +241,18 @@ private:
|
||||
*/
|
||||
bool IsRemoteFrame();
|
||||
|
||||
/**
|
||||
* Is this a frameloader for a bona fide <iframe mozbrowser> or
|
||||
* <iframe mozapp>? (I.e., does the frame return true for
|
||||
* nsIMozBrowserFrame::GetReallyIsBrowserOrApp()?)
|
||||
* <xul:browser> is not a mozbrowser or app, so this is false for that case.
|
||||
*/
|
||||
bool OwnerIsMozBrowserOrAppFrame();
|
||||
|
||||
/**
|
||||
* Is this a frameloader for a bona fide <iframe mozapp>? (I.e., does the
|
||||
* frame return true for nsIMozBrowserFrame::GetReallyIsApp()?)
|
||||
*/
|
||||
bool OwnerIsAppFrame();
|
||||
|
||||
/**
|
||||
* Is this a frame loader for a bona fide <iframe mozbrowser>?
|
||||
* <xul:browser> is not a mozbrowser, so this is false for that case.
|
||||
*/
|
||||
bool OwnerIsMozBrowserFrame();
|
||||
|
||||
/**
|
||||
* Is this a frame loader for an isolated <iframe mozbrowser>?
|
||||
*
|
||||
* By default, mozbrowser frames are isolated. Isolation can be disabled by
|
||||
* setting the frame's noisolation attribute. Disabling isolation is
|
||||
* only allowed if the containing document is chrome.
|
||||
*/
|
||||
bool OwnerIsIsolatedMozBrowserFrame();
|
||||
|
||||
/**
|
||||
* Get our owning element's app manifest URL, or return the empty string if
|
||||
* our owning element doesn't have an app manifest URL.
|
||||
*/
|
||||
void GetOwnerAppManifestURL(nsAString& aOut);
|
||||
|
||||
/**
|
||||
* Get the app for our frame. This is the app whose manifest is returned by
|
||||
* GetOwnerAppManifestURL.
|
||||
*/
|
||||
already_AddRefed<mozIApplication> GetOwnApp();
|
||||
|
||||
/**
|
||||
* Get the app which contains this frame. This is the app associated with
|
||||
* the frame element's principal.
|
||||
*/
|
||||
already_AddRefed<mozIApplication> GetContainingApp();
|
||||
|
||||
/**
|
||||
* If we are an IPC frame, set mRemoteFrame. Otherwise, create and
|
||||
* initialize mDocShell.
|
||||
|
||||
@@ -101,7 +101,6 @@ GK_ATOM(animations, "animations")
|
||||
GK_ATOM(anonid, "anonid")
|
||||
GK_ATOM(anonlocation, "anonlocation")
|
||||
GK_ATOM(any, "any")
|
||||
GK_ATOM(mozapp, "mozapp")
|
||||
GK_ATOM(applet, "applet")
|
||||
GK_ATOM(applyImports, "apply-imports")
|
||||
GK_ATOM(applyTemplates, "apply-templates")
|
||||
@@ -665,7 +664,6 @@ GK_ATOM(nodeSet, "node-set")
|
||||
GK_ATOM(noembed, "noembed")
|
||||
GK_ATOM(noframes, "noframes")
|
||||
GK_ATOM(nohref, "nohref")
|
||||
GK_ATOM(noisolation, "noisolation")
|
||||
GK_ATOM(nomodule, "nomodule")
|
||||
GK_ATOM(nonce, "nonce")
|
||||
GK_ATOM(none, "none")
|
||||
@@ -1003,7 +1001,6 @@ GK_ATOM(panel, "panel")
|
||||
GK_ATOM(param, "param")
|
||||
GK_ATOM(parameter, "parameter")
|
||||
GK_ATOM(parent, "parent")
|
||||
GK_ATOM(parentapp, "parentapp")
|
||||
GK_ATOM(parentfocused, "parentfocused")
|
||||
GK_ATOM(parsetype, "parsetype")
|
||||
GK_ATOM(password, "password")
|
||||
|
||||
+13
-14
@@ -4490,7 +4490,7 @@ nsGlobalWindow::GetParentOuter()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> parent;
|
||||
if (mDocShell->GetIsMozBrowserOrApp()) {
|
||||
if (mDocShell->GetIsMozBrowser()) {
|
||||
parent = AsOuter();
|
||||
} else {
|
||||
parent = GetParent();
|
||||
@@ -4548,7 +4548,7 @@ nsGlobalWindow::GetParent()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> parent;
|
||||
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
|
||||
mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
|
||||
|
||||
if (parent) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = parent->GetWindow();
|
||||
@@ -4667,9 +4667,9 @@ nsGlobalWindow::GetContentInternal(ErrorResult& aError, bool aUnprivilegedCaller
|
||||
return domWindow.forget();
|
||||
}
|
||||
|
||||
// If we're contained in <iframe mozbrowser> or <iframe mozapp>, then
|
||||
// GetContent is the same as window.top.
|
||||
if (mDocShell && mDocShell->GetIsInMozBrowserOrApp()) {
|
||||
// If we're contained in <iframe mozbrowser>, then GetContent is the same as
|
||||
// window.top.
|
||||
if (mDocShell && mDocShell->GetIsInMozBrowser()) {
|
||||
return GetTopOuter();
|
||||
}
|
||||
|
||||
@@ -7997,7 +7997,7 @@ nsGlobalWindow::ResizeToOuter(int32_t aWidth, int32_t aHeight, ErrorResult& aErr
|
||||
* If caller is a browser-element then dispatch a resize event to
|
||||
* the embedder.
|
||||
*/
|
||||
if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
|
||||
if (mDocShell && mDocShell->GetIsMozBrowser()) {
|
||||
CSSIntSize size(aWidth, aHeight);
|
||||
if (!DispatchResizeEvent(size)) {
|
||||
// The embedder chose to prevent the default action for this
|
||||
@@ -8047,7 +8047,7 @@ nsGlobalWindow::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
|
||||
* If caller is a browser-element then dispatch a resize event to
|
||||
* parent.
|
||||
*/
|
||||
if (mDocShell && mDocShell->GetIsMozBrowserOrApp()) {
|
||||
if (mDocShell && mDocShell->GetIsMozBrowser()) {
|
||||
CSSIntSize size;
|
||||
if (NS_FAILED(GetInnerSize(size))) {
|
||||
return;
|
||||
@@ -9018,7 +9018,7 @@ nsGlobalWindow::CloseOuter(bool aTrustedCaller)
|
||||
MOZ_RELEASE_ASSERT(IsOuterWindow());
|
||||
|
||||
if (!mDocShell || IsInModalState() ||
|
||||
(IsFrame() && !mDocShell->GetIsMozBrowserOrApp())) {
|
||||
(IsFrame() && !mDocShell->GetIsMozBrowser())) {
|
||||
// window.close() is called on a frame in a frameset, on a window
|
||||
// that's already closed, or on a window for which there's
|
||||
// currently a modal dialog open. Ignore such calls.
|
||||
@@ -9039,14 +9039,13 @@ nsGlobalWindow::CloseOuter(bool aTrustedCaller)
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't allow scripts from content to close non-app or non-neterror
|
||||
// windows that were not opened by script.
|
||||
// Don't allow scripts from content to close non-neterror windows that
|
||||
// were not opened by script.
|
||||
nsAutoString url;
|
||||
nsresult rv = mDoc->GetURL(url);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (!mDocShell->GetIsApp() &&
|
||||
!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
|
||||
if (!StringBeginsWith(url, NS_LITERAL_STRING("about:neterror")) &&
|
||||
!mHadOriginalOpener && !aTrustedCaller) {
|
||||
bool allowClose = mAllowScriptsToClose ||
|
||||
Preferences::GetBool("dom.allow_scripts_to_close_windows", true);
|
||||
@@ -9494,7 +9493,7 @@ nsGlobalWindow::GetFrameElementOuter(nsIPrincipal& aSubjectPrincipal)
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(IsOuterWindow());
|
||||
|
||||
if (!mDocShell || mDocShell->GetIsMozBrowserOrApp()) {
|
||||
if (!mDocShell || mDocShell->GetIsMozBrowser()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -9529,7 +9528,7 @@ nsGlobalWindow::GetRealFrameElementOuter()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> parent;
|
||||
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
|
||||
mDocShell->GetSameTypeParentIgnoreBrowserBoundaries(getter_AddRefs(parent));
|
||||
|
||||
if (!parent || parent == mDocShell) {
|
||||
// We're at a chrome boundary, don't expose the chrome iframe
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface mozIApplication;
|
||||
interface nsFrameLoader;
|
||||
interface nsIDocShell;
|
||||
interface nsIURI;
|
||||
@@ -216,11 +215,10 @@ interface nsIFrameLoader : nsISupports
|
||||
[infallible] attribute boolean visible;
|
||||
|
||||
/**
|
||||
* Find out whether the owner content really is a mozbrowser or app frame
|
||||
* Especially, a widget frame is regarded as an app frame. <xul:browser> is
|
||||
* not considered to be a mozbrowser frame.
|
||||
* Find out whether the owner content really is a mozbrowser. <xul:browser>
|
||||
* is not considered to be a mozbrowser frame.
|
||||
*/
|
||||
readonly attribute boolean ownerIsMozBrowserOrAppFrame;
|
||||
readonly attribute boolean ownerIsMozBrowserFrame;
|
||||
|
||||
/**
|
||||
* The last known width of the frame. Reading this property will not trigger
|
||||
@@ -265,12 +263,6 @@ interface nsIFrameLoaderOwner : nsISupports
|
||||
[binaryname(FrameLoaderXPCOM)] readonly attribute nsIFrameLoader frameLoader;
|
||||
[noscript, notxpcom] alreadyAddRefed_nsFrameLoader GetFrameLoader();
|
||||
|
||||
/**
|
||||
* The principal of parent mozIApplication in case of nested mozbrowser
|
||||
* iframes.
|
||||
*/
|
||||
readonly attribute mozIApplication parentApplication;
|
||||
|
||||
/**
|
||||
* Puts the FrameLoaderOwner in prerendering mode.
|
||||
*/
|
||||
|
||||
@@ -88,21 +88,24 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
|
||||
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
||||
nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome)
|
||||
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
mPreventEventsEscaping(false),
|
||||
mOwner(aOwner), mChromeMessageManager(aChrome)
|
||||
: mDocShell(aShell)
|
||||
, mInitialized(false)
|
||||
, mLoadingScript(false)
|
||||
, mPreventEventsEscaping(false)
|
||||
, mOwner(aOwner)
|
||||
, mChromeMessageManager(aChrome)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
// If owner corresponds to an <iframe mozbrowser> or <iframe mozapp>, we'll
|
||||
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
|
||||
// GetEventTargetParent implementation.
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(mOwner);
|
||||
if (browserFrame) {
|
||||
mIsBrowserOrAppFrame = browserFrame->GetReallyIsBrowserOrApp();
|
||||
mIsBrowserFrame = browserFrame->GetReallyIsBrowser();
|
||||
}
|
||||
else {
|
||||
mIsBrowserOrAppFrame = false;
|
||||
mIsBrowserFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +275,7 @@ nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mIsBrowserOrAppFrame &&
|
||||
if (mIsBrowserFrame &&
|
||||
(!mOwner || !nsContentUtils::IsInChromeDocshell(mOwner->OwnerDoc()))) {
|
||||
if (mOwner) {
|
||||
if (nsPIDOMWindowInner* innerWindow = mOwner->OwnerDoc()->GetInnerWindow()) {
|
||||
|
||||
@@ -165,10 +165,9 @@ protected:
|
||||
bool mInitialized;
|
||||
bool mLoadingScript;
|
||||
|
||||
// Is this the message manager for an in-process <iframe mozbrowser> or
|
||||
// <iframe mozapp>? This affects where events get sent, so it affects
|
||||
// GetEventTargetParent.
|
||||
bool mIsBrowserOrAppFrame;
|
||||
// Is this the message manager for an in-process <iframe mozbrowser>? This
|
||||
// affects where events get sent, so it affects GetEventTargetParent.
|
||||
bool mIsBrowserFrame;
|
||||
bool mPreventEventsEscaping;
|
||||
|
||||
// We keep a strong reference to the frameloader after we've started
|
||||
|
||||
@@ -2265,7 +2265,6 @@ AsmJSCacheOpenEntryForRead(JS::Handle<JSObject*> aGlobal,
|
||||
|
||||
static JS::AsmJSCacheResult
|
||||
AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
|
||||
bool aInstalled,
|
||||
const char16_t* aBegin,
|
||||
const char16_t* aEnd,
|
||||
size_t aSize,
|
||||
@@ -2274,8 +2273,7 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
|
||||
{
|
||||
nsIPrincipal* principal =
|
||||
nsJSPrincipals::get(JS_GetCompartmentPrincipals(js::GetObjectCompartment(aGlobal)));
|
||||
return asmjscache::OpenEntryForWrite(principal, aInstalled, aBegin, aEnd,
|
||||
aSize, aMemory, aHandle);
|
||||
return asmjscache::OpenEntryForWrite(principal, aBegin, aEnd, aSize, aMemory, aHandle);
|
||||
}
|
||||
|
||||
class AsyncTaskRunnable final : public Runnable
|
||||
|
||||
@@ -1250,17 +1250,6 @@ nsObjectLoadingContent::GetFrameLoader()
|
||||
return loader.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObjectLoadingContent::GetParentApplication(mozIApplication** aApplication)
|
||||
{
|
||||
if (!aApplication) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aApplication = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ function parentDocShell(docshell) {
|
||||
function isTopBrowserElement(docShell) {
|
||||
while (docShell) {
|
||||
docShell = parentDocShell(docShell);
|
||||
if (docShell && docShell.isMozBrowserOrApp) {
|
||||
if (docShell && docShell.isMozBrowser) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ var CopyPasteAssistent = {
|
||||
let targetDocShell = currentWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation);
|
||||
if(targetDocShell.isMozBrowserOrApp) {
|
||||
if(targetDocShell.isMozBrowser) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,23 +54,6 @@ CreateIframe(Element* aOpenerFrameElement, const nsAString& aName, bool aRemote)
|
||||
|
||||
popupFrameElement->SetMozbrowser(true);
|
||||
|
||||
// Copy the opener frame's mozapp attribute to the popup frame.
|
||||
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)) {
|
||||
nsAutoString mozapp;
|
||||
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, mozapp);
|
||||
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::mozapp,
|
||||
mozapp, /* aNotify = */ false);
|
||||
}
|
||||
|
||||
// Copy the opener frame's parentApp attribute to the popup frame.
|
||||
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::parentapp)) {
|
||||
nsAutoString parentApp;
|
||||
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
|
||||
parentApp);
|
||||
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
|
||||
parentApp, /* aNotify = */ false);
|
||||
}
|
||||
|
||||
// Copy the window name onto the iframe.
|
||||
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
|
||||
aName, /* aNotify = */ false);
|
||||
|
||||
@@ -8,27 +8,6 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
|
||||
// We'll need to get the appId from the current document,
|
||||
// it's either SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID when
|
||||
// we are not running inside an app (e.g. Firefox Desktop),
|
||||
// or the appId of Mochitest app when we are running inside that app
|
||||
// (e.g. Emulator).
|
||||
var currentAppId = SpecialPowers.wrap(document).nodePrincipal.appId;
|
||||
var inApp =
|
||||
currentAppId !== SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||
// We will also need the manifest URL and set it on iframes.
|
||||
var currentAppManifestURL;
|
||||
|
||||
if (inApp) {
|
||||
let appsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"]
|
||||
.getService(SpecialPowers.Ci.nsIAppsService);
|
||||
|
||||
currentAppManifestURL = appsService.getManifestURLByLocalId(currentAppId);
|
||||
};
|
||||
|
||||
info('appId=' + currentAppId);
|
||||
info('manifestURL=' + currentAppManifestURL);
|
||||
|
||||
function setup() {
|
||||
let appInfo = SpecialPowers.Cc['@mozilla.org/xre/app-info;1']
|
||||
.getService(SpecialPowers.Ci.nsIXULAppInfo);
|
||||
@@ -73,9 +52,6 @@ function createFrames() {
|
||||
for (let i = 0; i < 2; i++) {
|
||||
let frame = gInputMethodFrames[i] = document.createElement('iframe');
|
||||
frame.setAttribute('mozbrowser', 'true');
|
||||
if (currentAppManifestURL) {
|
||||
frame.setAttribute('mozapp', currentAppManifestURL);
|
||||
}
|
||||
frame.addEventListener('mozbrowserloadend', countLoadend);
|
||||
frame.src = 'file_empty.html#' + i;
|
||||
document.body.appendChild(frame);
|
||||
@@ -88,20 +64,10 @@ function setPermissions() {
|
||||
allow: true,
|
||||
context: {
|
||||
url: SimpleTest.getTestFileURL('/file_empty.html'),
|
||||
originAttributes: {
|
||||
appId: currentAppId,
|
||||
inIsolatedMozBrowser: true
|
||||
}
|
||||
originAttributes: {}
|
||||
}
|
||||
}];
|
||||
|
||||
if (inApp) {
|
||||
// The current document would also need to be given access for IPC to
|
||||
// recognize our permission (why)?
|
||||
permissions.push({
|
||||
type: 'input', allow: true, context: document });
|
||||
}
|
||||
|
||||
SpecialPowers.pushPermissions(permissions,
|
||||
SimpleTest.waitForFocus.bind(SimpleTest, startTest));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
// set 'remote' to true here will make the the iframe remote in _inproc_
|
||||
// test and in-process in _oop_ test.
|
||||
iframe.setAttribute('remote', 'true');
|
||||
iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
||||
|
||||
iframe.addEventListener('mozbrowserloadend', function(e) {
|
||||
ok("mute" in iframe, "iframe.mute exists");
|
||||
|
||||
@@ -13,7 +13,5 @@ support-files =
|
||||
|
||||
[test_Simple.html]
|
||||
[test_HighPriority.html]
|
||||
[test_Preallocated.html]
|
||||
disabled = bug 968604, bug 987164
|
||||
[test_WebGLContextLost.html]
|
||||
disabled = bug 865844
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test that the preallocated process starts up with priority BACKGROUND.
|
||||
-->
|
||||
<head>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="../browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.7">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
browserElementTestHelpers.enableProcessPriorityManager();
|
||||
|
||||
var preallocationEnabledPref = null;
|
||||
try {
|
||||
preallocationEnabledPref = SpecialPowers.getBoolPref('dom.ipc.processPrelaunch.enabled');
|
||||
}
|
||||
catch(e) {
|
||||
preallocationEnabledPref = null;
|
||||
}
|
||||
|
||||
var childID = null;
|
||||
|
||||
var cleanedUp = false;
|
||||
function cleanUp()
|
||||
{
|
||||
if (cleanedUp) {
|
||||
return;
|
||||
}
|
||||
|
||||
cleanedUp = true;
|
||||
}
|
||||
|
||||
// Even if this test times out, we still want to run cleanUp so as to set the
|
||||
// pref back.
|
||||
addEventListener('unload', cleanUp);
|
||||
|
||||
function runTest()
|
||||
{
|
||||
if (preallocationEnabledPref) {
|
||||
ok(false, "dom.ipc.processPrelaunch.enabled must be " +
|
||||
"false for this test to work.");
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that the preallocated process initially gets BACKGROUND priority.
|
||||
// That's it.
|
||||
expectProcessCreated('PREALLOC').then(function() {
|
||||
// We need to set the pref asynchoronously or the preallocated process won't
|
||||
// be shut down.
|
||||
SimpleTest.executeSoon(function(){
|
||||
cleanUp();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
// Setting this pref to true should cause us to prelaunch a process.
|
||||
addEventListener('testready', function() {
|
||||
SpecialPowers.pushPrefEnv({'set':[["dom.ipc.processPrelaunch.enabled",true]]},runTest);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
+1
-4
@@ -259,7 +259,6 @@ Context::QuotaInitRunnable::OpenDirectory()
|
||||
QuotaManager::Get()->OpenDirectory(PERSISTENCE_TYPE_DEFAULT,
|
||||
mQuotaInfo.mGroup,
|
||||
mQuotaInfo.mOrigin,
|
||||
mQuotaInfo.mIsApp,
|
||||
quota::Client::DOMCACHE,
|
||||
/* aExclusive */ false,
|
||||
this);
|
||||
@@ -376,8 +375,7 @@ Context::QuotaInitRunnable::Run()
|
||||
nsresult rv = QuotaManager::GetInfoFromPrincipal(principal,
|
||||
&mQuotaInfo.mSuffix,
|
||||
&mQuotaInfo.mGroup,
|
||||
&mQuotaInfo.mOrigin,
|
||||
&mQuotaInfo.mIsApp);
|
||||
&mQuotaInfo.mOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
resolver->Resolve(rv);
|
||||
break;
|
||||
@@ -436,7 +434,6 @@ Context::QuotaInitRunnable::Run()
|
||||
mQuotaInfo.mSuffix,
|
||||
mQuotaInfo.mGroup,
|
||||
mQuotaInfo.mOrigin,
|
||||
mQuotaInfo.mIsApp,
|
||||
getter_AddRefs(mQuotaInfo.mDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
resolver->Resolve(rv);
|
||||
|
||||
Vendored
+1
-2
@@ -29,8 +29,7 @@ ManagerId::Create(nsIPrincipal* aPrincipal, ManagerId** aManagerIdOut)
|
||||
nsresult rv = QuotaManager::GetInfoFromPrincipal(aPrincipal,
|
||||
nullptr, // suffix
|
||||
nullptr, // group
|
||||
"aOrigin,
|
||||
nullptr); // is app
|
||||
"aOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
|
||||
|
||||
RefPtr<ManagerId> ref = new ManagerId(aPrincipal, quotaOrigin);
|
||||
|
||||
Vendored
-2
@@ -28,12 +28,10 @@ static const CacheId INVALID_CACHE_ID = -1;
|
||||
|
||||
struct QuotaInfo
|
||||
{
|
||||
QuotaInfo() : mIsApp(false) { }
|
||||
nsCOMPtr<nsIFile> mDir;
|
||||
nsCString mSuffix;
|
||||
nsCString mGroup;
|
||||
nsCString mOrigin;
|
||||
bool mIsApp;
|
||||
};
|
||||
|
||||
} // namespace cache
|
||||
|
||||
@@ -1824,7 +1824,9 @@ WebGLContext::UpdateContextLossStatus()
|
||||
void
|
||||
WebGLContext::ForceLoseContext(bool simulateLosing)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf_stderr("WebGL(%p)::ForceLoseContext\n", this);
|
||||
#endif
|
||||
MOZ_ASSERT(!IsContextLost());
|
||||
mContextStatus = ContextLostAwaitingEvent;
|
||||
mContextLostErrorSet = false;
|
||||
@@ -1840,7 +1842,9 @@ WebGLContext::ForceLoseContext(bool simulateLosing)
|
||||
void
|
||||
WebGLContext::ForceRestoreContext()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf_stderr("WebGL(%p)::ForceRestoreContext\n", this);
|
||||
#endif
|
||||
mContextStatus = ContextLostAwaitingRestore;
|
||||
mAllowContextRestore = true; // Hey, you did say 'force'.
|
||||
|
||||
|
||||
@@ -1279,9 +1279,9 @@ EventStateManager::IsRemoteTarget(nsIContent* target) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// <frame/iframe mozbrowser/mozapp>
|
||||
// <frame/iframe mozbrowser>
|
||||
nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(target);
|
||||
if (browserFrame && browserFrame->GetReallyIsBrowserOrApp()) {
|
||||
if (browserFrame && browserFrame->GetReallyIsBrowser()) {
|
||||
return !!TabParent::GetFrom(target);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
|
||||
#include "AudioChannelService.h"
|
||||
|
||||
#include "mozIApplication.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsFrameLoader.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDOMRequest.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@@ -44,13 +42,13 @@ nsBrowserElement::IsBrowserElementOrThrow(ErrorResult& aRv)
|
||||
void
|
||||
nsBrowserElement::InitBrowserElementAPI()
|
||||
{
|
||||
bool isMozBrowserOrApp;
|
||||
bool isMozBrowser;
|
||||
nsCOMPtr<nsIFrameLoader> frameLoader = GetFrameLoader();
|
||||
NS_ENSURE_TRUE_VOID(frameLoader);
|
||||
nsresult rv = frameLoader->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
|
||||
nsresult rv = frameLoader->GetOwnerIsMozBrowserFrame(&isMozBrowser);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
if (!isMozBrowserOrApp) {
|
||||
if (!isMozBrowser) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -495,13 +493,13 @@ nsBrowserElement::GetAllowedAudioChannels(
|
||||
return;
|
||||
}
|
||||
|
||||
bool isMozBrowserOrApp;
|
||||
aRv = frameLoader->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
|
||||
bool isMozBrowser;
|
||||
aRv = frameLoader->GetOwnerIsMozBrowserFrame(&isMozBrowser);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isMozBrowserOrApp) {
|
||||
if (!isMozBrowser) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ public:
|
||||
|
||||
protected:
|
||||
NS_IMETHOD_(already_AddRefed<nsFrameLoader>) GetFrameLoader() = 0;
|
||||
NS_IMETHOD GetParentApplication(mozIApplication** aApplication) = 0;
|
||||
|
||||
void InitBrowserElementAPI();
|
||||
void DestroyBrowserElementFrameScripts();
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "nsAttrValueInlines.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
@@ -191,31 +189,6 @@ nsGenericHTMLFrameElement::GetFrameLoader()
|
||||
return loader.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetParentApplication(mozIApplication** aApplication)
|
||||
{
|
||||
if (!aApplication) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aApplication = nullptr;
|
||||
|
||||
nsIPrincipal *principal = NodePrincipal();
|
||||
uint32_t appId = principal->GetAppId();
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
if (NS_WARN_IF(!appsService)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult rv = appsService->GetAppByLocalId(appId, aApplication);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGenericHTMLFrameElement::PresetOpenerWindow(mozIDOMWindowProxy* aWindow, ErrorResult& aRv)
|
||||
{
|
||||
@@ -512,144 +485,17 @@ nsGenericHTMLFrameElement::BrowserFramesEnabled()
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this frame element really is a mozbrowser or mozapp. (It
|
||||
* Return true if this frame element really is a mozbrowser. (It
|
||||
* needs to have the right attributes, and its creator must have the right
|
||||
* permissions.)
|
||||
*/
|
||||
/* [infallible] */ nsresult
|
||||
nsGenericHTMLFrameElement::GetReallyIsBrowserOrApp(bool *aOut)
|
||||
nsGenericHTMLFrameElement::GetReallyIsBrowser(bool *aOut)
|
||||
{
|
||||
*aOut = mReallyIsBrowser;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetReallyIsApp(bool *aOut)
|
||||
{
|
||||
nsAutoString manifestURL;
|
||||
GetAppManifestURL(manifestURL);
|
||||
|
||||
*aOut = !manifestURL.IsEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool NestedEnabled()
|
||||
{
|
||||
static bool sMozNestedEnabled = false;
|
||||
static bool sBoolVarCacheInitialized = false;
|
||||
|
||||
if (!sBoolVarCacheInitialized) {
|
||||
sBoolVarCacheInitialized = true;
|
||||
Preferences::AddBoolVarCache(&sMozNestedEnabled,
|
||||
"dom.ipc.tabs.nested.enabled");
|
||||
}
|
||||
|
||||
return sMozNestedEnabled;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/* [infallible] */ NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetIsolated(bool *aOut)
|
||||
{
|
||||
*aOut = true;
|
||||
|
||||
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal())) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Isolation is only disabled if the attribute is present
|
||||
*aOut = !HasAttr(kNameSpaceID_None, nsGkAtoms::noisolation);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get manifest url of app.
|
||||
*/
|
||||
void nsGenericHTMLFrameElement::GetManifestURL(nsAString& aManifestURL)
|
||||
{
|
||||
aManifestURL.Truncate();
|
||||
|
||||
nsAutoString manifestURL;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, manifestURL);
|
||||
if (manifestURL.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check permission.
|
||||
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
|
||||
NS_ENSURE_TRUE_VOID(permMgr);
|
||||
nsIPrincipal *principal = NodePrincipal();
|
||||
const char* aPermissionType = "embed-apps";
|
||||
uint32_t permission = nsIPermissionManager::DENY_ACTION;
|
||||
nsresult rv = permMgr->TestPermissionFromPrincipal(principal,
|
||||
aPermissionType,
|
||||
&permission);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (permission != nsIPermissionManager::ALLOW_ACTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(appsService);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByManifestURL(manifestURL, getter_AddRefs(app));
|
||||
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
aManifestURL.Assign(manifestURL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut)
|
||||
{
|
||||
aOut.Truncate();
|
||||
|
||||
// At the moment, you can't be an app without being a browser.
|
||||
if (!nsIMozBrowserFrame::GetReallyIsBrowserOrApp()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Only allow content process to embed an app when nested content
|
||||
// process is enabled.
|
||||
if (!XRE_IsParentProcess() &&
|
||||
!(GetBoolAttr(nsGkAtoms::Remote) && NestedEnabled())){
|
||||
NS_WARNING("Can't embed-apps. Embed-apps is restricted to in-proc apps "
|
||||
"or content processes with nested pref enabled, see bug 1097479");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString appManifestURL;
|
||||
|
||||
GetManifestURL(appManifestURL);
|
||||
|
||||
bool isApp = !appManifestURL.IsEmpty();
|
||||
|
||||
if (!isApp) {
|
||||
// No valid case to get manifest
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (isApp) {
|
||||
NS_WARNING("Can not simultaneously be mozapp");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString manifestURL;
|
||||
if (isApp) {
|
||||
manifestURL.Assign(appManifestURL);
|
||||
}
|
||||
|
||||
aOut.Assign(manifestURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::DisallowCreateFrameLoader()
|
||||
{
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
@@ -7394,7 +7393,6 @@ protected:
|
||||
nsCString mDatabaseId;
|
||||
nsString mDatabaseFilePath;
|
||||
State mState;
|
||||
bool mIsApp;
|
||||
bool mEnforcingQuota;
|
||||
const bool mDeleting;
|
||||
bool mBlockedDatabaseOpen;
|
||||
@@ -16904,7 +16902,6 @@ Cursor::RecvContinue(const CursorRequestParams& aParams)
|
||||
FileManager::FileManager(PersistenceType aPersistenceType,
|
||||
const nsACString& aGroup,
|
||||
const nsACString& aOrigin,
|
||||
bool aIsApp,
|
||||
const nsAString& aDatabaseName,
|
||||
bool aEnforcingQuota)
|
||||
: mPersistenceType(aPersistenceType)
|
||||
@@ -16912,7 +16909,6 @@ FileManager::FileManager(PersistenceType aPersistenceType,
|
||||
, mOrigin(aOrigin)
|
||||
, mDatabaseName(aDatabaseName)
|
||||
, mLastFileId(0)
|
||||
, mIsApp(aIsApp)
|
||||
, mEnforcingQuota(aEnforcingQuota)
|
||||
, mInvalidated(false)
|
||||
{ }
|
||||
@@ -18293,7 +18289,7 @@ Maintenance::DirectoryWork()
|
||||
|
||||
// The storage directory is structured like this:
|
||||
//
|
||||
// <profile>/storage/<persistence>/<origin>/idb/*.sqlite
|
||||
// <profile>\storage\<persistence>\<origin>\idb\*.sqlite
|
||||
//
|
||||
// We have to find all database files that match any persistence type and any
|
||||
// origin. We ignore anything out of the ordinary for now.
|
||||
@@ -18489,7 +18485,6 @@ Maintenance::DirectoryWork()
|
||||
nsCString suffix;
|
||||
nsCString group;
|
||||
nsCString origin;
|
||||
bool isApp;
|
||||
nsTArray<nsString> databasePaths;
|
||||
|
||||
while (true) {
|
||||
@@ -18555,8 +18550,7 @@ Maintenance::DirectoryWork()
|
||||
&dummyTimeStamp,
|
||||
suffix,
|
||||
group,
|
||||
origin,
|
||||
&isApp)))) {
|
||||
origin)))) {
|
||||
// Not much we can do here...
|
||||
continue;
|
||||
}
|
||||
@@ -18582,7 +18576,6 @@ Maintenance::DirectoryWork()
|
||||
suffix,
|
||||
group,
|
||||
origin,
|
||||
isApp,
|
||||
getter_AddRefs(directory));
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@@ -19426,7 +19419,6 @@ UpgradeFileIdsFunction::Init(nsIFile* aFMDirectory,
|
||||
new FileManager(PERSISTENCE_TYPE_INVALID,
|
||||
EmptyCString(),
|
||||
EmptyCString(),
|
||||
false,
|
||||
EmptyString(),
|
||||
false);
|
||||
|
||||
@@ -20669,7 +20661,6 @@ FactoryOp::FactoryOp(Factory* aFactory,
|
||||
, mContentParent(Move(aContentParent))
|
||||
, mCommonParams(aCommonParams)
|
||||
, mState(State::Initial)
|
||||
, mIsApp(false)
|
||||
, mEnforcingQuota(true)
|
||||
, mDeleting(aDeleting)
|
||||
, mBlockedDatabaseOpen(false)
|
||||
@@ -21021,13 +21012,11 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
|
||||
}
|
||||
|
||||
if (State::Initial == mState) {
|
||||
QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin, &mIsApp);
|
||||
QuotaManager::GetInfoForChrome(&mSuffix, &mGroup, &mOrigin);
|
||||
|
||||
MOZ_ASSERT(!QuotaManager::IsFirstPromptRequired(persistenceType, mOrigin,
|
||||
mIsApp));
|
||||
MOZ_ASSERT(QuotaManager::IsOriginInternal(mOrigin));
|
||||
|
||||
mEnforcingQuota =
|
||||
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
|
||||
mEnforcingQuota = false;
|
||||
}
|
||||
|
||||
*aPermission = PermissionRequestBase::kPermissionAllowed;
|
||||
@@ -21046,22 +21035,24 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
|
||||
nsCString suffix;
|
||||
nsCString group;
|
||||
nsCString origin;
|
||||
bool isApp;
|
||||
rv = QuotaManager::GetInfoFromPrincipal(principal,
|
||||
&suffix,
|
||||
&group,
|
||||
&origin,
|
||||
&isApp);
|
||||
&origin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PermissionRequestBase::PermissionValue permission;
|
||||
|
||||
if (QuotaManager::IsFirstPromptRequired(persistenceType, origin, isApp)) {
|
||||
rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
if (persistenceType == PERSISTENCE_TYPE_PERSISTENT) {
|
||||
if (QuotaManager::IsOriginInternal(origin)) {
|
||||
permission = PermissionRequestBase::kPermissionAllowed;
|
||||
} else {
|
||||
rv = PermissionRequestBase::GetCurrentPermission(principal, &permission);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
permission = PermissionRequestBase::kPermissionAllowed;
|
||||
@@ -21072,10 +21063,8 @@ FactoryOp::CheckPermission(ContentParent* aContentParent,
|
||||
mSuffix = suffix;
|
||||
mGroup = group;
|
||||
mOrigin = origin;
|
||||
mIsApp = isApp;
|
||||
|
||||
mEnforcingQuota =
|
||||
QuotaManager::IsQuotaEnforced(persistenceType, mOrigin, mIsApp);
|
||||
mEnforcingQuota = persistenceType != PERSISTENCE_TYPE_PERSISTENT;
|
||||
}
|
||||
|
||||
*aPermission = permission;
|
||||
@@ -21232,7 +21221,6 @@ FactoryOp::OpenDirectory()
|
||||
quotaManager->OpenDirectory(persistenceType,
|
||||
mGroup,
|
||||
mOrigin,
|
||||
mIsApp,
|
||||
Client::IDB,
|
||||
/* aExclusive */ false,
|
||||
this);
|
||||
@@ -21497,7 +21485,6 @@ OpenDatabaseOp::DoDatabaseWork()
|
||||
mSuffix,
|
||||
mGroup,
|
||||
mOrigin,
|
||||
mIsApp,
|
||||
getter_AddRefs(dbDirectory));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
@@ -21618,7 +21605,6 @@ OpenDatabaseOp::DoDatabaseWork()
|
||||
fileManager = new FileManager(persistenceType,
|
||||
mGroup,
|
||||
mOrigin,
|
||||
mIsApp,
|
||||
databaseName,
|
||||
mEnforcingQuota);
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ class FileManager final
|
||||
// Protected by IndexedDatabaseManager::FileMutex()
|
||||
nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
|
||||
|
||||
const bool mIsApp;
|
||||
const bool mEnforcingQuota;
|
||||
bool mInvalidated;
|
||||
|
||||
@@ -65,7 +64,6 @@ public:
|
||||
FileManager(PersistenceType aPersistenceType,
|
||||
const nsACString& aGroup,
|
||||
const nsACString& aOrigin,
|
||||
bool aIsApp,
|
||||
const nsAString& aDatabaseName,
|
||||
bool aEnforcingQuota);
|
||||
|
||||
@@ -87,12 +85,6 @@ public:
|
||||
return mOrigin;
|
||||
}
|
||||
|
||||
bool
|
||||
IsApp() const
|
||||
{
|
||||
return mIsApp;
|
||||
}
|
||||
|
||||
const nsAString&
|
||||
DatabaseName() const
|
||||
{
|
||||
|
||||
@@ -1074,7 +1074,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
|
||||
MOZ_CRASH("Is this needed?!");
|
||||
|
||||
case PrincipalInfo::TSystemPrincipalInfo:
|
||||
QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin, nullptr);
|
||||
QuotaManager::GetInfoForChrome(nullptr, nullptr, &aOrigin);
|
||||
return NS_OK;
|
||||
|
||||
case PrincipalInfo::TContentPrincipalInfo: {
|
||||
@@ -1088,8 +1088,7 @@ IDBDatabase::GetQuotaInfo(nsACString& aOrigin,
|
||||
rv = QuotaManager::GetInfoFromPrincipal(principal,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&aOrigin,
|
||||
nullptr);
|
||||
&aOrigin);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1272,7 +1272,6 @@ DeleteFilesRunnable::Open()
|
||||
quotaManager->OpenDirectory(mFileManager->Type(),
|
||||
mFileManager->Group(),
|
||||
mFileManager->Origin(),
|
||||
mFileManager->IsApp(),
|
||||
Client::IDB,
|
||||
/* aExclusive */ false,
|
||||
this);
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
foobar!
|
||||
</body>
|
||||
<script>
|
||||
var data = [
|
||||
{ id: "0", name: "foo" },
|
||||
];
|
||||
|
||||
var action = window.location.search.substring(1);
|
||||
var finished = false;
|
||||
var created = false; // We use that for 'read-no' action.
|
||||
|
||||
function finish(value) {
|
||||
value ? alert('success') : alert('failure');
|
||||
finished = true;
|
||||
}
|
||||
|
||||
var request = window.indexedDB.open('AppIsolationTest');
|
||||
|
||||
request.onupgradeneeded = function(event) {
|
||||
if (finished) {
|
||||
finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case 'read-no':
|
||||
created = true;
|
||||
break;
|
||||
case 'read-yes':
|
||||
finish(false);
|
||||
break;
|
||||
case 'write':
|
||||
created = true;
|
||||
|
||||
var db = event.target.result;
|
||||
|
||||
var objectStore = db.createObjectStore("test", { keyPath: "id" });
|
||||
for (var i in data) {
|
||||
objectStore.add(data[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
request.onsuccess = function(event) {
|
||||
if (finished) {
|
||||
finish(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var db = event.target.result;
|
||||
|
||||
// Think about close the db!
|
||||
switch (action) {
|
||||
case 'read-no':
|
||||
db.close();
|
||||
|
||||
if (created) { // That means we have created it.
|
||||
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
|
||||
finish(true);
|
||||
};
|
||||
} else {
|
||||
finish(false);
|
||||
}
|
||||
break;
|
||||
case 'read-yes':
|
||||
db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
|
||||
var name = event.target.result.name;
|
||||
db.close();
|
||||
|
||||
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
|
||||
finish(name == 'foo');
|
||||
};
|
||||
};
|
||||
break;
|
||||
case 'write':
|
||||
db.close();
|
||||
|
||||
// Success only if the db was actually created.
|
||||
finish(created);
|
||||
break;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,161 +0,0 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var fileTestOnCurrentOrigin = (location.protocol + '//' + location.host + location.pathname)
|
||||
.replace('test_', 'file_')
|
||||
.replace('_inproc', '').replace('_oop', '');
|
||||
|
||||
var previousPrefs = {
|
||||
mozBrowserFramesEnabled: undefined,
|
||||
oop_by_default: undefined,
|
||||
};
|
||||
|
||||
try {
|
||||
previousPrefs.mozBrowserFramesEnabled = SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
|
||||
} catch(e)
|
||||
{
|
||||
}
|
||||
|
||||
try {
|
||||
previousPrefs.oop_by_default = SpecialPowers.getBoolPref('dom.ipc.browser_frames.oop_by_default');
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', true);
|
||||
SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", location.pathname.indexOf('_inproc') == -1);
|
||||
|
||||
SpecialPowers.addPermission("browser", true, window.document);
|
||||
|
||||
var gData = [
|
||||
// APP 1
|
||||
{
|
||||
app: 'http://example.org/manifest.webapp',
|
||||
action: 'read-no',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
app: 'http://example.org/manifest.webapp',
|
||||
action: 'write',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
app: 'http://example.org/manifest.webapp',
|
||||
action: 'read-yes',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
// APP 2
|
||||
{
|
||||
app: 'https://example.com/manifest.webapp',
|
||||
action: 'read-no',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
app: 'https://example.com/manifest.webapp',
|
||||
action: 'write',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
app: 'https://example.com/manifest.webapp',
|
||||
action: 'read-yes',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
// Browser
|
||||
{
|
||||
browser: true,
|
||||
action: 'read-no',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
browser: true,
|
||||
action: 'write',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
{
|
||||
browser: true,
|
||||
action: 'read-yes',
|
||||
src: fileTestOnCurrentOrigin,
|
||||
},
|
||||
];
|
||||
|
||||
function runTest() {
|
||||
for (var i in gData) {
|
||||
var iframe = document.createElement('iframe');
|
||||
var data = gData[i];
|
||||
|
||||
if (data.app) {
|
||||
iframe.setAttribute('mozbrowser', '');
|
||||
iframe.setAttribute('mozapp', data.app);
|
||||
} else if (data.browser) {
|
||||
iframe.setAttribute('mozbrowser', '');
|
||||
}
|
||||
|
||||
if (data.app || data.browser) {
|
||||
iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
|
||||
is(e.detail.message, 'success', 'test number ' + i);
|
||||
|
||||
// document.getElementById('content').removeChild(iframe);
|
||||
|
||||
i++;
|
||||
if (i >= gData.length) {
|
||||
if (previousPrefs.mozBrowserFramesEnabled !== undefined) {
|
||||
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', previousPrefs.mozBrowserFramesEnabled);
|
||||
}
|
||||
if (previousPrefs.oop_by_default !== undefined) {
|
||||
SpecialPowers.setBoolPref("dom.ipc.browser_frames.oop_by_default", previousPrefs.oop_by_default);
|
||||
}
|
||||
|
||||
SpecialPowers.removePermission("browser", window.document);
|
||||
|
||||
indexedDB.deleteDatabase('AppIsolationTest').onsuccess = function() {
|
||||
SimpleTest.finish();
|
||||
};
|
||||
} else {
|
||||
gTestRunner.next();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
iframe.src = data.src + '?' + data.action;
|
||||
|
||||
document.getElementById('content').appendChild(iframe);
|
||||
|
||||
yield undefined;
|
||||
}
|
||||
}
|
||||
|
||||
var gTestRunner = runTest();
|
||||
|
||||
function startTest() {
|
||||
var request = window.indexedDB.open('AppIsolationTest');
|
||||
var created = false;
|
||||
|
||||
request.onupgradeneeded = function(event) {
|
||||
created = true;
|
||||
var db = event.target.result;
|
||||
var data = [
|
||||
{ id: "0", name: "foo" },
|
||||
];
|
||||
var objectStore = db.createObjectStore("test", { keyPath: "id" });
|
||||
for (var i in data) {
|
||||
objectStore.add(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
request.onsuccess = function(event) {
|
||||
var db = event.target.result;
|
||||
is(created, true, "we should have created the db");
|
||||
|
||||
db.transaction("test").objectStore("test").get("0").onsuccess = function(event) {
|
||||
is(event.target.result.name, 'foo', 'data have been written');
|
||||
db.close();
|
||||
|
||||
gTestRunner.next();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove unsetting network.disable.ipc.security as part of bug 820712
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["network.disable.ipc.security", true],
|
||||
]
|
||||
}, startTest);
|
||||
@@ -11,8 +11,6 @@ support-files =
|
||||
event_propagation_iframe.html
|
||||
exceptions_in_events_iframe.html
|
||||
file.js
|
||||
file_app_isolation.html
|
||||
file_app_isolation.js
|
||||
helpers.js
|
||||
leaving_page_iframe.html
|
||||
service_worker.js
|
||||
@@ -125,12 +123,6 @@ support-files =
|
||||
[test_add_put.html]
|
||||
[test_add_twice_failure.html]
|
||||
[test_advance.html]
|
||||
[test_app_isolation_inproc.html]
|
||||
# The app isolation tests are only supposed to run in the main process.
|
||||
skip-if = e10s
|
||||
[test_app_isolation_oop.html]
|
||||
# The app isolation tests are only supposed to run in the main process.
|
||||
skip-if = e10s
|
||||
[test_autoIncrement.html]
|
||||
[test_autoIncrement_indexes.html]
|
||||
[test_bfcache.html]
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
|
||||
-->
|
||||
<head>
|
||||
<title>Test for IndexedDB app isolation (unique process)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,21 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=756645
|
||||
-->
|
||||
<head>
|
||||
<title>Test for IndexedDB app isolation (unique process)</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=756645">Mozilla Bug 756645</a>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.7" src="file_app_isolation.js">
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -19,10 +19,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
|
||||
"resource://gre/modules/SystemAppProxy.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "appsService", function() {
|
||||
return Cc["@mozilla.org/AppsService;1"].getService(Ci.nsIAppsService);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "hardwareKeyHandler", function() {
|
||||
return null;
|
||||
});
|
||||
@@ -174,8 +170,8 @@ this.Keyboard = {
|
||||
this.formMM = null;
|
||||
}
|
||||
} else {
|
||||
// Ignore notifications that aren't from a BrowserOrApp
|
||||
if (!frameLoader.ownerIsMozBrowserOrAppFrame) {
|
||||
// Ignore notifications that aren't from a Browser
|
||||
if (!frameLoader.ownerIsMozBrowserFrame) {
|
||||
return;
|
||||
}
|
||||
this.initFormsFrameScript(mm);
|
||||
@@ -554,24 +550,6 @@ InputRegistryGlue.prototype.addInput = function(msg, mm) {
|
||||
mm: mm,
|
||||
requestId: msg.data.requestId
|
||||
});
|
||||
|
||||
let manifestURL = appsService.getManifestURLByLocalId(msg.data.appId);
|
||||
|
||||
Keyboard.sendToSystem('System:InputRegistry:Add', {
|
||||
id: msgId,
|
||||
manifestURL: manifestURL,
|
||||
inputId: msg.data.inputId,
|
||||
inputManifest: msg.data.inputManifest
|
||||
});
|
||||
|
||||
// XXX: To be removed when content migrate away from mozChromeEvents.
|
||||
SystemAppProxy.dispatchEvent({
|
||||
type: 'inputregistry-add',
|
||||
id: msgId,
|
||||
manifestURL: manifestURL,
|
||||
inputId: msg.data.inputId,
|
||||
inputManifest: msg.data.inputManifest
|
||||
});
|
||||
};
|
||||
|
||||
InputRegistryGlue.prototype.removeInput = function(msg, mm) {
|
||||
@@ -580,22 +558,6 @@ InputRegistryGlue.prototype.removeInput = function(msg, mm) {
|
||||
mm: mm,
|
||||
requestId: msg.data.requestId
|
||||
});
|
||||
|
||||
let manifestURL = appsService.getManifestURLByLocalId(msg.data.appId);
|
||||
|
||||
Keyboard.sendToSystem('System:InputRegistry:Remove', {
|
||||
id: msgId,
|
||||
manifestURL: manifestURL,
|
||||
inputId: msg.data.inputId
|
||||
});
|
||||
|
||||
// XXX: To be removed when content migrate away from mozChromeEvents.
|
||||
SystemAppProxy.dispatchEvent({
|
||||
type: 'inputregistry-remove',
|
||||
id: msgId,
|
||||
manifestURL: manifestURL,
|
||||
inputId: msg.data.inputId
|
||||
});
|
||||
};
|
||||
|
||||
InputRegistryGlue.prototype.returnMessage = function(detail) {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# 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/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'mozIApplication.idl',
|
||||
'mozIApplicationClearPrivateDataParams.idl',
|
||||
'nsIAppsService.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'dom_apps'
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIPrincipal;
|
||||
|
||||
/**
|
||||
* We expose Gecko-internal helpers related to "web apps" through this
|
||||
* sub-interface.
|
||||
*/
|
||||
[scriptable, uuid(e76aa5e0-80b2-404f-bccc-1067828bb6ed)]
|
||||
interface mozIApplication: nsISupports
|
||||
{
|
||||
/* Return true if this app has |permission|. */
|
||||
boolean hasPermission(in string permission);
|
||||
|
||||
/* Application status as defined in nsIPrincipal. */
|
||||
readonly attribute unsigned short appStatus;
|
||||
|
||||
/* Returns the uuid of the app. */
|
||||
readonly attribute DOMString id;
|
||||
|
||||
/* Returns the origin of the app. */
|
||||
readonly attribute DOMString origin;
|
||||
|
||||
/* Returns the manifest url of the app. */
|
||||
readonly attribute DOMString manifestURL;
|
||||
|
||||
/* Returns the local id of the app. */
|
||||
readonly attribute unsigned long localId;
|
||||
|
||||
/* Returns the base directory for the app */
|
||||
readonly attribute DOMString basePath;
|
||||
|
||||
/* Name copied from the manifest */
|
||||
readonly attribute DOMString name;
|
||||
|
||||
/* CSP copied from the manifest */
|
||||
readonly attribute DOMString csp;
|
||||
|
||||
/* Store ID if the app is installed from a store */
|
||||
readonly attribute DOMString storeID;
|
||||
|
||||
/* Store version if the app is installed from a store */
|
||||
readonly attribute unsigned long storeVersion;
|
||||
|
||||
/* role copied from the manifest */
|
||||
readonly attribute DOMString role;
|
||||
|
||||
/* Returns the kind of the app. */
|
||||
readonly attribute DOMString kind;
|
||||
|
||||
/* Returns the app's principal */
|
||||
readonly attribute nsIPrincipal principal;
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(ba0e6c8e-8c03-4b9b-8f9b-4fb14216f56e)]
|
||||
interface mozIApplicationClearPrivateDataParams : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long appId;
|
||||
readonly attribute boolean browserOnly;
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define TOPIC_WEB_APP_CLEAR_DATA "webapps-clear-data"
|
||||
#define TOPIC_CLEAR_ORIGIN_DATA "clear-origin-attributes-data"
|
||||
%}
|
||||
@@ -1,75 +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 "domstubs.idl"
|
||||
|
||||
interface mozIApplication;
|
||||
interface nsIURI;
|
||||
|
||||
%{C++
|
||||
#define APPS_SERVICE_CID { 0x05072afa, 0x92fe, 0x45bf, { 0xae, 0x22, 0x39, 0xb6, 0x9c, 0x11, 0x70, 0x58 } }
|
||||
#define APPS_SERVICE_CONTRACTID "@mozilla.org/AppsService;1"
|
||||
%}
|
||||
|
||||
/*
|
||||
* This service allows accessing some DOMApplicationRegistry methods from
|
||||
* non-javascript code.
|
||||
*/
|
||||
[scriptable, uuid(711cfab6-7b72-4aa2-a60c-17952ea05661)]
|
||||
interface nsIAppsService : nsISupports
|
||||
{
|
||||
mozIApplication getAppByManifestURL(in DOMString manifestURL);
|
||||
|
||||
/**
|
||||
* Returns a Promise for the manifest for a given manifestURL.
|
||||
* This is only supported in the parent process: the promise will be rejected
|
||||
* in content processes.
|
||||
*/
|
||||
jsval getManifestFor(in DOMString manifestURL);
|
||||
|
||||
/**
|
||||
* Returns the |localId| of the app associated with the |manifestURL| passed
|
||||
* in parameter.
|
||||
* Returns nsIScriptSecurityManager::NO_APP_ID if |manifestURL| isn't a valid
|
||||
* installed manifest URL.
|
||||
*/
|
||||
unsigned long getAppLocalIdByManifestURL(in DOMString manifestURL);
|
||||
|
||||
/**
|
||||
* Returns the application associated to this localId.
|
||||
*/
|
||||
mozIApplication getAppByLocalId(in unsigned long localId);
|
||||
|
||||
/**
|
||||
* Returns the manifest URL associated to this localId.
|
||||
*/
|
||||
DOMString getManifestURLByLocalId(in unsigned long localId);
|
||||
|
||||
/**
|
||||
* Returns the basepath for core apps
|
||||
*/
|
||||
DOMString getCoreAppsBasePath();
|
||||
|
||||
/**
|
||||
* Returns the basepath for regular packaged apps
|
||||
*/
|
||||
DOMString getWebAppsBasePath();
|
||||
|
||||
/**
|
||||
* Returns true if at least one app is in the registry.
|
||||
*/
|
||||
boolean areAnyAppsInstalled();
|
||||
|
||||
jsval getAppInfo(in DOMString appId);
|
||||
|
||||
/**
|
||||
* Returns the localId if the app was installed from a store
|
||||
*/
|
||||
DOMString getAppLocalIdByStoreId(in DOMString storeID);
|
||||
|
||||
/**
|
||||
* Returns the scope for app to use with service workers.
|
||||
*/
|
||||
DOMString getScopeByLocalId(in unsigned long localId);
|
||||
};
|
||||
@@ -12,44 +12,13 @@ interface nsITabParent;
|
||||
interface nsIMozBrowserFrame : nsIDOMMozBrowserFrame
|
||||
{
|
||||
/**
|
||||
* Gets whether this frame really is a browser or app frame.
|
||||
* Gets whether this frame really is a browser frame.
|
||||
*
|
||||
* In order to really be a browser frame, this frame's
|
||||
* nsIDOMMozBrowserFrame::mozbrowser attribute must be true, and the frame
|
||||
* may have to pass various security checks.
|
||||
*/
|
||||
[infallible] readonly attribute boolean reallyIsBrowserOrApp;
|
||||
|
||||
/**
|
||||
* Gets whether this frame really is an app frame.
|
||||
*
|
||||
* In order to really be an app frame, this frame must really be a browser
|
||||
* frame (this requirement will go away eventually), and the frame's mozapp
|
||||
* attribute must point to the manifest of a valid app.
|
||||
*/
|
||||
[infallible] readonly attribute boolean reallyIsApp;
|
||||
|
||||
/**
|
||||
* Gets whether this frame is an isolated frame.
|
||||
*
|
||||
* By default, browser frames are isolated, meaning they have a principal
|
||||
* where OriginAttributes.mIsInIsolatedMozBrowser == true. This isolates
|
||||
* storage and other origin related items from non-browser apps, xul:browsers,
|
||||
* etc.
|
||||
*
|
||||
* Isolation can be disabled by setting the frame's isolated attribute to
|
||||
* false. Disabling isolation is only allowed if the containing document has
|
||||
* browser permission (or equivalent access).
|
||||
*/
|
||||
[infallible] readonly attribute boolean isolated;
|
||||
|
||||
/**
|
||||
* Gets this frame's app manifest URL, if the frame really is an app frame.
|
||||
* Otherwise, returns the empty string.
|
||||
*
|
||||
* This method is guaranteed not to fail.
|
||||
*/
|
||||
readonly attribute AString appManifestURL;
|
||||
[infallible] readonly attribute boolean reallyIsBrowser;
|
||||
|
||||
/**
|
||||
* Normally, a frame tries to create its frame loader when its src is
|
||||
|
||||
@@ -77,7 +77,6 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return PContentBridgeChild::SendPBrowserConstructor(aActor,
|
||||
@@ -85,7 +84,6 @@ ContentBridgeChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -130,14 +128,12 @@ ContentBridgeChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
const IPCTabContext &aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return nsIContentChild::AllocPBrowserChild(aTabId,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -153,7 +149,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return ContentChild::GetSingleton()->RecvPBrowserConstructor(aActor,
|
||||
@@ -161,7 +156,6 @@ ContentBridgeChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual mozilla::ipc::PFileDescriptorSetChild*
|
||||
@@ -60,7 +59,6 @@ protected:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
virtual bool DeallocPBrowserChild(PBrowserChild*) override;
|
||||
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
|
||||
@@ -68,7 +66,6 @@ protected:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual mozilla::jsipc::PJavaScriptChild* AllocPJavaScriptChild() override;
|
||||
|
||||
@@ -102,7 +102,6 @@ ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return PContentBridgeParent::SendPBrowserConstructor(aActor,
|
||||
@@ -110,7 +109,6 @@ ContentBridgeParent::SendPBrowserConstructor(PBrowserParent* aActor,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -143,14 +141,12 @@ ContentBridgeParent::AllocPBrowserParent(const TabId& aTabId,
|
||||
const IPCTabContext &aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return nsIContentParent::AllocPBrowserParent(aTabId,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
|
||||
@@ -53,10 +52,6 @@ public:
|
||||
{
|
||||
return mChildID;
|
||||
}
|
||||
virtual bool IsForApp() const override
|
||||
{
|
||||
return mIsForApp;
|
||||
}
|
||||
virtual bool IsForBrowser() const override
|
||||
{
|
||||
return mIsForBrowser;
|
||||
@@ -75,11 +70,6 @@ protected:
|
||||
mChildID = aId;
|
||||
}
|
||||
|
||||
void SetIsForApp(bool aIsForApp)
|
||||
{
|
||||
mIsForApp = aIsForApp;
|
||||
}
|
||||
|
||||
void SetIsForBrowser(bool aIsForBrowser)
|
||||
{
|
||||
mIsForBrowser = aIsForBrowser;
|
||||
@@ -114,7 +104,6 @@ protected:
|
||||
const IPCTabContext &aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual bool DeallocPBrowserParent(PBrowserParent*) override;
|
||||
@@ -140,7 +129,6 @@ protected: // members
|
||||
RefPtr<ContentBridgeParent> mSelfRef;
|
||||
Transport* mTransport; // owned
|
||||
ContentParentId mChildID;
|
||||
bool mIsForApp;
|
||||
bool mIsForBrowser;
|
||||
|
||||
private:
|
||||
|
||||
@@ -550,8 +550,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
||||
SendBackUpXResources(FileDescriptor(xSocketFd));
|
||||
#endif
|
||||
|
||||
SendGetProcessAttributes(&mID, &mIsForApp, &mIsForBrowser);
|
||||
InitProcessAttributes();
|
||||
SendGetProcessAttributes(&mID, &mIsForBrowser);
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
// Force the creation of the nsPrintingProxy so that it's IPC counterpart,
|
||||
@@ -562,12 +561,6 @@ ContentChild::Init(MessageLoop* aIOLoop,
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentChild::InitProcessAttributes()
|
||||
{
|
||||
SetProcessName(NS_LITERAL_STRING("Web Content"), true);
|
||||
}
|
||||
|
||||
void
|
||||
ContentChild::SetProcessName(const nsAString& aName, bool aDontOverride)
|
||||
{
|
||||
@@ -674,7 +667,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
||||
// We release this ref in DeallocPBrowserChild
|
||||
RefPtr<TabChild>(newChild).forget().take(),
|
||||
tabId, *ipcContext, aChromeFlags,
|
||||
GetID(), IsForApp(), IsForBrowser());
|
||||
GetID(), IsForBrowser());
|
||||
|
||||
nsString name(aName);
|
||||
nsAutoCString features(aFeatures);
|
||||
@@ -1237,15 +1230,6 @@ ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL,
|
||||
return true;
|
||||
}
|
||||
|
||||
static CancelableRunnable* sFirstIdleTask;
|
||||
|
||||
static void FirstIdle(void)
|
||||
{
|
||||
MOZ_ASSERT(sFirstIdleTask);
|
||||
sFirstIdleTask = nullptr;
|
||||
ContentChild::GetSingleton()->SendFirstIdle();
|
||||
}
|
||||
|
||||
mozilla::jsipc::PJavaScriptChild *
|
||||
ContentChild::AllocPJavaScriptChild()
|
||||
{
|
||||
@@ -1265,14 +1249,12 @@ ContentChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return nsIContentChild::AllocPBrowserChild(aTabId,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -1282,7 +1264,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
if (IsShuttingDown()) {
|
||||
@@ -1294,7 +1275,6 @@ ContentChild::SendPBrowserConstructor(PBrowserChild* aActor,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpID,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -1304,7 +1284,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
MOZ_ASSERT(!IsShuttingDown());
|
||||
@@ -1319,23 +1298,6 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
|
||||
os->NotifyObservers(tc, "tab-child-created", nullptr);
|
||||
}
|
||||
|
||||
static bool hasRunOnce = false;
|
||||
if (!hasRunOnce) {
|
||||
hasRunOnce = true;
|
||||
|
||||
MOZ_ASSERT(!sFirstIdleTask);
|
||||
RefPtr<CancelableRunnable> firstIdleTask = NewCancelableRunnableFunction(FirstIdle);
|
||||
sFirstIdleTask = firstIdleTask;
|
||||
MessageLoop::current()->PostIdleTask(firstIdleTask.forget());
|
||||
|
||||
// Redo InitProcessAttributes() when the app or browser is really
|
||||
// launching so the attributes will be correct.
|
||||
mID = aCpID;
|
||||
mIsForApp = aIsForApp;
|
||||
mIsForBrowser = aIsForBrowser;
|
||||
InitProcessAttributes();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1784,9 +1746,6 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
|
||||
// keep persistent state.
|
||||
ProcessChild::QuickExit();
|
||||
#else
|
||||
if (sFirstIdleTask) {
|
||||
sFirstIdleTask->Cancel();
|
||||
}
|
||||
|
||||
nsHostObjectProtocolHandler::RemoveDataEntries();
|
||||
|
||||
@@ -2080,16 +2039,6 @@ ContentChild::RecvCycleCollect()
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
PreloadSlowThings()
|
||||
{
|
||||
// This fetches and creates all the built-in stylesheets.
|
||||
nsLayoutStylesheetCache::Get()->UserContentSheet();
|
||||
|
||||
TabChild::PreloadSlowThings();
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
|
||||
const nsCString& name, const nsCString& UAName,
|
||||
@@ -2105,25 +2054,6 @@ ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvAppInit()
|
||||
{
|
||||
if (!Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we're part of the mozbrowser machinery, go ahead and start
|
||||
// preloading things. We can only do this for mozbrowser because
|
||||
// PreloadSlowThings() may set the docshell of the first TabChild
|
||||
// inactive, and we can only safely restore it to active from
|
||||
// BrowserElementChild.js.
|
||||
if (mIsForApp || mIsForBrowser) {
|
||||
PreloadSlowThings();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig)
|
||||
{
|
||||
|
||||
@@ -91,8 +91,6 @@ public:
|
||||
base::ProcessId aParentPid,
|
||||
IPC::Channel* aChannel);
|
||||
|
||||
void InitProcessAttributes();
|
||||
|
||||
void InitXPCOM();
|
||||
|
||||
void InitGraphicsDeviceData();
|
||||
@@ -173,7 +171,6 @@ public:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual bool DeallocPBrowserChild(PBrowserChild*) override;
|
||||
@@ -379,8 +376,6 @@ public:
|
||||
const nsCString& name, const nsCString& UAName,
|
||||
const nsCString& ID, const nsCString& vendor) override;
|
||||
|
||||
virtual bool RecvAppInit() override;
|
||||
|
||||
virtual bool
|
||||
RecvInitServiceWorkers(const ServiceWorkerConfiguration& aConfig) override;
|
||||
|
||||
@@ -481,7 +476,6 @@ public:
|
||||
uint32_t GetMsaaID() const { return mMsaaID; }
|
||||
#endif
|
||||
|
||||
bool IsForApp() const { return mIsForApp; }
|
||||
bool IsForBrowser() const { return mIsForBrowser; }
|
||||
|
||||
virtual PBlobChild*
|
||||
@@ -502,7 +496,6 @@ public:
|
||||
const IPCTabContext& context,
|
||||
const uint32_t& chromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual bool RecvPBrowserConstructor(PBrowserChild* aCctor,
|
||||
@@ -510,7 +503,6 @@ public:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)
|
||||
@@ -616,7 +608,6 @@ private:
|
||||
|
||||
AppInfo mAppInfo;
|
||||
|
||||
bool mIsForApp;
|
||||
bool mIsForBrowser;
|
||||
bool mCanOverrideProcessName;
|
||||
bool mIsAlive;
|
||||
|
||||
+92
-471
@@ -25,7 +25,6 @@
|
||||
#include "HandlerServiceParent.h"
|
||||
#include "IHistory.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "mozIApplication.h"
|
||||
#if defined(XP_WIN) && defined(ACCESSIBILITY)
|
||||
#include "mozilla/a11y/AccessibleWrap.h"
|
||||
#endif
|
||||
@@ -95,7 +94,6 @@
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
#include "nsIAlertsService.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsICycleCollectorListener.h"
|
||||
@@ -143,7 +141,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "PreallocatedProcessManager.h"
|
||||
#include "ProcessPriorityManager.h"
|
||||
#include "SandboxHal.h"
|
||||
#include "ScreenManagerParent.h"
|
||||
@@ -456,8 +453,7 @@ ContentParentsMemoryReporter::CollectReports(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
|
||||
nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
|
||||
nsTArray<ContentParent*>* ContentParent::sBrowserContentParents;
|
||||
nsTArray<ContentParent*>* ContentParent::sLargeAllocationContentParents;
|
||||
nsTArray<ContentParent*>* ContentParent::sPrivateContent;
|
||||
StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
|
||||
@@ -473,11 +469,6 @@ static bool sDisableUnsafeCPOWWarnings = false;
|
||||
// The first content child has ID 1, so the chrome process can have ID 0.
|
||||
static uint64_t gContentChildID = 1;
|
||||
|
||||
// We want the prelaunched process to know that it's for apps, but not
|
||||
// actually for any app in particular. Use a magic manifest URL.
|
||||
// Can't be a static constant.
|
||||
#define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
|
||||
|
||||
static const char* sObserverTopics[] = {
|
||||
"xpcom-shutdown",
|
||||
"profile-before-change",
|
||||
@@ -496,77 +487,6 @@ static const char* sObserverTopics[] = {
|
||||
"cacheservice:empty-cache",
|
||||
};
|
||||
|
||||
// PreallocateAppProcess is called by the PreallocatedProcessManager.
|
||||
// ContentParent then takes this process back within
|
||||
// GetNewOrPreallocatedAppProcess.
|
||||
/*static*/ already_AddRefed<ContentParent>
|
||||
ContentParent::PreallocateAppProcess()
|
||||
{
|
||||
RefPtr<ContentParent> process =
|
||||
new ContentParent(/* app = */ nullptr,
|
||||
/* aOpener = */ nullptr,
|
||||
/* isForBrowserElement = */ false,
|
||||
/* isForPreallocated = */ true);
|
||||
|
||||
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
process->Init();
|
||||
return process.forget();
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<ContentParent>
|
||||
ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
|
||||
ProcessPriority aInitialPriority,
|
||||
ContentParent* aOpener,
|
||||
/*out*/ bool* aTookPreAllocated)
|
||||
{
|
||||
MOZ_ASSERT(aApp);
|
||||
RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
|
||||
|
||||
if (process) {
|
||||
if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
|
||||
// Kill the process just in case it's not actually dead; we don't want
|
||||
// to "leak" this process!
|
||||
process->KillHard("GetNewOrPreallocatedAppProcess");
|
||||
}
|
||||
else {
|
||||
nsAutoString manifestURL;
|
||||
if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
|
||||
NS_ERROR("Failed to get manifest URL");
|
||||
return nullptr;
|
||||
}
|
||||
process->TransformPreallocatedIntoApp(aOpener, manifestURL);
|
||||
process->ForwardKnownInfo();
|
||||
|
||||
if (aTookPreAllocated) {
|
||||
*aTookPreAllocated = true;
|
||||
}
|
||||
return process.forget();
|
||||
}
|
||||
}
|
||||
|
||||
NS_WARNING("Unable to use pre-allocated app process");
|
||||
process = new ContentParent(aApp,
|
||||
/* aOpener = */ aOpener,
|
||||
/* isForBrowserElement = */ false,
|
||||
/* isForPreallocated = */ false);
|
||||
|
||||
if (!process->LaunchSubprocess(aInitialPriority)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
process->Init();
|
||||
process->ForwardKnownInfo();
|
||||
|
||||
if (aTookPreAllocated) {
|
||||
*aTookPreAllocated = false;
|
||||
}
|
||||
|
||||
return process.forget();
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
ContentParent::StartUp()
|
||||
{
|
||||
@@ -588,9 +508,6 @@ ContentParent::StartUp()
|
||||
|
||||
BackgroundChild::Startup();
|
||||
|
||||
// Try to preallocate a process that we can transform into an app later.
|
||||
PreallocatedProcessManager::AllocateAfterDelay();
|
||||
|
||||
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
|
||||
}
|
||||
|
||||
@@ -668,10 +585,10 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
||||
|
||||
maxContentParents = Preferences::GetInt("dom.ipc.dedicatedProcessCount", 2);
|
||||
} else {
|
||||
if (!sNonAppContentParents) {
|
||||
sNonAppContentParents = new nsTArray<ContentParent*>();
|
||||
if (!sBrowserContentParents) {
|
||||
sBrowserContentParents = new nsTArray<ContentParent*>();
|
||||
}
|
||||
contentParents = sNonAppContentParents;
|
||||
contentParents = sBrowserContentParents;
|
||||
|
||||
maxContentParents = Preferences::GetInt("dom.ipc.processCount", 1);
|
||||
}
|
||||
@@ -687,7 +604,7 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
||||
uint32_t currIdx = startIdx;
|
||||
do {
|
||||
RefPtr<ContentParent> p = (*contentParents)[currIdx];
|
||||
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
|
||||
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sBrowserContntParents?");
|
||||
if (p->mOpener == aOpener) {
|
||||
return p.forget();
|
||||
}
|
||||
@@ -695,24 +612,14 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
|
||||
} while (currIdx != startIdx);
|
||||
}
|
||||
|
||||
// Try to take and transform the preallocated process into browser.
|
||||
RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
|
||||
if (p) {
|
||||
p->TransformPreallocatedIntoBrowser(aOpener);
|
||||
} else {
|
||||
// Failed in using the preallocated process: fork from the chrome process.
|
||||
p = new ContentParent(/* app = */ nullptr,
|
||||
aOpener,
|
||||
aForBrowserElement,
|
||||
/* isForPreallocated = */ false);
|
||||
RefPtr<ContentParent> p = new ContentParent(aOpener, aForBrowserElement);
|
||||
|
||||
if (!p->LaunchSubprocess(aPriority)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->Init();
|
||||
if (!p->LaunchSubprocess(aPriority)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
p->Init();
|
||||
|
||||
p->mLargeAllocationProcess = aLargeAllocationProcess;
|
||||
|
||||
p->ForwardKnownInfo();
|
||||
@@ -767,18 +674,11 @@ ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
|
||||
}
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
bool
|
||||
ContentParent::PreallocatedProcessReady()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
|
||||
const hal::ProcessPriority& aPriority,
|
||||
const TabId& aOpenerTabId,
|
||||
ContentParentId* aCpId,
|
||||
bool* aIsForApp,
|
||||
bool* aIsForBrowser,
|
||||
TabId* aTabId)
|
||||
{
|
||||
@@ -796,24 +696,16 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
|
||||
if (ownApp) {
|
||||
cp = GetNewOrPreallocatedAppProcess(ownApp, aPriority, this);
|
||||
}
|
||||
else {
|
||||
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
|
||||
aPriority, this);
|
||||
}
|
||||
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
|
||||
aPriority, this);
|
||||
|
||||
if (!cp) {
|
||||
*aCpId = 0;
|
||||
*aIsForApp = false;
|
||||
*aIsForBrowser = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
*aCpId = cp->ChildID();
|
||||
*aIsForApp = cp->IsForApp();
|
||||
*aIsForBrowser = cp->IsForBrowser();
|
||||
|
||||
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
|
||||
@@ -944,10 +836,10 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
|
||||
}
|
||||
|
||||
/*static*/ TabParent*
|
||||
ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess)
|
||||
ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess)
|
||||
{
|
||||
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
||||
|
||||
@@ -970,222 +862,74 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
|
||||
openerTabId = TabParent::GetTabIdFrom(docShell);
|
||||
}
|
||||
|
||||
if (aContext.IsMozBrowserElement() || !aContext.HasOwnApp()) {
|
||||
RefPtr<nsIContentParent> constructorSender;
|
||||
if (isInContentProcess) {
|
||||
MOZ_ASSERT(aContext.IsMozBrowserElement());
|
||||
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
|
||||
openerTabId, &tabId);
|
||||
} else {
|
||||
if (aOpenerContentParent) {
|
||||
constructorSender = aOpenerContentParent;
|
||||
} else {
|
||||
constructorSender =
|
||||
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
|
||||
initialPriority,
|
||||
nullptr,
|
||||
aFreshProcess);
|
||||
if (!constructorSender) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
tabId = AllocateTabId(openerTabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
constructorSender->ChildID());
|
||||
}
|
||||
if (constructorSender) {
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (!treeOwner) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
|
||||
if (!wbc) {
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t chromeFlags = 0;
|
||||
wbc->GetChromeFlags(&chromeFlags);
|
||||
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
||||
if (loadContext && loadContext->UsePrivateBrowsing()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
|
||||
}
|
||||
if (docShell->GetAffectPrivateSessionLifetime()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
|
||||
}
|
||||
|
||||
if (tabId == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
|
||||
aContext, chromeFlags));
|
||||
tp->SetInitedByParent();
|
||||
|
||||
PBrowserParent* browser =
|
||||
constructorSender->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
tp.forget().take(), tabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
chromeFlags,
|
||||
constructorSender->ChildID(),
|
||||
constructorSender->IsForApp(),
|
||||
constructorSender->IsForBrowser());
|
||||
|
||||
if (aFreshProcess) {
|
||||
Unused << browser->SendSetFreshProcess();
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
|
||||
constructedTabParent->SetOwnerElement(aFrameElement);
|
||||
return constructedTabParent;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If we got here, we have an app and we're not a browser element. ownApp
|
||||
// shouldn't be null, because we otherwise would have gone into the
|
||||
// !HasOwnApp() branch above.
|
||||
RefPtr<nsIContentParent> parent;
|
||||
bool reused = false;
|
||||
bool tookPreallocated = false;
|
||||
nsAutoString manifestURL;
|
||||
|
||||
RefPtr<nsIContentParent> constructorSender;
|
||||
if (isInContentProcess) {
|
||||
parent = CreateContentBridgeParent(aContext,
|
||||
initialPriority,
|
||||
openerTabId,
|
||||
&tabId);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
|
||||
|
||||
if (!sAppContentParents) {
|
||||
sAppContentParents =
|
||||
new nsDataHashtable<nsStringHashKey, ContentParent*>();
|
||||
MOZ_ASSERT(aContext.IsMozBrowserElement());
|
||||
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
|
||||
openerTabId, &tabId);
|
||||
} else {
|
||||
constructorSender =
|
||||
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
|
||||
initialPriority, nullptr, aFreshProcess);
|
||||
if (!constructorSender) {
|
||||
return nullptr;
|
||||
}
|
||||
tabId = AllocateTabId(openerTabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
constructorSender->ChildID());
|
||||
}
|
||||
|
||||
// Each app gets its own ContentParent instance unless it shares it with
|
||||
// a parent app.
|
||||
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
|
||||
NS_ERROR("Failed to get manifest URL");
|
||||
if (constructorSender) {
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||
if (!treeOwner) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
|
||||
|
||||
if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
|
||||
nsAutoString parentAppManifestURL;
|
||||
aFrameElement->GetAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::parentapp, parentAppManifestURL);
|
||||
nsAdoptingString systemAppManifestURL =
|
||||
Preferences::GetString("b2g.system_manifest_url");
|
||||
nsCOMPtr<nsIAppsService> appsService =
|
||||
do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
if (!parentAppManifestURL.IsEmpty() &&
|
||||
!parentAppManifestURL.Equals(systemAppManifestURL) &&
|
||||
appsService) {
|
||||
nsCOMPtr<mozIApplication> parentApp;
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByManifestURL(parentAppManifestURL,
|
||||
getter_AddRefs(parentApp));
|
||||
appsService->GetAppByManifestURL(manifestURL,
|
||||
getter_AddRefs(app));
|
||||
|
||||
// Only let certified apps re-use the same process.
|
||||
unsigned short parentAppStatus = 0;
|
||||
unsigned short appStatus = 0;
|
||||
if (app &&
|
||||
NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
|
||||
appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
|
||||
parentApp &&
|
||||
NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
|
||||
parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
|
||||
// Check if we can re-use the process of the parent app.
|
||||
p = sAppContentParents->Get(parentAppManifestURL);
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
|
||||
if (!wbc) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (p) {
|
||||
// Check that the process is still alive and set its priority.
|
||||
// Hopefully the process won't die after this point, if this call
|
||||
// succeeds.
|
||||
if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
|
||||
p = nullptr;
|
||||
}
|
||||
uint32_t chromeFlags = 0;
|
||||
wbc->GetChromeFlags(&chromeFlags);
|
||||
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
||||
if (loadContext && loadContext->UsePrivateBrowsing()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
|
||||
}
|
||||
|
||||
reused = !!p;
|
||||
if (!p) {
|
||||
p = GetNewOrPreallocatedAppProcess(ownApp, initialPriority, nullptr,
|
||||
&tookPreallocated);
|
||||
MOZ_ASSERT(p);
|
||||
sAppContentParents->Put(manifestURL, p);
|
||||
}
|
||||
tabId = AllocateTabId(openerTabId, aContext.AsIPCTabContext(),
|
||||
p->ChildID());
|
||||
parent = static_cast<nsIContentParent*>(p);
|
||||
}
|
||||
|
||||
if (!parent || (tabId == 0)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t chromeFlags = 0;
|
||||
|
||||
RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
|
||||
tp->SetInitedByParent();
|
||||
PBrowserParent* browser = parent->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
RefPtr<TabParent>(tp).forget().take(),
|
||||
tabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
chromeFlags,
|
||||
parent->ChildID(),
|
||||
parent->IsForApp(),
|
||||
parent->IsForBrowser());
|
||||
|
||||
if (aFreshProcess) {
|
||||
Unused << browser->SendSetFreshProcess();
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
|
||||
constructedTabParent->SetOwnerElement(aFrameElement);
|
||||
}
|
||||
|
||||
if (isInContentProcess) {
|
||||
// Just return directly without the following check in content process.
|
||||
return TabParent::GetFrom(browser);
|
||||
}
|
||||
|
||||
if (!browser) {
|
||||
// We failed to actually start the PBrowser. This can happen if the
|
||||
// other process has already died.
|
||||
if (!reused) {
|
||||
// Don't leave a broken ContentParent in the hashtable.
|
||||
parent->AsContentParent()->KillHard("CreateBrowserOrApp");
|
||||
sAppContentParents->Remove(manifestURL);
|
||||
parent = nullptr;
|
||||
if (docShell->GetAffectPrivateSessionLifetime()) {
|
||||
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
|
||||
}
|
||||
|
||||
// If we took the preallocated process and it was already dead, try
|
||||
// again with a non-preallocated process. We can be sure this won't
|
||||
// loop forever, because the next time through there will be no
|
||||
// preallocated process to take.
|
||||
if (tookPreallocated) {
|
||||
return ContentParent::CreateBrowserOrApp(aContext, aFrameElement,
|
||||
aOpenerContentParent);
|
||||
if (tabId == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
|
||||
aContext, chromeFlags));
|
||||
tp->SetInitedByParent();
|
||||
|
||||
PBrowserParent* browser =
|
||||
constructorSender->SendPBrowserConstructor(
|
||||
// DeallocPBrowserParent() releases this ref.
|
||||
tp.forget().take(), tabId,
|
||||
aContext.AsIPCTabContext(),
|
||||
chromeFlags,
|
||||
constructorSender->ChildID(),
|
||||
constructorSender->IsForBrowser());
|
||||
|
||||
if (aFreshProcess) {
|
||||
Unused << browser->SendSetFreshProcess();
|
||||
}
|
||||
|
||||
// Otherwise just give up.
|
||||
return nullptr;
|
||||
if (browser) {
|
||||
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
|
||||
constructedTabParent->SetOwnerElement(aFrameElement);
|
||||
return constructedTabParent;
|
||||
}
|
||||
}
|
||||
|
||||
return TabParent::GetFrom(browser);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*static*/ ContentBridgeParent*
|
||||
@@ -1198,13 +942,11 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
|
||||
|
||||
ContentChild* child = ContentChild::GetSingleton();
|
||||
ContentParentId cpId;
|
||||
bool isForApp;
|
||||
bool isForBrowser;
|
||||
if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
|
||||
aPriority,
|
||||
aOpenerTabId,
|
||||
&cpId,
|
||||
&isForApp,
|
||||
&isForBrowser,
|
||||
aTabId)) {
|
||||
return nullptr;
|
||||
@@ -1217,7 +959,6 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
|
||||
}
|
||||
ContentBridgeParent* parent = child->GetLastBridge();
|
||||
parent->SetChildID(cpId);
|
||||
parent->SetIsForApp(isForApp);
|
||||
parent->SetIsForBrowser(isForBrowser);
|
||||
return parent;
|
||||
}
|
||||
@@ -1336,51 +1077,6 @@ ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helper for ContentParent::TransformPreallocatedIntoApp.
|
||||
static void
|
||||
TryGetNameFromManifestURL(const nsAString& aManifestURL,
|
||||
nsAString& aName)
|
||||
{
|
||||
aName.Truncate();
|
||||
if (aManifestURL.IsEmpty() ||
|
||||
aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE_VOID(appsService);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
|
||||
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
app->GetName(aName);
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
|
||||
const nsAString& aAppManifestURL)
|
||||
{
|
||||
MOZ_ASSERT(IsPreallocated());
|
||||
mMetamorphosed = true;
|
||||
mOpener = aOpener;
|
||||
mAppManifestURL = aAppManifestURL;
|
||||
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
|
||||
{
|
||||
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
|
||||
mMetamorphosed = true;
|
||||
mOpener = aOpener;
|
||||
mAppManifestURL.Truncate();
|
||||
mIsForBrowser = true;
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
|
||||
{
|
||||
@@ -1464,29 +1160,19 @@ ContentParent::ShutDownMessageManager()
|
||||
void
|
||||
ContentParent::MarkAsDead()
|
||||
{
|
||||
if (!mAppManifestURL.IsEmpty()) {
|
||||
if (sAppContentParents) {
|
||||
sAppContentParents->Remove(mAppManifestURL);
|
||||
if (!sAppContentParents->Count()) {
|
||||
delete sAppContentParents;
|
||||
sAppContentParents = nullptr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sNonAppContentParents) {
|
||||
sNonAppContentParents->RemoveElement(this);
|
||||
if (!sNonAppContentParents->Length()) {
|
||||
delete sNonAppContentParents;
|
||||
sNonAppContentParents = nullptr;
|
||||
}
|
||||
if (sBrowserContentParents) {
|
||||
sBrowserContentParents->RemoveElement(this);
|
||||
if (!sBrowserContentParents->Length()) {
|
||||
delete sBrowserContentParents;
|
||||
sBrowserContentParents = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (sLargeAllocationContentParents) {
|
||||
sLargeAllocationContentParents->RemoveElement(this);
|
||||
if (!sLargeAllocationContentParents->Length()) {
|
||||
delete sLargeAllocationContentParents;
|
||||
sLargeAllocationContentParents = nullptr;
|
||||
}
|
||||
if (sLargeAllocationContentParents) {
|
||||
sLargeAllocationContentParents->RemoveElement(this);
|
||||
if (!sLargeAllocationContentParents->Length()) {
|
||||
delete sLargeAllocationContentParents;
|
||||
sLargeAllocationContentParents = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1789,7 +1475,7 @@ ContentParent::NotifyTabDestroying(const TabId& aTabId,
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
|
||||
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
|
||||
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
|
||||
if (!cp->mLargeAllocationProcess && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive) {
|
||||
return;
|
||||
@@ -1846,7 +1532,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
|
||||
|
||||
// We might want to keep alive some content processes for testing, because of performance
|
||||
// reasons, but we don't want to alter behavior if the pref is not set.
|
||||
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
|
||||
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
|
||||
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
|
||||
bool shouldKeepAliveAny = !mLargeAllocationProcess && processesToKeepAlive > 0;
|
||||
bool shouldKeepAliveThis = shouldKeepAliveAny && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive;
|
||||
@@ -1940,10 +1626,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
|
||||
return true;
|
||||
}
|
||||
|
||||
ContentParent::ContentParent(mozIApplication* aApp,
|
||||
ContentParent* aOpener,
|
||||
bool aIsForBrowser,
|
||||
bool aIsForPreallocated)
|
||||
ContentParent::ContentParent(ContentParent* aOpener,
|
||||
bool aIsForBrowser)
|
||||
: nsIContentParent()
|
||||
, mOpener(aOpener)
|
||||
, mIsForBrowser(aIsForBrowser)
|
||||
@@ -1951,10 +1635,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||
{
|
||||
InitializeMembers(); // Perform common initialization.
|
||||
|
||||
// No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
|
||||
// true.
|
||||
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
|
||||
|
||||
mMetamorphosed = true;
|
||||
|
||||
// Insert ourselves into the global linked list of ContentParent objects.
|
||||
@@ -1963,13 +1643,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
|
||||
}
|
||||
sContentParents->insertBack(this);
|
||||
|
||||
if (aApp) {
|
||||
aApp->GetManifestURL(mAppManifestURL);
|
||||
aApp->GetName(mAppName);
|
||||
} else if (aIsForPreallocated) {
|
||||
mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
|
||||
}
|
||||
|
||||
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
|
||||
// PID along with the warning.
|
||||
nsDebugImpl::SetMultiprocessMode("Parent");
|
||||
@@ -1996,19 +1669,10 @@ ContentParent::~ContentParent()
|
||||
|
||||
// We should be removed from all these lists in ActorDestroy.
|
||||
MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
|
||||
if (mAppManifestURL.IsEmpty()) {
|
||||
MOZ_ASSERT((!sNonAppContentParents ||
|
||||
!sNonAppContentParents->Contains(this)) &&
|
||||
(!sLargeAllocationContentParents ||
|
||||
!sLargeAllocationContentParents->Contains(this)));
|
||||
} else {
|
||||
// In general, we expect sAppContentParents->Get(mAppManifestURL) to be
|
||||
// nullptr. But it could be that we created another ContentParent for
|
||||
// this app after we did this->ActorDestroy(), so the right check is
|
||||
// that sAppContentParents->Get(mAppManifestURL) != this.
|
||||
MOZ_ASSERT(!sAppContentParents ||
|
||||
sAppContentParents->Get(mAppManifestURL) != this);
|
||||
}
|
||||
MOZ_ASSERT((!sBrowserContentParents ||
|
||||
!sBrowserContentParents->Contains(this)) &&
|
||||
(!sLargeAllocationContentParents ||
|
||||
!sLargeAllocationContentParents->Contains(this)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2080,11 +1744,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
||||
}
|
||||
}
|
||||
|
||||
if (gAppData) {
|
||||
// Sending all information to content process.
|
||||
Unused << SendAppInit();
|
||||
}
|
||||
|
||||
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
|
||||
if (sheetService) {
|
||||
// This looks like a lot of work, but in a normal browser session we just
|
||||
@@ -2144,12 +1803,6 @@ ContentParent::IsAlive() const
|
||||
return mIsAlive;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::IsForApp() const
|
||||
{
|
||||
return !mAppManifestURL.IsEmpty();
|
||||
}
|
||||
|
||||
int32_t
|
||||
ContentParent::Pid() const
|
||||
{
|
||||
@@ -2390,17 +2043,6 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvFirstIdle()
|
||||
{
|
||||
// When the ContentChild goes idle, it sends us a FirstIdle message
|
||||
// which we use as a good time to prelaunch another process. If we
|
||||
// prelaunch any sooner than this, then we'll be competing with the
|
||||
// child process and slowing it down.
|
||||
PreallocatedProcessManager::AllocateAfterDelay();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
|
||||
const bool& aHidden)
|
||||
@@ -2575,10 +2217,9 @@ ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
|
||||
|
||||
bool
|
||||
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
|
||||
bool* aIsForApp, bool* aIsForBrowser)
|
||||
bool* aIsForBrowser)
|
||||
{
|
||||
*aCpId = mChildID;
|
||||
*aIsForApp = IsForApp();
|
||||
*aIsForBrowser = mIsForBrowser;
|
||||
|
||||
return true;
|
||||
@@ -2687,14 +2328,12 @@ ContentParent::AllocPBrowserParent(const TabId& aTabId,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return nsIContentParent::AllocPBrowserParent(aTabId,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpId,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -2792,27 +2431,14 @@ ContentParent::KillHard(const char* aReason)
|
||||
otherProcessHandle, /*force=*/true));
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::IsPreallocated() const
|
||||
{
|
||||
return mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL;
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
|
||||
{
|
||||
aName.Truncate();
|
||||
if (IsPreallocated()) {
|
||||
aName.AssignLiteral("(Preallocated)");
|
||||
} else if (mIsForBrowser) {
|
||||
if (mIsForBrowser) {
|
||||
aName.AssignLiteral("Browser");
|
||||
} else if (aAnonymize) {
|
||||
aName.AssignLiteral("<anonymized-name>");
|
||||
} else if (!mAppName.IsEmpty()) {
|
||||
aName = mAppName;
|
||||
} else if (!mAppManifestURL.IsEmpty()) {
|
||||
aName.AssignLiteral("Unknown app: ");
|
||||
aName.Append(mAppManifestURL);
|
||||
} else {
|
||||
aName.AssignLiteral("???");
|
||||
}
|
||||
@@ -3649,7 +3275,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
return PContentParent::SendPBrowserConstructor(aActor,
|
||||
@@ -3657,7 +3282,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
|
||||
aContext,
|
||||
aChromeFlags,
|
||||
aCpId,
|
||||
aIsForApp,
|
||||
aIsForBrowser);
|
||||
}
|
||||
|
||||
@@ -3775,12 +3399,9 @@ ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus,
|
||||
// recording-device-ipc-events needs to gather more information from content process
|
||||
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
|
||||
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), ChildID());
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), IsForApp());
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
|
||||
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
|
||||
|
||||
nsString requestURL = IsForApp() ? AppManifestURL() : aPageURL;
|
||||
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
|
||||
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), aPageURL);
|
||||
|
||||
obs->NotifyObservers((nsIPropertyBag2*) props,
|
||||
"recording-device-ipc-events",
|
||||
@@ -4235,7 +3856,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
|
||||
thisTabParent = TabParent::GetFrom(aThisTab);
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowserOrApp())) {
|
||||
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowser())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+9
-60
@@ -114,8 +114,6 @@ public:
|
||||
*/
|
||||
static void JoinAllSubprocesses();
|
||||
|
||||
static bool PreallocatedProcessReady();
|
||||
|
||||
/**
|
||||
* Get or create a content process for:
|
||||
* 1. browser iframe
|
||||
@@ -129,21 +127,16 @@ public:
|
||||
ContentParent* aOpener = nullptr,
|
||||
bool aLargeAllocationProcess = false);
|
||||
|
||||
/**
|
||||
* Create a subprocess suitable for use as a preallocated app process.
|
||||
*/
|
||||
static already_AddRefed<ContentParent> PreallocateAppProcess();
|
||||
|
||||
/**
|
||||
* Get or create a content process for the given TabContext. aFrameElement
|
||||
* should be the frame/iframe element with which this process will
|
||||
* associated.
|
||||
*/
|
||||
static TabParent*
|
||||
CreateBrowserOrApp(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess = false);
|
||||
CreateBrowser(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess = false);
|
||||
|
||||
static void GetAll(nsTArray<ContentParent*>& aArray);
|
||||
|
||||
@@ -231,7 +224,6 @@ public:
|
||||
const hal::ProcessPriority& aPriority,
|
||||
const TabId& aOpenerTabId,
|
||||
ContentParentId* aCpId,
|
||||
bool* aIsForApp,
|
||||
bool* aIsForBrowser,
|
||||
TabId* aTabId) override;
|
||||
|
||||
@@ -320,8 +312,6 @@ public:
|
||||
|
||||
bool IsAlive() const;
|
||||
|
||||
virtual bool IsForApp() const override;
|
||||
|
||||
virtual bool IsForBrowser() const override
|
||||
{
|
||||
return mIsForBrowser;
|
||||
@@ -354,10 +344,6 @@ public:
|
||||
|
||||
ContentParentId ChildID() const override { return mChildID; }
|
||||
|
||||
const nsString& AppManifestURL() const { return mAppManifestURL; }
|
||||
|
||||
bool IsPreallocated() const;
|
||||
|
||||
/**
|
||||
* Get a user-friendly name for this ContentParent. We make no guarantees
|
||||
* about this name: It might not be unique, apps can spoof special names,
|
||||
@@ -543,8 +529,7 @@ protected:
|
||||
void OnCompositorUnexpectedShutdown() override;
|
||||
|
||||
private:
|
||||
static nsDataHashtable<nsStringHashKey, ContentParent*> *sAppContentParents;
|
||||
static nsTArray<ContentParent*>* sNonAppContentParents;
|
||||
static nsTArray<ContentParent*>* sBrowserContentParents;
|
||||
static nsTArray<ContentParent*>* sLargeAllocationContentParents;
|
||||
static nsTArray<ContentParent*>* sPrivateContent;
|
||||
static StaticAutoPtr<LinkedList<ContentParent> > sContentParents;
|
||||
@@ -552,15 +537,6 @@ private:
|
||||
static void JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
|
||||
Monitor* aMonitor, bool* aDone);
|
||||
|
||||
// Take the preallocated process and transform it into a "real" app process,
|
||||
// for the specified manifest URL. If there is no preallocated process (or
|
||||
// if it's dead), create a new one and set aTookPreAllocated to false.
|
||||
static already_AddRefed<ContentParent>
|
||||
GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
|
||||
hal::ProcessPriority aInitialPriority,
|
||||
ContentParent* aOpener,
|
||||
/*out*/ bool* aTookPreAllocated = nullptr);
|
||||
|
||||
static hal::ProcessPriority GetInitialProcessPriority(Element* aFrameElement);
|
||||
|
||||
static ContentBridgeParent* CreateContentBridgeParent(const TabContext& aContext,
|
||||
@@ -576,18 +552,13 @@ private:
|
||||
const IPCTabContext& context,
|
||||
const uint32_t& chromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
using PContentParent::SendPTestShellConstructor;
|
||||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PContentParent)
|
||||
|
||||
// No more than one of !!aApp, aIsForBrowser, and aIsForPreallocated may be
|
||||
// true.
|
||||
ContentParent(mozIApplication* aApp,
|
||||
ContentParent* aOpener,
|
||||
bool aIsForBrowser,
|
||||
bool aIsForPreallocated);
|
||||
ContentParent(ContentParent* aOpener,
|
||||
bool aIsForBrowser);
|
||||
|
||||
// The common initialization for the constructors.
|
||||
void InitializeMembers();
|
||||
@@ -607,7 +578,7 @@ private:
|
||||
|
||||
// Some information could be sent to content very early, it
|
||||
// should be send from this function. This function should only be
|
||||
// called after the process has been transformed to app or browser.
|
||||
// called after the process has been transformed to browser.
|
||||
void ForwardKnownInfo();
|
||||
|
||||
// Set the child process's priority and then check whether the child is
|
||||
@@ -616,15 +587,6 @@ private:
|
||||
// unlikely that the process will be killed after this point.
|
||||
bool SetPriorityAndCheckIsAlive(hal::ProcessPriority aPriority);
|
||||
|
||||
// Transform a pre-allocated app process into a "real" app
|
||||
// process, for the specified manifest URL.
|
||||
void TransformPreallocatedIntoApp(ContentParent* aOpener,
|
||||
const nsAString& aAppManifestURL);
|
||||
|
||||
// Transform a pre-allocated app process into a browser process. If this
|
||||
// returns false, the child process has died.
|
||||
void TransformPreallocatedIntoBrowser(ContentParent* aOpener);
|
||||
|
||||
/**
|
||||
* Mark this ContentParent as dead for the purposes of Get*().
|
||||
* This method is idempotent.
|
||||
@@ -683,7 +645,6 @@ private:
|
||||
ProcessId aOtherProcess) override;
|
||||
|
||||
virtual bool RecvGetProcessAttributes(ContentParentId* aCpId,
|
||||
bool* aIsForApp,
|
||||
bool* aIsForBrowser) override;
|
||||
|
||||
virtual bool
|
||||
@@ -708,7 +669,6 @@ private:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) override;
|
||||
|
||||
virtual bool DeallocPBrowserParent(PBrowserParent* frame) override;
|
||||
@@ -907,8 +867,6 @@ private:
|
||||
|
||||
virtual bool RecvPrivateDocShellsExist(const bool& aExist) override;
|
||||
|
||||
virtual bool RecvFirstIdle() override;
|
||||
|
||||
virtual bool RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
|
||||
const bool& aHidden) override;
|
||||
|
||||
@@ -1044,17 +1002,8 @@ private:
|
||||
ContentParentId mChildID;
|
||||
int32_t mGeolocationWatchID;
|
||||
|
||||
nsString mAppManifestURL;
|
||||
|
||||
nsCString mKillHardAnnotation;
|
||||
|
||||
/**
|
||||
* We cache mAppName instead of looking it up using mAppManifestURL when we
|
||||
* need it because it turns out that getting an app from the apps service is
|
||||
* expensive.
|
||||
*/
|
||||
nsString mAppName;
|
||||
|
||||
// After we initiate shutdown, we also start a timer to ensure
|
||||
// that even content processes that are 100% blocked (say from
|
||||
// SIGSTOP), are still killed eventually. This task enforces that
|
||||
@@ -1070,7 +1019,7 @@ private:
|
||||
// through.
|
||||
bool mIsAlive;
|
||||
|
||||
// True only the if process is already a browser or app or has
|
||||
// True only the if process is already a browser or has
|
||||
// been transformed into one.
|
||||
bool mMetamorphosed;
|
||||
|
||||
|
||||
@@ -353,19 +353,5 @@ ContentProcessManager::GetTabParentsByProcessId(const ContentParentId& aChildCpI
|
||||
return Move(tabIdList);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ContentProcessManager::GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
|
||||
const TabId& aChildTabId)
|
||||
{
|
||||
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
|
||||
if (aChildCpId && aChildTabId) {
|
||||
TabContext tabContext;
|
||||
if (GetTabContextByProcessAndTabId(aChildCpId, aChildTabId, &tabContext)) {
|
||||
appId = tabContext.OwnOrContainingAppId();
|
||||
}
|
||||
}
|
||||
return appId;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -142,15 +142,6 @@ public:
|
||||
GetTopLevelTabParentByProcessAndTabId(const ContentParentId& aChildCpId,
|
||||
const TabId& aChildTabId);
|
||||
|
||||
/**
|
||||
* Return appId by given TabId and ContentParentId.
|
||||
* It will return nsIScriptSecurityManager::NO_APP_ID
|
||||
* if the given tab is not an app.
|
||||
*/
|
||||
uint32_t
|
||||
GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
|
||||
const TabId& aChildTabId);
|
||||
|
||||
private:
|
||||
static StaticAutoPtr<ContentProcessManager> sSingleton;
|
||||
TabId mUniqueId;
|
||||
|
||||
+13
-26
@@ -264,27 +264,20 @@ both:
|
||||
// The child creates the PBrowser as part of
|
||||
// TabChild::BrowserFrameProvideWindow (which happens when the child's
|
||||
// content calls window.open()), and the parent creates the PBrowser as part
|
||||
// of ContentParent::CreateBrowserOrApp.
|
||||
// of ContentParent::CreateBrowser.
|
||||
//
|
||||
// When the parent constructs a PBrowser, the child trusts the app token and
|
||||
// other attributes it receives from the parent. In that case, the
|
||||
// context should be FrameIPCTabContext.
|
||||
// When the parent constructs a PBrowser, the child trusts the attributes it
|
||||
// receives from the parent. In that case, the context should be
|
||||
// FrameIPCTabContext.
|
||||
//
|
||||
// When the child constructs a PBrowser, the parent doesn't trust the app
|
||||
// token it receives from the child. In this case, context must have type
|
||||
// PopupIPCTabContext. The browser created using a PopupIPCTabContext has
|
||||
// the opener PBrowser's app-id and containing-app-id. The parent checks
|
||||
// that if the opener is a browser element, the context is also for a
|
||||
// browser element.
|
||||
//
|
||||
// This allows the parent to prevent a malicious child from escalating its
|
||||
// privileges by requesting a PBrowser corresponding to a highly-privileged
|
||||
// app; the child can only request privileges for an app which the child has
|
||||
// access to (in the form of a TabChild).
|
||||
// When the child constructs a PBrowser, the parent doesn't trust the
|
||||
// attributes it receives from the child. In this case, context must have
|
||||
// type PopupIPCTabContext. The parent checks that if the opener is a
|
||||
// browser element, the context is also for a browser element.
|
||||
//
|
||||
// Keep the last 3 attributes in sync with GetProcessAttributes!
|
||||
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
|
||||
ContentParentId cpId, bool isForApp, bool isForBrowser);
|
||||
ContentParentId cpId, bool isForBrowser);
|
||||
|
||||
async PBlob(BlobConstructorParams params);
|
||||
|
||||
@@ -399,7 +392,6 @@ child:
|
||||
|
||||
async AppInfo(nsCString version, nsCString buildID, nsCString name, nsCString UAName,
|
||||
nsCString ID, nsCString vendor);
|
||||
async AppInit();
|
||||
|
||||
/**
|
||||
* Send ServiceWorkerRegistrationData to child process.
|
||||
@@ -526,15 +518,13 @@ parent:
|
||||
* startup. (The message is sync to allow the content process to
|
||||
* control when it receives the information.)
|
||||
*
|
||||
* |id| is a unique ID among all subprocesses. When |isForApp &&
|
||||
* isForBrowser|, we're loading <browser> for an app. When
|
||||
* |isForBrowser|, we're loading <browser>. When |!isForApp &&
|
||||
* !isForBrowser|, we're probably loading <xul:browser remote>.
|
||||
* |id| is a unique ID among all subprocesses. When
|
||||
* |isForBrowser|, we're loading <browser> or <xul:browser remote>.
|
||||
*
|
||||
* Keep the return values in sync with PBrowser()!
|
||||
*/
|
||||
sync GetProcessAttributes()
|
||||
returns (ContentParentId cpId, bool isForApp, bool isForBrowser);
|
||||
returns (ContentParentId cpId, bool isForBrowser);
|
||||
sync GetXPCOMProcessAttributes()
|
||||
returns (bool isOffline, bool isConnected, int32_t captivePortalState,
|
||||
bool isLangRTL,
|
||||
@@ -547,7 +537,7 @@ parent:
|
||||
sync CreateChildProcess(IPCTabContext context,
|
||||
ProcessPriority priority,
|
||||
TabId openerTabId)
|
||||
returns (ContentParentId cpId, bool isForApp, bool isForBrowser, TabId tabId);
|
||||
returns (ContentParentId cpId, bool isForBrowser, TabId tabId);
|
||||
sync BridgeToChildProcess(ContentParentId cpId);
|
||||
|
||||
async CreateGMPService();
|
||||
@@ -755,9 +745,6 @@ parent:
|
||||
// Notify the parent of the presence or absence of private docshells
|
||||
async PrivateDocShellsExist(bool aExist);
|
||||
|
||||
// Tell the parent that the child has gone idle for the first time
|
||||
async FirstIdle();
|
||||
|
||||
async AudioChannelServiceStatus(bool aActiveTelephonyChannel,
|
||||
bool aContentOrNormalChannel,
|
||||
bool aAnyActiveChannel);
|
||||
|
||||
@@ -54,7 +54,7 @@ both:
|
||||
// Both the parent and the child can construct the PBrowser.
|
||||
// See the comment in PContent::PBrowser().
|
||||
async PBrowser(TabId tabId, IPCTabContext context, uint32_t chromeFlags,
|
||||
ContentParentId cpId, bool isForApp, bool isForBrowser);
|
||||
ContentParentId cpId, bool isForBrowser);
|
||||
|
||||
async PBlob(BlobConstructorParams params);
|
||||
|
||||
|
||||
@@ -38,9 +38,6 @@ struct FrameIPCTabContext
|
||||
// The originAttributes dictionary.
|
||||
DocShellOriginAttributes originAttributes;
|
||||
|
||||
// The ID of the app containing this app/browser frame, if applicable.
|
||||
uint32_t frameOwnerAppId;
|
||||
|
||||
// Whether this is a mozbrowser frame. <iframe mozbrowser mozapp> and
|
||||
// <xul:browser> are not considered to be mozbrowser frames.
|
||||
bool isMozBrowserElement;
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
|
||||
|
||||
#include "mozilla/PreallocatedProcessManager.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "nsIPropertyBag2.h"
|
||||
#include "ProcessPriorityManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
// This number is fairly arbitrary ... the intention is to put off
|
||||
// launching another app process until the last one has finished
|
||||
// loading its content, to reduce CPU/memory/IO contention.
|
||||
#define DEFAULT_ALLOCATE_DELAY 1000
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::hal;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* This singleton class implements the static methods on
|
||||
* PreallocatedProcessManager.
|
||||
*/
|
||||
class PreallocatedProcessManagerImpl final
|
||||
: public nsIObserver
|
||||
{
|
||||
public:
|
||||
static PreallocatedProcessManagerImpl* Singleton();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// See comments on PreallocatedProcessManager for these methods.
|
||||
void AllocateAfterDelay();
|
||||
void AllocateOnIdle();
|
||||
void AllocateNow();
|
||||
already_AddRefed<ContentParent> Take();
|
||||
|
||||
private:
|
||||
static mozilla::StaticRefPtr<PreallocatedProcessManagerImpl> sSingleton;
|
||||
|
||||
PreallocatedProcessManagerImpl();
|
||||
~PreallocatedProcessManagerImpl() {}
|
||||
DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManagerImpl);
|
||||
|
||||
void Init();
|
||||
|
||||
void RereadPrefs();
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
||||
void ObserveProcessShutdown(nsISupports* aSubject);
|
||||
|
||||
bool mEnabled;
|
||||
bool mShutdown;
|
||||
RefPtr<ContentParent> mPreallocatedAppProcess;
|
||||
};
|
||||
|
||||
/* static */ StaticRefPtr<PreallocatedProcessManagerImpl>
|
||||
PreallocatedProcessManagerImpl::sSingleton;
|
||||
|
||||
/* static */ PreallocatedProcessManagerImpl*
|
||||
PreallocatedProcessManagerImpl::Singleton()
|
||||
{
|
||||
if (!sSingleton) {
|
||||
sSingleton = new PreallocatedProcessManagerImpl();
|
||||
sSingleton->Init();
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
|
||||
return sSingleton;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(PreallocatedProcessManagerImpl, nsIObserver)
|
||||
|
||||
PreallocatedProcessManagerImpl::PreallocatedProcessManagerImpl()
|
||||
:
|
||||
mEnabled(false)
|
||||
, mShutdown(false)
|
||||
{}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::Init()
|
||||
{
|
||||
Preferences::AddStrongObserver(this, "dom.ipc.processPrelaunch.enabled");
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
os->AddObserver(this, "ipc:content-shutdown",
|
||||
/* weakRef = */ false);
|
||||
os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
/* weakRef = */ false);
|
||||
}
|
||||
{
|
||||
RereadPrefs();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PreallocatedProcessManagerImpl::Observe(nsISupports* aSubject,
|
||||
const char* aTopic,
|
||||
const char16_t* aData)
|
||||
{
|
||||
if (!strcmp("ipc:content-shutdown", aTopic)) {
|
||||
ObserveProcessShutdown(aSubject);
|
||||
} else if (!strcmp("nsPref:changed", aTopic)) {
|
||||
// The only other observer we registered was for our prefs.
|
||||
RereadPrefs();
|
||||
} else if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
|
||||
mShutdown = true;
|
||||
} else {
|
||||
MOZ_ASSERT(false);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::RereadPrefs()
|
||||
{
|
||||
if (Preferences::GetBool("dom.ipc.processPrelaunch.enabled")) {
|
||||
Enable();
|
||||
} else {
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<ContentParent>
|
||||
PreallocatedProcessManagerImpl::Take()
|
||||
{
|
||||
return mPreallocatedAppProcess.forget();
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::Enable()
|
||||
{
|
||||
if (mEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mEnabled = true;
|
||||
AllocateAfterDelay();
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::AllocateAfterDelay()
|
||||
{
|
||||
if (!mEnabled || mPreallocatedAppProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle),
|
||||
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
|
||||
DEFAULT_ALLOCATE_DELAY));
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::AllocateOnIdle()
|
||||
{
|
||||
if (!mEnabled || mPreallocatedAppProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
MessageLoop::current()->PostIdleTask(NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::AllocateNow()
|
||||
{
|
||||
if (!mEnabled || mPreallocatedAppProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPreallocatedAppProcess = ContentParent::PreallocateAppProcess();
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::Disable()
|
||||
{
|
||||
if (!mEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mEnabled = false;
|
||||
|
||||
if (mPreallocatedAppProcess) {
|
||||
mPreallocatedAppProcess->Close();
|
||||
mPreallocatedAppProcess = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PreallocatedProcessManagerImpl::ObserveProcessShutdown(nsISupports* aSubject)
|
||||
{
|
||||
if (!mPreallocatedAppProcess) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);
|
||||
NS_ENSURE_TRUE_VOID(props);
|
||||
|
||||
uint64_t childID = CONTENT_PROCESS_ID_UNKNOWN;
|
||||
props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"), &childID);
|
||||
NS_ENSURE_TRUE_VOID(childID != CONTENT_PROCESS_ID_UNKNOWN);
|
||||
|
||||
if (childID == mPreallocatedAppProcess->ChildID()) {
|
||||
mPreallocatedAppProcess = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline PreallocatedProcessManagerImpl* GetPPMImpl()
|
||||
{
|
||||
return PreallocatedProcessManagerImpl::Singleton();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
/* static */ void
|
||||
PreallocatedProcessManager::AllocateAfterDelay()
|
||||
{
|
||||
GetPPMImpl()->AllocateAfterDelay();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
PreallocatedProcessManager::AllocateOnIdle()
|
||||
{
|
||||
GetPPMImpl()->AllocateOnIdle();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
PreallocatedProcessManager::AllocateNow()
|
||||
{
|
||||
GetPPMImpl()->AllocateNow();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<ContentParent>
|
||||
PreallocatedProcessManager::Take()
|
||||
{
|
||||
return GetPPMImpl()->Take();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
@@ -1,87 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
|
||||
|
||||
#ifndef mozilla_PreallocatedProcessManager_h
|
||||
#define mozilla_PreallocatedProcessManager_h
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class ContentParent;
|
||||
} // namespace dom
|
||||
|
||||
/**
|
||||
* This class manages a ContentParent that it starts up ahead of any particular
|
||||
* need. You can then call Take() to get this process and use it. Since we
|
||||
* already started it up, it should be ready for use faster than if you'd
|
||||
* created the process when you needed it.
|
||||
*
|
||||
* This class watches the dom.ipc.processPrelaunch.enabled pref. If it changes
|
||||
* from false to true, it preallocates a process. If it changes from true to
|
||||
* false, it kills the preallocated process, if any.
|
||||
*
|
||||
* We don't expect this pref to flip between true and false in production, but
|
||||
* flipping the pref is important for tests.
|
||||
*
|
||||
* The static methods here are implemented by forwarding calls on to a
|
||||
* PreallocatedProcessManagerImpl singleton class, so if you add a new static
|
||||
* method here, you'll need to write a corresponding public method on the
|
||||
* singleton.
|
||||
*/
|
||||
class PreallocatedProcessManager final
|
||||
{
|
||||
typedef mozilla::dom::ContentParent ContentParent;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a process after a delay. We wait for a period of time (specified
|
||||
* by the dom.ipc.processPrelaunch.delayMs pref), then wait for this process
|
||||
* to go idle, then allocate the new process.
|
||||
*
|
||||
* If the dom.ipc.processPrelaunch.enabled pref is false, or if we already
|
||||
* have a preallocated process, this function does nothing.
|
||||
*/
|
||||
static void AllocateAfterDelay();
|
||||
|
||||
/**
|
||||
* Create a process once this process goes idle.
|
||||
*
|
||||
* If the dom.ipc.processPrelaunch.enabled pref is false, or if we already
|
||||
* have a preallocated process, this function does nothing.
|
||||
*/
|
||||
static void AllocateOnIdle();
|
||||
|
||||
/**
|
||||
* Create a process right now.
|
||||
*
|
||||
* If the dom.ipc.processPrelaunch.enabled pref is false, or if we already
|
||||
* have a preallocated process, this function does nothing.
|
||||
*/
|
||||
static void AllocateNow();
|
||||
|
||||
/**
|
||||
* Take the preallocated process, if we have one. If we don't have one, this
|
||||
* returns null.
|
||||
*
|
||||
* If you call Take() twice in a row, the second call is guaranteed to return
|
||||
* null.
|
||||
*
|
||||
* After you Take() the preallocated process, you need to call one of the
|
||||
* Allocate* functions (or change the dom.ipc.processPrelaunch pref from
|
||||
* false to true) before we'll create a new process.
|
||||
*/
|
||||
static already_AddRefed<ContentParent> Take();
|
||||
|
||||
private:
|
||||
PreallocatedProcessManager();
|
||||
DISALLOW_EVIL_CONSTRUCTORS(PreallocatedProcessManager);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // defined mozilla_PreallocatedProcessManager_h
|
||||
@@ -300,7 +300,6 @@ public:
|
||||
|
||||
int32_t Pid() const;
|
||||
uint64_t ChildID() const;
|
||||
bool IsPreallocated() const;
|
||||
|
||||
/**
|
||||
* Used in logging, this method returns the ContentParent's name followed by
|
||||
@@ -617,15 +616,12 @@ ProcessPriorityManagerImpl::NotifyProcessPriorityChanged(
|
||||
ProcessPriority aOldPriority)
|
||||
{
|
||||
ProcessPriority newPriority = aParticularManager->CurrentPriority();
|
||||
bool isPreallocated = aParticularManager->IsPreallocated();
|
||||
|
||||
if (newPriority == PROCESS_PRIORITY_BACKGROUND &&
|
||||
aOldPriority != PROCESS_PRIORITY_BACKGROUND &&
|
||||
!isPreallocated) {
|
||||
aOldPriority != PROCESS_PRIORITY_BACKGROUND) {
|
||||
mBackgroundLRUPool.Add(aParticularManager);
|
||||
} else if (newPriority != PROCESS_PRIORITY_BACKGROUND &&
|
||||
aOldPriority == PROCESS_PRIORITY_BACKGROUND &&
|
||||
!isPreallocated) {
|
||||
aOldPriority == PROCESS_PRIORITY_BACKGROUND) {
|
||||
mBackgroundLRUPool.Remove(aParticularManager);
|
||||
}
|
||||
|
||||
@@ -808,12 +804,6 @@ ParticularProcessPriorityManager::Pid() const
|
||||
return mContentParent ? mContentParent->Pid() : -1;
|
||||
}
|
||||
|
||||
bool
|
||||
ParticularProcessPriorityManager::IsPreallocated() const
|
||||
{
|
||||
return mContentParent ? mContentParent->IsPreallocated() : false;
|
||||
}
|
||||
|
||||
const nsAutoCString&
|
||||
ParticularProcessPriorityManager::NameWithComma()
|
||||
{
|
||||
@@ -860,10 +850,10 @@ ParticularProcessPriorityManager::OnRemoteBrowserFrameShown(nsISupports* aSubjec
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore notifications that aren't from a BrowserOrApp
|
||||
bool isMozBrowserOrApp;
|
||||
fl->GetOwnerIsMozBrowserOrAppFrame(&isMozBrowserOrApp);
|
||||
if (isMozBrowserOrApp) {
|
||||
// Ignore notifications that aren't from a Browser
|
||||
bool isMozBrowser;
|
||||
fl->GetOwnerIsMozBrowserFrame(&isMozBrowser);
|
||||
if (isMozBrowser) {
|
||||
ResetPriority();
|
||||
}
|
||||
|
||||
|
||||
+13
-122
@@ -44,7 +44,6 @@
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSFrameConstructor.h"
|
||||
#include "nsDocShell.h"
|
||||
@@ -98,7 +97,6 @@
|
||||
#include "nsColorPickerProxy.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsPresShell.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsIURILoader.h"
|
||||
@@ -319,8 +317,6 @@ private:
|
||||
};
|
||||
|
||||
namespace {
|
||||
StaticRefPtr<TabChild> sPreallocatedTab;
|
||||
|
||||
std::map<TabId, RefPtr<TabChild>>&
|
||||
NestedTabChildMap()
|
||||
{
|
||||
@@ -341,91 +337,13 @@ TabChild::FindTabChild(const TabId& aTabId)
|
||||
return tabChild.forget();
|
||||
}
|
||||
|
||||
static void
|
||||
PreloadSlowThingsPostFork(void* aUnused)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
observerService->NotifyObservers(nullptr, "preload-postfork", nullptr);
|
||||
|
||||
MOZ_ASSERT(sPreallocatedTab);
|
||||
// Initialize initial reflow of the PresShell has to happen after fork
|
||||
// because about:blank content viewer is created in the above observer
|
||||
// notification.
|
||||
nsCOMPtr<nsIDocShell> docShell =
|
||||
do_GetInterface(sPreallocatedTab->WebNavigation());
|
||||
if (nsIPresShell* presShell = docShell->GetPresShell()) {
|
||||
// Initialize and do an initial reflow of the about:blank
|
||||
// PresShell to let it preload some things for us.
|
||||
presShell->Initialize(0, 0);
|
||||
nsIDocument* doc = presShell->GetDocument();
|
||||
doc->FlushPendingNotifications(Flush_Layout);
|
||||
// ... but after it's done, make sure it doesn't do any more
|
||||
// work.
|
||||
presShell->MakeZombie();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool sPreloaded = false;
|
||||
|
||||
/*static*/ void
|
||||
TabChild::PreloadSlowThings()
|
||||
{
|
||||
if (sPreloaded) {
|
||||
// If we are alredy initialized in Nuwa, don't redo preloading.
|
||||
return;
|
||||
}
|
||||
sPreloaded = true;
|
||||
|
||||
// Pass nullptr to aManager since at this point the TabChild is
|
||||
// not connected to any manager. Any attempt to use the TabChild
|
||||
// in IPC will crash.
|
||||
RefPtr<TabChild> tab(new TabChild(nullptr,
|
||||
TabId(0),
|
||||
TabContext(), /* chromeFlags */ 0));
|
||||
if (!NS_SUCCEEDED(tab->Init()) ||
|
||||
!tab->InitTabChildGlobal(DONT_LOAD_SCRIPTS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Just load and compile these scripts, but don't run them.
|
||||
tab->TryCacheLoadAndCompileScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
||||
// Load, compile, and run these scripts.
|
||||
tab->RecvLoadRemoteScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/preload.js"),
|
||||
true);
|
||||
|
||||
sPreallocatedTab = tab;
|
||||
ClearOnShutdown(&sPreallocatedTab);
|
||||
|
||||
PreloadSlowThingsPostFork(nullptr);
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<TabChild>
|
||||
TabChild::Create(nsIContentChild* aManager,
|
||||
const TabId& aTabId,
|
||||
const TabContext &aContext,
|
||||
uint32_t aChromeFlags)
|
||||
{
|
||||
if (sPreallocatedTab &&
|
||||
sPreallocatedTab->mChromeFlags == aChromeFlags &&
|
||||
aContext.IsMozBrowserOrApp()) {
|
||||
|
||||
RefPtr<TabChild> child = sPreallocatedTab.get();
|
||||
sPreallocatedTab = nullptr;
|
||||
|
||||
MOZ_ASSERT(!child->mTriedBrowserInit);
|
||||
|
||||
child->mManager = aManager;
|
||||
child->SetTabId(aTabId);
|
||||
child->SetTabContext(aContext);
|
||||
child->NotifyTabContextUpdated(true);
|
||||
return child.forget();
|
||||
}
|
||||
|
||||
RefPtr<TabChild> iframe = new TabChild(aManager, aTabId,
|
||||
aContext, aChromeFlags);
|
||||
RefPtr<TabChild> iframe = new TabChild(aManager, aTabId, aContext, aChromeFlags);
|
||||
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget() : nullptr;
|
||||
}
|
||||
|
||||
@@ -614,13 +532,6 @@ TabChild::DoUpdateZoomConstraints(const uint32_t& aPresShellId,
|
||||
const ViewID& aViewId,
|
||||
const Maybe<ZoomConstraints>& aConstraints)
|
||||
{
|
||||
if (sPreallocatedTab == this) {
|
||||
// If we're the preallocated tab, bail out because doing IPC will crash.
|
||||
// Once we get used for something we'll get another zoom constraints update
|
||||
// and all will be well.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mApzcTreeManager) {
|
||||
return false;
|
||||
}
|
||||
@@ -779,9 +690,9 @@ TabChild::UpdateFrameType()
|
||||
MOZ_ASSERT(docShell);
|
||||
|
||||
// TODO: Bug 1252794 - remove frameType from nsIDocShell.idl
|
||||
docShell->SetFrameType(IsMozBrowserElement() ? nsIDocShell::FRAME_TYPE_BROWSER :
|
||||
HasOwnApp() ? nsIDocShell::FRAME_TYPE_APP :
|
||||
nsIDocShell::FRAME_TYPE_REGULAR);
|
||||
docShell->SetFrameType(IsMozBrowserElement() ?
|
||||
nsIDocShell::FRAME_TYPE_BROWSER :
|
||||
nsIDocShell::FRAME_TYPE_REGULAR);
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChild)
|
||||
@@ -1091,11 +1002,11 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
|
||||
// If aParent is inside an <iframe mozbrowser> or <iframe mozapp> and this
|
||||
// isn't a request to open a modal-type window, we're going to create a new
|
||||
// <iframe mozbrowser/mozapp> and return its window here.
|
||||
// If aParent is inside an <iframe mozbrowser> and this isn't a request to
|
||||
// open a modal-type window, we're going to create a new <iframe mozbrowser>
|
||||
// and return its window here.
|
||||
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
|
||||
bool iframeMoz = (docshell && docshell->GetIsInMozBrowserOrApp() &&
|
||||
bool iframeMoz = (docshell && docshell->GetIsInMozBrowser() &&
|
||||
!(aChromeFlags & (nsIWebBrowserChrome::CHROME_MODAL |
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
||||
nsIWebBrowserChrome::CHROME_OPENAS_CHROME)));
|
||||
@@ -1208,24 +1119,6 @@ TabChild::~TabChild()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::SetProcessNameToAppName()
|
||||
{
|
||||
nsCOMPtr<mozIApplication> app = GetOwnApp();
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoString appName;
|
||||
nsresult rv = app->GetName(appName);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to retrieve app name");
|
||||
return;
|
||||
}
|
||||
|
||||
ContentChild::GetSingleton()->SetProcessName(appName, true);
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::RecvLoadURL(const nsCString& aURI,
|
||||
const ShowInfo& aInfo)
|
||||
@@ -1237,8 +1130,6 @@ TabChild::RecvLoadURL(const nsCString& aURI,
|
||||
}
|
||||
|
||||
ApplyShowInfo(aInfo);
|
||||
|
||||
SetProcessNameToAppName();
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
@@ -1279,7 +1170,7 @@ TabChild::ApplyShowInfo(const ShowInfo& aInfo)
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> item = do_GetInterface(docShell);
|
||||
if (IsMozBrowserOrApp()) {
|
||||
if (IsMozBrowser()) {
|
||||
// B2G allows window.name to be set by changing the name attribute on the
|
||||
// <iframe mozbrowser> element. window.open calls cause this attribute to
|
||||
// be set to the correct value. A normal <xul:browser> element has no such
|
||||
@@ -2135,7 +2026,7 @@ TabChild::RecvSwappedWithOtherRemoteLoader(const IPCTabContext& aContext)
|
||||
// Ignore previous value of mTriedBrowserInit since owner content has changed.
|
||||
mTriedBrowserInit = true;
|
||||
// Initialize the child side of the browser element machinery, if appropriate.
|
||||
if (IsMozBrowserOrApp()) {
|
||||
if (IsMozBrowser()) {
|
||||
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
||||
}
|
||||
|
||||
@@ -2466,7 +2357,7 @@ TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
||||
TabChild::InitTabChildGlobal()
|
||||
{
|
||||
if (!mGlobal && !mTabChildGlobal) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
||||
@@ -2490,11 +2381,11 @@ TabChild::InitTabChildGlobal(FrameScriptLoading aScriptLoading)
|
||||
root->SetParentTarget(scope);
|
||||
}
|
||||
|
||||
if (aScriptLoading != DONT_LOAD_SCRIPTS && !mTriedBrowserInit) {
|
||||
if (!mTriedBrowserInit) {
|
||||
mTriedBrowserInit = true;
|
||||
// Initialize the child side of the browser element machinery,
|
||||
// if appropriate.
|
||||
if (IsMozBrowserOrApp()) {
|
||||
if (IsMozBrowser()) {
|
||||
RecvLoadRemoteScript(BROWSER_ELEMENT_CHILD_SCRIPT, true);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-12
@@ -278,13 +278,6 @@ public:
|
||||
|
||||
nsresult Init();
|
||||
|
||||
/**
|
||||
* This is expected to be called off the critical path to content
|
||||
* startup. This is an opportunity to load things that are slow
|
||||
* on the critical path.
|
||||
*/
|
||||
static void PreloadSlowThings();
|
||||
|
||||
/** Return a TabChild with the given attributes. */
|
||||
static already_AddRefed<TabChild>
|
||||
Create(nsIContentChild* aManager, const TabId& aTabId,
|
||||
@@ -697,9 +690,7 @@ private:
|
||||
|
||||
void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
enum FrameScriptLoading { DONT_LOAD_SCRIPTS, DEFAULT_LOAD_SCRIPTS };
|
||||
|
||||
bool InitTabChildGlobal(FrameScriptLoading aScriptLoading = DEFAULT_LOAD_SCRIPTS);
|
||||
bool InitTabChildGlobal();
|
||||
|
||||
bool InitRenderingState(const TextureFactoryIdentifier& aTextureFactoryIdentifier,
|
||||
const uint64_t& aLayersId,
|
||||
@@ -707,8 +698,6 @@ private:
|
||||
|
||||
void DestroyWindow();
|
||||
|
||||
void SetProcessNameToAppName();
|
||||
|
||||
void ApplyShowInfo(const ShowInfo& aInfo);
|
||||
|
||||
bool HasValidInnerSize();
|
||||
|
||||
+6
-180
@@ -7,7 +7,6 @@
|
||||
#include "mozilla/dom/PTabContext.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
@@ -23,7 +22,7 @@ TabContext::TabContext()
|
||||
: mIsPrerendered(false)
|
||||
, mInitialized(false)
|
||||
, mIsMozBrowserElement(false)
|
||||
, mContainingAppId(NO_APP_ID)
|
||||
, mOriginAttributes()
|
||||
, mShowAccelerators(UIStateChangeType_NoChange)
|
||||
, mShowFocusRings(UIStateChangeType_NoChange)
|
||||
{
|
||||
@@ -36,117 +35,9 @@ TabContext::IsMozBrowserElement() const
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::IsIsolatedMozBrowserElement() const
|
||||
TabContext::IsMozBrowser() const
|
||||
{
|
||||
return mOriginAttributes.mInIsolatedMozBrowser;
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::IsMozBrowserOrApp() const
|
||||
{
|
||||
return HasOwnApp() || IsMozBrowserElement();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TabContext::OwnAppId() const
|
||||
{
|
||||
return mOriginAttributes.mAppId;
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
TabContext::GetOwnApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownApp = mOwnApp;
|
||||
return ownApp.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::HasOwnApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownApp = GetOwnApp();
|
||||
return !!ownApp;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TabContext::BrowserOwnerAppId() const
|
||||
{
|
||||
if (IsMozBrowserElement()) {
|
||||
return mContainingAppId;
|
||||
}
|
||||
return NO_APP_ID;
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
TabContext::GetBrowserOwnerApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownerApp;
|
||||
if (IsMozBrowserElement()) {
|
||||
ownerApp = mContainingApp;
|
||||
}
|
||||
return ownerApp.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::HasBrowserOwnerApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownerApp = GetBrowserOwnerApp();
|
||||
return !!ownerApp;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TabContext::AppOwnerAppId() const
|
||||
{
|
||||
if (HasOwnApp()) {
|
||||
return mContainingAppId;
|
||||
}
|
||||
return NO_APP_ID;
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
TabContext::GetAppOwnerApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownerApp;
|
||||
if (HasOwnApp()) {
|
||||
ownerApp = mContainingApp;
|
||||
}
|
||||
return ownerApp.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::HasAppOwnerApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownerApp = GetAppOwnerApp();
|
||||
return !!ownerApp;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
TabContext::OwnOrContainingAppId() const
|
||||
{
|
||||
if (HasOwnApp()) {
|
||||
return mOriginAttributes.mAppId;
|
||||
}
|
||||
|
||||
return mContainingAppId;
|
||||
}
|
||||
|
||||
already_AddRefed<mozIApplication>
|
||||
TabContext::GetOwnOrContainingApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownOrContainingApp;
|
||||
if (HasOwnApp()) {
|
||||
ownOrContainingApp = mOwnApp;
|
||||
} else {
|
||||
ownOrContainingApp = mContainingApp;
|
||||
}
|
||||
|
||||
return ownOrContainingApp.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TabContext::HasOwnOrContainingApp() const
|
||||
{
|
||||
nsCOMPtr<mozIApplication> ownOrContainingApp = GetOwnOrContainingApp();
|
||||
return !!ownOrContainingApp;
|
||||
return IsMozBrowserElement();
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -174,9 +65,7 @@ TabContext::UpdateTabContextAfterSwap(const TabContext& aContext)
|
||||
|
||||
// The only permissable change is to `mIsMozBrowserElement`. All other fields
|
||||
// must match for the change to be accepted.
|
||||
if (aContext.OwnAppId() != OwnAppId() ||
|
||||
aContext.mContainingAppId != mContainingAppId ||
|
||||
aContext.mOriginAttributes != mOriginAttributes) {
|
||||
if (aContext.mOriginAttributes != mOriginAttributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,42 +94,19 @@ TabContext::ShowFocusRings() const
|
||||
bool
|
||||
TabContext::SetTabContext(bool aIsMozBrowserElement,
|
||||
bool aIsPrerendered,
|
||||
mozIApplication* aOwnApp,
|
||||
mozIApplication* aAppFrameOwnerApp,
|
||||
UIStateChangeType aShowAccelerators,
|
||||
UIStateChangeType aShowFocusRings,
|
||||
const DocShellOriginAttributes& aOriginAttributes)
|
||||
{
|
||||
NS_ENSURE_FALSE(mInitialized, false);
|
||||
|
||||
// Get ids for both apps and only write to our member variables after we've
|
||||
// verified that this worked.
|
||||
uint32_t ownAppId = NO_APP_ID;
|
||||
if (aOwnApp) {
|
||||
nsresult rv = aOwnApp->GetLocalId(&ownAppId);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
NS_ENSURE_TRUE(ownAppId != NO_APP_ID, false);
|
||||
}
|
||||
|
||||
uint32_t containingAppId = NO_APP_ID;
|
||||
if (aAppFrameOwnerApp) {
|
||||
nsresult rv = aAppFrameOwnerApp->GetLocalId(&containingAppId);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
NS_ENSURE_TRUE(containingAppId != NO_APP_ID, false);
|
||||
}
|
||||
|
||||
// Veryify that app id matches mAppId passed in originAttributes
|
||||
MOZ_RELEASE_ASSERT((aOwnApp && aOriginAttributes.mAppId == ownAppId) ||
|
||||
(aAppFrameOwnerApp && aOriginAttributes.mAppId == containingAppId) ||
|
||||
aOriginAttributes.mAppId == NO_APP_ID);
|
||||
// Verify that app id matches mAppId passed in originAttributes
|
||||
MOZ_RELEASE_ASSERT(aOriginAttributes.mAppId == NO_APP_ID);
|
||||
|
||||
mInitialized = true;
|
||||
mIsMozBrowserElement = aIsMozBrowserElement;
|
||||
mIsPrerendered = aIsPrerendered;
|
||||
mOriginAttributes = aOriginAttributes;
|
||||
mContainingAppId = containingAppId;
|
||||
mOwnApp = aOwnApp;
|
||||
mContainingApp = aAppFrameOwnerApp;
|
||||
mShowAccelerators = aShowAccelerators;
|
||||
mShowFocusRings = aShowFocusRings;
|
||||
return true;
|
||||
@@ -250,31 +116,17 @@ IPCTabContext
|
||||
TabContext::AsIPCTabContext() const
|
||||
{
|
||||
return IPCTabContext(FrameIPCTabContext(mOriginAttributes,
|
||||
mContainingAppId,
|
||||
mIsMozBrowserElement,
|
||||
mIsPrerendered,
|
||||
mShowAccelerators,
|
||||
mShowFocusRings));
|
||||
}
|
||||
|
||||
static already_AddRefed<mozIApplication>
|
||||
GetAppForId(uint32_t aAppId)
|
||||
{
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(appsService, nullptr);
|
||||
|
||||
nsCOMPtr<mozIApplication> app;
|
||||
appsService->GetAppByLocalId(aAppId, getter_AddRefs(app));
|
||||
|
||||
return app.forget();
|
||||
}
|
||||
|
||||
MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
: mInvalidReason(nullptr)
|
||||
{
|
||||
bool isMozBrowserElement = false;
|
||||
bool isPrerendered = false;
|
||||
uint32_t containingAppId = NO_APP_ID;
|
||||
DocShellOriginAttributes originAttributes;
|
||||
UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
|
||||
UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
|
||||
@@ -324,11 +176,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
// opener app.
|
||||
isMozBrowserElement = ipcContext.isMozBrowserElement();
|
||||
originAttributes = context->mOriginAttributes;
|
||||
if (isMozBrowserElement) {
|
||||
containingAppId = context->OwnOrContainingAppId();
|
||||
} else {
|
||||
containingAppId = context->mContainingAppId;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IPCTabContext::TFrameIPCTabContext: {
|
||||
@@ -337,7 +184,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
|
||||
isMozBrowserElement = ipcContext.isMozBrowserElement();
|
||||
isPrerendered = ipcContext.isPrerendered();
|
||||
containingAppId = ipcContext.frameOwnerAppId();
|
||||
showAccelerators = ipcContext.showAccelerators();
|
||||
showFocusRings = ipcContext.showFocusRings();
|
||||
originAttributes = ipcContext.originAttributes();
|
||||
@@ -352,7 +198,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
return;
|
||||
}
|
||||
|
||||
containingAppId = NO_APP_ID;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -360,28 +205,9 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIApplication> ownApp;
|
||||
if (!isMozBrowserElement) {
|
||||
// mAppId corresponds to OwnOrContainingAppId; if isMozBrowserElement is
|
||||
// false then it's ownApp otherwise it's containingApp
|
||||
ownApp = GetAppForId(originAttributes.mAppId);
|
||||
if ((ownApp == nullptr) != (originAttributes.mAppId == NO_APP_ID)) {
|
||||
mInvalidReason = "Got an ownAppId that didn't correspond to an app.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<mozIApplication> containingApp = GetAppForId(containingAppId);
|
||||
if ((containingApp == nullptr) != (containingAppId == NO_APP_ID)) {
|
||||
mInvalidReason = "Got a containingAppId that didn't correspond to an app.";
|
||||
return;
|
||||
}
|
||||
|
||||
bool rv;
|
||||
rv = mTabContext.SetTabContext(isMozBrowserElement,
|
||||
isPrerendered,
|
||||
ownApp,
|
||||
containingApp,
|
||||
showAccelerators,
|
||||
showFocusRings,
|
||||
originAttributes);
|
||||
|
||||
+13
-110
@@ -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:
|
||||
*
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "AudioChannelService.h"
|
||||
#include "AppProcessChecker.h"
|
||||
#include "mozIApplication.h"
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
@@ -2940,8 +2939,6 @@ public:
|
||||
NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL
|
||||
NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL
|
||||
NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL
|
||||
NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool*) NO_IMPL
|
||||
NS_IMETHOD GetAppId(uint32_t*) NO_IMPL
|
||||
NS_IMETHOD GetOriginAttributes(JS::MutableHandleValue) NO_IMPL
|
||||
NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL
|
||||
NS_IMETHOD SetRemoteTabs(bool) NO_IMPL
|
||||
|
||||
@@ -10,4 +10,3 @@ toolkit.jar:
|
||||
content/global/BrowserElementCopyPaste.js (../browser-element/BrowserElementCopyPaste.js)
|
||||
content/global/extensions.js (extensions.js)
|
||||
content/global/manifestMessages.js (manifestMessages.js)
|
||||
content/global/preload.js (preload.js)
|
||||
|
||||
@@ -37,7 +37,6 @@ EXPORTS.mozilla.dom += [
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'AppProcessChecker.h',
|
||||
'PreallocatedProcessManager.h',
|
||||
'ProcessHangMonitor.h',
|
||||
'ProcessHangMonitorIPC.h',
|
||||
'ProcessPriorityManager.h',
|
||||
@@ -55,7 +54,6 @@ UNIFIED_SOURCES += [
|
||||
'nsIContentChild.cpp',
|
||||
'nsIContentParent.cpp',
|
||||
'PermissionMessageUtils.cpp',
|
||||
'PreallocatedProcessManager.cpp',
|
||||
'ProcessPriorityManager.cpp',
|
||||
'ScreenManagerParent.cpp',
|
||||
'StructuredCloneData.cpp',
|
||||
|
||||
@@ -43,7 +43,6 @@ nsIContentChild::AllocPBrowserChild(const TabId& aTabId,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
// We'll happily accept any kind of IPCTabContext here; we don't need to
|
||||
|
||||
@@ -68,7 +68,6 @@ public:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpID,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) = 0;
|
||||
|
||||
virtual mozilla::ipc::PFileDescriptorSetChild*
|
||||
@@ -85,7 +84,6 @@ protected:
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser);
|
||||
virtual bool DeallocPBrowserChild(PBrowserChild*);
|
||||
|
||||
|
||||
@@ -122,11 +122,9 @@ nsIContentParent::AllocPBrowserParent(const TabId& aTabId,
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser)
|
||||
{
|
||||
Unused << aCpId;
|
||||
Unused << aIsForApp;
|
||||
Unused << aIsForBrowser;
|
||||
|
||||
if (!CanOpenBrowser(aContext)) {
|
||||
|
||||
@@ -60,7 +60,6 @@ public:
|
||||
BlobParent* GetOrCreateActorForBlobImpl(BlobImpl* aImpl);
|
||||
|
||||
virtual ContentParentId ChildID() const = 0;
|
||||
virtual bool IsForApp() const = 0;
|
||||
virtual bool IsForBrowser() const = 0;
|
||||
|
||||
MOZ_MUST_USE virtual PBlobParent*
|
||||
@@ -73,7 +72,6 @@ public:
|
||||
const IPCTabContext& context,
|
||||
const uint32_t& chromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser) = 0;
|
||||
|
||||
virtual bool IsContentParent() const { return false; }
|
||||
@@ -99,7 +97,6 @@ protected: // IPDL methods
|
||||
const IPCTabContext& aContext,
|
||||
const uint32_t& aChromeFlags,
|
||||
const ContentParentId& aCpId,
|
||||
const bool& aIsForApp,
|
||||
const bool& aIsForBrowser);
|
||||
virtual bool DeallocPBrowserParent(PBrowserParent* frame);
|
||||
|
||||
|
||||
@@ -1,129 +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/. */
|
||||
|
||||
// Preload some things, in an attempt to make app startup faster.
|
||||
//
|
||||
// This script is run when the preallocated process starts. It is injected as
|
||||
// a frame script.
|
||||
|
||||
var BrowserElementIsPreloaded = true;
|
||||
|
||||
var DoPreloadPostfork = function(aCallback) {
|
||||
Services.obs.addObserver({
|
||||
_callback: aCallback,
|
||||
|
||||
observe: function() {
|
||||
this._callback();
|
||||
Services.obs.removeObserver(this, "preload-postfork");
|
||||
}
|
||||
}, "preload-postfork", false);
|
||||
};
|
||||
|
||||
(function (global) {
|
||||
"use strict";
|
||||
|
||||
let Cu = Components.utils;
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Geometry.jsm");
|
||||
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/SettingsDB.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
Cc["@mozilla.org/appshell/appShellService;1"].getService(Ci["nsIAppShellService"]);
|
||||
Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci["nsIWindowMediator"]);
|
||||
Cc["@mozilla.org/categorymanager;1"].getService(Ci["nsICategoryManager"]);
|
||||
Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci["nsIMessageSender"]);
|
||||
Cc["@mozilla.org/consoleservice;1"].getService(Ci["nsIConsoleService"]);
|
||||
Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci["nsIURIFixup"]);
|
||||
Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci["nsIDOMRequestService"]);
|
||||
Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci["nsIPromptService"]);
|
||||
Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci["nsIWindowWatcher"]);
|
||||
Cc["@mozilla.org/eventlistenerservice;1"].getService(Ci["nsIEventListenerService"]);
|
||||
Cc["@mozilla.org/focus-manager;1"].getService(Ci["nsIFocusManager"]);
|
||||
Cc["@mozilla.org/intl/nslocaleservice;1"].getService(Ci["nsILocaleService"]);
|
||||
Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci["nsIStringBundleService"]);
|
||||
Cc["@mozilla.org/layout/content-policy;1"].getService(Ci["nsIContentPolicy"]);
|
||||
Cc["@mozilla.org/message-loop;1"].getService(Ci["nsIMessageLoop"]);
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci["mozIJSSubScriptLoader"]);
|
||||
Cc["@mozilla.org/network/application-cache-service;1"].getService(Ci["nsIApplicationCacheService"]);
|
||||
Cc["@mozilla.org/network/dns-service;1"].getService(Ci["nsIDNSService"]);
|
||||
Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci["nsIEffectiveTLDService"]);
|
||||
Cc["@mozilla.org/network/idn-service;1"].getService(Ci["nsIIDNService"]);
|
||||
Cc["@mozilla.org/network/io-service;1"].getService(Ci["nsIIOService2"]);
|
||||
Cc["@mozilla.org/network/mime-hdrparam;1"].getService(Ci["nsIMIMEHeaderParam"]);
|
||||
Cc["@mozilla.org/network/socket-transport-service;1"].getService(Ci["nsISocketTransportService"]);
|
||||
Cc["@mozilla.org/network/stream-transport-service;1"].getService(Ci["nsIStreamTransportService"]);
|
||||
Cc["@mozilla.org/network/url-parser;1?auth=maybe"].getService(Ci["nsIURLParser"]);
|
||||
Cc["@mozilla.org/network/url-parser;1?auth=no"].getService(Ci["nsIURLParser"]);
|
||||
Cc["@mozilla.org/network/url-parser;1?auth=yes"].getService(Ci["nsIURLParser"]);
|
||||
Cc["@mozilla.org/observer-service;1"].getService(Ci["nsIObserverService"]);
|
||||
Cc["@mozilla.org/preferences-service;1"].getService(Ci["nsIPrefBranch"]);
|
||||
Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci["nsIScriptSecurityManager"]);
|
||||
Cc["@mozilla.org/storage/service;1"].getService(Ci["mozIStorageService"]);
|
||||
Cc["@mozilla.org/system-info;1"].getService(Ci["nsIPropertyBag2"]);
|
||||
Cc["@mozilla.org/thread-manager;1"].getService(Ci["nsIThreadManager"]);
|
||||
Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci["nsIAppStartup"]);
|
||||
Cc["@mozilla.org/uriloader;1"].getService(Ci["nsIURILoader"]);
|
||||
Cc["@mozilla.org/cspcontext;1"].createInstance(Ci["nsIContentSecurityPolicy"]);
|
||||
Cc["@mozilla.org/settingsManager;1"].createInstance(Ci["nsISupports"]);
|
||||
|
||||
/* Applications Specific Helper */
|
||||
try {
|
||||
if (Services.prefs.getBoolPref("dom.sysmsg.enabled")) {
|
||||
Cc["@mozilla.org/system-message-manager;1"].getService(Ci["nsIDOMNavigatorSystemMessages"]);
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (Services.prefs.getBoolPref("dom.mozInputMethod.enabled")) {
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/forms.js", global);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementCopyPaste.js", global);
|
||||
Services.scriptloader.loadSubScript("chrome://global/content/BrowserElementChildPreload.js", global);
|
||||
|
||||
Services.io.getProtocolHandler("app");
|
||||
Services.io.getProtocolHandler("default");
|
||||
|
||||
// Register an observer for topic "preload_postfork" after we fork a content
|
||||
// process.
|
||||
DoPreloadPostfork(function () {
|
||||
// Load AppsServiceChild.jsm after fork since it sends an async message to
|
||||
// the chrome process in its init() function.
|
||||
Cu.import("resource://gre/modules/AppsServiceChild.jsm");
|
||||
|
||||
// Load nsIAppsService after fork since its implementation loads
|
||||
// AppsServiceChild.jsm
|
||||
Cc["@mozilla.org/AppsService;1"].getService(Ci["nsIAppsService"]);
|
||||
|
||||
// Load nsICookieService after fork since it sends an IPC constructor
|
||||
// message to the chrome process.
|
||||
Cc["@mozilla.org/cookieService;1"].getService(Ci["nsICookieService"]);
|
||||
|
||||
// Load nsIPermissionManager after fork since it sends a message to the
|
||||
// chrome process to read permissions.
|
||||
Cc["@mozilla.org/permissionmanager;1"].getService(Ci["nsIPermissionManager"]);
|
||||
|
||||
// Load nsIProtocolProxyService after fork since it asynchronously accesses
|
||||
// the "Proxy Resolution" thread after it's frozen.
|
||||
Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(Ci["nsIProtocolProxyService"]);
|
||||
|
||||
// Call docShell.createAboutBlankContentViewer() after fork since it has IPC
|
||||
// activity in the PCompositor protocol.
|
||||
docShell.createAboutBlankContentViewer(null);
|
||||
docShell.isActive = false;
|
||||
});
|
||||
})(this);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user