mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781515 - Use a default allowConnection handler in dbg-server.js so that add-ons don't have to provide their own. r=rcampbell, f=Pike,mgoodwin
This commit is contained in:
parent
c7397616ed
commit
a23a7fbcb1
@ -466,38 +466,12 @@ ChromeDebuggerProcess.prototype = {
|
||||
*/
|
||||
_initServer: function RDP__initServer() {
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init(this._allowConnection);
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
DebuggerServer.openListener(DebuggerPreferences.remotePort);
|
||||
},
|
||||
|
||||
/**
|
||||
* Prompt the user to accept or decline the incoming connection.
|
||||
*
|
||||
* @return true if the connection should be permitted, false otherwise
|
||||
*/
|
||||
_allowConnection: function RDP__allowConnection() {
|
||||
let title = L10N.getStr("remoteIncomingPromptTitle");
|
||||
let msg = L10N.getStr("remoteIncomingPromptMessage");
|
||||
let disableButton = L10N.getStr("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,
|
||||
disableButton, null, { value: false });
|
||||
if (result == 0) {
|
||||
return true;
|
||||
}
|
||||
if (result == 2) {
|
||||
DebuggerServer.closeListener(true);
|
||||
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", false);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a profile for the remote debugger process.
|
||||
*/
|
||||
|
@ -126,19 +126,6 @@ loadingText=Loading\u2026
|
||||
# %1$S=URL, %2$S=status code
|
||||
loadingError=Error loading %1$S: %2$S
|
||||
|
||||
# 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?
|
||||
|
||||
# LOCALIZATION NOTE (remoteIncomingPromptDisable): The label displayed on the
|
||||
# third button in the incoming connection dialog that lets the user disable the
|
||||
# remote debugger server.
|
||||
remoteIncomingPromptDisable=Disable
|
||||
|
||||
# LOCALIZATION NOTE (emptyVariablesText): The text that is displayed in the
|
||||
# variables pane when there are no variables to display.
|
||||
emptyVariablesText=No variables to display.
|
||||
|
@ -15,8 +15,10 @@ const Cc = Components.classes;
|
||||
const CC = Components.Constructor;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
const DBG_STRINGS_URI = "chrome://global/locale/devtools/debugger.properties";
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
|
||||
|
||||
Cu.import("resource://gre/modules/jsdebugger.jsm");
|
||||
@ -59,7 +61,6 @@ var DebuggerServer = {
|
||||
_listener: null,
|
||||
_transportInitialized: false,
|
||||
xpcInspector: null,
|
||||
_allowConnection: null,
|
||||
// Number of currently open TCP connections.
|
||||
_socketConnections: 0,
|
||||
// Map of global actor names to actor constructors provided by extensions.
|
||||
@ -70,6 +71,32 @@ var DebuggerServer = {
|
||||
LONG_STRING_LENGTH: 10000,
|
||||
LONG_STRING_INITIAL_LENGTH: 1000,
|
||||
|
||||
/**
|
||||
* Prompt the user to accept or decline the incoming connection.
|
||||
*
|
||||
* @return true if the connection should be permitted, false otherwise
|
||||
*/
|
||||
_allowConnection: function DH__allowConnection() {
|
||||
let title = L10N.getStr("remoteIncomingPromptTitle");
|
||||
let msg = L10N.getStr("remoteIncomingPromptMessage");
|
||||
let disableButton = L10N.getStr("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,
|
||||
disableButton, null, { value: false });
|
||||
if (result == 0) {
|
||||
return true;
|
||||
}
|
||||
if (result == 2) {
|
||||
DebuggerServer.closeListener(true);
|
||||
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", false);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize the debugger server.
|
||||
*
|
||||
@ -106,7 +133,9 @@ var DebuggerServer = {
|
||||
this._connections = {};
|
||||
this._nextConnID = 0;
|
||||
this._transportInitialized = true;
|
||||
this._allowConnection = aAllowConnectionCallback;
|
||||
if (aAllowConnectionCallback) {
|
||||
this._allowConnection = aAllowConnectionCallback;
|
||||
}
|
||||
},
|
||||
|
||||
get initialized() { return !!this.globalActorFactories; },
|
||||
@ -232,6 +261,9 @@ var DebuggerServer = {
|
||||
// nsIServerSocketListener implementation
|
||||
|
||||
onSocketAccepted: function DH_onSocketAccepted(aSocket, aTransport) {
|
||||
if (!this._allowConnection()) {
|
||||
return;
|
||||
}
|
||||
dumpn("New debugging connection on " + aTransport.host + ":" + aTransport.port);
|
||||
|
||||
try {
|
||||
@ -264,9 +296,6 @@ var DebuggerServer = {
|
||||
* after connectPipe() or after an incoming socket connection.
|
||||
*/
|
||||
_onConnection: function DH_onConnection(aTransport) {
|
||||
if (!this._allowConnection()) {
|
||||
return;
|
||||
}
|
||||
let connID = "conn" + this._nextConnID++ + '.';
|
||||
let conn = new DebuggerServerConnection(connID, aTransport);
|
||||
this._connections[connID] = conn;
|
||||
@ -553,3 +582,23 @@ DebuggerServerConnection.prototype = {
|
||||
DebuggerServer._connectionClosed(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Localization convenience methods.
|
||||
*/
|
||||
let L10N = {
|
||||
|
||||
/**
|
||||
* L10N shortcut function.
|
||||
*
|
||||
* @param string aName
|
||||
* @return string
|
||||
*/
|
||||
getStr: function L10N_getStr(aName) {
|
||||
return this.stringBundle.GetStringFromName(aName);
|
||||
}
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyGetter(L10N, "stringBundle", function() {
|
||||
return Services.strings.createBundle(DBG_STRINGS_URI);
|
||||
});
|
||||
|
@ -0,0 +1,24 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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/.
|
||||
|
||||
# LOCALIZATION NOTE These strings are used inside the Debugger
|
||||
# which is available from the Web Developer sub-menu -> 'Debugger'.
|
||||
# The correct localization of this file might be to keep it in
|
||||
# English, or another language commonly spoken among web developers.
|
||||
# You want to make that choice consistent across the developer tools.
|
||||
# A good criteria is the language in which you'd find the best
|
||||
# documentation on web development on the web.
|
||||
|
||||
# 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?
|
||||
|
||||
# LOCALIZATION NOTE (remoteIncomingPromptDisable): The label displayed on the
|
||||
# third button in the incoming connection dialog that lets the user disable the
|
||||
# remote debugger server.
|
||||
remoteIncomingPromptDisable=Disable
|
@ -29,6 +29,7 @@
|
||||
locale/@AB_CD@/global/customizeToolbar.properties (%chrome/global/customizeToolbar.properties)
|
||||
locale/@AB_CD@/global/datetimepicker.dtd (%chrome/global/datetimepicker.dtd)
|
||||
locale/@AB_CD@/global/dateFormat.properties (%chrome/global/dateFormat.properties)
|
||||
locale/@AB_CD@/global/devtools/debugger.properties (%chrome/global/devtools/debugger.properties)
|
||||
locale/@AB_CD@/global/dialogOverlay.dtd (%chrome/global/dialogOverlay.dtd)
|
||||
locale/@AB_CD@/global/downloadProgress.properties (%chrome/global/downloadProgress.properties)
|
||||
locale/@AB_CD@/global/editMenuOverlay.dtd (%chrome/global/editMenuOverlay.dtd)
|
||||
|
Loading…
Reference in New Issue
Block a user