Bug 1238160 - Rename nsILoadContext::GetIsInBrowserElement. r=smaug,mayhemer

This change renames nsILoadContext::GetIsInBrowserElement to
GetIsInIsolatedMozBrowserElement.  Other methods that pass these values around
also have name changes.

Tokens such as "isInBrowserElement" have previously been serialized into cache
keys, used as DB column names, stored in app registries, etc.  No changes are
made to any serialization formats.  Only runtime method and variable names are
updated.

No behavior changes are made in this patch, so some renamed methods may have
nonsensical implementations.  These are corrected in subsequent patches
focused on behavior.

MozReview-Commit-ID: CUttXANQjSv
This commit is contained in:
J. Ryan Stinnett 2016-02-17 20:55:57 -06:00
parent 9c1253b6c8
commit 8bb8ba83be
31 changed files with 129 additions and 109 deletions

View File

@ -172,13 +172,13 @@ LoadContext::SetRemoteTabs(bool aUseRemoteTabs)
} }
NS_IMETHODIMP NS_IMETHODIMP
LoadContext::GetIsInBrowserElement(bool* aIsInBrowserElement) LoadContext::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
{ {
MOZ_ASSERT(mIsNotNull); MOZ_ASSERT(mIsNotNull);
NS_ENSURE_ARG_POINTER(aIsInBrowserElement); NS_ENSURE_ARG_POINTER(aIsInIsolatedMozBrowserElement);
*aIsInBrowserElement = mOriginAttributes.mInIsolatedMozBrowser; *aIsInIsolatedMozBrowserElement = mOriginAttributes.mInIsolatedMozBrowser;
return NS_OK; return NS_OK;
} }

View File

