Commit 830919ba authored by Scott Wu's avatar Scott Wu Committed by Commit Bot

Rename PasswordControllerHelper to PasswordFormHelper

Bug: 865114
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: If08aa34d7c17e9f5a6dabb818669012275443587
Reviewed-on: https://chromium-review.googlesource.com/c/1278670
Commit-Queue: Scott Wu <scottwu@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599167}
parent e2dd9b16
...@@ -23,8 +23,8 @@ component("ios") { ...@@ -23,8 +23,8 @@ component("ios") {
"account_select_fill_data.h", "account_select_fill_data.h",
"js_password_manager.h", "js_password_manager.h",
"js_password_manager.mm", "js_password_manager.mm",
"password_controller_helper.h", "password_form_helper.h",
"password_controller_helper.mm", "password_form_helper.mm",
"password_suggestion_helper.h", "password_suggestion_helper.h",
"password_suggestion_helper.mm", "password_suggestion_helper.mm",
] ]
...@@ -50,7 +50,7 @@ source_set("unit_tests") { ...@@ -50,7 +50,7 @@ source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"account_select_fill_data_unittest.cc", "account_select_fill_data_unittest.cc",
"password_controller_helper_unittest.mm", "password_form_helper_unittest.mm",
] ]
deps = [ deps = [
":ios", ":ios",
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_CONTROLLER_HELPER_H_ #ifndef COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_FORM_HELPER_H_
#define COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_CONTROLLER_HELPER_H_ #define COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_FORM_HELPER_H_
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class JsPasswordManager; @class JsPasswordManager;
@class PasswordControllerHelper; @class PasswordFormHelper;
namespace autofill { namespace autofill {
struct PasswordForm; struct PasswordForm;
...@@ -33,18 +33,17 @@ namespace web { ...@@ -33,18 +33,17 @@ namespace web {
class WebState; class WebState;
} // namespace web } // namespace web
// A protocol implemented by a delegate of PasswordControllerHelper. // A protocol implemented by a delegate of PasswordFormHelper.
@protocol PasswordControllerHelperDelegate @protocol PasswordFormHelperDelegate
// Called when the password form is submitted. // Called when the password form is submitted.
- (void)helper:(PasswordControllerHelper*)helper - (void)formHelper:(PasswordFormHelper*)formHelper
didSubmitForm:(const autofill::PasswordForm&)form didSubmitForm:(const autofill::PasswordForm&)form
inMainFrame:(BOOL)inMainFrame; inMainFrame:(BOOL)inMainFrame;
@end @end
// Handles common logic of password controller for both ios/chrome and // Handles common form processing logic of password controller for both
// ios/web_view. // ios/chrome and ios/web_view.
// TODO(crbug.com/865114): Rename to PasswordFormHelper. @interface PasswordFormHelper
@interface PasswordControllerHelper
: NSObject<FormActivityObserver, CRWWebStateObserver> : NSObject<FormActivityObserver, CRWWebStateObserver>
// The JsPasswordManager processing password form via javascript. // The JsPasswordManager processing password form via javascript.
...@@ -82,8 +81,9 @@ class WebState; ...@@ -82,8 +81,9 @@ class WebState;
// Creates a instance with the given WebState, observer and delegate. // Creates a instance with the given WebState, observer and delegate.
- (instancetype)initWithWebState:(web::WebState*)webState - (instancetype)initWithWebState:(web::WebState*)webState
delegate:(nullable id<PasswordControllerHelperDelegate>) delegate:
delegate NS_DESIGNATED_INITIALIZER; (nullable id<PasswordFormHelperDelegate>)delegate
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
...@@ -91,4 +91,4 @@ class WebState; ...@@ -91,4 +91,4 @@ class WebState;
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif // COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_CONTROLLER_HELPER_H_ #endif // COMPONENTS_PASSWORD_MANAGER_IOS_PASSWORD_FORM_HELPER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#include <stddef.h> #include <stddef.h>
...@@ -48,9 +48,9 @@ namespace { ...@@ -48,9 +48,9 @@ namespace {
constexpr char kCommandPrefix[] = "passwordForm"; constexpr char kCommandPrefix[] = "passwordForm";
} // namespace } // namespace
@interface PasswordControllerHelper () @interface PasswordFormHelper ()
@property(nonatomic, weak) id<PasswordControllerHelperDelegate> delegate; @property(nonatomic, weak) id<PasswordFormHelperDelegate> delegate;
// Handler for injected JavaScript callbacks. // Handler for injected JavaScript callbacks.
- (BOOL)handleScriptCommand:(const base::DictionaryValue&)JSONCommand; - (BOOL)handleScriptCommand:(const base::DictionaryValue&)JSONCommand;
...@@ -80,14 +80,14 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -80,14 +80,14 @@ constexpr char kCommandPrefix[] = "passwordForm";
@end @end
// Category for test only. // Category for test only.
@interface PasswordControllerHelper (Testing) @interface PasswordFormHelper (Testing)
// Replaces JsPasswordManager for test. // Replaces JsPasswordManager for test.
- (void)setJsPasswordManager:(JsPasswordManager*)jsPasswordManager; - (void)setJsPasswordManager:(JsPasswordManager*)jsPasswordManager;
@end @end
@implementation PasswordControllerHelper { @implementation PasswordFormHelper {
// The WebState this instance is observing. Will be null after // The WebState this instance is observing. Will be null after
// -webStateDestroyed: has been called. // -webStateDestroyed: has been called.
web::WebState* _webState; web::WebState* _webState;
...@@ -112,8 +112,7 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -112,8 +112,7 @@ constexpr char kCommandPrefix[] = "passwordForm";
#pragma mark - Initialization #pragma mark - Initialization
- (instancetype)initWithWebState:(web::WebState*)webState - (instancetype)initWithWebState:(web::WebState*)webState
delegate: delegate:(id<PasswordFormHelperDelegate>)delegate {
(id<PasswordControllerHelperDelegate>)delegate {
self = [super init]; self = [super init];
if (self) { if (self) {
DCHECK(webState); DCHECK(webState);
...@@ -127,7 +126,7 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -127,7 +126,7 @@ constexpr char kCommandPrefix[] = "passwordForm";
_jsPasswordManager = [[JsPasswordManager alloc] _jsPasswordManager = [[JsPasswordManager alloc]
initWithReceiver:_webState->GetJSInjectionReceiver()]; initWithReceiver:_webState->GetJSInjectionReceiver()];
__weak PasswordControllerHelper* weakSelf = self; __weak PasswordFormHelper* weakSelf = self;
auto callback = base::BindRepeating( auto callback = base::BindRepeating(
^bool(const base::DictionaryValue& JSON, const GURL& originURL, ^bool(const base::DictionaryValue& JSON, const GURL& originURL,
bool interacting, bool isMainFrame, web::WebFrame* senderFrame) { bool interacting, bool isMainFrame, web::WebFrame* senderFrame) {
...@@ -181,18 +180,18 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -181,18 +180,18 @@ constexpr char kCommandPrefix[] = "passwordForm";
// origin. // origin.
return; return;
} }
__weak PasswordControllerHelper* weakSelf = self; __weak PasswordFormHelper* weakSelf = self;
// This code is racing against the new page loading and will not get the // This code is racing against the new page loading and will not get the
// password form data if the page has changed. In most cases this code wins // password form data if the page has changed. In most cases this code wins
// the race. // the race.
// TODO(crbug.com/418827): Fix this by passing in more data from the JS side. // TODO(crbug.com/418827): Fix this by passing in more data from the JS side.
id completionHandler = ^(BOOL found, const autofill::PasswordForm& form) { id completionHandler = ^(BOOL found, const autofill::PasswordForm& form) {
PasswordControllerHelper* strongSelf = weakSelf; PasswordFormHelper* strongSelf = weakSelf;
id<PasswordControllerHelperDelegate> strongDelegate = strongSelf.delegate; id<PasswordFormHelperDelegate> strongDelegate = strongSelf.delegate;
if (!strongSelf || !strongSelf->_webState || !strongDelegate) { if (!strongSelf || !strongSelf->_webState || !strongDelegate) {
return; return;
} }
[strongDelegate helper:strongSelf [strongDelegate formHelper:strongSelf
didSubmitForm:form didSubmitForm:form
inMainFrame:formInMainFrame]; inMainFrame:formInMainFrame];
}; };
...@@ -231,7 +230,7 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -231,7 +230,7 @@ constexpr char kCommandPrefix[] = "passwordForm";
} }
if (_webState && self.delegate) { if (_webState && self.delegate) {
[self.delegate helper:self didSubmitForm:*form inMainFrame:YES]; [self.delegate formHelper:self didSubmitForm:*form inMainFrame:YES];
return YES; return YES;
} }
...@@ -343,7 +342,7 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -343,7 +342,7 @@ constexpr char kCommandPrefix[] = "passwordForm";
return; return;
} }
__weak PasswordControllerHelper* weakSelf = self; __weak PasswordFormHelper* weakSelf = self;
[self.jsPasswordManager findPasswordFormsWithCompletionHandler:^( [self.jsPasswordManager findPasswordFormsWithCompletionHandler:^(
NSString* jsonString) { NSString* jsonString) {
std::vector<autofill::PasswordForm> forms; std::vector<autofill::PasswordForm> forms;
...@@ -386,10 +385,10 @@ constexpr char kCommandPrefix[] = "passwordForm"; ...@@ -386,10 +385,10 @@ constexpr char kCommandPrefix[] = "passwordForm";
password:(NSString*)password password:(NSString*)password
completionHandler: completionHandler:
(nullable void (^)(BOOL))completionHandler { (nullable void (^)(BOOL))completionHandler {
__weak PasswordControllerHelper* weakSelf = self; __weak PasswordFormHelper* weakSelf = self;
[self findPasswordFormsWithCompletionHandler:^( [self findPasswordFormsWithCompletionHandler:^(
const std::vector<autofill::PasswordForm>& forms) { const std::vector<autofill::PasswordForm>& forms) {
PasswordControllerHelper* strongSelf = weakSelf; PasswordFormHelper* strongSelf = weakSelf;
for (const auto& form : forms) { for (const auto& form : forms) {
autofill::PasswordFormFillData formData; autofill::PasswordFormFillData formData;
std::map<base::string16, const autofill::PasswordForm*> matches; std::map<base::string16, const autofill::PasswordForm*> matches;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#include <stddef.h> #include <stddef.h>
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "components/password_manager/core/browser/stub_password_manager_driver.h" #include "components/password_manager/core/browser/stub_password_manager_driver.h"
#include "components/password_manager/ios/account_select_fill_data.h" #include "components/password_manager/ios/account_select_fill_data.h"
#import "components/password_manager/ios/js_password_manager.h" #import "components/password_manager/ios/js_password_manager.h"
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#include "components/password_manager/ios/test_helpers.h" #include "components/password_manager/ios/test_helpers.h"
#include "ios/web/public/test/fakes/test_web_client.h" #include "ios/web/public/test/fakes/test_web_client.h"
#import "ios/web/public/test/web_test_with_web_state.h" #import "ios/web/public/test/web_test_with_web_state.h"
...@@ -38,7 +38,7 @@ using password_manager::FillData; ...@@ -38,7 +38,7 @@ using password_manager::FillData;
using test_helpers::SetPasswordFormFillData; using test_helpers::SetPasswordFormFillData;
using test_helpers::SetFillData; using test_helpers::SetFillData;
@interface PasswordControllerHelper (Testing) @interface PasswordFormHelper (Testing)
// Provides access to the method below for testing with mocks. // Provides access to the method below for testing with mocks.
- (void)extractSubmittedPasswordForm:(const std::string&)formName - (void)extractSubmittedPasswordForm:(const std::string&)formName
...@@ -126,17 +126,17 @@ class TestWebClientWithScript : public web::TestWebClient { ...@@ -126,17 +126,17 @@ class TestWebClientWithScript : public web::TestWebClient {
} }
}; };
class PasswordControllerHelperTest : public web::WebTestWithWebState { class PasswordFormHelperTest : public web::WebTestWithWebState {
public: public:
PasswordControllerHelperTest() PasswordFormHelperTest()
: web::WebTestWithWebState(std::make_unique<TestWebClientWithScript>()) {} : web::WebTestWithWebState(std::make_unique<TestWebClientWithScript>()) {}
~PasswordControllerHelperTest() override = default; ~PasswordFormHelperTest() override = default;
void SetUp() override { void SetUp() override {
WebTestWithWebState::SetUp(); WebTestWithWebState::SetUp();
helper_ = [[PasswordControllerHelper alloc] initWithWebState:web_state() helper_ =
delegate:nil]; [[PasswordFormHelper alloc] initWithWebState:web_state() delegate:nil];
} }
void TearDown() override { void TearDown() override {
...@@ -155,10 +155,10 @@ class PasswordControllerHelperTest : public web::WebTestWithWebState { ...@@ -155,10 +155,10 @@ class PasswordControllerHelperTest : public web::WebTestWithWebState {
[NSString stringWithFormat:kGetFormIdScript, form_index])); [NSString stringWithFormat:kGetFormIdScript, form_index]));
} }
// PasswordControllerHelper for testing. // PasswordFormHelper for testing.
PasswordControllerHelper* helper_; PasswordFormHelper* helper_;
DISALLOW_COPY_AND_ASSIGN(PasswordControllerHelperTest); DISALLOW_COPY_AND_ASSIGN(PasswordFormHelperTest);
}; };
struct GetSubmittedPasswordFormTestData { struct GetSubmittedPasswordFormTestData {
...@@ -176,7 +176,7 @@ struct GetSubmittedPasswordFormTestData { ...@@ -176,7 +176,7 @@ struct GetSubmittedPasswordFormTestData {
// Check that HTML forms are captured and converted correctly into // Check that HTML forms are captured and converted correctly into
// PasswordForms on submission. // PasswordForms on submission.
TEST_F(PasswordControllerHelperTest, GetSubmittedPasswordForm) { TEST_F(PasswordFormHelperTest, GetSubmittedPasswordForm) {
// clang-format off // clang-format off
const GetSubmittedPasswordFormTestData test_data[] = { const GetSubmittedPasswordFormTestData test_data[] = {
// Two forms with no explicit names. // Two forms with no explicit names.
...@@ -267,7 +267,7 @@ struct FindPasswordFormTestData { ...@@ -267,7 +267,7 @@ struct FindPasswordFormTestData {
}; };
// Check that HTML forms are converted correctly into PasswordForms. // Check that HTML forms are converted correctly into PasswordForms.
TEST_F(PasswordControllerHelperTest, FindPasswordFormsInView) { TEST_F(PasswordFormHelperTest, FindPasswordFormsInView) {
// clang-format off // clang-format off
const FindPasswordFormTestData test_data[] = { const FindPasswordFormTestData test_data[] = {
// Normal form: a username and a password element. // Normal form: a username and a password element.
...@@ -500,7 +500,7 @@ struct FillPasswordFormTestData { ...@@ -500,7 +500,7 @@ struct FillPasswordFormTestData {
}; };
// Tests that filling password forms works correctly. // Tests that filling password forms works correctly.
TEST_F(PasswordControllerHelperTest, FillPasswordForm) { TEST_F(PasswordFormHelperTest, FillPasswordForm) {
LoadHtml(kHtmlWithMultiplePasswordForms); LoadHtml(kHtmlWithMultiplePasswordForms);
const std::string base_url = BaseUrl(); const std::string base_url = BaseUrl();
...@@ -649,7 +649,7 @@ TEST_F(PasswordControllerHelperTest, FillPasswordForm) { ...@@ -649,7 +649,7 @@ TEST_F(PasswordControllerHelperTest, FillPasswordForm) {
} }
// Tests that filling password forms with fill data works correctly. // Tests that filling password forms with fill data works correctly.
TEST_F(PasswordControllerHelperTest, FillPasswordFormWithFillData) { TEST_F(PasswordFormHelperTest, FillPasswordFormWithFillData) {
LoadHtml( LoadHtml(
@"<form><input id='u1' type='text' name='un1'>" @"<form><input id='u1' type='text' name='un1'>"
"<input id='p1' type='password' name='pw1'></form>"); "<input id='p1' type='password' name='pw1'></form>");
...@@ -673,7 +673,7 @@ TEST_F(PasswordControllerHelperTest, FillPasswordFormWithFillData) { ...@@ -673,7 +673,7 @@ TEST_F(PasswordControllerHelperTest, FillPasswordFormWithFillData) {
// Tests that a form is found and the found form is filled in with the given // Tests that a form is found and the found form is filled in with the given
// username and password. // username and password.
TEST_F(PasswordControllerHelperTest, FindAndFillOnePasswordForm) { TEST_F(PasswordFormHelperTest, FindAndFillOnePasswordForm) {
LoadHtml( LoadHtml(
@"<form><input id='u1' type='text' name='un1'>" @"<form><input id='u1' type='text' name='un1'>"
"<input id='p1' type='password' name='pw1'></form>"); "<input id='p1' type='password' name='pw1'></form>");
...@@ -698,7 +698,7 @@ TEST_F(PasswordControllerHelperTest, FindAndFillOnePasswordForm) { ...@@ -698,7 +698,7 @@ TEST_F(PasswordControllerHelperTest, FindAndFillOnePasswordForm) {
// Tests that multiple forms on the same page are found and filled. // Tests that multiple forms on the same page are found and filled.
// This test includes an mock injected failure on form filling to verify // This test includes an mock injected failure on form filling to verify
// that completion handler is called with the proper values. // that completion handler is called with the proper values.
TEST_F(PasswordControllerHelperTest, FindAndFillMultiplePasswordForms) { TEST_F(PasswordFormHelperTest, FindAndFillMultiplePasswordForms) {
// Fails the first call to fill password form. // Fails the first call to fill password form.
MockJsPasswordManager* mockJsPasswordManager = [[MockJsPasswordManager alloc] MockJsPasswordManager* mockJsPasswordManager = [[MockJsPasswordManager alloc]
initWithReceiver:web_state()->GetJSInjectionReceiver()]; initWithReceiver:web_state()->GetJSInjectionReceiver()];
......
...@@ -72,7 +72,7 @@ retrieveSuggestionsWithFormName:(NSString*)formName ...@@ -72,7 +72,7 @@ retrieveSuggestionsWithFormName:(NSString*)formName
(SuggestionsAvailableCompletion)completion; (SuggestionsAvailableCompletion)completion;
// Retrieves password form fill data for |username| for use in // Retrieves password form fill data for |username| for use in
// |PasswordControllerHelper|'s // |PasswordFormHelper|'s
// -fillPasswordFormWithFillData:completionHandler:. // -fillPasswordFormWithFillData:completionHandler:.
- (std::unique_ptr<password_manager::FillData>)getFillDataForUsername: - (std::unique_ptr<password_manager::FillData>)getFillDataForUsername:
(NSString*)username; (NSString*)username;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <memory> #include <memory>
#import "components/autofill/ios/browser/form_suggestion_provider.h" #import "components/autofill/ios/browser/form_suggestion_provider.h"
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#import "ios/chrome/browser/passwords/ios_chrome_password_manager_client.h" #import "ios/chrome/browser/passwords/ios_chrome_password_manager_client.h"
#import "ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h" #import "ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h" #import "ios/web/public/web_state/web_state_observer_bridge.h"
...@@ -42,7 +42,7 @@ class PasswordManagerClient; ...@@ -42,7 +42,7 @@ class PasswordManagerClient;
@interface PasswordController : NSObject<CRWWebStateObserver, @interface PasswordController : NSObject<CRWWebStateObserver,
PasswordManagerClientDelegate, PasswordManagerClientDelegate,
PasswordManagerDriverDelegate, PasswordManagerDriverDelegate,
PasswordControllerHelperDelegate> PasswordFormHelperDelegate>
// An object that can provide suggestions from this PasswordController. // An object that can provide suggestions from this PasswordController.
@property(nonatomic, readonly) id<FormSuggestionProvider> suggestionProvider; @property(nonatomic, readonly) id<FormSuggestionProvider> suggestionProvider;
......
...@@ -116,8 +116,8 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -116,8 +116,8 @@ void LogSuggestionShown(PasswordSuggestionType type) {
@property(nonatomic, strong) @property(nonatomic, strong)
NotifyUserAutoSigninViewController* notifyAutoSigninViewController; NotifyUserAutoSigninViewController* notifyAutoSigninViewController;
// Helper contains common password controller logic. // Helper contains common password form processing logic.
@property(nonatomic, readonly) PasswordControllerHelper* helper; @property(nonatomic, readonly) PasswordFormHelper* formHelper;
// Helper contains common password suggestion logic. // Helper contains common password suggestion logic.
@property(nonatomic, readonly) PasswordSuggestionHelper* suggestionHelper; @property(nonatomic, readonly) PasswordSuggestionHelper* suggestionHelper;
...@@ -177,7 +177,7 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -177,7 +177,7 @@ void LogSuggestionShown(PasswordSuggestionType type) {
@synthesize notifyAutoSigninViewController = _notifyAutoSigninViewController; @synthesize notifyAutoSigninViewController = _notifyAutoSigninViewController;
@synthesize helper = _helper; @synthesize formHelper = _formHelper;
@synthesize suggestionHelper = _suggestionHelper; @synthesize suggestionHelper = _suggestionHelper;
...@@ -197,8 +197,8 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -197,8 +197,8 @@ void LogSuggestionShown(PasswordSuggestionType type) {
_webStateObserverBridge = _webStateObserverBridge =
std::make_unique<web::WebStateObserverBridge>(self); std::make_unique<web::WebStateObserverBridge>(self);
_webState->AddObserver(_webStateObserverBridge.get()); _webState->AddObserver(_webStateObserverBridge.get());
_helper = [[PasswordControllerHelper alloc] initWithWebState:webState _formHelper =
delegate:self]; [[PasswordFormHelper alloc] initWithWebState:webState delegate:self];
_suggestionHelper = _suggestionHelper =
[[PasswordSuggestionHelper alloc] initWithDelegate:self]; [[PasswordSuggestionHelper alloc] initWithDelegate:self];
if (passwordManagerClient) if (passwordManagerClient)
...@@ -246,7 +246,7 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -246,7 +246,7 @@ void LogSuggestionShown(PasswordSuggestionType type) {
- (void)findAndFillPasswordForms:(NSString*)username - (void)findAndFillPasswordForms:(NSString*)username
password:(NSString*)password password:(NSString*)password
completionHandler:(void (^)(BOOL))completionHandler { completionHandler:(void (^)(BOOL))completionHandler {
[self.helper findAndFillPasswordFormsWithUserName:username [self.formHelper findAndFillPasswordFormsWithUserName:username
password:password password:password
completionHandler:completionHandler]; completionHandler:completionHandler];
} }
...@@ -411,7 +411,7 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -411,7 +411,7 @@ void LogSuggestionShown(PasswordSuggestionType type) {
if (!fillData) if (!fillData)
completion(); completion();
[self.helper fillPasswordFormWithFillData:*fillData [self.formHelper fillPasswordFormWithFillData:*fillData
completionHandler:^(BOOL success) { completionHandler:^(BOOL success) {
completion(); completion();
}]; }];
...@@ -430,7 +430,7 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -430,7 +430,7 @@ void LogSuggestionShown(PasswordSuggestionType type) {
} }
- (const GURL&)lastCommittedURL { - (const GURL&)lastCommittedURL {
return self.helper.lastCommittedURL; return self.formHelper.lastCommittedURL;
} }
- (void)showSavePasswordInfoBar: - (void)showSavePasswordInfoBar:
...@@ -490,16 +490,17 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -490,16 +490,17 @@ void LogSuggestionShown(PasswordSuggestionType type) {
- (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData - (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData
completionHandler:(void (^)(BOOL))completionHandler { completionHandler:(void (^)(BOOL))completionHandler {
[self.suggestionHelper processWithPasswordFormFillData:formData]; [self.suggestionHelper processWithPasswordFormFillData:formData];
[self.helper fillPasswordForm:formData completionHandler:completionHandler]; [self.formHelper fillPasswordForm:formData
completionHandler:completionHandler];
} }
- (void)onNoSavedCredentials { - (void)onNoSavedCredentials {
[self.suggestionHelper processWithNoSavedCredentials]; [self.suggestionHelper processWithNoSavedCredentials];
} }
#pragma mark - PasswordControllerHelperDelegate #pragma mark - PasswordFormHelperDelegate
- (void)helper:(PasswordControllerHelper*)helper - (void)formHelper:(PasswordFormHelper*)formHelper
didSubmitForm:(const PasswordForm&)form didSubmitForm:(const PasswordForm&)form
inMainFrame:(BOOL)inMainFrame { inMainFrame:(BOOL)inMainFrame {
if (inMainFrame) { if (inMainFrame) {
...@@ -559,7 +560,7 @@ void LogSuggestionShown(PasswordSuggestionType type) { ...@@ -559,7 +560,7 @@ void LogSuggestionShown(PasswordSuggestionType type) {
// Read all password forms from the page and send them to the password // Read all password forms from the page and send them to the password
// manager. // manager.
__weak PasswordController* weakSelf = self; __weak PasswordController* weakSelf = self;
[self.helper findPasswordFormsWithCompletionHandler:^( [self.formHelper findPasswordFormsWithCompletionHandler:^(
const std::vector<autofill::PasswordForm>& forms) { const std::vector<autofill::PasswordForm>& forms) {
[weakSelf didFinishPasswordFormExtraction:forms]; [weakSelf didFinishPasswordFormExtraction:forms];
}]; }];
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "components/password_manager/core/browser/stub_password_manager_client.h" #include "components/password_manager/core/browser/stub_password_manager_client.h"
#include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.h"
#import "components/password_manager/ios/js_password_manager.h" #import "components/password_manager/ios/js_password_manager.h"
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#include "components/password_manager/ios/test_helpers.h" #include "components/password_manager/ios/test_helpers.h"
#include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h" #include "components/prefs/testing_pref_service.h"
...@@ -150,8 +150,8 @@ ACTION(InvokeEmptyConsumerWithForms) { ...@@ -150,8 +150,8 @@ ACTION(InvokeEmptyConsumerWithForms) {
@interface PasswordController ( @interface PasswordController (
Testing)<CRWWebStateObserver, FormSuggestionProvider> Testing)<CRWWebStateObserver, FormSuggestionProvider>
// Provides access to common helper logic for testing with mocks. // Provides access to common form helper logic for testing with mocks.
@property(readonly) PasswordControllerHelper* helper; @property(readonly) PasswordFormHelper* formHelper;
- (void)fillPasswordForm:(const PasswordFormFillData&)formData - (void)fillPasswordForm:(const PasswordFormFillData&)formData
completionHandler:(void (^)(BOOL))completionHandler; completionHandler:(void (^)(BOOL))completionHandler;
...@@ -160,7 +160,7 @@ ACTION(InvokeEmptyConsumerWithForms) { ...@@ -160,7 +160,7 @@ ACTION(InvokeEmptyConsumerWithForms) {
@end @end
@interface PasswordControllerHelper (Testing) @interface PasswordFormHelper (Testing)
// Provides access to JavaScript Manager for testing with mocks. // Provides access to JavaScript Manager for testing with mocks.
@property(readonly) JsPasswordManager* jsPasswordManager; @property(readonly) JsPasswordManager* jsPasswordManager;
...@@ -254,7 +254,7 @@ class PasswordControllerTest : public ChromeWebTest { ...@@ -254,7 +254,7 @@ class PasswordControllerTest : public ChromeWebTest {
// |failure_count| reaches |target_failure_count|, stop the partial mock // |failure_count| reaches |target_failure_count|, stop the partial mock
// and let the original JavaScript manager execute. // and let the original JavaScript manager execute.
void SetFillPasswordFormFailureCount(int target_failure_count) { void SetFillPasswordFormFailureCount(int target_failure_count) {
id original_manager = passwordController_.helper.jsPasswordManager; id original_manager = passwordController_.formHelper.jsPasswordManager;
OCPartialMockObject* failing_manager = OCPartialMockObject* failing_manager =
[OCMockObject partialMockForObject:original_manager]; [OCMockObject partialMockForObject:original_manager];
__block int failure_count = 0; __block int failure_count = 0;
...@@ -388,7 +388,8 @@ TEST_F(PasswordControllerTest, FLAKY_FindPasswordFormsInView) { ...@@ -388,7 +388,8 @@ TEST_F(PasswordControllerTest, FLAKY_FindPasswordFormsInView) {
LoadHtml(data.html_string); LoadHtml(data.html_string);
__block std::vector<PasswordForm> forms; __block std::vector<PasswordForm> forms;
__block BOOL block_was_called = NO; __block BOOL block_was_called = NO;
[passwordController_.helper findPasswordFormsWithCompletionHandler:^( [passwordController_.formHelper
findPasswordFormsWithCompletionHandler:^(
const std::vector<PasswordForm>& result) { const std::vector<PasswordForm>& result) {
block_was_called = YES; block_was_called = YES;
forms = result; forms = result;
...@@ -489,7 +490,7 @@ TEST_F(PasswordControllerTest, FLAKY_GetSubmittedPasswordForm) { ...@@ -489,7 +490,7 @@ TEST_F(PasswordControllerTest, FLAKY_GetSubmittedPasswordForm) {
form.username_element); form.username_element);
} }
}; };
[passwordController_.helper [passwordController_.formHelper
extractSubmittedPasswordForm:FormName(data.number_of_forms_to_submit) extractSubmittedPasswordForm:FormName(data.number_of_forms_to_submit)
completionHandler:completion_handler]; completionHandler:completion_handler];
EXPECT_TRUE( EXPECT_TRUE(
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "components/autofill/ios/browser/autofill_util.h" #include "components/autofill/ios/browser/autofill_util.h"
#import "components/password_manager/core/browser/form_parsing/ios_form_parser.h" #import "components/password_manager/core/browser/form_parsing/ios_form_parser.h"
#include "components/password_manager/core/browser/password_manager.h" #include "components/password_manager/core/browser/password_manager.h"
#import "components/password_manager/ios/password_controller_helper.h" #import "components/password_manager/ios/password_form_helper.h"
#import "ios/web/public/origin_util.h" #import "ios/web/public/origin_util.h"
#include "ios/web/public/url_scheme_util.h" #include "ios/web/public/url_scheme_util.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h" #import "ios/web/public/web_state/web_state_observer_bridge.h"
...@@ -36,14 +36,14 @@ using password_manager::PasswordFormManagerForUI; ...@@ -36,14 +36,14 @@ using password_manager::PasswordFormManagerForUI;
@interface CWVPasswordController ()<CRWWebStateObserver, @interface CWVPasswordController ()<CRWWebStateObserver,
CWVPasswordManagerClientDelegate, CWVPasswordManagerClientDelegate,
CWVPasswordManagerDriverDelegate, CWVPasswordManagerDriverDelegate,
PasswordControllerHelperDelegate> PasswordFormHelperDelegate>
// The PasswordManagerDriver owned by this PasswordController. // The PasswordManagerDriver owned by this PasswordController.
@property(nonatomic, readonly) @property(nonatomic, readonly)
password_manager::PasswordManagerDriver* passwordManagerDriver; password_manager::PasswordManagerDriver* passwordManagerDriver;
// Helper contains common password controller logic. // Helper contains common password form processing logic.
@property(nonatomic, readonly) PasswordControllerHelper* helper; @property(nonatomic, readonly) PasswordFormHelper* formHelper;
// Delegate to receive password autofill suggestion callbacks. // Delegate to receive password autofill suggestion callbacks.
@property(nonatomic, weak, nullable) id<CWVPasswordControllerDelegate> delegate; @property(nonatomic, weak, nullable) id<CWVPasswordControllerDelegate> delegate;
...@@ -83,7 +83,7 @@ using password_manager::PasswordFormManagerForUI; ...@@ -83,7 +83,7 @@ using password_manager::PasswordFormManagerForUI;
#pragma mark - Properties #pragma mark - Properties
@synthesize helper = _helper; @synthesize formHelper = _formHelper;
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
- (password_manager::PasswordManagerDriver*)passwordManagerDriver { - (password_manager::PasswordManagerDriver*)passwordManagerDriver {
...@@ -102,8 +102,8 @@ using password_manager::PasswordFormManagerForUI; ...@@ -102,8 +102,8 @@ using password_manager::PasswordFormManagerForUI;
_webStateObserverBridge = _webStateObserverBridge =
std::make_unique<web::WebStateObserverBridge>(self); std::make_unique<web::WebStateObserverBridge>(self);
_webState->AddObserver(_webStateObserverBridge.get()); _webState->AddObserver(_webStateObserverBridge.get());
_helper = [[PasswordControllerHelper alloc] initWithWebState:webState _formHelper =
delegate:self]; [[PasswordFormHelper alloc] initWithWebState:webState delegate:self];
_passwordManagerClient = _passwordManagerClient =
std::make_unique<WebViewPasswordManagerClient>(self); std::make_unique<WebViewPasswordManagerClient>(self);
...@@ -186,7 +186,7 @@ using password_manager::PasswordFormManagerForUI; ...@@ -186,7 +186,7 @@ using password_manager::PasswordFormManagerForUI;
} }
- (const GURL&)lastCommittedURL { - (const GURL&)lastCommittedURL {
return self.helper.lastCommittedURL; return self.formHelper.lastCommittedURL;
} }
- (void)showSavePasswordInfoBar: - (void)showSavePasswordInfoBar:
...@@ -259,7 +259,7 @@ using password_manager::PasswordFormManagerForUI; ...@@ -259,7 +259,7 @@ using password_manager::PasswordFormManagerForUI;
- (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData { - (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData {
// TODO(crbug.com/865114): Add suggestion related logic. // TODO(crbug.com/865114): Add suggestion related logic.
[self.helper fillPasswordForm:formData completionHandler:nil]; [self.formHelper fillPasswordForm:formData completionHandler:nil];
} }
// Informs delegate that there are no saved credentials for the current page. // Informs delegate that there are no saved credentials for the current page.
...@@ -267,9 +267,9 @@ using password_manager::PasswordFormManagerForUI; ...@@ -267,9 +267,9 @@ using password_manager::PasswordFormManagerForUI;
// TODO(crbug.com/865114): Implement remaining logic. // TODO(crbug.com/865114): Implement remaining logic.
} }
#pragma mark - PasswordControllerHelperDelegate #pragma mark - PasswordFormHelperDelegate
- (void)helper:(PasswordControllerHelper*)helper - (void)formHelper:(PasswordFormHelper*)formHelper
didSubmitForm:(const PasswordForm&)form didSubmitForm:(const PasswordForm&)form
inMainFrame:(BOOL)inMainFrame { inMainFrame:(BOOL)inMainFrame {
if (inMainFrame) { if (inMainFrame) {
...@@ -314,7 +314,7 @@ using password_manager::PasswordFormManagerForUI; ...@@ -314,7 +314,7 @@ using password_manager::PasswordFormManagerForUI;
// Read all password forms from the page and send them to the password // Read all password forms from the page and send them to the password
// manager. // manager.
__weak CWVPasswordController* weakSelf = self; __weak CWVPasswordController* weakSelf = self;
[self.helper findPasswordFormsWithCompletionHandler:^( [self.formHelper findPasswordFormsWithCompletionHandler:^(
const std::vector<autofill::PasswordForm>& forms) { const std::vector<autofill::PasswordForm>& forms) {
[weakSelf didFinishPasswordFormExtraction:forms]; [weakSelf didFinishPasswordFormExtraction:forms];
}]; }];
......
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