public AutofillId[] GetOptionalSaveIds() { if (SaveType == SaveDataType.Password) { return(UsernameFields.Select(f => f.AutofillId).ToArray()); } else if (SaveType == SaveDataType.CreditCard) { var fieldList = new List <Field>(); if (HintToFieldsMap.ContainsKey(View.AutofillHintCreditCardSecurityCode)) { fieldList.AddRange(HintToFieldsMap[View.AutofillHintCreditCardSecurityCode]); } if (HintToFieldsMap.ContainsKey(View.AutofillHintCreditCardExpirationYear)) { fieldList.AddRange(HintToFieldsMap[View.AutofillHintCreditCardExpirationYear]); } if (HintToFieldsMap.ContainsKey(View.AutofillHintCreditCardExpirationMonth)) { fieldList.AddRange(HintToFieldsMap[View.AutofillHintCreditCardExpirationMonth]); } if (HintToFieldsMap.ContainsKey(View.AutofillHintName)) { fieldList.AddRange(HintToFieldsMap[View.AutofillHintName]); } return(fieldList.Select(f => f.AutofillId).ToArray()); } return(new AutofillId[0]); }
private static string GuessUsername(Account.Field[] fields) { // If there's only one text field with a special name then it's the username. var username = fields.Where(i => i.Kind == Account.FieldKind.Text && UsernameFields.Contains(i.Name.ToLower())).ToArray(); if (username.Length == 1) { return(username[0].Value); } // If there's only one text field, assume it's the username. username = fields.Where(i => i.Kind == Account.FieldKind.Text).ToArray(); if (username.Length == 1) { return(username[0].Value); } return(null); }