Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-05-03 22:32:37 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
/* 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/dom/TabContext.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "mozilla/dom/PTabContext.h"
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
|
|
|
#include "mozilla/dom/TabChild.h"
|
2018-09-10 21:36:15 +03:00
|
|
|
#include "mozilla/StaticPrefs.h"
|
2013-09-24 01:30:40 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2013-09-11 00:56:05 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
#define NO_APP_ID (nsIScriptSecurityManager::NO_APP_ID)
|
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
using namespace mozilla::dom::ipc;
|
2012-11-28 00:43:52 +04:00
|
|
|
using namespace mozilla::layout;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
TabContext::TabContext()
|
2017-12-15 01:03:14 +03:00
|
|
|
: mInitialized(false)
|
2016-02-18 07:35:45 +03:00
|
|
|
, mIsMozBrowserElement(false)
|
2018-07-11 05:31:55 +03:00
|
|
|
, mChromeOuterWindowID(0)
|
2017-05-29 13:38:46 +03:00
|
|
|
, mJSPluginID(-1)
|
2016-06-09 14:59:31 +03:00
|
|
|
, mShowAccelerators(UIStateChangeType_NoChange)
|
|
|
|
, mShowFocusRings(UIStateChangeType_NoChange)
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-02-18 07:35:45 +03:00
|
|
|
TabContext::IsMozBrowserElement() const
|
|
|
|
{
|
|
|
|
return mIsMozBrowserElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabContext::IsIsolatedMozBrowserElement() const
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
{
|
2016-02-05 04:42:44 +03:00
|
|
|
return mOriginAttributes.mInIsolatedMozBrowser;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2016-10-15 04:46:26 +03:00
|
|
|
TabContext::IsMozBrowser() const
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
{
|
2016-10-15 04:46:26 +03:00
|
|
|
return IsMozBrowserElement();
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
}
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
bool
|
|
|
|
TabContext::IsJSPlugin() const
|
|
|
|
{
|
|
|
|
return mJSPluginID >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
TabContext::JSPluginId() const
|
|
|
|
{
|
|
|
|
return mJSPluginID;
|
|
|
|
}
|
|
|
|
|
2018-07-11 05:31:55 +03:00
|
|
|
uint64_t
|
|
|
|
TabContext::ChromeOuterWindowID() const
|
|
|
|
{
|
|
|
|
return mChromeOuterWindowID;
|
|
|
|
}
|
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
bool
|
|
|
|
TabContext::SetTabContext(const TabContext& aContext)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInitialized, false);
|
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
*this = aContext;
|
2013-07-30 23:50:46 +04:00
|
|
|
mInitialized = true;
|
2013-07-31 01:42:34 +04:00
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-03 00:02:29 +03:00
|
|
|
void
|
|
|
|
TabContext::SetPrivateBrowsingAttributes(bool aIsPrivateBrowsing)
|
|
|
|
{
|
|
|
|
mOriginAttributes.SyncAttributesWithPrivateBrowsing(aIsPrivateBrowsing);
|
|
|
|
}
|
|
|
|
|
2016-04-29 01:04:52 +03:00
|
|
|
bool
|
|
|
|
TabContext::UpdateTabContextAfterSwap(const TabContext& aContext)
|
|
|
|
{
|
|
|
|
// This is only used after already initialized.
|
|
|
|
MOZ_ASSERT(mInitialized);
|
|
|
|
|
2018-07-11 05:31:55 +03:00
|
|
|
// The only permissable changes are to `mIsMozBrowserElement` and
|
|
|
|
// mChromeOuterWindowID. All other fields must match for the change
|
|
|
|
// to be accepted.
|
2016-10-15 04:46:26 +03:00
|
|
|
if (aContext.mOriginAttributes != mOriginAttributes) {
|
2016-04-29 01:04:52 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-11 05:31:55 +03:00
|
|
|
mChromeOuterWindowID = aContext.mChromeOuterWindowID;
|
2016-04-29 01:04:52 +03:00
|
|
|
mIsMozBrowserElement = aContext.mIsMozBrowserElement;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes&
|
2015-10-07 06:47:46 +03:00
|
|
|
TabContext::OriginAttributesRef() const
|
|
|
|
{
|
|
|
|
return mOriginAttributes;
|
|
|
|
}
|
|
|
|
|
2016-05-17 06:10:59 +03:00
|
|
|
const nsAString&
|
|
|
|
TabContext::PresentationURL() const
|
|
|
|
{
|
|
|
|
return mPresentationURL;
|
|
|
|
}
|
|
|
|
|
2016-06-09 14:59:31 +03:00
|
|
|
UIStateChangeType
|
|
|
|
TabContext::ShowAccelerators() const
|
|
|
|
{
|
|
|
|
return mShowAccelerators;
|
|
|
|
}
|
|
|
|
|
|
|
|
UIStateChangeType
|
|
|
|
TabContext::ShowFocusRings() const
|
|
|
|
{
|
|
|
|
return mShowFocusRings;
|
|
|
|
}
|
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
bool
|
2016-02-18 07:35:45 +03:00
|
|
|
TabContext::SetTabContext(bool aIsMozBrowserElement,
|
2018-07-11 05:31:55 +03:00
|
|
|
uint64_t aChromeOuterWindowID,
|
2016-06-09 14:59:31 +03:00
|
|
|
UIStateChangeType aShowAccelerators,
|
|
|
|
UIStateChangeType aShowFocusRings,
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes& aOriginAttributes,
|
2016-05-17 06:10:59 +03:00
|
|
|
const nsAString& aPresentationURL)
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInitialized, false);
|
|
|
|
|
2015-10-07 06:47:46 +03:00
|
|
|
// Veryify that app id matches mAppId passed in originAttributes
|
2016-10-15 04:46:26 +03:00
|
|
|
MOZ_RELEASE_ASSERT(aOriginAttributes.mAppId == NO_APP_ID);
|
2015-10-07 06:47:46 +03:00
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
mInitialized = true;
|
2016-02-18 07:35:45 +03:00
|
|
|
mIsMozBrowserElement = aIsMozBrowserElement;
|
2018-07-11 05:31:55 +03:00
|
|
|
mChromeOuterWindowID = aChromeOuterWindowID;
|
2015-10-07 06:47:46 +03:00
|
|
|
mOriginAttributes = aOriginAttributes;
|
2016-05-17 06:10:59 +03:00
|
|
|
mPresentationURL = aPresentationURL;
|
2016-06-09 14:59:31 +03:00
|
|
|
mShowAccelerators = aShowAccelerators;
|
|
|
|
mShowFocusRings = aShowFocusRings;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-05-29 13:38:46 +03:00
|
|
|
bool
|
|
|
|
TabContext::SetTabContextForJSPluginFrame(int32_t aJSPluginID)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mInitialized, false);
|
|
|
|
|
|
|
|
mInitialized = true;
|
|
|
|
mJSPluginID = aJSPluginID;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
IPCTabContext
|
|
|
|
TabContext::AsIPCTabContext() const
|
|
|
|
{
|
2017-05-29 13:38:46 +03:00
|
|
|
if (IsJSPlugin()) {
|
|
|
|
return IPCTabContext(JSPluginFrameIPCTabContext(mJSPluginID));
|
|
|
|
}
|
|
|
|
|
2016-10-31 20:49:29 +03:00
|
|
|
return IPCTabContext(FrameIPCTabContext(mOriginAttributes,
|
2016-05-20 06:36:27 +03:00
|
|
|
mIsMozBrowserElement,
|
2018-07-11 05:31:55 +03:00
|
|
|
mChromeOuterWindowID,
|
2016-06-09 14:59:31 +03:00
|
|
|
mPresentationURL,
|
|
|
|
mShowAccelerators,
|
|
|
|
mShowFocusRings));
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
}
|
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
|
|
|
|
: mInvalidReason(nullptr)
|
|
|
|
{
|
2016-02-18 07:35:45 +03:00
|
|
|
bool isMozBrowserElement = false;
|
2018-07-11 05:31:55 +03:00
|
|
|
uint64_t chromeOuterWindowID = 0;
|
2017-05-29 13:38:46 +03:00
|
|
|
int32_t jsPluginId = -1;
|
2017-01-12 19:38:48 +03:00
|
|
|
OriginAttributes originAttributes;
|
2016-05-17 06:10:59 +03:00
|
|
|
nsAutoString presentationURL;
|
2016-08-22 17:06:31 +03:00
|
|
|
UIStateChangeType showAccelerators = UIStateChangeType_NoChange;
|
|
|
|
UIStateChangeType showFocusRings = UIStateChangeType_NoChange;
|
2013-07-31 01:42:34 +04:00
|
|
|
|
2015-10-30 02:30:57 +03:00
|
|
|
switch(aParams.type()) {
|
|
|
|
case IPCTabContext::TPopupIPCTabContext: {
|
|
|
|
const PopupIPCTabContext &ipcContext = aParams.get_PopupIPCTabContext();
|
2013-07-31 01:42:34 +04:00
|
|
|
|
|
|
|
TabContext *context;
|
2014-10-29 21:11:00 +03:00
|
|
|
if (ipcContext.opener().type() == PBrowserOrId::TPBrowserParent) {
|
2015-02-06 00:47:32 +03:00
|
|
|
context = TabParent::GetFrom(ipcContext.opener().get_PBrowserParent());
|
2016-04-22 01:05:23 +03:00
|
|
|
if (!context) {
|
|
|
|
mInvalidReason = "Child is-browser process tried to "
|
|
|
|
"open a null tab.";
|
|
|
|
return;
|
|
|
|
}
|
2016-02-18 07:35:45 +03:00
|
|
|
if (context->IsMozBrowserElement() &&
|
|
|
|
!ipcContext.isMozBrowserElement()) {
|
2013-07-31 01:42:34 +04:00
|
|
|
// If the TabParent corresponds to a browser element, then it can only
|
|
|
|
// open other browser elements, for security reasons. We should have
|
|
|
|
// checked this before calling the TabContext constructor, so this is
|
|
|
|
// a fatal error.
|
|
|
|
mInvalidReason = "Child is-browser process tried to "
|
|
|
|
"open a non-browser tab.";
|
|
|
|
return;
|
|
|
|
}
|
2014-10-29 21:11:00 +03:00
|
|
|
} else if (ipcContext.opener().type() == PBrowserOrId::TPBrowserChild) {
|
|
|
|
context = static_cast<TabChild*>(ipcContext.opener().get_PBrowserChild());
|
|
|
|
} else if (ipcContext.opener().type() == PBrowserOrId::TTabId) {
|
|
|
|
// We should never get here because this PopupIPCTabContext is only
|
|
|
|
// used for allocating a new tab id, not for allocating a PBrowser.
|
|
|
|
mInvalidReason = "Child process tried to open an tab without the opener information.";
|
|
|
|
return;
|
2013-07-31 01:42:34 +04:00
|
|
|
} else {
|
|
|
|
// This should be unreachable because PopupIPCTabContext::opener is not a
|
|
|
|
// nullable field.
|
|
|
|
mInvalidReason = "PopupIPCTabContext::opener was null (?!).";
|
|
|
|
return;
|
|
|
|
}
|
2013-07-30 22:51:44 +04:00
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
// Browser elements can't nest other browser elements. So if
|
|
|
|
// our opener is browser element, we must be a new DOM window
|
|
|
|
// opened by it. In that case we inherit our containing app ID
|
|
|
|
// (if any).
|
|
|
|
//
|
|
|
|
// Otherwise, we're a new app window and we inherit from our
|
|
|
|
// opener app.
|
2016-02-18 07:35:45 +03:00
|
|
|
isMozBrowserElement = ipcContext.isMozBrowserElement();
|
2015-10-07 06:47:46 +03:00
|
|
|
originAttributes = context->mOriginAttributes;
|
2018-07-11 05:31:55 +03:00
|
|
|
chromeOuterWindowID = ipcContext.chromeOuterWindowID();
|
2013-07-31 01:42:34 +04:00
|
|
|
break;
|
2013-07-30 23:50:46 +04:00
|
|
|
}
|
2017-05-29 13:38:46 +03:00
|
|
|
case IPCTabContext::TJSPluginFrameIPCTabContext: {
|
|
|
|
const JSPluginFrameIPCTabContext &ipcContext =
|
|
|
|
aParams.get_JSPluginFrameIPCTabContext();
|
|
|
|
|
|
|
|
jsPluginId = ipcContext.jsPluginId();
|
|
|
|
break;
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
case IPCTabContext::TFrameIPCTabContext: {
|
2015-10-07 06:47:46 +03:00
|
|
|
const FrameIPCTabContext &ipcContext =
|
2015-10-30 02:30:57 +03:00
|
|
|
aParams.get_FrameIPCTabContext();
|
2013-07-31 01:42:34 +04:00
|
|
|
|
2016-02-18 07:35:45 +03:00
|
|
|
isMozBrowserElement = ipcContext.isMozBrowserElement();
|
2018-07-11 05:31:55 +03:00
|
|
|
chromeOuterWindowID = ipcContext.chromeOuterWindowID();
|
2016-05-17 06:10:59 +03:00
|
|
|
presentationURL = ipcContext.presentationURL();
|
2016-06-09 14:59:31 +03:00
|
|
|
showAccelerators = ipcContext.showAccelerators();
|
|
|
|
showFocusRings = ipcContext.showFocusRings();
|
2016-10-31 20:49:29 +03:00
|
|
|
originAttributes = ipcContext.originAttributes();
|
2013-07-31 01:42:34 +04:00
|
|
|
break;
|
|
|
|
}
|
2015-10-30 02:30:57 +03:00
|
|
|
case IPCTabContext::TUnsafeIPCTabContext: {
|
|
|
|
// XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow.
|
|
|
|
// It is meant as a temporary solution until service workers can
|
|
|
|
// provide a TabChild equivalent. Don't allow this on b2g since
|
|
|
|
// it might be used to escalate privileges.
|
2018-09-10 21:36:15 +03:00
|
|
|
if (!StaticPrefs::dom_serviceWorkers_enabled()) {
|
2015-10-30 02:30:57 +03:00
|
|
|
mInvalidReason = "ServiceWorkers should be enabled.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2013-07-31 01:42:34 +04:00
|
|
|
default: {
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rv;
|
2017-05-29 13:38:46 +03:00
|
|
|
if (jsPluginId >= 0) {
|
|
|
|
rv = mTabContext.SetTabContextForJSPluginFrame(jsPluginId);
|
|
|
|
} else {
|
|
|
|
rv = mTabContext.SetTabContext(isMozBrowserElement,
|
2018-07-11 05:31:55 +03:00
|
|
|
chromeOuterWindowID,
|
2017-05-29 13:38:46 +03:00
|
|
|
showAccelerators,
|
|
|
|
showFocusRings,
|
|
|
|
originAttributes,
|
|
|
|
presentationURL);
|
|
|
|
}
|
2013-07-31 01:42:34 +04:00
|
|
|
if (!rv) {
|
|
|
|
mInvalidReason = "Couldn't initialize TabContext.";
|
2013-04-16 17:34:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
bool
|
|
|
|
MaybeInvalidTabContext::IsValid()
|
2013-07-30 22:51:44 +04:00
|
|
|
{
|
2013-07-31 01:42:34 +04:00
|
|
|
return mInvalidReason == nullptr;
|
|
|
|
}
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
const char*
|
|
|
|
MaybeInvalidTabContext::GetInvalidReason()
|
|
|
|
{
|
|
|
|
return mInvalidReason;
|
|
|
|
}
|
2013-07-30 22:51:44 +04:00
|
|
|
|
2013-07-31 01:42:34 +04:00
|
|
|
const TabContext&
|
|
|
|
MaybeInvalidTabContext::GetTabContext()
|
|
|
|
{
|
|
|
|
if (!IsValid()) {
|
|
|
|
MOZ_CRASH("Can't GetTabContext() if !IsValid().");
|
|
|
|
}
|
|
|
|
|
|
|
|
return mTabContext;
|
Bug 802366 - The main event: Let a browser process inherit its app's id. r=bz,cjones
The main bug fixed here is that in half of our interfaces, we use "is browser frame/element" to mean "browser or app", and in the other half, we use it to mean "is browser not app".
There's a related, functional bug also fixed here, which is that a browser process doesn't inherit its parent's app-id. This causes problems e.g. for IndexedDB: If a browser inside an app uses IndexedDB, the DB should have the app's app-id.
I also modified Tab{Parent,Child} and nsFrameLoader to call "app" "ownOrContainingApp", to emphasize that we might have inherited the app from a parent process. I left nsIDocShell::appId alone, because changing that would have necessitated changing nsILoadGroup and therefore a /lot/ of users in Necko; it's also not clear it would have clarified anything in those cases.
2012-11-10 22:32:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|