Bug 758696 - Add a dialog to the debugger to deny or allow incoming server connections (Part 2: Fennec); r=mfinkle

This commit is contained in:
Panos Astithas 2012-06-01 18:25:54 +03:00
parent 0b6cecb6b6
commit 2c3c8d93cc
2 changed files with 34 additions and 1 deletions

View File

@ -5249,6 +5249,30 @@ var RemoteDebugger = {
return Services.prefs.getBoolPref("remote-debugger.enabled");
},
/**
* Prompt the user to accept or decline the incoming connection.
*
* @return true if the connection should be permitted, false otherwise
*/
_allowConnection: function rd_allowConnection() {
let title = Strings.browser.GetStringFromName("remoteIncomingPromptTitle");
let msg = Strings.browser.GetStringFromName("remoteIncomingPromptMessage");
let btn = Strings.browser.GetStringFromName("remoteIncomingPromptDisable");
let prompt = Services.prompt;
let flags = prompt.BUTTON_POS_0 * prompt.BUTTON_TITLE_OK +
prompt.BUTTON_POS_1 * prompt.BUTTON_TITLE_CANCEL +
prompt.BUTTON_POS_2 * prompt.BUTTON_TITLE_IS_STRING +
prompt.BUTTON_POS_1_DEFAULT;
let result = prompt.confirmEx(null, title, msg, flags, null, null, btn, null, { value: false });
if (result == 0)
return true;
if (result == 2) {
this._stop();
Services.prefs.setBoolPref("remote-debugger.enabled", false);
}
return false;
},
_restart: function rd_restart() {
this._stop();
this._start();
@ -5257,7 +5281,7 @@ var RemoteDebugger = {
_start: function rd_start() {
try {
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.init(this._allowConnection);
DebuggerServer.addActors("chrome://browser/content/dbg-browser-actors.js");
}

View File

@ -255,3 +255,12 @@ clickToPlayPlugins.playPlugins=Play Plugins
siteSettings.labelToValue=%S: %S
masterPassword.incorrect=Incorrect password
# Debugger
# LOCALIZATION NOTE (remoteIncomingPromptTitle): The title displayed on the
# dialog that prompts the user to allow the incoming connection.
remoteIncomingPromptTitle=Incoming Connection
# LOCALIZATION NOTE (remoteIncomingPromptMessage): The message displayed on the
# dialog that prompts the user to allow the incoming connection.
remoteIncomingPromptMessage=An incoming request to permit remote debugging connection was detected. A remote client can take complete control over your browser! Allow connection?
remoteIncomingPromptDisable=Disable