Bug 988129 - Correct the chaotic naming styles in system message codes (part 3, s/uri/pageURL). r=fabrice

This commit is contained in:
Gene Lian 2014-03-31 16:04:36 +08:00
parent 3d7539977a
commit ef988a9700
4 changed files with 49 additions and 49 deletions

View File

@ -597,7 +597,7 @@ var shell = {
openAppForSystemMessage: function shell_openAppForSystemMessage(msg) {
let payload = {
url: msg.uri,
url: msg.pageURL,
manifestURL: msg.manifestURL,
isActivity: (msg.type == 'activity'),
onlyShowApp: msg.onlyShowApp,

View File

@ -235,7 +235,7 @@ SystemMessageInternal.prototype = {
let result = this._sendMessageCommon(aType,
aMessage,
messageID,
aPage.uri,
aPage.pageURL,
aPage.manifestURL,
aExtra);
debug("Returned status of sending message: " + result);
@ -272,7 +272,7 @@ SystemMessageInternal.prototype = {
}
this._pages.push({ type: aType,
uri: pageURL,
pageURL: pageURL,
manifestURL: manifestURL,
pendingMessages: [] });
},
@ -297,7 +297,7 @@ SystemMessageInternal.prototype = {
return true;
},
_removeTargetFromListener: function(aTarget, aManifestURL, aRemoveListener, aUri) {
_removeTargetFromListener: function(aTarget, aManifestURL, aRemoveListener, aPageURL) {
let targets = this._listeners[aManifestURL];
if (!targets) {
return false;
@ -315,9 +315,9 @@ SystemMessageInternal.prototype = {
}
let target = targets[index];
if (aUri && target.winCounts[aUri] !== undefined &&
--target.winCounts[aUri] === 0) {
delete target.winCounts[aUri];
if (aPageURL && target.winCounts[aPageURL] !== undefined &&
--target.winCounts[aPageURL] === 0) {
delete target.winCounts[aPageURL];
}
if (this._isEmptyObject(target.winCounts)) {
@ -357,25 +357,25 @@ SystemMessageInternal.prototype = {
break;
case "SystemMessageManager:Register":
{
debug("Got Register from " + msg.uri + " @ " + msg.manifestURL);
let uri = msg.uri;
debug("Got Register from " + msg.pageURL + " @ " + msg.manifestURL);
let pageURL = msg.pageURL;
let targets, index;
if (!(targets = this._listeners[msg.manifestURL])) {
let winCounts = {};
winCounts[uri] = 1;
winCounts[pageURL] = 1;
this._listeners[msg.manifestURL] = [{ target: aMessage.target,
winCounts: winCounts }];
} else if ((index = this._findTargetIndex(targets, aMessage.target)) === -1) {
let winCounts = {};
winCounts[uri] = 1;
winCounts[pageURL] = 1;
targets.push({ target: aMessage.target,
winCounts: winCounts });
} else {
let winCounts = targets[index].winCounts;
if (winCounts[uri] === undefined) {
winCounts[uri] = 1;
if (winCounts[pageURL] === undefined) {
winCounts[pageURL] = 1;
} else {
winCounts[uri]++;
winCounts[pageURL]++;
}
}
@ -396,17 +396,17 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Unregister":
{
debug("Got Unregister from " + aMessage.target + "innerWinID " + msg.innerWindowID);
this._removeTargetFromListener(aMessage.target, msg.manifestURL, false, msg.uri);
this._removeTargetFromListener(aMessage.target, msg.manifestURL, false, msg.pageURL);
break;
}
case "SystemMessageManager:GetPendingMessages":
{
debug("received SystemMessageManager:GetPendingMessages " + msg.type +
" for " + msg.uri + " @ " + msg.manifestURL);
" for " + msg.pageURL + " @ " + msg.manifestURL);
// This is a sync call used to return the pending messages for a page.
// Find the right page to get its corresponding pending messages.
let page = this._findPage(msg.type, msg.uri, msg.manifestURL);
let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
if (!page) {
return;
}
@ -426,18 +426,18 @@ SystemMessageInternal.prototype = {
.sendAsyncMessage("SystemMessageManager:GetPendingMessages:Return",
{ type: msg.type,
manifestURL: msg.manifestURL,
uri: msg.uri,
pageURL: msg.pageURL,
msgQueue: pendingMessages });
break;
}
case "SystemMessageManager:HasPendingMessages":
{
debug("received SystemMessageManager:HasPendingMessages " + msg.type +
" for " + msg.uri + " @ " + msg.manifestURL);
" for " + msg.pageURL + " @ " + msg.manifestURL);
// This is a sync call used to return if a page has pending messages.
// Find the right page to get its corresponding pending messages.
let page = this._findPage(msg.type, msg.uri, msg.manifestURL);
let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
if (!page) {
return false;
}
@ -448,11 +448,11 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:Message:Return:OK":
{
debug("received SystemMessageManager:Message:Return:OK " + msg.type +
" for " + msg.uri + " @ " + msg.manifestURL);
" for " + msg.pageURL + " @ " + msg.manifestURL);
// We need to clean up the pending message since the app has already
// received it, thus avoiding the re-lanunched app handling it again.
let page = this._findPage(msg.type, msg.uri, msg.manifestURL);
let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
if (page) {
let pendingMessages = page.pendingMessages;
for (let i = 0; i < pendingMessages.length; i++) {
@ -467,7 +467,7 @@ SystemMessageInternal.prototype = {
case "SystemMessageManager:HandleMessagesDone":
{
debug("received SystemMessageManager:HandleMessagesDone " + msg.type +
" with " + msg.handledCount + " for " + msg.uri + " @ " + msg.manifestURL);
" with " + msg.handledCount + " for " + msg.pageURL + " @ " + msg.manifestURL);
// A page has finished handling some of its system messages, so we try
// to release the CPU wake lock we acquired on behalf of that page.
@ -538,7 +538,7 @@ SystemMessageInternal.prototype = {
let onlyShowApp = (aMsgSentStatus === MSG_SENT_SUCCESS) && showApp;
// We don't need to send the full object to observers.
let page = { uri: aPage.uri,
let page = { pageURL: aPage.pageURL,
manifestURL: aPage.manifestURL,
type: aPage.type,
extra: aExtra,
@ -549,10 +549,10 @@ SystemMessageInternal.prototype = {
Services.obs.notifyObservers(this, "system-messages-open-app", JSON.stringify(page));
},
_isPageMatched: function(aPage, aType, aPageURI, aManifestURL) {
_isPageMatched: function(aPage, aType, aPageURL, aManifestURL) {
return (aPage.type === aType &&
aPage.manifestURL === aManifestURL &&
aPage.uri === aPageURI)
aPage.pageURL === aPageURL)
},
_createKeyForPage: function _createKeyForPage(aPage) {
@ -564,8 +564,8 @@ SystemMessageInternal.prototype = {
.createInstance(Ci.nsICryptoHash);
hasher.init(hasher.SHA1);
// add uri and action to the hash
["type", "manifestURL", "uri"].forEach(function(aProp) {
// add manifest/page URL and action to the hash
["type", "manifestURL", "pageURL"].forEach(function(aProp) {
let data = converter.convertToByteArray(aPage[aProp], {});
hasher.update(data, data.length);
});
@ -574,11 +574,11 @@ SystemMessageInternal.prototype = {
},
_sendMessageCommon: function(aType, aMessage, aMessageID,
aPageURI, aManifestURL, aExtra) {
aPageURL, aManifestURL, aExtra) {
// Don't send the system message not granted by the app's permissions.
if (!SystemMessagePermissionsChecker
.isSystemMessagePermittedToSend(aType,
aPageURI,
aPageURL,
aManifestURL)) {
return MSG_SENT_FAILURE_PERM_DENIED;
}
@ -586,7 +586,7 @@ SystemMessageInternal.prototype = {
let appPageIsRunning = false;
let pageKey = this._createKeyForPage({ type: aType,
manifestURL: aManifestURL,
uri: aPageURI });
pageURL: aPageURL });
let targets = this._listeners[aManifestURL];
if (targets) {
@ -595,7 +595,7 @@ SystemMessageInternal.prototype = {
// We only need to send the system message to the targets (processes)
// which contain the window page that matches the manifest/page URL of
// the destination of system message.
if (target.winCounts[aPageURI] === undefined) {
if (target.winCounts[aPageURL] === undefined) {
continue;
}
@ -614,7 +614,7 @@ SystemMessageInternal.prototype = {
{ type: aType,
msg: aMessage,
manifestURL: aManifestURL,
uri: aPageURI,
pageURL: aPageURL,
msgID: aMessageID });
}
}

View File

@ -100,7 +100,7 @@ SystemMessageManager.prototype = {
cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
{ type: aType,
manifestURL: this._manifestURL,
uri: this._uri,
pageURL: this._pageURL,
handledCount: 1 });
aDispatcher.isHandling = false;
@ -137,7 +137,7 @@ SystemMessageManager.prototype = {
// Ask for the list of currently pending messages.
cpmm.sendAsyncMessage("SystemMessageManager:GetPendingMessages",
{ type: aType,
uri: this._uri,
pageURL: this._pageURL,
manifestURL: this._manifestURL });
},
@ -157,7 +157,7 @@ SystemMessageManager.prototype = {
return cpmm.sendSyncMessage("SystemMessageManager:HasPendingMessages",
{ type: aType,
uri: this._uri,
pageURL: this._pageURL,
manifestURL: this._manifestURL })[0];
},
@ -177,7 +177,7 @@ SystemMessageManager.prototype = {
cpmm.sendAsyncMessage("SystemMessageManager:Unregister",
{ manifestURL: this._manifestURL,
uri: this._uri,
pageURL: this._pageURL,
innerWindowID: this.innerWindowID });
},
@ -194,14 +194,14 @@ SystemMessageManager.prototype = {
receiveMessage: function(aMessage) {
let msg = aMessage.data;
debug("receiveMessage " + aMessage.name + " for [" + msg.type + "] " +
"with manifest URL = " + msg.manifestURL + " and uri = " + msg.uri);
"with manifest URL = " + msg.manifestURL + " and page URL = " + msg.pageURL);
// Multiple windows can share the same target (process), the content
// window needs to check if the manifest/page URL is matched. Only
// *one* window should handle the system message.
if (msg.manifestURL !== this._manifestURL || msg.uri !== this._uri) {
if (msg.manifestURL !== this._manifestURL || msg.pageURL !== this._pageURL) {
debug("This page shouldn't handle the messages because its " +
"manifest URL = " + this._manifestURL + " and uri = " + this._uri);
"manifest URL = " + this._manifestURL + " and page URL = " + this._pageURL);
return;
}
@ -211,7 +211,7 @@ SystemMessageManager.prototype = {
cpmm.sendAsyncMessage("SystemMessageManager:Message:Return:OK",
{ type: msg.type,
manifestURL: this._manifestURL,
uri: this._uri,
pageURL: this._pageURL,
msgID: msg.msgID });
}
@ -232,7 +232,7 @@ SystemMessageManager.prototype = {
cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
{ type: msg.type,
manifestURL: this._manifestURL,
uri: this._uri,
pageURL: this._pageURL,
handledCount: messages.length });
}
@ -252,7 +252,7 @@ SystemMessageManager.prototype = {
let principal = aWindow.document.nodePrincipal;
this._isInBrowserElement = principal.isInBrowserElement;
this._uri = principal.URI.spec;
this._pageURL = principal.URI.spec;
let appsService = Cc["@mozilla.org/AppsService;1"]
.getService(Ci.nsIAppsService);
@ -296,7 +296,7 @@ SystemMessageManager.prototype = {
if (!this._registerManifestURLReady) {
cpmm.sendAsyncMessage("SystemMessageManager:Register",
{ manifestURL: this._manifestURL,
uri: this._uri,
pageURL: this._pageURL,
innerWindowID: this.innerWindowID });
this._registerManifestURLReady = true;

View File

@ -249,18 +249,18 @@ this.SystemMessagePermissionsChecker = {
* app's page at run-time based on the current app's permissions.
* @param string aSysMsgName
* The system messsage name.
* @param string aPageURI
* The app's page URI.
* @param string aPageURL
* The app's page URL.
* @param string aManifestURL
* The app's manifest URL.
* @returns bool
* Is permitted or not.
**/
isSystemMessagePermittedToSend:
function isSystemMessagePermittedToSend(aSysMsgName, aPageURI, aManifestURL) {
function isSystemMessagePermittedToSend(aSysMsgName, aPageURL, aManifestURL) {
debug("isSystemMessagePermittedToSend(): " +
"aSysMsgName: " + aSysMsgName + ", " +
"aPageURI: " + aPageURI + ", " +
"aPageURL: " + aPageURL + ", " +
"aManifestURL: " + aManifestURL);
let permNames = this.getSystemMessagePermissions(aSysMsgName);
@ -268,7 +268,7 @@ this.SystemMessagePermissionsChecker = {
return false;
}
let pageURI = Services.io.newURI(aPageURI, null, null);
let pageURI = Services.io.newURI(aPageURL, null, null);
for (let permName in permNames) {
let permNamesWithAccess = permNames[permName];