Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Revert "Bug 1032128 - Add "always allow" for cert-based authenticatio…
Browse files Browse the repository at this point in the history
…n. r=janx" per request for too many changes after r+

This reverts commit e2b633d.
  • Loading branch information
BavarianTomcat committed Mar 19, 2015
1 parent 8db6389 commit 77f2585
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 188 deletions.
23 changes: 8 additions & 15 deletions apps/system/js/app_chrome.js
Expand Up @@ -11,6 +11,7 @@

(function(exports) {
var _id = 0;
var _ = navigator.mozL10n.get;

var newTabManifestURL = null;
SettingsListener.observe('rocketbar.newTabAppURL', '',
Expand Down Expand Up @@ -821,27 +822,19 @@
}
}

var title = 'add-to-home-screen';
var options = [];
var data = {
title: _('add-to-home-screen'),
options: []
};

if (this.isSearch()) {
var dataset = this.app.config;
options.push({
id: 'search',
text: {
raw: dataset.searchName
}
});
data.options.push({ id: 'search', text: dataset.searchName });
} else {
options.push({
id: 'origin',
text: {
raw: this.title.textContent
}
});
data.options.push({ id: 'origin', text: this.title.textContent });
}

ModalDialog.selectOne(title, options, selected);
ModalDialog.selectOne(data, selected);
};

