| // Copyright 2017 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_TAB_HELPER_H_ |
| #define IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_TAB_HELPER_H_ |
| |
| #include "ios/web/public/navigation/web_state_policy_decider.h" |
| #include "ios/web/public/web_state_observer.h" |
| #import "ios/web/public/web_state_user_data.h" |
| |
| @class CommandDispatcher; |
| @protocol FormSuggestionProvider; |
| @protocol PasswordsAccountStorageNoticeHandler; |
| @class PasswordController; |
| @protocol PasswordControllerDelegate; |
| @protocol PasswordGenerationProvider; |
| @protocol PasswordsUiDelegate; |
| @class UIViewController; |
| |
| namespace password_manager { |
| class PasswordGenerationFrameHelper; |
| class PasswordManager; |
| class PasswordManagerClient; |
| } |
| |
| // Class binding a PasswordController to a WebState. This class also opens a |
| // native Passwords UI on a specific link. |
| class PasswordTabHelper : public web::WebStateObserver, |
| public web::WebStatePolicyDecider, |
| public web::WebStateUserData<PasswordTabHelper> { |
| public: |
| PasswordTabHelper(const PasswordTabHelper&) = delete; |
| PasswordTabHelper& operator=(const PasswordTabHelper&) = delete; |
| |
| ~PasswordTabHelper() override; |
| |
| // Sets the BaseViewController from which to present UI. |
| void SetBaseViewController(UIViewController* baseViewController); |
| |
| // Sets the PasswordController delegate. |
| void SetPasswordControllerDelegate(id<PasswordControllerDelegate> delegate); |
| |
| // Sets the CommandDispatcher. |
| void SetDispatcher(CommandDispatcher* dispatcher); |
| |
| // Returns an object that can provide suggestions from the PasswordController. |
| // May return nil. |
| id<FormSuggestionProvider> GetSuggestionProvider(); |
| |
| // TODO(crbug.com/1434606): Remove this when the move to account storage |
| // notice is removed. |
| id<PasswordsAccountStorageNoticeHandler> |
| GetPasswordsAccountStorageNoticeHandler(); |
| |
| // Returns the PasswordGenerationFrameHelper owned by the PasswordController. |
| password_manager::PasswordGenerationFrameHelper* GetGenerationHelper(); |
| |
| // Returns the PasswordManager owned by the PasswordController. |
| password_manager::PasswordManager* GetPasswordManager(); |
| |
| // Returns the PasswordManagerClient owned by the PasswordController. |
| password_manager::PasswordManagerClient* GetPasswordManagerClient(); |
| |
| // Returns an object that can provide password generation from the |
| // PasswordController. May return nil. |
| id<PasswordGenerationProvider> GetPasswordGenerationProvider(); |
| |
| // web::WebStatePolicyDecider: |
| void ShouldAllowRequest( |
| NSURLRequest* request, |
| web::WebStatePolicyDecider::RequestInfo request_info, |
| web::WebStatePolicyDecider::PolicyDecisionCallback callback) override; |
| void WebStateDestroyed() override; |
| |
| private: |
| friend class web::WebStateUserData<PasswordTabHelper>; |
| |
| explicit PasswordTabHelper(web::WebState* web_state); |
| |
| // web::WebStateObserver implementation. |
| void WebStateDestroyed(web::WebState* web_state) override; |
| |
| // The Objective-C password controller instance. |
| __strong PasswordController* controller_; |
| |
| WEB_STATE_USER_DATA_KEY_DECL(); |
| }; |
| |
| #endif // IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_TAB_HELPER_H_ |