mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 19:33:18 +00:00
Bug 1167740 - Allow editing login from "Update login" doorhanger. r=margaret
--HG-- extra : rebase_source : eb4420e38f386505b7728bd76405bcb37efc0a1c
This commit is contained in:
parent
2a777a408e
commit
44e833a7d7
@ -452,7 +452,6 @@ size. -->
|
||||
<!ENTITY button_clear_data "Clear data">
|
||||
<!ENTITY button_set "Set">
|
||||
<!ENTITY button_clear "Clear">
|
||||
<!ENTITY button_remember "Remember">
|
||||
<!ENTITY button_copy "Copy">
|
||||
|
||||
<!ENTITY firstrun_panel_title_welcome "Welcome">
|
||||
|
@ -385,7 +385,6 @@
|
||||
<string name="button_clear">&button_clear;</string>
|
||||
<string name="button_yes">&button_yes;</string>
|
||||
<string name="button_no">&button_no;</string>
|
||||
<string name="button_remember">&button_remember;</string>
|
||||
<string name="button_copy">&button_copy;</string>
|
||||
|
||||
<string name="firstrun_panel_title_welcome">&firstrun_panel_title_welcome;</string>
|
||||
|
@ -38,7 +38,7 @@ public class LoginDoorHanger extends DoorHanger {
|
||||
private final TextView mTitle;
|
||||
private final TextView mMessage;
|
||||
private final TextView mLink;
|
||||
private int mCallbackID;
|
||||
private final DoorhangerConfig.ButtonConfig mButtonConfig;
|
||||
|
||||
public LoginDoorHanger(Context context, DoorhangerConfig config) {
|
||||
super(context, config, Type.LOGIN);
|
||||
@ -49,6 +49,8 @@ public class LoginDoorHanger extends DoorHanger {
|
||||
mIcon.setImageResource(R.drawable.icon_key);
|
||||
mIcon.setVisibility(View.VISIBLE);
|
||||
|
||||
mButtonConfig = config.getPositiveButtonConfig();
|
||||
|
||||
loadConfig(config);
|
||||
}
|
||||
|
||||
@ -62,7 +64,6 @@ public class LoginDoorHanger extends DoorHanger {
|
||||
setOptions(config.getOptions());
|
||||
setMessage(config.getMessage());
|
||||
// Store the positive callback id for nested dialogs that need the same callback id.
|
||||
mCallbackID = config.getPositiveButtonConfig().callback;
|
||||
addButtonsToLayout(config);
|
||||
}
|
||||
|
||||
@ -160,12 +161,12 @@ public class LoginDoorHanger extends DoorHanger {
|
||||
});
|
||||
builder.setView(view);
|
||||
|
||||
builder.setPositiveButton(R.string.button_remember, new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(mButtonConfig.label, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
JSONObject response = new JSONObject();
|
||||
try {
|
||||
response.put("callback", mCallbackID);
|
||||
response.put("callback", mButtonConfig.callback);
|
||||
final JSONObject inputs = new JSONObject();
|
||||
inputs.put("username", username.getText());
|
||||
inputs.put("password", password.getText());
|
||||
@ -214,7 +215,7 @@ public class LoginDoorHanger extends DoorHanger {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final JSONObject response = new JSONObject();
|
||||
try {
|
||||
response.put("callback", mCallbackID);
|
||||
response.put("callback", mButtonConfig.callback);
|
||||
response.put("password", passwords[which]);
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "Error making login select dialog JSON", e);
|
||||
|
@ -146,16 +146,24 @@ LoginManagerPrompter.prototype = {
|
||||
* String message to be displayed in the doorhanger
|
||||
* @param aButtons
|
||||
* Buttons to display with the doorhanger
|
||||
* @param aActionText
|
||||
* Object with text to be displayed as clickable, along with a bundle to create an action
|
||||
*
|
||||
* @param aUsername
|
||||
* Username string used in creating a doorhanger action
|
||||
* @param aPassword
|
||||
* Password string used in creating a doorhanger action
|
||||
*/
|
||||
_showLoginNotification : function (aTitle, aBody, aButtons, aActionText) {
|
||||
_showLoginNotification : function (aTitle, aBody, aButtons, aUsername, aPassword) {
|
||||
let notifyWin = this._window.top;
|
||||
let chromeWin = this._getChromeWindow(notifyWin).wrappedJSObject;
|
||||
let browser = chromeWin.BrowserApp.getBrowserForWindow(notifyWin);
|
||||
let tabID = chromeWin.BrowserApp.getTabForBrowser(browser).id;
|
||||
|
||||
let actionText = {
|
||||
text: aUsername,
|
||||
type: "EDIT",
|
||||
bundle: { username: aUsername,
|
||||
password: aPassword }
|
||||
};
|
||||
|
||||
// The page we're going to hasn't loaded yet, so we want to persist
|
||||
// across the first location change.
|
||||
|
||||
@ -163,12 +171,11 @@ LoginManagerPrompter.prototype = {
|
||||
// at the post-authentication page. I don't see a good way to
|
||||
// heuristically determine when to ignore such location changes, so
|
||||
// we'll try ignoring location changes based on a time interval.
|
||||
|
||||
let options = {
|
||||
persistWhileVisible: true,
|
||||
timeout: Date.now() + 10000,
|
||||
title: aTitle,
|
||||
actionText: aActionText
|
||||
actionText: actionText
|
||||
}
|
||||
|
||||
var nativeWindow = this._getNativeWindow();
|
||||
@ -194,13 +201,6 @@ LoginManagerPrompter.prototype = {
|
||||
|
||||
let username = aLogin.username ? this._sanitizeUsername(aLogin.username) : "";
|
||||
|
||||
let actionText = {
|
||||
text: username,
|
||||
type: "EDIT",
|
||||
bundle: { username: username,
|
||||
password: aLogin.password }
|
||||
};
|
||||
|
||||
// The callbacks in |buttons| have a closure to access the variables
|
||||
// in scope here; set one to |this._pwmgr| so we can get back to pwmgr
|
||||
// without a getService() call.
|
||||
@ -230,7 +230,7 @@ LoginManagerPrompter.prototype = {
|
||||
}
|
||||
];
|
||||
|
||||
this._showLoginNotification(title, notificationText, buttons, actionText);
|
||||
this._showLoginNotification(title, notificationText, buttons, aLogin.username, aLogin.password);
|
||||
},
|
||||
|
||||
/*
|
||||
@ -280,15 +280,17 @@ LoginManagerPrompter.prototype = {
|
||||
},
|
||||
{
|
||||
label: this._getLocalizedString("updateButton"),
|
||||
callback: function() {
|
||||
self._updateLogin(aOldLogin, aNewPassword);
|
||||
promptHistogram.add(PROMPT_UPDATE);
|
||||
callback: function(checked, response) {
|
||||
let password = response ? response["password"] : aNewPassword;
|
||||
self._updateLogin(aOldLogin, password);
|
||||
|
||||
promptHistogram.add(PROMPT_UPDATE);
|
||||
},
|
||||
positive: true
|
||||
}
|
||||
];
|
||||
|
||||
this._showLoginNotification(title, notificationText, buttons);
|
||||
this._showLoginNotification(title, notificationText, buttons, aOldLogin.username, aNewPassword);
|
||||
},
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user