mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 770532 - Make new nsIPrincipal and nsIDocShell attributes work in content process. r=jlebar
This commit is contained in:
parent
38a7f3af0d
commit
77caa7b002
@ -1971,6 +1971,31 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
return false;
|
||||
}
|
||||
|
||||
PRUint32 appId = 0;
|
||||
bool isBrowserElement = false;
|
||||
|
||||
if (OwnerIsBrowserFrame()) {
|
||||
isBrowserElement = true;
|
||||
|
||||
if (mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)) {
|
||||
nsAutoString manifest;
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, manifest);
|
||||
|
||||
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
|
||||
if (!appsService) {
|
||||
NS_ERROR("Apps Service is not available!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
appsService->GetAppLocalIdByManifestURL(manifest, &appId);
|
||||
|
||||
// If the frame is actually an app, we should not mark it as a browser.
|
||||
if (appId != nsIScriptSecurityManager::NO_APP_ID) {
|
||||
isBrowserElement = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If our owner has no app manifest URL, then this is equivalent to
|
||||
// ContentParent::GetNewOrUsed().
|
||||
nsAutoString appManifest;
|
||||
@ -1978,8 +2003,7 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
ContentParent* parent = ContentParent::GetForApp(appManifest);
|
||||
|
||||
NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!");
|
||||
mRemoteBrowser = parent->CreateTab(chromeFlags,
|
||||
/* aIsBrowserFrame = */ OwnerIsBrowserFrame());
|
||||
mRemoteBrowser = parent->CreateTab(chromeFlags, isBrowserElement, appId);
|
||||
if (mRemoteBrowser) {
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
|
||||
mRemoteBrowser->SetOwnerElement(element);
|
||||
|
@ -396,9 +396,11 @@ ContentChild::AllocPCompositor(ipc::Transport* aTransport,
|
||||
}
|
||||
|
||||
PBrowserChild*
|
||||
ContentChild::AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame)
|
||||
ContentChild::AllocPBrowser(const PRUint32& aChromeFlags,
|
||||
const bool& aIsBrowserElement,
|
||||
const PRUint32& aAppId)
|
||||
{
|
||||
nsRefPtr<TabChild> iframe = new TabChild(aChromeFlags, aIsBrowserFrame);
|
||||
nsRefPtr<TabChild> iframe = new TabChild(aChromeFlags, aIsBrowserElement, aAppId);
|
||||
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget().get() : NULL;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,8 @@ public:
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
||||
virtual PBrowserChild* AllocPBrowser(const PRUint32& aChromeFlags,
|
||||
const bool& aIsBrowserFrame);
|
||||
const bool& aIsBrowserElement,
|
||||
const PRUint32& aAppId);
|
||||
virtual bool DeallocPBrowser(PBrowserChild*);
|
||||
|
||||
virtual PDeviceStorageRequestChild* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
||||
|
@ -430,9 +430,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
|
||||
}
|
||||
|
||||
TabParent*
|
||||
ContentParent::CreateTab(PRUint32 aChromeFlags, bool aIsBrowserFrame)
|
||||
ContentParent::CreateTab(PRUint32 aChromeFlags, bool aIsBrowserElement, PRUint32 aAppId)
|
||||
{
|
||||
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags, aIsBrowserFrame));
|
||||
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags, aIsBrowserElement, aAppId));
|
||||
}
|
||||
|
||||
void
|
||||
@ -834,7 +834,9 @@ ContentParent::AllocPCompositor(ipc::Transport* aTransport,
|
||||
}
|
||||
|
||||
PBrowserParent*
|
||||
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame)
|
||||
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags,
|
||||
const bool& aIsBrowserElement,
|
||||
const PRUint32& aAppId)
|
||||
{
|
||||
TabParent* parent = new TabParent();
|
||||
if (parent){
|
||||
|
@ -69,10 +69,11 @@ public:
|
||||
/**
|
||||
* Create a new tab.
|
||||
*
|
||||
* |aIsBrowserFrame| indicates whether this tab is part of an
|
||||
* |aIsBrowserElement| indicates whether this tab is part of an
|
||||
* <iframe mozbrowser>.
|
||||
* |aAppId| indicates which app the tab belongs to.
|
||||
*/
|
||||
TabParent* CreateTab(PRUint32 aChromeFlags, bool aIsBrowserFrame);
|
||||
TabParent* CreateTab(PRUint32 aChromeFlags, bool aIsBrowserElement, PRUint32 aAppId);
|
||||
/** Notify that a tab was destroyed during normal operation. */
|
||||
void NotifyTabDestroyed(PBrowserParent* aTab);
|
||||
|
||||
@ -132,7 +133,7 @@ private:
|
||||
PCompositorParent* AllocPCompositor(ipc::Transport* aTransport,
|
||||
base::ProcessId aOtherProcess) MOZ_OVERRIDE;
|
||||
|
||||
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame);
|
||||
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserElement, const PRUint32& aAppId);
|
||||
virtual bool DeallocPBrowser(PBrowserParent* frame);
|
||||
|
||||
virtual PDeviceStorageRequestParent* AllocPDeviceStorageRequest(const DeviceStorageParams&);
|
||||
|
@ -120,7 +120,7 @@ both:
|
||||
// The child creates the PBrowser as part of
|
||||
// TabChild::BrowserFrameProvideWindow, and the parent creates the PBrowser
|
||||
// as part of ContentParent::CreateTab.
|
||||
async PBrowser(PRUint32 chromeFlags, bool isBrowserFrame);
|
||||
async PBrowser(PRUint32 chromeFlags, bool isBrowserElement, PRUint32 appId);
|
||||
|
||||
child:
|
||||
PMemoryReportRequest();
|
||||
|
@ -88,14 +88,16 @@ public:
|
||||
};
|
||||
|
||||
|
||||
TabChild::TabChild(PRUint32 aChromeFlags, bool aIsBrowserFrame)
|
||||
TabChild::TabChild(PRUint32 aChromeFlags, bool aIsBrowserElement,
|
||||
PRUint32 aAppId)
|
||||
: mRemoteFrame(nsnull)
|
||||
, mTabChildGlobal(nsnull)
|
||||
, mChromeFlags(aChromeFlags)
|
||||
, mOuterRect(0, 0, 0, 0)
|
||||
, mLastBackgroundColor(NS_RGB(255, 255, 255))
|
||||
, mDidFakeShow(false)
|
||||
, mIsBrowserFrame(aIsBrowserFrame)
|
||||
, mIsBrowserElement(aIsBrowserElement)
|
||||
, mAppId(aAppId)
|
||||
{
|
||||
printf("creating %d!\n", NS_IsMainThread());
|
||||
}
|
||||
@ -380,8 +382,7 @@ TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
|
||||
|
||||
nsRefPtr<TabChild> newChild =
|
||||
static_cast<TabChild*>(Manager()->SendPBrowserConstructor(
|
||||
/* aChromeFlags = */ 0,
|
||||
/* aIsBrowserFrame = */ true));
|
||||
/* aChromeFlags = */ 0, mIsBrowserElement, mAppId));
|
||||
|
||||
nsCAutoString spec;
|
||||
aURI->GetSpec(spec);
|
||||
@ -584,6 +585,17 @@ TabChild::RecvShow(const nsIntSize& size)
|
||||
baseWindow->InitWindow(0, mWidget,
|
||||
0, 0, size.width, size.height);
|
||||
baseWindow->Create();
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebNav);
|
||||
MOZ_ASSERT(docShell);
|
||||
|
||||
if (docShell) {
|
||||
docShell->SetAppId(mAppId);
|
||||
if (mIsBrowserElement) {
|
||||
docShell->SetIsBrowserElement();
|
||||
}
|
||||
}
|
||||
|
||||
baseWindow->SetVisibility(true);
|
||||
|
||||
// IPC uses a WebBrowser object for which DNS prefetching is turned off
|
||||
@ -1043,7 +1055,7 @@ TabChild::InitTabChildGlobal()
|
||||
root->SetParentTarget(scope);
|
||||
|
||||
// Initialize the child side of the browser element machinery, if appropriate.
|
||||
if (mIsBrowserFrame) {
|
||||
if (mIsBrowserElement || mAppId != nsIScriptSecurityManager::NO_APP_ID) {
|
||||
RecvLoadRemoteScript(
|
||||
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"));
|
||||
}
|
||||
|
@ -147,10 +147,11 @@ public:
|
||||
/**
|
||||
* Create a new TabChild object.
|
||||
*
|
||||
* |aIsBrowserFrame| indicates whether the TabChild is inside an
|
||||
* <iframe mozbrowser>.
|
||||
* |aIsBrowserElement| indicates whether the tab is inside an <iframe mozbrowser>.
|
||||
* |aAppId| is the app id of the app containing this tab. If the tab isn't
|
||||
* contained in an app, aAppId will be nsIScriptSecurityManager::NO_APP_ID.
|
||||
*/
|
||||
TabChild(PRUint32 aChromeFlags, bool aIsBrowserFrame);
|
||||
TabChild(PRUint32 aChromeFlags, bool aIsBrowserElement, PRUint32 aAppId);
|
||||
virtual ~TabChild();
|
||||
nsresult Init();
|
||||
|
||||
@ -304,7 +305,8 @@ private:
|
||||
nscolor mLastBackgroundColor;
|
||||
ScrollingBehavior mScrolling;
|
||||
bool mDidFakeShow;
|
||||
bool mIsBrowserFrame;
|
||||
bool mIsBrowserElement;
|
||||
PRUint32 mAppId;
|
||||
|
||||
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user