Bug 989046 - b. Drop JSON.stringify when calling handleGeckoMessage; r=mfinkle

This commit is contained in:
Jim Chen 2014-04-04 12:33:50 -04:00
parent 63fba87f92
commit 0d00aee3a9
10 changed files with 22 additions and 31 deletions

View File

@ -31,9 +31,8 @@ this.AccessFu = {
Utils.init(aWindow);
try {
let bridgeCc = Cc['@mozilla.org/android/bridge;1'];
bridgeCc.getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ type: 'Accessibility:Ready' }));
Services.androidBridge.handleGeckoMessage(
{ type: 'Accessibility:Ready' });
Services.obs.addObserver(this, 'Accessibility:Settings', false);
} catch (x) {
// Not on Android
@ -702,8 +701,7 @@ var Output = {
get androidBridge() {
delete this.androidBridge;
if (Utils.MozBuildApp === 'mobile/android') {
this.androidBridge = Cc['@mozilla.org/android/bridge;1'].getService(
Ci.nsIAndroidBridge);
this.androidBridge = Services.androidBridge;
} else {
this.androidBridge = null;
}
@ -734,7 +732,7 @@ var Output = {
androidEvent.brailleOutput = this.brailleState.init(androidEvent.brailleOutput);
break;
}
this.androidBridge.handleGeckoMessage(JSON.stringify(androidEvent));
this.androidBridge.handleGeckoMessage(androidEvent);
}
},
@ -902,9 +900,8 @@ var Input = {
if (Utils.MozBuildApp == 'mobile/android')
// Return focus to native Android browser chrome.
Cc['@mozilla.org/android/bridge;1'].
getService(Ci.nsIAndroidBridge).handleGeckoMessage(
JSON.stringify({ type: 'ToggleChrome:Focus' }));
Services.androidBridge.handleGeckoMessage(
{ type: 'ToggleChrome:Focus' });
break;
case aEvent.DOM_VK_RETURN:
if (this.editState.editing)

View File

@ -3,12 +3,8 @@
* 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/. */
let bridge = SpecialPowers.Cc["@mozilla.org/android/bridge;1"]
.getService(SpecialPowers.Ci.nsIAndroidBridge);
function sendMessageToJava(message) {
let data = JSON.stringify(message);
bridge.handleGeckoMessage(data);
SpecialPowers.Services.androidBridge.handleGeckoMessage(message);
}
function _evalURI(uri, sandbox) {

View File

@ -145,17 +145,17 @@
function checkForUpdates() {
showCheckingMessage();
Services.androidBridge.handleGeckoMessage(JSON.stringify({ type: "Update:Check" }));
Services.androidBridge.handleGeckoMessage({ type: "Update:Check" });
}
function downloadUpdate() {
Services.androidBridge.handleGeckoMessage(JSON.stringify({ type: "Update:Download" }));
Services.androidBridge.handleGeckoMessage({ type: "Update:Download" });
}
function installUpdate() {
showCheckAction();
Services.androidBridge.handleGeckoMessage(JSON.stringify({ type: "Update:Install" }));
Services.androidBridge.handleGeckoMessage({ type: "Update:Install" });
}
let updateLink = document.getElementById("updateLink");

View File

@ -225,7 +225,7 @@ FilePicker.prototype = {
},
sendMessageToJava: function(aMsg) {
Services.androidBridge.handleGeckoMessage(JSON.stringify(aMsg));
Services.androidBridge.handleGeckoMessage(aMsg);
},
observe: function(aSubject, aTopic, aData) {

View File

@ -47,7 +47,7 @@ let ContactService = {
},
_sendMessageToJava: function(aMsg) {
Services.androidBridge.handleGeckoMessage(JSON.stringify(aMsg));
Services.androidBridge.handleGeckoMessage(aMsg);
},
_sendReturnMessage: function(aTopic, aRequestID, aResult) {

View File

@ -39,6 +39,6 @@ LightweightThemeConsumer.prototype = {
let msg = active ? { type: "LightweightTheme:Update", data: aData } :
{ type: "LightweightTheme:Disable" };
Services.androidBridge.handleGeckoMessage(JSON.stringify(msg));
Services.androidBridge.handleGeckoMessage(msg);
}
}

View File

@ -37,5 +37,5 @@ function sendMessageToJava(aMessage, aCallback) {
Services.obs.addObserver(obs, aMessage.type + ":Error", false);
}
return Services.androidBridge.handleGeckoMessage(JSON.stringify(aMessage));
return Services.androidBridge.handleGeckoMessage(aMessage);
}

View File

@ -130,7 +130,7 @@ Notification.prototype = {
if (this._light)
msg.light = this._light;
Services.androidBridge.handleGeckoMessage(JSON.stringify(msg));
Services.androidBridge.handleGeckoMessage(msg);
return this;
},
@ -139,7 +139,7 @@ Notification.prototype = {
type: "Notification:Hide",
id: this._id
};
Services.androidBridge.handleGeckoMessage(JSON.stringify(msg));
Services.androidBridge.handleGeckoMessage(msg);
}
}

View File

@ -1,13 +1,15 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
function loadIntoWindow(window) {}
function unloadFromWindow(window) {}
function _sendMessageToJava (aMsg) {
let bridge = Cc["@mozilla.org/android/bridge;1"].getService(Ci.nsIAndroidBridge);
return bridge.handleGeckoMessage(JSON.stringify(aMsg));
return Services.androidBridge.handleGeckoMessage(aMsg);
};
/*

View File

@ -353,9 +353,7 @@ function copyRawDataToClipboard(button) {
message: stringBundle().GetStringFromName("rawDataCopied"),
duration: "short"
};
Cc["@mozilla.org/android/bridge;1"].
getService(Ci.nsIAndroidBridge).
handleGeckoMessage(JSON.stringify(message));
Services.androidBridge.handleGeckoMessage(message);
#endif
});
}
@ -409,9 +407,7 @@ function copyContentsToClipboard() {
message: stringBundle().GetStringFromName("textCopied"),
duration: "short"
};
Cc["@mozilla.org/android/bridge;1"].
getService(Ci.nsIAndroidBridge).
handleGeckoMessage(JSON.stringify(message));
Services.androidBridge.handleGeckoMessage(message);
#endif
}