@ -3500,7 +3500,8 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
return false; return false;
} }
if (targetDS->GetIsInBrowserElement() != accessingDS->GetIsInBrowserElement() || if (targetDS->GetIsInIsolatedMozBrowserElement() !=
accessingDS->GetIsInIsolatedMozBrowserElement() ||
targetDS->GetAppId() != accessingDS->GetAppId()) { targetDS->GetAppId() != accessingDS->GetAppId()) {
return false; return false;
} }
@ -13938,9 +13939,9 @@ nsDocShell::GetInheritedFrameType()
} }
/* [infallible] */ NS_IMETHODIMP /* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsInBrowserElement(bool* aIsInBrowserElement) nsDocShell::GetIsInIsolatedMozBrowserElement(bool* aIsInIsolatedMozBrowserElement)
{ {
*aIsInBrowserElement = (GetInheritedFrameType() == eFrameTypeBrowser); *aIsInIsolatedMozBrowserElement = (GetInheritedFrameType() == eFrameTypeBrowser);
return NS_OK; return NS_OK;
} }

View File

@ -780,16 +780,21 @@ interface nsIDocShell : nsIDocShellTreeItem
[infallible] readonly attribute boolean isBrowserOrApp; [infallible] readonly attribute boolean isBrowserOrApp;
/** /**
* Returns true if this docshell corresponds to an <iframe mozbrowser> or if * Returns true if this docshell corresponds to an isolated <iframe
* the docshell is contained in an <iframe mozbrowser>. (<iframe mozapp * mozbrowser> or if the docshell is contained in an isolated <iframe
* mozbrowser> does not count as a browser.) * 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 * 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 * 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 * until the hierarchy ends). Return true iff the docshell we stopped on has
* isBrowserElement == true. * isIsolatedMozBrowserElement == true.
*/ */
[infallible] readonly attribute boolean isInBrowserElement; [infallible] readonly attribute boolean isInIsolatedMozBrowserElement;
/** /**
* Returns true if this docshell corresponds to an <iframe mozbrowser> or * Returns true if this docshell corresponds to an <iframe mozbrowser> or

View File

@ -116,9 +116,13 @@ interface nsILoadContext : nsISupports
[noscript] void SetRemoteTabs(in boolean aUseRemoteTabs); [noscript] void SetRemoteTabs(in boolean aUseRemoteTabs);
/** /**
* Returns true iff the load is occurring inside a browser element. * 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 isInBrowserElement; readonly attribute boolean isInIsolatedMozBrowserElement;
/** /**
* Returns the app id of the app the load is occurring is in. Returns * Returns the app id of the app the load is occurring is in. Returns

View File

@ -156,7 +156,7 @@ this.AppsUtils = {
associatedWindow: null, associatedWindow: null,
topWindow : null, topWindow : null,
appId: aAppId, appId: aAppId,
isInBrowserElement: aInIsolatedMozBrowser, isInIsolatedMozBrowserElement: aInIsolatedMozBrowser,
originAttributes: { originAttributes: {
appId: aAppId, appId: aAppId,
inIsolatedMozBrowser: aInIsolatedMozBrowser inIsolatedMozBrowser: aInIsolatedMozBrowser

View File

@ -3536,7 +3536,7 @@ this.DOMApplicationRegistry = {
// nsILoadContext // nsILoadContext
appId: aOldApp.installerAppId, appId: aOldApp.installerAppId,
isInBrowserElement: aOldApp.installerIsBrowser, isInIsolatedMozBrowserElement: aOldApp.installerIsBrowser,
originAttributes: { originAttributes: {
appId: aOldApp.installerAppId, appId: aOldApp.installerAppId,
inIsolatedMozBrowser: aOldApp.installerIsBrowser inIsolatedMozBrowser: aOldApp.installerIsBrowser

View File

@ -62,7 +62,7 @@ function runTests() {
var context = { 'url': 'http://example.org', var context = { 'url': 'http://example.org',
'appId': SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID, 'appId': SpecialPowers.Ci.nsIScriptSecurityManager.NO_APP_ID,
'isInBrowserElement': true }; 'isInIsolatedMozBrowserElement': true };
SpecialPowers.pushPermissions([ SpecialPowers.pushPermissions([
{'type': 'browser', 'allow': 1, 'context': context}, {'type': 'browser', 'allow': 1, 'context': context},
{'type': 'embed-apps', 'allow': 1, 'context': context} {'type': 'embed-apps', 'allow': 1, 'context': context}

View File

@ -3103,7 +3103,7 @@ public:
NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL
NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL
NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL
NS_IMETHOD GetIsInBrowserElement(bool*) NO_IMPL NS_IMETHOD GetIsInIsolatedMozBrowserElement(bool*) NO_IMPL
NS_IMETHOD GetAppId(uint32_t*) NO_IMPL NS_IMETHOD GetAppId(uint32_t*) NO_IMPL
NS_IMETHOD GetOriginAttributes(JS::MutableHandleValue) NO_IMPL NS_IMETHOD GetOriginAttributes(JS::MutableHandleValue) NO_IMPL
NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL

View File

@ -738,9 +738,9 @@ this.NetworkStatsService = {
/* /*
* Function responsible for receiving stats which are not from netd. * Function responsible for receiving stats which are not from netd.
*/ */
saveStats: function saveStats(aAppId, aIsInBrowser, aServiceType, aNetworkInfo, saveStats: function saveStats(aAppId, aIsInIsolatedMozBrowser, aServiceType,
aTimeStamp, aRxBytes, aTxBytes, aIsAccumulative, aNetworkInfo, aTimeStamp, aRxBytes, aTxBytes,
aCallback) { aIsAccumulative, aCallback) {
let netId = this.convertNetworkInfo(aNetworkInfo); let netId = this.convertNetworkInfo(aNetworkInfo);
if (!netId) { if (!netId) {
if (aCallback) { if (aCallback) {
@ -761,7 +761,7 @@ this.NetworkStatsService = {
} }
let stats = { appId: aAppId, let stats = { appId: aAppId,
isInBrowser: aIsInBrowser, isInBrowser: aIsInIsolatedMozBrowser,
serviceType: aServiceType, serviceType: aServiceType,
networkId: this._networks[netId].network.id, networkId: this._networks[netId].network.id,
networkType: this._networks[netId].network.type, networkType: this._networks[netId].network.type,

View File

@ -29,7 +29,7 @@ NetworkStatsServiceProxy.prototype = {
* Function called in the protocol layer (HTTP, FTP, WebSocket ...etc) * Function called in the protocol layer (HTTP, FTP, WebSocket ...etc)
* to pass the per-app stats to NetworkStatsService. * to pass the per-app stats to NetworkStatsService.
*/ */
saveAppStats: function saveAppStats(aAppId, aIsInBrowser, aNetworkInfo, aTimeStamp, saveAppStats: function saveAppStats(aAppId, aIsInIsolatedMozBrowser, aNetworkInfo, aTimeStamp,
aRxBytes, aTxBytes, aIsAccumulative, aRxBytes, aTxBytes, aIsAccumulative,
aCallback) { aCallback) {
if (!aNetworkInfo) { if (!aNetworkInfo) {
@ -40,7 +40,7 @@ NetworkStatsServiceProxy.prototype = {
} }
if (DEBUG) { if (DEBUG) {
debug("saveAppStats: " + aAppId + " " + aIsInBrowser + " " + debug("saveAppStats: " + aAppId + " " + aIsInIsolatedMozBrowser + " " +
aNetworkInfo.type + " " + aTimeStamp + " " + aNetworkInfo.type + " " + aTimeStamp + " " +
aRxBytes + " " + aTxBytes + " " + aIsAccumulative); aRxBytes + " " + aTxBytes + " " + aIsAccumulative);
} }
@ -49,7 +49,7 @@ NetworkStatsServiceProxy.prototype = {
aCallback = aCallback.notify; aCallback = aCallback.notify;
} }
NetworkStatsService.saveStats(aAppId, aIsInBrowser, "", aNetworkInfo, NetworkStatsService.saveStats(aAppId, aIsInIsolatedMozBrowser, "", aNetworkInfo,
aTimeStamp, aRxBytes, aTxBytes, aTimeStamp, aRxBytes, aTxBytes,
aIsAccumulative, aCallback); aIsAccumulative, aCallback);
}, },

View File

@ -22,7 +22,12 @@ interface nsINetworkStatsServiceProxy : nsISupports
/* /*
* An interface used to record per-app traffic data. * An interface used to record per-app traffic data.
* @param aAppId app id * @param aAppId app id
* @param aIsInBrowser true if the iframe element is mozbrowser * @param aIsInIsolatedMozBrowser
* true if the frame is 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.
* @param aNetworkInterface network * @param aNetworkInterface network
* @param aTimeStamp time stamp * @param aTimeStamp time stamp
* @param aRxBytes received data amount * @param aRxBytes received data amount
@ -31,7 +36,7 @@ interface nsINetworkStatsServiceProxy : nsISupports
* @param aCallback an optional callback * @param aCallback an optional callback
*/ */
void saveAppStats(in unsigned long aAppId, void saveAppStats(in unsigned long aAppId,
in boolean aIsInBrowser, in boolean aIsInIsolatedMozBrowser,
in nsINetworkInfo aNetworkInfo, in nsINetworkInfo aNetworkInfo,
in unsigned long long aTimeStamp, in unsigned long long aTimeStamp,
in unsigned long long aRxBytes, in unsigned long long aRxBytes,

View File

@ -58,7 +58,7 @@ RequestSyncManager.prototype = {
return this.sendMessage("RequestSyncManager:Registrations", {}); return this.sendMessage("RequestSyncManager:Registrations", {});
}, },
setPolicy: function(aTask, aOrigin, aManifestURL, aIsInBrowserElement, setPolicy: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement,
aState, aOverwrittenMinInterval) { aState, aOverwrittenMinInterval) {
debug('setPolicy'); debug('setPolicy');
@ -66,19 +66,19 @@ RequestSyncManager.prototype = {
{ task: aTask, { task: aTask,
origin: aOrigin, origin: aOrigin,
manifestURL: aManifestURL, manifestURL: aManifestURL,
isInBrowserElement: aIsInBrowserElement, isInBrowserElement: aIsInIsolatedMozBrowserElement,
state: aState, state: aState,
overwrittenMinInterval: aOverwrittenMinInterval }); overwrittenMinInterval: aOverwrittenMinInterval });
}, },
runTask: function(aTask, aOrigin, aManifestURL, aIsInBrowserElement) { runTask: function(aTask, aOrigin, aManifestURL, aIsInIsolatedMozBrowserElement) {
debug('runTask'); debug('runTask');
return this.sendMessage("RequestSyncManager:RunTask", return this.sendMessage("RequestSyncManager:RunTask",
{ task: aTask, { task: aTask,
origin: aOrigin, origin: aOrigin,
manifestURL: aManifestURL, manifestURL: aManifestURL,
isInBrowserElement: aIsInBrowserElement }); isInBrowserElement: aIsInIsolatedMozBrowserElement });
}, },
registrationsResult: function(aData) { registrationsResult: function(aData) {

View File

@ -168,7 +168,7 @@ ChannelListener.prototype = {
*/ */
function LoadContextCallback(appId, inIsolatedMozBrowser, isPrivate, isContent) { function LoadContextCallback(appId, inIsolatedMozBrowser, isPrivate, isContent) {
this.appId = appId; this.appId = appId;
this.isInBrowserElement = inIsolatedMozBrowser; this.isInIsolatedMozBrowserElement = inIsolatedMozBrowser;
this.usePrivateBrowsing = isPrivate; this.usePrivateBrowsing = isPrivate;
this.isContent = isContent; this.isContent = isContent;
this.originAttributes = { this.originAttributes = {

View File

@ -46,13 +46,13 @@ GetActiveNetworkInfo(nsCOMPtr<nsINetworkInfo> &aNetworkInfo)
class SaveNetworkStatsEvent : public nsRunnable { class SaveNetworkStatsEvent : public nsRunnable {
public: public:
SaveNetworkStatsEvent(uint32_t aAppId, SaveNetworkStatsEvent(uint32_t aAppId,
bool aIsInBrowser, bool aIsInIsolatedMozBrowser,
nsMainThreadPtrHandle<nsINetworkInfo> &aActiveNetworkInfo, nsMainThreadPtrHandle<nsINetworkInfo> &aActiveNetworkInfo,
uint64_t aCountRecv, uint64_t aCountRecv,
uint64_t aCountSent, uint64_t aCountSent,
bool aIsAccumulative) bool aIsAccumulative)
: mAppId(aAppId), : mAppId(aAppId),
mIsInBrowser(aIsInBrowser), mIsInIsolatedMozBrowser(aIsInIsolatedMozBrowser),
mActiveNetworkInfo(aActiveNetworkInfo), mActiveNetworkInfo(aActiveNetworkInfo),
mCountRecv(aCountRecv), mCountRecv(aCountRecv),
mCountSent(aCountSent), mCountSent(aCountSent),
@ -75,7 +75,7 @@ public:
// save the network stats through NetworkStatsServiceProxy // save the network stats through NetworkStatsServiceProxy
mNetworkStatsServiceProxy->SaveAppStats(mAppId, mNetworkStatsServiceProxy->SaveAppStats(mAppId,
mIsInBrowser, mIsInIsolatedMozBrowser,
mActiveNetworkInfo, mActiveNetworkInfo,
PR_Now() / 1000, PR_Now() / 1000,
mCountRecv, mCountRecv,
@ -87,7 +87,7 @@ public:
} }
private: private:
uint32_t mAppId; uint32_t mAppId;
bool mIsInBrowser; bool mIsInIsolatedMozBrowser;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo; nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
uint64_t mCountRecv; uint64_t mCountRecv;
uint64_t mCountSent; uint64_t mCountSent;

View File

@ -107,7 +107,7 @@ PACGenerator.prototype = {
pac += "var origins ='" + appOrigins + pac += "var origins ='" + appOrigins +
"'.split(/[ ,]+/).filter(Boolean); " + "'.split(/[ ,]+/).filter(Boolean); " +
"if ((origins.indexOf('*') > -1 || origins.indexOf(myAppOrigin()) > -1)" + "if ((origins.indexOf('*') > -1 || origins.indexOf(myAppOrigin()) > -1)" +
" && isInBrowser()) { return 'PROXY " + proxy + "'; } "; " && isInIsolatedMozBrowser()) { return 'PROXY " + proxy + "'; } ";
} }
// Rules for system proxy. // Rules for system proxy.

View File

@ -500,23 +500,24 @@ bool PACMyAppOrigin(JSContext *cx, unsigned int argc, JS::Value *vp)
return GetRunning()->MyAppOrigin(args); return GetRunning()->MyAppOrigin(args);
} }
// IsInBrowser() javascript implementation // IsInIsolatedMozBrowser() javascript implementation
static static
bool PACIsInBrowser(JSContext *cx, unsigned int argc, JS::Value *vp) bool PACIsInIsolatedMozBrowser(JSContext *cx, unsigned int argc, JS::Value *vp)
{ {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
NS_WARNING("PACIsInBrowser on Main Thread. How did that happen?"); NS_WARNING("PACIsInIsolatedMozBrowser on Main Thread. How did that happen?");
return false; return false;
} }
if (!GetRunning()) { if (!GetRunning()) {
NS_WARNING("PACIsInBrowser without a running ProxyAutoConfig object"); NS_WARNING("PACIsInIsolatedMozBrowser without a running ProxyAutoConfig"
"object");
return false; return false;
} }
return GetRunning()->IsInBrowser(args); return GetRunning()->IsInIsolatedMozBrowser(args);
} }
// proxyAlert(msg) javascript implementation // proxyAlert(msg) javascript implementation
@ -554,7 +555,7 @@ static const JSFunctionSpec PACGlobalFunctions[] = {
JS_FS("myIpAddress", PACMyIpAddress, 0, 0), JS_FS("myIpAddress", PACMyIpAddress, 0, 0),
JS_FS("myAppId", PACMyAppId, 0, 0), JS_FS("myAppId", PACMyAppId, 0, 0),
JS_FS("myAppOrigin", PACMyAppOrigin, 0, 0), JS_FS("myAppOrigin", PACMyAppOrigin, 0, 0),
JS_FS("isInBrowser", PACIsInBrowser, 0, 0), JS_FS("isInIsolatedMozBrowser", PACIsInIsolatedMozBrowser, 0, 0),
JS_FS("alert", PACProxyAlert, 1, 0), JS_FS("alert", PACProxyAlert, 1, 0),
JS_FS_END JS_FS_END
}; };
@ -764,7 +765,7 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
const nsCString &aTestHost, const nsCString &aTestHost,
uint32_t aAppId, uint32_t aAppId,
const nsString &aAppOrigin, const nsString &aAppOrigin,
bool aIsInBrowser, bool aIsInIsolatedMozBrowser,
nsACString &result) nsACString &result)
{ {
if (mJSNeedsSetup) if (mJSNeedsSetup)
@ -783,7 +784,7 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
mRunningHost = aTestHost; mRunningHost = aTestHost;
mRunningAppId = aAppId; mRunningAppId = aAppId;
mRunningAppOrigin = aAppOrigin; mRunningAppOrigin = aAppOrigin;
mRunningIsInBrowser = aIsInBrowser; mRunningIsInIsolatedMozBrowser = aIsInIsolatedMozBrowser;
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
JS::RootedString uriString(cx, JS_NewStringCopyZ(cx, aTestURI.get())); JS::RootedString uriString(cx, JS_NewStringCopyZ(cx, aTestURI.get()));
@ -1015,9 +1016,9 @@ ProxyAutoConfig::MyAppOrigin(const JS::CallArgs &aArgs)
} }
bool bool
ProxyAutoConfig::IsInBrowser(const JS::CallArgs &aArgs) ProxyAutoConfig::IsInIsolatedMozBrowser(const JS::CallArgs &aArgs)
{ {
aArgs.rval().setBoolean(mRunningIsInBrowser); aArgs.rval().setBoolean(mRunningIsInIsolatedMozBrowser);
return true; return true;
} }

View File

@ -37,7 +37,7 @@ public:
bool MyIPAddress(const JS::CallArgs &aArgs); bool MyIPAddress(const JS::CallArgs &aArgs);
bool MyAppId(const JS::CallArgs &aArgs); bool MyAppId(const JS::CallArgs &aArgs);
bool MyAppOrigin(const JS::CallArgs &aArgs); bool MyAppOrigin(const JS::CallArgs &aArgs);
bool IsInBrowser(const JS::CallArgs &aArgs); bool IsInIsolatedMozBrowser(const JS::CallArgs &aArgs);
bool ResolveAddress(const nsCString &aHostName, bool ResolveAddress(const nsCString &aHostName,
NetAddr *aNetAddr, unsigned int aTimeout); NetAddr *aNetAddr, unsigned int aTimeout);
@ -75,8 +75,12 @@ public:
* The id of the app requesting connection. * The id of the app requesting connection.
* @param aAppOrigin * @param aAppOrigin
* The origin of the app requesting connection. * The origin of the app requesting connection.
* @param aIsInBrowser * @param aIsInIsolatedMozBrowser
* True if the iframe has mozbrowser but has no mozapp attribute. * True if the frame is 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.
* *
* @param result * @param result
* result string as defined above. * result string as defined above.
@ -85,7 +89,7 @@ public:
const nsCString &aTestHost, const nsCString &aTestHost,
uint32_t aAppId, uint32_t aAppId,
const nsString &aAppOrigin, const nsString &aAppOrigin,
bool aIsInBrowser, bool aIsInIsolatedMozBrowser,
nsACString &result); nsACString &result);
private: private:
@ -107,7 +111,7 @@ private:
nsCString mRunningHost; nsCString mRunningHost;
uint32_t mRunningAppId; uint32_t mRunningAppId;
nsString mRunningAppOrigin; nsString mRunningAppOrigin;
bool mRunningIsInBrowser; bool mRunningIsInIsolatedMozBrowser;
nsCOMPtr<nsITimer> mTimer; nsCOMPtr<nsITimer> mTimer;
}; };

View File

@ -559,10 +559,10 @@ NS_LoadGroupMatchesPrincipal(nsILoadGroup *aLoadGroup,
// Verify load context appId and browser flag match the principal // Verify load context appId and browser flag match the principal
uint32_t contextAppId; uint32_t contextAppId;
bool contextInBrowserElement; bool contextInIsolatedBrowser;
rv = loadContext->GetAppId(&contextAppId); rv = loadContext->GetAppId(&contextAppId);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInBrowserElement(&contextInBrowserElement); rv = loadContext->GetIsInIsolatedMozBrowserElement(&contextInIsolatedBrowser);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
uint32_t principalAppId; uint32_t principalAppId;
@ -573,7 +573,7 @@ NS_LoadGroupMatchesPrincipal(nsILoadGroup *aLoadGroup,
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
return contextAppId == principalAppId && return contextAppId == principalAppId &&
contextInBrowserElement == principalInIsolatedBrowser; contextInIsolatedBrowser == principalInIsolatedBrowser;
} }
nsresult nsresult
@ -1262,7 +1262,7 @@ NS_GetOriginAttributes(nsIChannel *aChannel,
bool bool
NS_GetAppInfo(nsIChannel *aChannel, NS_GetAppInfo(nsIChannel *aChannel,
uint32_t *aAppID, uint32_t *aAppID,
bool *aIsInBrowserElement) bool *aIsInIsolatedMozBrowserElement)
{ {
nsCOMPtr<nsILoadContext> loadContext; nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(aChannel, loadContext); NS_QueryNotificationCallbacks(aChannel, loadContext);
@ -1273,7 +1273,7 @@ NS_GetAppInfo(nsIChannel *aChannel,
nsresult rv = loadContext->GetAppId(aAppID); nsresult rv = loadContext->GetAppId(aAppID);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInBrowserElement(aIsInBrowserElement); rv = loadContext->GetIsInIsolatedMozBrowserElement(aIsInIsolatedMozBrowserElement);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, false);
return true; return true;

View File

@ -709,12 +709,12 @@ bool NS_HasBeenCrossOrigin(nsIChannel* aChannel, bool aReport = false);
#define NECKO_SAFEBROWSING_APP_ID UINT32_MAX - 1 #define NECKO_SAFEBROWSING_APP_ID UINT32_MAX - 1
/** /**
* Gets AppId and isInBrowserElement from channel's nsILoadContext. * Gets AppId and isInIsolatedMozBrowserElement from channel's nsILoadContext.
* Returns false if error or channel's callbacks don't implement nsILoadContext. * Returns false if error or channel's callbacks don't implement nsILoadContext.
*/ */
bool NS_GetAppInfo(nsIChannel *aChannel, bool NS_GetAppInfo(nsIChannel *aChannel,
uint32_t *aAppID, uint32_t *aAppID,
bool *aIsInBrowserElement); bool *aIsInIsolatedMozBrowserElement);
/** /**
* Gets appId and browserOnly parameters from the TOPIC_WEB_APP_CLEAR_DATA * Gets appId and browserOnly parameters from the TOPIC_WEB_APP_CLEAR_DATA

View File

@ -237,12 +237,12 @@ private:
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
PendingPACQuery::PendingPACQuery(nsPACMan *pacMan, nsIURI *uri, PendingPACQuery::PendingPACQuery(nsPACMan *pacMan, nsIURI *uri,
uint32_t appId, bool isInBrowser, uint32_t appId, bool isInIsolatedMozBrowser,
nsPACManCallback *callback, nsPACManCallback *callback,
bool mainThreadResponse) bool mainThreadResponse)
: mPACMan(pacMan) : mPACMan(pacMan)
, mAppId(appId) , mAppId(appId)
, mIsInBrowser(isInBrowser) , mIsInIsolatedMozBrowser(isInIsolatedMozBrowser)
, mCallback(callback) , mCallback(callback)
, mOnMainThreadOnly(mainThreadResponse) , mOnMainThreadOnly(mainThreadResponse)
{ {
@ -351,7 +351,8 @@ nsPACMan::Shutdown()
nsresult nsresult
nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId, nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId,
bool isInBrowser, nsPACManCallback *callback, bool isInIsolatedMozBrowser,
nsPACManCallback *callback,
bool mainThreadResponse) bool mainThreadResponse)
{ {
MOZ_ASSERT(NS_IsMainThread(), "wrong thread"); MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
@ -364,7 +365,7 @@ nsPACMan::AsyncGetProxyForURI(nsIURI *uri, uint32_t appId,
LoadPACFromURI(EmptyCString()); LoadPACFromURI(EmptyCString());
RefPtr<PendingPACQuery> query = RefPtr<PendingPACQuery> query =
new PendingPACQuery(this, uri, appId, isInBrowser, callback, new PendingPACQuery(this, uri, appId, isInIsolatedMozBrowser, callback,
mainThreadResponse); mainThreadResponse);
if (IsPACURI(uri)) { if (IsPACURI(uri)) {
@ -620,7 +621,7 @@ nsPACMan::ProcessPending()
if (!completed) { if (!completed) {
nsresult status = mPAC.GetProxyForURI(query->mSpec, query->mHost, nsresult status = mPAC.GetProxyForURI(query->mSpec, query->mHost,
query->mAppId, query->mAppOrigin, query->mAppId, query->mAppOrigin,
query->mIsInBrowser, query->mIsInIsolatedMozBrowser,
pacString); pacString);
query->Complete(status, pacString); query->Complete(status, pacString);
} }
@ -773,4 +774,3 @@ nsPACMan::Init(nsISystemProxySettings *systemProxySettings)
return NS_OK; return NS_OK;
} }

View File

@ -55,7 +55,7 @@ class PendingPACQuery final : public nsRunnable,
{ {
public: public:
PendingPACQuery(nsPACMan *pacMan, nsIURI *uri, uint32_t appId, PendingPACQuery(nsPACMan *pacMan, nsIURI *uri, uint32_t appId,
bool isInBrowser, nsPACManCallback *callback, bool isInIsolatedMozBrowser, nsPACManCallback *callback,
bool mainThreadResponse); bool mainThreadResponse);
// can be called from either thread // can be called from either thread
@ -74,7 +74,7 @@ private:
public: public:
uint32_t mAppId; uint32_t mAppId;
bool mIsInBrowser; bool mIsInIsolatedMozBrowser;
nsString mAppOrigin; nsString mAppOrigin;
private: private:

View File

@ -104,7 +104,7 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
nsAsyncResolveRequest(nsProtocolProxyService *pps, nsIChannel *channel, nsAsyncResolveRequest(nsProtocolProxyService *pps, nsIChannel *channel,
uint32_t aAppId, bool aIsInBrowser, uint32_t aAppId, bool aIsInIsolatedMozBrowser,
uint32_t aResolveFlags, uint32_t aResolveFlags,
nsIProtocolProxyCallback *callback) nsIProtocolProxyCallback *callback)
: mStatus(NS_OK) : mStatus(NS_OK)
@ -114,7 +114,7 @@ public:
, mXPComPPS(pps) , mXPComPPS(pps)
, mChannel(channel) , mChannel(channel)
, mAppId(aAppId) , mAppId(aAppId)
, mIsInBrowser(aIsInBrowser) , mIsInIsolatedMozBrowser(aIsInIsolatedMozBrowser)
, mCallback(callback) , mCallback(callback)
{ {
NS_ASSERTION(mCallback, "null callback"); NS_ASSERTION(mCallback, "null callback");
@ -256,10 +256,10 @@ private:
// now that the load is triggered, we can resubmit the query // now that the load is triggered, we can resubmit the query
RefPtr<nsAsyncResolveRequest> newRequest = RefPtr<nsAsyncResolveRequest> newRequest =
new nsAsyncResolveRequest(mPPS, mChannel, mAppId, new nsAsyncResolveRequest(mPPS, mChannel, mAppId,
mIsInBrowser, mResolveFlags, mIsInIsolatedMozBrowser, mResolveFlags,
mCallback); mCallback);
rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI, mAppId, rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI, mAppId,
mIsInBrowser, mIsInIsolatedMozBrowser,
newRequest, newRequest,
true); true);
} }
@ -299,7 +299,7 @@ private:
nsCOMPtr<nsIProtocolProxyService> mXPComPPS; nsCOMPtr<nsIProtocolProxyService> mXPComPPS;
nsCOMPtr<nsIChannel> mChannel; nsCOMPtr<nsIChannel> mChannel;
uint32_t mAppId; uint32_t mAppId;
bool mIsInBrowser; bool mIsInIsolatedMozBrowser;
nsCOMPtr<nsIProtocolProxyCallback> mCallback; nsCOMPtr<nsIProtocolProxyCallback> mCallback;
nsCOMPtr<nsIProxyInfo> mProxyInfo; nsCOMPtr<nsIProxyInfo> mProxyInfo;
}; };
@ -1261,13 +1261,13 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
uint32_t appId = NECKO_NO_APP_ID; uint32_t appId = NECKO_NO_APP_ID;
bool isInBrowser = false; bool isInIsolatedMozBrowser = false;
NS_GetAppInfo(channel, &appId, &isInBrowser); NS_GetAppInfo(channel, &appId, &isInIsolatedMozBrowser);
*result = nullptr; *result = nullptr;
RefPtr<nsAsyncResolveRequest> ctx = RefPtr<nsAsyncResolveRequest> ctx =
new nsAsyncResolveRequest(this, channel, appId, isInBrowser, flags, new nsAsyncResolveRequest(this, channel, appId, isInIsolatedMozBrowser,
callback); flags, callback);
nsProtocolInfo info; nsProtocolInfo info;
rv = GetProtocolInfo(uri, &info); rv = GetProtocolInfo(uri, &info);
@ -1281,7 +1281,7 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
// but if neither of them are in use, we can just do the work // but if neither of them are in use, we can just do the work
// right here and directly invoke the callback // right here and directly invoke the callback
rv = Resolve_Internal(channel, appId, isInBrowser, info, flags, rv = Resolve_Internal(channel, appId, isInIsolatedMozBrowser, info, flags,
&usePACThread, getter_AddRefs(pi)); &usePACThread, getter_AddRefs(pi));
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
@ -1303,7 +1303,8 @@ nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags
// else kick off a PAC thread query // else kick off a PAC thread query
rv = mPACMan->AsyncGetProxyForURI(uri, appId, isInBrowser, ctx, true); rv = mPACMan->AsyncGetProxyForURI(uri, appId, isInIsolatedMozBrowser, ctx,
true);
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
ctx.forget(result); ctx.forget(result);
return rv; return rv;

View File

@ -138,7 +138,7 @@ nsHttpTransaction::nsHttpTransaction()
, mCountRecv(0) , mCountRecv(0)
, mCountSent(0) , mCountSent(0)
, mAppId(NECKO_NO_APP_ID) , mAppId(NECKO_NO_APP_ID)
, mIsInBrowser(false) , mIsInIsolatedMozBrowser(false)
, mClassOfService(0) , mClassOfService(0)
{ {
LOG(("Creating nsHttpTransaction @%p\n", this)); LOG(("Creating nsHttpTransaction @%p\n", this));
@ -248,7 +248,7 @@ nsHttpTransaction::Init(uint32_t caps,
mChannel = do_QueryInterface(eventsink); mChannel = do_QueryInterface(eventsink);
nsCOMPtr<nsIChannel> channel = do_QueryInterface(eventsink); nsCOMPtr<nsIChannel> channel = do_QueryInterface(eventsink);
if (channel) { if (channel) {
NS_GetAppInfo(channel, &mAppId, &mIsInBrowser); NS_GetAppInfo(channel, &mAppId, &mIsInIsolatedMozBrowser);
} }
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
@ -869,9 +869,9 @@ nsHttpTransaction::SaveNetworkStats(bool enforce)
} }
// Create the event to save the network statistics. // Create the event to save the network statistics.
// the event is then dispathed to the main thread. // the event is then dispatched to the main thread.
RefPtr<nsRunnable> event = RefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo, new SaveNetworkStatsEvent(mAppId, mIsInIsolatedMozBrowser, mActiveNetworkInfo,
mCountRecv, mCountSent, false); mCountRecv, mCountSent, false);
NS_DispatchToMainThread(event); NS_DispatchToMainThread(event);

View File

@ -417,7 +417,7 @@ private:
uint64_t mCountRecv; uint64_t mCountRecv;
uint64_t mCountSent; uint64_t mCountSent;
uint32_t mAppId; uint32_t mAppId;
bool mIsInBrowser; bool mIsInIsolatedMozBrowser;
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo; nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif #endif

View File

@ -1176,7 +1176,7 @@ WebSocketChannel::WebSocketChannel() :
mCountRecv(0), mCountRecv(0),
mCountSent(0), mCountSent(0),
mAppId(NECKO_NO_APP_ID), mAppId(NECKO_NO_APP_ID),
mIsInBrowser(false) mIsInIsolatedMozBrowser(false)
{ {
MOZ_ASSERT(NS_IsMainThread(), "not main thread"); MOZ_ASSERT(NS_IsMainThread(), "not main thread");
@ -1388,7 +1388,7 @@ WebSocketChannel::BeginOpenInternal()
} }
if (localChannel) { if (localChannel) {
NS_GetAppInfo(localChannel, &mAppId, &mIsInBrowser); NS_GetAppInfo(localChannel, &mAppId, &mIsInIsolatedMozBrowser);
} }
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
@ -3909,9 +3909,9 @@ WebSocketChannel::SaveNetworkStats(bool enforce)
} }
// Create the event to save the network statistics. // Create the event to save the network statistics.
// the event is then dispathed to the main thread. // the event is then dispatched to the main thread.
RefPtr<nsRunnable> event = RefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo, new SaveNetworkStatsEvent(mAppId, mIsInIsolatedMozBrowser, mActiveNetworkInfo,
countRecv, countSent, false); countRecv, countSent, false);
NS_DispatchToMainThread(event); NS_DispatchToMainThread(event);

View File

@ -300,7 +300,7 @@ private:
Atomic<uint64_t, Relaxed> mCountRecv; Atomic<uint64_t, Relaxed> mCountRecv;
Atomic<uint64_t, Relaxed> mCountSent; Atomic<uint64_t, Relaxed> mCountSent;
uint32_t mAppId; uint32_t mAppId;
bool mIsInBrowser; bool mIsInIsolatedMozBrowser;
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo; nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif #endif

View File

@ -210,7 +210,7 @@ ChannelEventSink.prototype = {
*/ */
function LoadContextCallback(appId, inIsolatedMozBrowser, isPrivate, isContent) { function LoadContextCallback(appId, inIsolatedMozBrowser, isPrivate, isContent) {
this.appId = appId; this.appId = appId;
this.isInBrowserElement = inIsolatedMozBrowser; this.isInIsolatedMozBrowserElement = inIsolatedMozBrowser;
this.originAttributes = { this.originAttributes = {
appId: appId, appId: appId,
inIsolatedMozBrowser: inIsolatedMozBrowser inIsolatedMozBrowser: inIsolatedMozBrowser
@ -239,4 +239,3 @@ LoadContextCallback.prototype = {
throw Cr.NS_ERROR_NO_INTERFACE; throw Cr.NS_ERROR_NO_INTERFACE;
}, },
} }

View File

@ -24,7 +24,7 @@ function makeChan(url, appId, inIsolatedMozBrowser) {
.QueryInterface(Ci.nsIHttpChannel); .QueryInterface(Ci.nsIHttpChannel);
chan.notificationCallbacks = { chan.notificationCallbacks = {
appId: appId, appId: appId,
isInBrowserElement: inIsolatedMozBrowser, isInIsolatedMozBrowserElement: inIsolatedMozBrowser,
originAttributes: { originAttributes: {
appId: appId, appId: appId,
inIsolatedMozBrowser: inIsolatedMozBrowser, inIsolatedMozBrowser: inIsolatedMozBrowser,
@ -98,7 +98,7 @@ function run_test() {
function doneFirstLoad(req, buffer, expected) { function doneFirstLoad(req, buffer, expected) {
// Load it again, make sure it hits the cache // Load it again, make sure it hits the cache
var nc = req.notificationCallbacks.getInterface(Ci.nsILoadContext); var nc = req.notificationCallbacks.getInterface(Ci.nsILoadContext);
var chan = makeChan(URL, nc.appId, nc.isInBrowserElement); var chan = makeChan(URL, nc.appId, nc.isInIsolatedMozBrowserElement);
chan.asyncOpen2(new ChannelListener(doneSecondLoad, expected)); chan.asyncOpen2(new ChannelListener(doneSecondLoad, expected));
} }

View File

@ -568,7 +568,7 @@ function run_pac3_test() {
function run_pac4_test() { function run_pac4_test() {
var appId = 10; var appId = 10;
var isInBrowser = true; var isInIsolatedMozBrowser = true;
var appOrigin = "apps://browser.gaiamobile.com"; var appOrigin = "apps://browser.gaiamobile.com";
// We have to setup a profile, otherwise indexed db used by webapps // We have to setup a profile, otherwise indexed db used by webapps
@ -589,7 +589,7 @@ function run_pac4_test() {
var pac = 'data:text/plain,' + var pac = 'data:text/plain,' +
'function FindProxyForURL(url, host) {' + 'function FindProxyForURL(url, host) {' +
' if (myAppId() == ' + appId + ' if (myAppId() == ' + appId +
' && isInBrowser() == ' + isInBrowser + ' && isInIsolatedMozBrowser() == ' + isInIsolatedMozBrowser +
' && myAppOrigin() == "' + appOrigin + '")' + ' && myAppOrigin() == "' + appOrigin + '")' +
' return "PROXY foopy:8080; DIRECT";' + ' return "PROXY foopy:8080; DIRECT";' +
'}'; '}';
@ -598,7 +598,7 @@ function run_pac4_test() {
loadUsingSystemPrincipal: true loadUsingSystemPrincipal: true
}); });
channel.notificationCallbacks = channel.notificationCallbacks =
AppsUtils.createLoadContext(appId, isInBrowser); AppsUtils.createLoadContext(appId, isInIsolatedMozBrowser);
// Configure PAC // Configure PAC
prefs.setIntPref("network.proxy.type", 2); prefs.setIntPref("network.proxy.type", 2);

View File

@ -11,7 +11,7 @@ function makeChan(url, appId, inIsolatedMozBrowser) {
.QueryInterface(Ci.nsIHttpChannel); .QueryInterface(Ci.nsIHttpChannel);
chan.notificationCallbacks = { chan.notificationCallbacks = {
appId: appId, appId: appId,
isInBrowserElement: inIsolatedMozBrowser, isInIsolatedMozBrowserElement: inIsolatedMozBrowser,
originAttributes: { originAttributes: {
appId: appId, appId: appId,
inIsolatedMozBrowser: inIsolatedMozBrowser, inIsolatedMozBrowser: inIsolatedMozBrowser,

View File

@ -259,10 +259,10 @@ OfflineCacheUpdateParent::SetRemoteTabs(bool aUseRemoteTabs)
} }
NS_IMETHODIMP NS_IMETHODIMP
OfflineCacheUpdateParent::GetIsInBrowserElement(bool *aIsInBrowserElement) OfflineCacheUpdateParent::GetIsInIsolatedMozBrowserElement(bool *aIsInIsolatedMozBrowserElement)
{ {
NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(mLoadingPrincipal, NS_ERROR_UNEXPECTED);
return mLoadingPrincipal->GetIsInIsolatedMozBrowserElement(aIsInBrowserElement); return mLoadingPrincipal->GetIsInIsolatedMozBrowserElement(aIsInIsolatedMozBrowserElement);
} }
NS_IMETHODIMP NS_IMETHODIMP