Bug 758696 - Add a dialog to the debugger to deny or allow incoming server connections (Part 2: Fennec); r=mfinkle
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -5244,25 +5244,49 @@ var RemoteDebugger = {
_getPort: function _rd_getPort() {
return Services.prefs.getIntPref("remote-debugger.port");
},
_isEnabled: function rd_isEnabled() {
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();
},
_start: function rd_start() {
try {
if (!DebuggerServer.initialized) {
- DebuggerServer.init();
+ DebuggerServer.init(this._allowConnection);
DebuggerServer.addActors("chrome://browser/content/dbg-browser-actors.js");
}
let port = this._getPort();
DebuggerServer.openListener(port, false);
dump("Remote debugger listening on port " + port);
} catch(e) {
dump("Remote debugger didn't start: " + e);
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -250,8 +250,17 @@ clickToPlayPlugins.playPlugins=Play Plug
# Site settings dialog
# LOCALIZATION NOTE (siteSettings.labelToValue): This string will be used to
# dislay a list of current permissions settings for a site.
# Example: "Store Offline Data: Allow"
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