Created
April 26, 2010 05:42
-
-
Save yurenju/379012 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Ci = Components.interfaces; | |
const Cc = Components.classes; | |
const Cr = Components.results; | |
const Cu = Components.utils; | |
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | |
function promptService() { | |
let bundleService = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService); | |
this._bundle = bundleService.createBundle("chrome://global/locale/commonDialogs.properties"); | |
} | |
promptService.prototype = { | |
classDescription: "Mobile Prompt Service", | |
contractID: "@mozilla.org/embedcomp/prompt-service;1", | |
classID: Components.ID("{9a61149b-2276-4a0a-b79c-be994ad106cf}"), | |
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPromptService, Ci.nsIPromptService2]), | |
_getFallbackService: function() { | |
return Components.classesByID["{a2112d6a-0e28-421f-b46a-25c0B308cbd0}"] | |
.getService(Ci.nsIPromptService); | |
}, | |
alert: function(aParent, aTitle, aText) { | |
this._getFallbackService().alert(aParent, aTitle, aText); | |
return; | |
}, | |
alertCheck: function(aParent, aTitle, aText, aCheckMsg, aCheckState) { | |
this._getFallbackService().alertCheck(aParent, aTitle, aText, aCheckMsg, aCheckState); | |
return; | |
}, | |
confirm: function(aParent, aTitle, aText) { | |
return this._getFallbackService().confirm(aParent, aTitle, aText); | |
}, | |
confirmCheck: function(aParent, aTitle, aText, aCheckMsg, aCheckState) { | |
return this._getFallbackService().confirmCheck(aParent, aTitle, aText, aCheckMsg, aCheckState); | |
}, | |
confirmEx: function(aParent, aTitle, aText, aButtonFlags, aButton0, | |
aButton1, aButton2, aCheckMsg, aCheckState) { | |
this.alert (null, null, "test"); | |
return 1; | |
}, | |
prompt : function(aParent, aTitle, aText, aValue, aCheckMsg, aCheckState) { | |
return this._getFallbackService().prompt(aParent, aTitle, aText, aValue, aCheckMsg, aCheckState); | |
}, | |
promptPassword: function(aParent, aTitle, aText, aPassword, aCheckMsg, aCheckState) { | |
return this._getFallbackService().promptPassword(aParent, aTitle, aText, aPassword, aCheckMsg, aCheckState); | |
}, | |
promptUsernameAndPassword: function(aParent, aTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState) { | |
return this._getFallbackService().promptUsernameAndPassword(aParent, aTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState); | |
}, | |
select: function(aParent, aTitle, aText, aCount, aSelectList, aOutSelection) { | |
return this._getFallbackService().select(aParent, aTitle, aText, aCount, aSelectList, aOutSelection); | |
} | |
}; | |
//module initialization | |
function NSGetModule(aCompMgr, aFileSpec) { | |
return XPCOMUtils.generateModule([promptService]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment