Commit 0fb67af0 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Add data to CPE password list in showcase

No styling yet.

Bug: 1045454
Change-Id: I05155cd76c88cdaf828c62627914dffc0a1a7475
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129536Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755278}
parent 8ca2af76
...@@ -80,7 +80,10 @@ ios_appex_bundle("credential_provider_extension") { ...@@ -80,7 +80,10 @@ ios_appex_bundle("credential_provider_extension") {
} }
generate_localizable_strings("system_strings") { generate_localizable_strings("system_strings") {
visibility = [ ":*" ] visibility = [
":*",
"//ios/showcase:*",
]
_packed_resources_target = ":packed_resources" _packed_resources_target = ":packed_resources"
config_file = "credential_provider_extension_localize_strings_config.plist" config_file = "credential_provider_extension_localize_strings_config.plist"
datapack_dir = get_label_info(_packed_resources_target, "target_gen_dir") datapack_dir = get_label_info(_packed_resources_target, "target_gen_dir")
......
...@@ -13,18 +13,21 @@ ...@@ -13,18 +13,21 @@
<string>Localizable.strings</string> <string>Localizable.strings</string>
<key>strings</key> <key>strings</key>
<array> <array>
<string>IDS_IOS_CREDENTIAL_PROVIDER_ALL_PASSWORDS</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_ENABLE_BUTTON_TITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_ENABLE_BUTTON_TITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_SUBTITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_SUBTITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_TITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_TITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_EMPTY_CREDENTIALS_SUBTITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_EMPTY_CREDENTIALS_SUBTITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_EMPTY_CREDENTIALS_TITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_EMPTY_CREDENTIALS_TITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_EXTENSION_CANCEL</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_EXTENSION_CANCEL</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_NO_SEARCH_RESULTS</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_SUBTITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_SUBTITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_TITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_TITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_SCREENLOCK_REASON</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_SCREENLOCK_REASON</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_CONTENT</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_CONTENT</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_TITLE</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_TITLE</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_LEARN_HOW</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_LEARN_HOW</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_SUGGESTED_PASSWORDS</string>
<string>IDS_IOS_CREDENTIAL_PROVIDER_OK</string> <string>IDS_IOS_CREDENTIAL_PROVIDER_OK</string>
</array> </array>
</dict> </dict>
......
...@@ -158,6 +158,9 @@ all other OS specific variables will be false. ...@@ -158,6 +158,9 @@ all other OS specific variables will be false.
</translations> </translations>
<release seq="1" allow_pseudo="false"> <release seq="1" allow_pseudo="false">
<messages fallback_to_english="true"> <messages fallback_to_english="true">
<message name="IDS_IOS_CREDENTIAL_PROVIDER_ALL_PASSWORDS" desc="Header for table section for all passwords" meaning="Header of table section showing all passwords not in the suggested section.">
All Passwords
</message>
<message name="IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_ENABLE_BUTTON_TITLE" desc="Title for the button that triggers auth, in order to enable the extension. 'AutoFill' matches what Apple shows in settings. For other languages see: Settings > Safari > AutoFill." meaning="The user taps this button to enable the AutoFill extension."> <message name="IDS_IOS_CREDENTIAL_PROVIDER_CONSENT_ENABLE_BUTTON_TITLE" desc="Title for the button that triggers auth, in order to enable the extension. 'AutoFill' matches what Apple shows in settings. For other languages see: Settings > Safari > AutoFill." meaning="The user taps this button to enable the AutoFill extension.">
Enable AutoFill... Enable AutoFill...
</message> </message>
...@@ -176,6 +179,9 @@ all other OS specific variables will be false. ...@@ -176,6 +179,9 @@ all other OS specific variables will be false.
<message name="IDS_IOS_CREDENTIAL_PROVIDER_EXTENSION_CANCEL" desc="Title for cancel buttons" meaning="Title for buttons meant to cancel an action [Length: 10 chars]"> <message name="IDS_IOS_CREDENTIAL_PROVIDER_EXTENSION_CANCEL" desc="Title for cancel buttons" meaning="Title for buttons meant to cancel an action [Length: 10 chars]">
Cancel Cancel
</message> </message>
<message name="IDS_IOS_CREDENTIAL_PROVIDER_NO_SEARCH_RESULTS" desc="Text shown when no password search results have been found" meaning="Textual search for passwords returned nothing.">
No search results found
</message>
<message name="IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_SUBTITLE" desc="Subtitle for stale credentials screen" meaning="Subtitle to show when a user signs out, and the credentials are no longer available."> <message name="IDS_IOS_CREDENTIAL_PROVIDER_STALE_CREDENTIALS_SUBTITLE" desc="Subtitle for stale credentials screen" meaning="Subtitle to show when a user signs out, and the credentials are no longer available.">
You recently signed out of your Google Account, which removed your synced passwords. Sign in to Chrome and turn on sync to see them here. You recently signed out of your Google Account, which removed your synced passwords. Sign in to Chrome and turn on sync to see them here.
</message> </message>
...@@ -194,6 +200,9 @@ all other OS specific variables will be false. ...@@ -194,6 +200,9 @@ all other OS specific variables will be false.
<message name="IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_LEARN_HOW" desc="The label of the 'Learn how' button" meaning="'Learn how' button of the alert informing the user that in order to use passwords, a screen lock needs to be set up on the device. The button leads to a help article on how to set up a device lock."> <message name="IDS_IOS_CREDENTIAL_PROVIDER_SET_UP_SCREENLOCK_LEARN_HOW" desc="The label of the 'Learn how' button" meaning="'Learn how' button of the alert informing the user that in order to use passwords, a screen lock needs to be set up on the device. The button leads to a help article on how to set up a device lock.">
Learn How Learn How
</message> </message>
<message name="IDS_IOS_CREDENTIAL_PROVIDER_SUGGESTED_PASSWORDS" desc="Header for table section for suggested passwords" meaning="Header of table section showing passwords most likely to be selected by user.">
Suggested Passwords
</message>
<message name="IDS_IOS_CREDENTIAL_PROVIDER_OK" desc="Used for OK on buttons"> <message name="IDS_IOS_CREDENTIAL_PROVIDER_OK" desc="Used for OK on buttons">
OK OK
</message> </message>
......
...@@ -21,6 +21,7 @@ source_set("ui") { ...@@ -21,6 +21,7 @@ source_set("ui") {
] ]
deps = [ deps = [
"//ios/chrome/common/credential_provider", "//ios/chrome/common/credential_provider",
"//ios/chrome/common/credential_provider:ui",
"//ios/chrome/common/ui/colors", "//ios/chrome/common/ui/colors",
"//ios/chrome/common/ui/confirmation_alert", "//ios/chrome/common/ui/confirmation_alert",
"//ios/chrome/credential_provider_extension/ui/resources", "//ios/chrome/credential_provider_extension/ui/resources",
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_ #ifndef IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_
#define IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_ #define IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_
#include "ios/chrome/common/credential_provider/credential.h"
@class UIButton; @class UIButton;
@protocol CredentialListConsumerDelegate <NSObject> @protocol CredentialListConsumerDelegate <NSObject>
...@@ -22,6 +24,10 @@ ...@@ -22,6 +24,10 @@
// The delegate for the actions in the consumer. // The delegate for the actions in the consumer.
@property(nonatomic, weak) id<CredentialListConsumerDelegate> delegate; @property(nonatomic, weak) id<CredentialListConsumerDelegate> delegate;
// Tells the consumer to show the passed in suggested and all passwords.
- (void)presentSuggestedPasswords:(NSArray<id<Credential>>*)suggested
allPasswords:(NSArray<id<Credential>>*)all;
@end @end
#endif // IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_ #endif // IOS_CHROME_CREDENTIAL_PROVIDER_EXTENSION_UI_CREDENTIAL_LIST_CONSUMER_H_
...@@ -4,20 +4,28 @@ ...@@ -4,20 +4,28 @@
#import "ios/chrome/credential_provider_extension/ui/credential_list_view_controller.h" #import "ios/chrome/credential_provider_extension/ui/credential_list_view_controller.h"
#import "ios/chrome/common/credential_provider/credential.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface CredentialListViewController () <UISearchResultsUpdating> @interface CredentialListViewController () <UITableViewDataSource,
UISearchResultsUpdating>
// Search controller that contains search bar. // Search controller that contains search bar.
@property(nonatomic, strong) UISearchController* searchController; @property(nonatomic, strong) UISearchController* searchController;
// Current list of suggested passwords.
@property(nonatomic, copy) NSArray<id<Credential>>* suggestedPasswords;
// Current list of all passwords.
@property(nonatomic, copy) NSArray<id<Credential>>* allPasswords;
@end @end
// TODO(crbug.com/1045454): Implement this view controller. // TODO(crbug.com/1045454): Implement this view controller's items.
@implementation CredentialListViewController @implementation CredentialListViewController
@synthesize delegate; @synthesize delegate;
...@@ -41,6 +49,63 @@ ...@@ -41,6 +49,63 @@
self.definesPresentationContext = YES; self.definesPresentationContext = YES;
} }
#pragma mark - CredentialListConsumer
- (void)presentSuggestedPasswords:(NSArray<id<Credential>>*)suggested
allPasswords:(NSArray<id<Credential>>*)all {
self.suggestedPasswords = suggested;
self.allPasswords = all;
[self.tableView reloadData];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
return [self numberOfSections];
}
- (NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section {
if ([self isSuggestedPasswordSection:section]) {
return self.suggestedPasswords.count;
} else {
return self.allPasswords.count;
}
}
- (NSString*)tableView:(UITableView*)tableView
titleForHeaderInSection:(NSInteger)section {
if ([self isEmptyTable]) {
return NSLocalizedString(@"IDS_IOS_CREDENTIAL_PROVIDER_NO_SEARCH_RESULTS",
@"No search results found");
} else if ([self isSuggestedPasswordSection:section]) {
return NSLocalizedString(@"IDS_IOS_CREDENTIAL_PROVIDER_SUGGESTED_PASSWORDS",
@"Suggested Passwords");
} else {
return NSLocalizedString(@"IDS_IOS_CREDENTIAL_PROVIDER_ALL_PASSWORDS",
@"All Passwords");
}
}
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"cell"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
id<Credential> credential;
if ([self isSuggestedPasswordSection:indexPath.section]) {
credential = self.suggestedPasswords[indexPath.row];
} else {
credential = self.allPasswords[indexPath.row];
}
cell.textLabel.text = credential.user;
cell.detailTextLabel.text = credential.serviceName;
return cell;
}
#pragma mark - UISearchResultsUpdating #pragma mark - UISearchResultsUpdating
- (void)updateSearchResultsForSearchController: - (void)updateSearchResultsForSearchController:
...@@ -59,4 +124,29 @@ ...@@ -59,4 +124,29 @@
return cancelButton; return cancelButton;
} }
// Returns number of sections to display based on |suggestedPasswords| and
// |allPasswords|. If no sections with data, returns 1 for the 'no data' banner.
- (int)numberOfSections {
if ([self.suggestedPasswords count] == 0 || [self.allPasswords count] == 0) {
return 1;
}
return 2;
}
// Returns YES if there is no data to display.
- (BOOL)isEmptyTable {
return [self.suggestedPasswords count] == 0 && [self.allPasswords count] == 0;
}
// Returns YES if given section is for suggested passwords.
- (BOOL)isSuggestedPasswordSection:(int)section {
int sections = [self numberOfSections];
if ((sections == 2 && section == 0) ||
(sections == 1 && self.suggestedPasswords.count)) {
return YES;
} else {
return NO;
}
}
@end @end
...@@ -16,7 +16,10 @@ ios_app_bundle("showcase") { ...@@ -16,7 +16,10 @@ ios_app_bundle("showcase") {
":features", ":features",
"//ios/showcase/core:main", "//ios/showcase/core:main",
] ]
bundle_deps = [ "//ios/showcase/core/resources" ] bundle_deps = [
"//ios/chrome/credential_provider_extension:system_strings",
"//ios/showcase/core/resources",
]
assert_no_deps = ios_assert_no_deps assert_no_deps = ios_assert_no_deps
} }
......
...@@ -8,6 +8,7 @@ source_set("credential_provider") { ...@@ -8,6 +8,7 @@ source_set("credential_provider") {
"sc_credential_list_coordinator.mm", "sc_credential_list_coordinator.mm",
] ]
deps = [ deps = [
"//ios/chrome/common/credential_provider:ui",
"//ios/chrome/credential_provider_extension/ui", "//ios/chrome/credential_provider_extension/ui",
"//ios/showcase/common", "//ios/showcase/common",
] ]
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/common/credential_provider/credential.h"
#import "ios/chrome/credential_provider_extension/ui/credential_list_consumer.h" #import "ios/chrome/credential_provider_extension/ui/credential_list_consumer.h"
#import "ios/chrome/credential_provider_extension/ui/credential_list_view_controller.h" #import "ios/chrome/credential_provider_extension/ui/credential_list_view_controller.h"
...@@ -13,6 +14,48 @@ ...@@ -13,6 +14,48 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface SCCredential : NSObject <Credential>
@end
@implementation SCCredential
@synthesize favicon = _favicon;
@synthesize keychainIdentifier = _keychainIdentifier;
@synthesize rank = _rank;
@synthesize recordIdentifier = _recordIdentifier;
@synthesize serviceIdentifier = _serviceIdentifier;
@synthesize serviceName = _serviceName;
@synthesize user = _user;
@synthesize validationIdentifier = _validationIdentifier;
- (instancetype)initWithServiceName:(NSString*)serviceName
user:(NSString*)user {
self = [super init];
if (self) {
_serviceName = serviceName;
_user = user;
}
return self;
}
@end
namespace {
NSArray<id<Credential>>* suggestedPasswords = @[
[[SCCredential alloc] initWithServiceName:@"www.domain.com"
user:@"johnsmith"],
[[SCCredential alloc] initWithServiceName:@"www.domain.com"
user:@"janesmythe"],
];
NSArray<id<Credential>>* allPasswords = @[
[[SCCredential alloc] initWithServiceName:@"www.domain1.com"
user:@"jsmythe@fazebook.com"],
[[SCCredential alloc] initWithServiceName:@"www.domain2.com"
user:@"jasmith@twitcher.com"],
[[SCCredential alloc] initWithServiceName:@"www.domain3.com"
user:@"HughZername"],
];
}
@interface SCCredentialListCoordinator () <CredentialListConsumerDelegate> @interface SCCredentialListCoordinator () <CredentialListConsumerDelegate>
@property(nonatomic, strong) CredentialListViewController* viewController; @property(nonatomic, strong) CredentialListViewController* viewController;
@end @end
...@@ -27,6 +70,9 @@ ...@@ -27,6 +70,9 @@
self.viewController.delegate = self; self.viewController.delegate = self;
[self.baseViewController setHidesBarsOnSwipe:NO]; [self.baseViewController setHidesBarsOnSwipe:NO];
[self.baseViewController pushViewController:self.viewController animated:YES]; [self.baseViewController pushViewController:self.viewController animated:YES];
[self.viewController presentSuggestedPasswords:suggestedPasswords
allPasswords:allPasswords];
} }
#pragma mark - CredentialListConsumerDelegate #pragma mark - CredentialListConsumerDelegate
...@@ -36,6 +82,23 @@ ...@@ -36,6 +82,23 @@
- (void)updateResultsWithFilter:(NSString*)filter { - (void)updateResultsWithFilter:(NSString*)filter {
// TODO(crbug.com/1045454): Implement this method. // TODO(crbug.com/1045454): Implement this method.
NSMutableArray<id<Credential>>* suggested = [[NSMutableArray alloc] init];
for (id<Credential> credential in suggestedPasswords) {
if ([filter length] == 0 ||
[credential.serviceName localizedStandardContainsString:filter] ||
[credential.user localizedStandardContainsString:filter]) {
[suggested addObject:credential];
}
}
NSMutableArray<id<Credential>>* all = [[NSMutableArray alloc] init];
for (id<Credential> credential in allPasswords) {
if ([filter length] == 0 ||
[credential.serviceName localizedStandardContainsString:filter] ||
[credential.user localizedStandardContainsString:filter]) {
[all addObject:credential];
}
}
[self.viewController presentSuggestedPasswords:suggested allPasswords:all];
} }
@end @end
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