shared_password_controller.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2012 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 COMPONENTS_PASSWORD_MANAGER_IOS_SHARED_PASSWORD_CONTROLLER_H_
  5. #define COMPONENTS_PASSWORD_MANAGER_IOS_SHARED_PASSWORD_CONTROLLER_H_
  6. #import <Foundation/Foundation.h>
  7. #import "components/autofill/ios/browser/form_suggestion_provider.h"
  8. #import "components/autofill/ios/form_util/form_activity_observer.h"
  9. #include "components/password_manager/core/browser/password_manager_interface.h"
  10. #import "components/password_manager/ios/password_form_helper.h"
  11. #import "components/password_manager/ios/password_generation_provider.h"
  12. #import "components/password_manager/ios/password_manager_driver_bridge.h"
  13. #import "components/password_manager/ios/password_suggestion_helper.h"
  14. #import "ios/web/public/web_state_observer_bridge.h"
  15. namespace password_manager {
  16. class PasswordManagerClient;
  17. class PasswordManagerDriver;
  18. } // namespace password_manager
  19. @class FormSuggestion;
  20. @class SharedPasswordController;
  21. // Protocol to define methods that must be implemented by the embedder.
  22. @protocol SharedPasswordControllerDelegate <NSObject>
  23. // The PasswordManagerClient owned by the delegate.
  24. @property(nonatomic, readonly)
  25. password_manager::PasswordManagerClient* passwordManagerClient;
  26. // The PasswordManagerClient owned by the delegate.
  27. @property(nonatomic, readonly)
  28. password_manager::PasswordManagerDriver* passwordManagerDriver;
  29. // Called to inform the delegate that it should prompt the user for a decision
  30. // on whether or not to use the |generatedPotentialPassword|.
  31. // |decisionHandler| takes a single BOOL indicating if the user accepted the
  32. // the suggested |generatedPotentialPassword|.
  33. - (void)sharedPasswordController:(SharedPasswordController*)controller
  34. showGeneratedPotentialPassword:(NSString*)generatedPotentialPassword
  35. decisionHandler:(void (^)(BOOL accept))decisionHandler;
  36. // Called when SharedPasswordController accepts a suggestion displayed to the
  37. // user. This can be used to additional client specific behavior.
  38. - (void)sharedPasswordController:(SharedPasswordController*)controller
  39. didAcceptSuggestion:(FormSuggestion*)suggestion;
  40. @end
  41. // Per-tab shared password controller. Handles parsing forms, loading
  42. // suggestions, filling forms, and generating passwords.
  43. @interface SharedPasswordController
  44. : NSObject <CRWWebStateObserver,
  45. FormActivityObserver,
  46. FormSuggestionProvider,
  47. PasswordFormHelperDelegate,
  48. PasswordGenerationProvider,
  49. PasswordManagerDriverBridge,
  50. PasswordSuggestionHelperDelegate>
  51. // Helper contains common password form processing logic.
  52. @property(nonatomic, readonly) PasswordFormHelper* formHelper;
  53. // Delegate to receive callbacks from this class.
  54. @property(nonatomic, weak) id<SharedPasswordControllerDelegate> delegate;
  55. - (instancetype)initWithWebState:(web::WebState*)webState
  56. manager:(password_manager::PasswordManagerInterface*)
  57. passwordManager
  58. formHelper:(PasswordFormHelper*)formHelper
  59. suggestionHelper:(PasswordSuggestionHelper*)suggestionHelper
  60. NS_DESIGNATED_INITIALIZER;
  61. - (instancetype)init NS_UNAVAILABLE;
  62. @end
  63. #endif // COMPONENTS_PASSWORD_MANAGER_IOS_SHARED_PASSWORD_CONTROLLER_H_