password_spec_fetcher.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef IOS_COMPONENTS_CREDENTIAL_PROVIDER_EXTENSION_PASSWORD_SPEC_FETCHER_H_
  5. #define IOS_COMPONENTS_CREDENTIAL_PROVIDER_EXTENSION_PASSWORD_SPEC_FETCHER_H_
  6. #import <Foundation/Foundation.h>
  7. namespace autofill {
  8. class PasswordRequirementsSpec;
  9. }
  10. // Type of the block invoked when spec fetch is complete.
  11. using FetchSpecCompletionBlock =
  12. void (^)(autofill::PasswordRequirementsSpec spec);
  13. // Can fetch a password specification for the given host.
  14. @interface PasswordSpecFetcher : NSObject
  15. // |host| indicates which spec should be fetched from the service.
  16. // |APIKey| is the API key used to fetch the service.
  17. - (instancetype)initWithHost:(NSString*)host APIKey:(NSString*)APIKey;
  18. // Indicates if the spec has been fetched already.
  19. @property(nonatomic, readonly) BOOL didFetchSpec;
  20. // The spec if ready or an empty one if fetch hasn't happened.
  21. @property(nonatomic, readonly) autofill::PasswordRequirementsSpec spec;
  22. // Fetches the spec and executes |completion| in the main thread. If called
  23. // multiple times only the last completion is executed. An empty spec is
  24. // returned in case there is any error or it is not found.
  25. - (void)fetchSpecWithCompletion:(FetchSpecCompletionBlock)completion;
  26. @end
  27. #endif // IOS_COMPONENTS_CREDENTIAL_PROVIDER_EXTENSION_PASSWORD_SPEC_FETCHER_H_