AppChrome.prototype.showWindows = function ac_showWindows() {
Expand Down
115 changes: 13 additions & 102 deletions apps/system/js/devtools/remote_debugger.js
Expand Up @@ -3,41 +3,6 @@

(function(exports) {

/**
* Note: Values copied from Gecko:
* toolkit/devtools/security/auth.js
*/
var AuthenticationResult = {

/**
* Close all listening sockets, and disable them from opening again.
*/
DISABLE_ALL: 'DISABLE_ALL',

/**
* Deny the current connection.
*/
DENY: 'DENY',

/**
* Additional data needs to be exchanged before a result can be determined.
*/
PENDING: 'PENDING',

/**
* Allow the current connection.
*/
ALLOW: 'ALLOW',

/**
* Allow the current connection, and persist this choice for future
* connections from the same client. This requires a trustable mechanism to
* identify the client in the future, such as the cert used during OOB_CERT.
*/
ALLOW_PERSIST: 'ALLOW_PERSIST'

};

/**
* RemoteDebugger displays a prompt asking the user if they want to enable
* remote debugging on their device. This is generally called when the user
Expand Down Expand Up @@ -70,89 +35,35 @@
}

var session = e.detail.session;
var dialog;
var text;
if (!session.server.port) {
dialog = this._buildUSBDialog(session);
text = 'remoteDebuggerPromptUSB';
} else {
dialog = this._buildTCPDialog(session);
}

if (!dialog) {
// Session does not meet the requirements of this dialog, so deny the
// connection immediately.
this._dispatchEvent(AuthenticationResult.DENY);
return;
text = {
id: 'remoteDebuggerPromptTCP',
args: session.client
};
}

// Reusing the ModalDialog infrastructure.
ModalDialog.showWithPseudoEvent({
type: 'selectone',
title: dialog.title,
text: dialog.options,
callback: this._dispatchEvent.bind(this),
cancel: this._dispatchEvent.bind(this)
text: text,
type: 'confirm',
callback: this._dispatchEvent.bind(this, true),
cancel: this._dispatchEvent.bind(this, false)
});
},

_buildUSBDialog: function(session) {
var dialog = {};
if (session.authentication !== 'PROMPT') {
// This dialog is not prepared for any other authentication method at
// this time.
return false;
}
dialog.title = 'remoteDebuggerPromptUSB';
dialog.options = [
{
id: AuthenticationResult.ALLOW,
text: 'remoteDebuggerPrompt-allow'
},
{
id: AuthenticationResult.DENY,
text: 'remoteDebuggerPrompt-deny'
}
];
return dialog;
},

_buildTCPDialog: function(session) {
var dialog = {};
if (session.authentication !== 'OOB_CERT' || !session.client.cert) {
// This dialog is not prepared for any other authentication method at
// this time.
return false;
}
dialog.title = {
id: 'remoteDebuggerPromptTCP',
args: {
host: session.client.host,
port: session.client.port
}
};
dialog.options = [
{
id: AuthenticationResult.ALLOW_PERSIST,
text: 'remoteDebuggerPrompt-scanAndRemember'
},
{
id: AuthenticationResult.ALLOW,
text: 'remoteDebuggerPrompt-scan'
}
];
return dialog;
},

/**
* Dispatches an event based on the user selection of the modal dialog.
* @memberof RemoteDebugger.prototype
* @param {String} id ID of option chosen, or null if cancelled.
* @param {Boolean} value True if the user enabled the remote debugger.
*/
_dispatchEvent: function(id) {
var authResult = id || AuthenticationResult.DENY;
_dispatchEvent: function(value) {
var event = document.createEvent('CustomEvent');
event.initCustomEvent('mozContentEvent', true, true,
{ type: 'remote-debugger-prompt',
authResult: authResult });
value: value });
window.dispatchEvent(event);
}
};
Expand Down
79 changes: 39 additions & 40 deletions apps/system/js/modal_dialog.js
Expand Up @@ -161,26 +161,6 @@ var ModalDialog = {
this.overlay.style.height = height + 'px';
},

_localizeElement: function(node, payload) {
if (typeof payload === 'string') {
node.setAttribute('data-l10n-id', payload);
return;
}

if (typeof payload === 'object') {
if (payload.raw) {
node.removeAttribute('data-l10n-id');
node.textContent = payload.raw;
return;
}

if (payload.id) {
navigator.mozL10n.setAttributes(node, payload.id, payload.args);
return;
}
}
},

// Show relative dialog and set message/input value well
show: function md_show(target, origin) {
if (!(origin in this.currentEvents)) {
Expand All @@ -203,9 +183,29 @@ var ModalDialog = {
title = '';
}

function localizeElement(node, payload) {
if (typeof payload === 'string') {
node.setAttribute('data-l10n-id', payload);
return;
}

if (typeof payload === 'object') {
if (payload.raw) {
node.removeAttribute('data-l10n-id');
node.textContent = payload.raw;
return;
}

if (payload.id) {
navigator.mozL10n.setAttributes(node, payload.id, payload.args);
return;
}
}
}

switch (type) {
case 'alert':
this._localizeElement(elements.alertMessage, message);
localizeElement(elements.alertMessage, message);
elements.alert.classList.add('visible');
this.setTitle('alert', title);
elements.alertOk.setAttribute('data-l10n-id', evt.yesText ?
Expand All @@ -216,7 +216,7 @@ var ModalDialog = {
case 'prompt':
elements.prompt.classList.add('visible');
elements.promptInput.value = evt.detail.initialValue;
this._localizeElement(elements.promptMessage, message);
localizeElement(elements.promptMessage, message);
this.setTitle('prompt', title);
elements.promptOk.setAttribute('data-l10n-id', evt.yesText ?
evt.yesText : 'ok');
Expand All @@ -227,7 +227,7 @@ var ModalDialog = {

case 'confirm':
elements.confirm.classList.add('visible');
this._localizeElement(elements.confirmMessage, message);
localizeElement(elements.confirmMessage, message);
this.setTitle('confirm', title);
elements.confirmOk.setAttribute('data-l10n-id', evt.yesText ?
evt.yesText : 'ok');
Expand All @@ -237,7 +237,6 @@ var ModalDialog = {
break;

case 'selectone':
this.setTitle('selectOne', title);
this.buildSelectOneDialog(message);
elements.selectOne.classList.add('visible');
elements.selectOne.focus();
Expand All @@ -259,7 +258,7 @@ var ModalDialog = {
},

setTitle: function md_setTitle(type, title) {
this._localizeElement(this.elements[type + 'Title'], title);
this.elements[type + 'Title'].setAttribute('data-l10n-id', title);
},

// When user clicks OK button on alert/confirm/prompt
Expand Down Expand Up @@ -363,23 +362,23 @@ var ModalDialog = {

buildSelectOneDialog: function md_buildSelectOneDialog(data) {
var elements = this.elements;
var menu = elements.selectOneMenu;
while (menu.firstChild) {
menu.removeChild(menu.firstChild);
}
elements.selectOneTitle.textContent = data.title;
elements.selectOneMenu.innerHTML = '';

if (!data) {
if (!data.options) {
return;
}

for (var i = 0; i < data.length; i++) {
var li = document.createElement('li');
var button = document.createElement('button');
button.setAttribute('id', data[i].id);
this._localizeElement(button, data[i].text);
li.appendChild(button);
menu.appendChild(li);
var itemsHTML = [];
for (var i = 0; i < data.options.length; i++) {
itemsHTML.push('<li><button id="');
itemsHTML.push(data.options[i].id);
itemsHTML.push('">');
itemsHTML.push(data.options[i].text);
itemsHTML.push('</button></li>');
}

elements.selectOneMenu.innerHTML = itemsHTML.join('');
},

/**
Expand Down Expand Up @@ -441,11 +440,10 @@ var ModalDialog = {
});
},

selectOne: function md_selectOne(title, options, callback) {
selectOne: function md_selectOne(data, callback) {
this.showWithPseudoEvent({
type: 'selectone',
title: title,
text: options,
text: data,
callback: callback
});
},
Expand Down Expand Up @@ -484,3 +482,4 @@ var ModalDialog = {
};

ModalDialog.init();

20 changes: 2 additions & 18 deletions apps/system/locales/system.en-US.properties
Expand Up @@ -477,24 +477,8 @@ persona-signin=Sign In
payment-flow=Purchase

# Remote Debugger Connection Dialog
remoteDebuggerPromptUSB.innerHTML=Allow USB debugging connection?
remoteDebuggerPromptTCP.innerHTML=Allow remote debugging connection from <code>{{host}}:{{port}}</code>?<br/><br/>This connection requires a QR code to be scanned in order to authenticate the other endpoint's certificate. You can also remember the other endpoint to skip scans in the future.
# LOCALIZATION NOTE (remoteDebuggerPrompt-deny): This button will deny an
# an incoming remote debugger connection.
remoteDebuggerPrompt-deny=Deny
# LOCALIZATION NOTE (remoteDebuggerPrompt-allow): This button will allow an
# an incoming remote debugger connection.
remoteDebuggerPrompt-allow=Allow
# LOCALIZATION NOTE (remoteDebuggerPrompt-scan): This button will start a QR
# code scanner to authenticate an incoming remote debugger connection. The
# connection will be allowed assuming the scan succeeds.
remoteDebuggerPrompt-scan=Scan
# LOCALIZATION NOTE (remoteDebuggerPrompt-scanAndRemember): This button will
# start a QR code scanner to authenticate an incoming remote debugger
# connection. The connection will be allowed assuming the scan succeeds, and
# the other endpoint's certificate will be saved to skip future scans for this
# client.
remoteDebuggerPrompt-scanAndRemember=Scan and Remember
remoteDebuggerPromptUSB=Allow USB debugging connection?
remoteDebuggerPromptTCP=Allow remote debugging connection from {{host}}:{{port}}?

# DevTools Authentication
# LOCALIZATION NOTE (devtools-auth-scan2): This header text appears above a live
Expand Down
2 changes: 1 addition & 1 deletion apps/system/style/modal_dialog/modal_dialog.css
Expand Up @@ -84,7 +84,7 @@
}

#modal-dialog-select-one h3 {
line-height: 1.8rem;
font-size: 1.8rem;
}

#modal-dialog-select-one ul {
Expand Down

0 comments on commit 77f2585

Please sign in to comment.