Commit 1559a4e7 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Chromium LUCI CQ

[iOS][CredentialProvider] Show loading indicator for GCRSSOService APIs

Bug: 1156847
Change-Id: Ie15241942f1a22666ad2e9cf3a12927a8d18fc12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597401Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Commit-Queue: Javier Flores <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838665}
parent bd7f4e96
......@@ -64,6 +64,7 @@ ios_appex_bundle("credential_provider_extension") {
":password_util",
":reauthentication_handler",
":system_strings",
"//base",
"//ios/chrome/common/app_group",
"//ios/chrome/common/app_group:client",
"//ios/chrome/common/credential_provider",
......
......@@ -6,11 +6,13 @@
#import <Foundation/Foundation.h>
#include "base/check.h"
#include "ios/chrome/common/app_group/app_group_constants.h"
#include "ios/chrome/common/app_group/app_group_metrics.h"
#import "ios/chrome/common/credential_provider/archivable_credential_store.h"
#import "ios/chrome/common/credential_provider/constants.h"
#import "ios/chrome/common/credential_provider/credential.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"
#import "ios/chrome/common/ui/confirmation_alert/confirmation_alert_action_handler.h"
#import "ios/chrome/common/ui/reauthentication/reauthentication_module.h"
#import "ios/chrome/credential_provider_extension/account_verification_provider.h"
......@@ -51,6 +53,9 @@
// Interface for verified that accounts are still valid.
@property(nonatomic, strong) AccountVerificationProvider* accountVerificator;
// Loading indicator used for user validation, which APIs can take a long time.
@property(nonatomic, strong) UIActivityIndicatorView* activityIndicatorView;
@end
@implementation CredentialProviderViewController
......@@ -191,11 +196,36 @@
[self exitWithErrorCode:ASExtensionErrorCodeCredentialIdentityNotFound];
}
// Shows a loading indicator,
- (void)showLoadingIndicator {
DCHECK(!self.activityIndicatorView);
self.activityIndicatorView = [[UIActivityIndicatorView alloc] init];
UIActivityIndicatorView* activityView = self.activityIndicatorView;
activityView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:activityView];
[NSLayoutConstraint activateConstraints:@[
[activityView.centerXAnchor
constraintEqualToAnchor:self.view.centerXAnchor],
[activityView.centerYAnchor
constraintEqualToAnchor:self.view.centerYAnchor],
]];
[activityView startAnimating];
activityView.color = [UIColor colorNamed:kBlueColor];
}
// Hides the loading indicator.
- (void)hideLoadingIndicator {
[self.activityIndicatorView removeFromSuperview];
self.activityIndicatorView = nil;
}
// Verifies that the user is still signed in.
// Return NO in the completion when the user is no longer valid. YES otherwise.
- (void)validateUserWithCompletion:(void (^)(BOOL))completion {
[self showLoadingIndicator];
auto handler = ^(BOOL isValid) {
dispatch_async(dispatch_get_main_queue(), ^{
[self hideLoadingIndicator];
if (completion) {
completion(isValid);
}
......
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