Exemplo n.º 1
0
        public static void AddSaveInfo(Parser parser, FillResponse.Builder responseBuilder, FieldCollection fields)
        {
            // Docs state that password fields cannot be reliably saved in Compat mode since they will show as
            // masked values.
            var compatBrowser = CompatBrowsers.Contains(parser.PackageName);

            if (compatBrowser && fields.SaveType == SaveDataType.Password)
            {
                return;
            }

            var requiredIds = fields.GetRequiredSaveFields();

            if (fields.SaveType == SaveDataType.Generic || requiredIds.Length == 0)
            {
                return;
            }

            var saveBuilder = new SaveInfo.Builder(fields.SaveType, requiredIds);
            var optionalIds = fields.GetOptionalSaveIds();

            if (optionalIds.Length > 0)
            {
                saveBuilder.SetOptionalIds(optionalIds);
            }
            if (compatBrowser)
            {
                saveBuilder.SetFlags(SaveFlags.SaveOnAllViewsInvisible);
            }
            responseBuilder.SetSaveInfo(saveBuilder.Build());
        }
Exemplo n.º 2
0
        public bool ApplyToFields(FieldCollection fieldCollection, Dataset.Builder datasetBuilder)
        {
            if (!fieldCollection?.Fields.Any() ?? true)
            {
                return(false);
            }

            var setValues = false;

            if (Type == CipherType.Login)
            {
                if (fieldCollection.PasswordFields.Any() && !string.IsNullOrWhiteSpace(_password))
                {
                    foreach (var f in fieldCollection.PasswordFields)
                    {
                        var val = ApplyValue(f, _password);
                        if (val != null)
                        {
                            setValues = true;
                            datasetBuilder.SetValue(f.AutofillId, val);
                        }
                    }
                }
                if (fieldCollection.UsernameFields.Any() && !string.IsNullOrWhiteSpace(Subtitle))
                {
                    foreach (var f in fieldCollection.UsernameFields)
                    {
                        var val = ApplyValue(f, Subtitle);
                        if (val != null)
                        {
                            setValues = true;
                            datasetBuilder.SetValue(f.AutofillId, val);
                        }
                    }
                }
            }
            else if (Type == CipherType.Card)
            {
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintCreditCardNumber,
                               _cardNumber))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintCreditCardSecurityCode,
                               _cardCode))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection,
                               Android.Views.View.AutofillHintCreditCardExpirationMonth, _cardExpMonth, true))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintCreditCardExpirationYear,
                               _cardExpYear))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintName, _cardName))
                {
                    setValues = true;
                }
            }
            else if (Type == CipherType.Identity)
            {
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintPhone, _idPhone))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintEmailAddress, _idEmail))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintUsername,
                               _idUsername))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintPostalAddress,
                               _idAddress))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintPostalCode,
                               _idPostalCode))
                {
                    setValues = true;
                }
                if (ApplyValue(datasetBuilder, fieldCollection, Android.Views.View.AutofillHintName, Subtitle))
                {
                    setValues = true;
                }
            }
            return(setValues);
        }