mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
implement blacklisted uris options for autofill
This commit is contained in:
parent
999c9667c8
commit
e8c776fe49
2 changed files with 25 additions and 4 deletions
|
@ -24,7 +24,8 @@ namespace Bit.Droid.Autofill
|
|||
private ILockService _lockService;
|
||||
private IStorageService _storageService;
|
||||
|
||||
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal, FillCallback callback)
|
||||
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal,
|
||||
FillCallback callback)
|
||||
{
|
||||
var structure = request.FillContexts?.LastOrDefault()?.Structure;
|
||||
if(structure == null)
|
||||
|
@ -35,7 +36,13 @@ namespace Bit.Droid.Autofill
|
|||
var parser = new Parser(structure, ApplicationContext);
|
||||
parser.Parse();
|
||||
|
||||
if(!parser.ShouldAutofill)
|
||||
if(_storageService == null)
|
||||
{
|
||||
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
|
||||
}
|
||||
|
||||
var shouldAutofill = await parser.ShouldAutofillAsync(_storageService);
|
||||
if(!shouldAutofill)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ using Android.App.Assist;
|
|||
using System.Collections.Generic;
|
||||
using Bit.Core;
|
||||
using Android.Content;
|
||||
using Bit.Core.Abstractions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Droid.Autofill
|
||||
{
|
||||
|
@ -77,8 +79,20 @@ namespace Bit.Droid.Autofill
|
|||
}
|
||||
}
|
||||
|
||||
public bool ShouldAutofill => !string.IsNullOrWhiteSpace(Uri) &&
|
||||
!AutofillHelpers.BlacklistedUris.Contains(Uri) && FieldCollection != null && FieldCollection.Fillable;
|
||||
public async Task<bool> ShouldAutofillAsync(IStorageService storageService)
|
||||
{
|
||||
var fillable = !string.IsNullOrWhiteSpace(Uri) && !AutofillHelpers.BlacklistedUris.Contains(Uri) &&
|
||||
FieldCollection != null && FieldCollection.Fillable;
|
||||
if(fillable)
|
||||
{
|
||||
var blacklistedUris = await storageService.GetAsync<List<string>>(Constants.AutofillBlacklistedUrisKey);
|
||||
if(blacklistedUris != null && blacklistedUris.Count > 0)
|
||||
{
|
||||
fillable = !new HashSet<string>(blacklistedUris).Contains(Uri);
|
||||
}
|
||||
}
|
||||
return fillable;
|
||||
}
|
||||
|
||||
public void Parse()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue