Commit d19c1078 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Add search to cpe list mediator.

Bug: 1045454
Change-Id: I187eec6794ba509f32560c0d422124a628ee4d54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144176Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758195}
parent 7956cbe6
...@@ -32,6 +32,12 @@ ...@@ -32,6 +32,12 @@
// The extension context in which the credential list was started. // The extension context in which the credential list was started.
@property(nonatomic, weak) ASCredentialProviderExtensionContext* context; @property(nonatomic, weak) ASCredentialProviderExtensionContext* context;
// List of suggested credentials.
@property(nonatomic, copy) NSArray<id<Credential>>* suggestedCredentials;
// List of all credentials.
@property(nonatomic, copy) NSArray<id<Credential>>* allCredentials;
@end @end
@implementation CredentialListMediator @implementation CredentialListMediator
...@@ -56,12 +62,14 @@ ...@@ -56,12 +62,14 @@
- (void)fetchCredentials { - (void)fetchCredentials {
// TODO(crbug.com/1045454): Implement ordering and suggestions. // TODO(crbug.com/1045454): Implement ordering and suggestions.
NSArray<id<Credential>>* allCredentials = self.credentialStore.credentials; self.allCredentials = self.credentialStore.credentials;
if (!allCredentials.count) { self.suggestedCredentials = nil;
if (!self.allCredentials.count) {
[self.UIHandler showEmptyCredentials]; [self.UIHandler showEmptyCredentials];
return; return;
} }
[self.consumer presentSuggestedPasswords:nil allPasswords:allCredentials]; [self.consumer presentSuggestedPasswords:self.suggestedCredentials
allPasswords:self.allCredentials];
} }
#pragma mark - CredentialListConsumerDelegate #pragma mark - CredentialListConsumerDelegate
...@@ -75,7 +83,27 @@ ...@@ -75,7 +83,27 @@
} }
- (void)updateResultsWithFilter:(NSString*)filter { - (void)updateResultsWithFilter:(NSString*)filter {
// TODO(crbug.com/1045454): Implement this method. NSMutableArray<id<Credential>>* suggested = [[NSMutableArray alloc] init];
if (self.suggestedCredentials.count > 0) {
for (id<Credential> credential in self.suggestedCredentials) {
if ([filter length] == 0 ||
[credential.serviceName localizedStandardContainsString:filter] ||
[credential.user localizedStandardContainsString:filter]) {
[suggested addObject:credential];
}
}
}
NSMutableArray<id<Credential>>* all = [[NSMutableArray alloc] init];
if (self.allCredentials.count > 0) {
for (id<Credential> credential in self.allCredentials) {
if ([filter length] == 0 ||
[credential.serviceName localizedStandardContainsString:filter] ||
[credential.user localizedStandardContainsString:filter]) {
[all addObject:credential];
}
}
}
[self.consumer presentSuggestedPasswords:suggested allPasswords:all];
} }
- (void)showDetailsForCredential:(id<Credential>)credential { - (void)showDetailsForCredential:(id<Credential>)credential {
......
...@@ -90,7 +90,6 @@ NSArray<id<Credential>>* allPasswords = @[ ...@@ -90,7 +90,6 @@ NSArray<id<Credential>>* allPasswords = @[
} }
- (void)updateResultsWithFilter:(NSString*)filter { - (void)updateResultsWithFilter:(NSString*)filter {
// TODO(crbug.com/1045454): Implement this method.
NSMutableArray<id<Credential>>* suggested = [[NSMutableArray alloc] init]; NSMutableArray<id<Credential>>* suggested = [[NSMutableArray alloc] init];
for (id<Credential> credential in suggestedPasswords) { for (id<Credential> credential in suggestedPasswords) {
if ([filter length] == 0 || if ([filter length] == 0 ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment