diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 22:11:37 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-09 22:11:37 +0000 |
commit | 234ceced6c4d95d8602656f3bdbbe5b9399f0432 (patch) | |
tree | 5739420a7cf2940c33404ac4c61b0c64af2dbf07 | |
parent | db97b49fdd856f33bd810db4564c6f2cc14be71a (diff) | |
download | chromium_src-234ceced6c4d95d8602656f3bdbbe5b9399f0432.zip chromium_src-234ceced6c4d95d8602656f3bdbbe5b9399f0432.tar.gz chromium_src-234ceced6c4d95d8602656f3bdbbe5b9399f0432.tar.bz2 |
Change all other AutofillDialogView methods with a const DetailInput& as a param
to a ServerFieldType.
This is necessary as some browser tests started failing when country changes
caused DetailInputs for a section to be rebuilt even with the same type and
contents.
R=estade@chromium.org,groby@chromium.org
BUG=331544
Review URL: https://codereview.chromium.org/130563003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243992 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 130 insertions, 162 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index f4ec293..bc1bf94 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -556,21 +556,21 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { const DetailInputs& inputs = controller()->RequestedFieldsForSection(SECTION_SHIPPING); - const DetailInput& triggering_input = inputs[0]; - base::string16 value = full_profile.GetRawInfo(triggering_input.type); + const ServerFieldType triggering_type = inputs[0].type; + base::string16 value = full_profile.GetRawInfo(triggering_type); TestableAutofillDialogView* view = controller()->GetTestableView(); - view->SetTextContentsOfInput(triggering_input, + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); + view->ActivateInput(triggering_type); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); // All inputs should be filled. AutofillProfileWrapper wrapper(&full_profile); for (size_t i = 0; i < inputs.size(); ++i) { EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), - view->GetTextContentsOfInput(inputs[i])); + view->GetTextContentsOfInput(inputs[i].type)); } // Now simulate some user edits and try again. @@ -578,23 +578,23 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, FillInputFromAutofill) { for (size_t i = 0; i < inputs.size(); ++i) { base::string16 users_input = i % 2 == 0 ? base::string16() : ASCIIToUTF16("dummy"); - view->SetTextContentsOfInput(inputs[i], users_input); + view->SetTextContentsOfInput(inputs[i].type, users_input); // Empty inputs should be filled, others should be left alone. base::string16 expectation = - &inputs[i] == &triggering_input || users_input.empty() ? + inputs[i].type == triggering_type || users_input.empty() ? wrapper.GetInfo(AutofillType(inputs[i].type)) : users_input; expectations.push_back(expectation); } - view->SetTextContentsOfInput(triggering_input, + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + view->ActivateInput(triggering_type); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); for (size_t i = 0; i < inputs.size(); ++i) { - EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); + EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); } } @@ -609,24 +609,24 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, const DetailInputs& inputs = controller()->RequestedFieldsForSection(SECTION_SHIPPING); - const DetailInput& triggering_input = inputs[0]; - base::string16 value = full_profile.GetRawInfo(triggering_input.type); + const ServerFieldType triggering_type = inputs[0].type; + base::string16 value = full_profile.GetRawInfo(triggering_type); TestableAutofillDialogView* view = controller()->GetTestableView(); - view->SetTextContentsOfInput(triggering_input, + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); + view->ActivateInput(triggering_type); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); // All inputs should be filled. AutofillProfileWrapper wrapper(&full_profile); for (size_t i = 0; i < inputs.size(); ++i) { + const ServerFieldType type = inputs[i].type; base::string16 expectation = - AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY ? - ASCIIToUTF16("United States") : - wrapper.GetInfo(AutofillType(inputs[i].type)); - EXPECT_EQ(expectation, view->GetTextContentsOfInput(inputs[i])); + AutofillType(type).GetStorableType() == ADDRESS_HOME_COUNTRY ? + ASCIIToUTF16("United States") : wrapper.GetInfo(AutofillType(type)); + EXPECT_EQ(expectation, view->GetTextContentsOfInput(type)); } // Now simulate some user edits and try again. @@ -634,10 +634,10 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, for (size_t i = 0; i < inputs.size(); ++i) { base::string16 users_input = i % 2 == 0 ? base::string16() : ASCIIToUTF16("dummy"); - view->SetTextContentsOfInput(inputs[i], users_input); + view->SetTextContentsOfInput(inputs[i].type, users_input); // Empty inputs should be filled, others should be left alone. base::string16 expectation = - &inputs[i] == &triggering_input || users_input.empty() ? + inputs[i].type == triggering_type || users_input.empty() ? wrapper.GetInfo(AutofillType(inputs[i].type)) : users_input; if (AutofillType(inputs[i].type).GetStorableType() == ADDRESS_HOME_COUNTRY) @@ -646,14 +646,14 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, expectations.push_back(expectation); } - view->SetTextContentsOfInput(triggering_input, + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + view->ActivateInput(triggering_type); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); for (size_t i = 0; i < inputs.size(); ++i) { - EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i])); + EXPECT_EQ(expectations[i], view->GetTextContentsOfInput(inputs[i].type)); } } @@ -676,12 +676,12 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, const DetailInputs& inputs = controller()->RequestedFieldsForSection(SECTION_BILLING); - const DetailInput& triggering_input = inputs[0]; - EXPECT_EQ(NAME_BILLING_FULL, triggering_input.type); + const ServerFieldType triggering_type = inputs[0].type; + EXPECT_EQ(NAME_BILLING_FULL, triggering_type); TestableAutofillDialogView* view = controller()->GetTestableView(); - view->ActivateInput(triggering_input); + view->ActivateInput(triggering_type); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); // Choose the variant suggestion. controller()->DidAcceptSuggestion(base::string16(), 1); @@ -691,7 +691,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, &full_profile, AutofillType(NAME_BILLING_FULL), 1); for (size_t i = 0; i < inputs.size(); ++i) { EXPECT_EQ(wrapper.GetInfo(AutofillType(inputs[i].type)), - view->GetTextContentsOfInput(inputs[i])); + view->GetTextContentsOfInput(inputs[i].type)); } // Make sure the wrapper applies the variant index to the right group. @@ -722,72 +722,72 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, const DetailInputs& inputs = controller()->RequestedFieldsForSection(SECTION_CC); - const DetailInput& triggering_input = inputs[0]; - base::string16 value = card1.GetRawInfo(triggering_input.type); + const ServerFieldType triggering_type = inputs[0].type; + base::string16 value = card1.GetRawInfo(triggering_type); TestableAutofillDialogView* view = controller()->GetTestableView(); - view->SetTextContentsOfInput(triggering_input, + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); + view->ActivateInput(triggering_type); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); // All inputs should be filled. AutofillCreditCardWrapper wrapper1(&card1); for (size_t i = 0; i < inputs.size(); ++i) { EXPECT_EQ(wrapper1.GetInfo(AutofillType(inputs[i].type)), - view->GetTextContentsOfInput(inputs[i])); + view->GetTextContentsOfInput(inputs[i].type)); } // Try again with different data. Only expiration date and the triggering // input should be overwritten. - value = card2.GetRawInfo(triggering_input.type); - view->SetTextContentsOfInput(triggering_input, + value = card2.GetRawInfo(triggering_type); + view->SetTextContentsOfInput(triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(triggering_input); - ASSERT_EQ(triggering_input.type, controller()->popup_input_type()); + view->ActivateInput(triggering_type); + ASSERT_EQ(triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); AutofillCreditCardWrapper wrapper2(&card2); for (size_t i = 0; i < inputs.size(); ++i) { - const DetailInput& input = inputs[i]; - if (&input == &triggering_input || - input.type == CREDIT_CARD_EXP_MONTH || - input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { - EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), - view->GetTextContentsOfInput(input)); - } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { - EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); + const ServerFieldType type = inputs[i].type; + if (type == triggering_type || + type == CREDIT_CARD_EXP_MONTH || + type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { + EXPECT_EQ(wrapper2.GetInfo(AutofillType(type)), + view->GetTextContentsOfInput(type)); + } else if (type == CREDIT_CARD_VERIFICATION_CODE) { + EXPECT_TRUE(view->GetTextContentsOfInput(type).empty()); } else { - EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), - view->GetTextContentsOfInput(input)); + EXPECT_EQ(wrapper1.GetInfo(AutofillType(type)), + view->GetTextContentsOfInput(type)); } } // Now fill from a profile. It should not overwrite any CC info. const DetailInputs& billing_inputs = controller()->RequestedFieldsForSection(SECTION_BILLING); - const DetailInput& billing_triggering_input = billing_inputs[0]; - value = full_profile.GetRawInfo(triggering_input.type); - view->SetTextContentsOfInput(billing_triggering_input, + const ServerFieldType billing_triggering_type = billing_inputs[0].type; + value = full_profile.GetRawInfo(triggering_type); + view->SetTextContentsOfInput(billing_triggering_type, value.substr(0, value.size() / 2)); - view->ActivateInput(billing_triggering_input); + view->ActivateInput(billing_triggering_type); - ASSERT_EQ(billing_triggering_input.type, controller()->popup_input_type()); + ASSERT_EQ(billing_triggering_type, controller()->popup_input_type()); controller()->DidAcceptSuggestion(base::string16(), 0); for (size_t i = 0; i < inputs.size(); ++i) { - const DetailInput& input = inputs[i]; - if (&input == &triggering_input || - input.type == CREDIT_CARD_EXP_MONTH || - input.type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { - EXPECT_EQ(wrapper2.GetInfo(AutofillType(input.type)), - view->GetTextContentsOfInput(input)); - } else if (input.type == CREDIT_CARD_VERIFICATION_CODE) { - EXPECT_TRUE(view->GetTextContentsOfInput(input).empty()); + const ServerFieldType type = inputs[i].type; + if (type == triggering_type || + type == CREDIT_CARD_EXP_MONTH || + type == CREDIT_CARD_EXP_4_DIGIT_YEAR) { + EXPECT_EQ(wrapper2.GetInfo(AutofillType(type)), + view->GetTextContentsOfInput(type)); + } else if (type == CREDIT_CARD_VERIFICATION_CODE) { + EXPECT_TRUE(view->GetTextContentsOfInput(type).empty()); } else { - EXPECT_EQ(wrapper1.GetInfo(AutofillType(input.type)), - view->GetTextContentsOfInput(input)); + EXPECT_EQ(wrapper1.GetInfo(AutofillType(type)), + view->GetTextContentsOfInput(type)); } } } @@ -799,17 +799,12 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, ShouldShowErrorBubble) { ASSERT_FALSE(card.IsVerified()); controller()->GetTestingManager()->AddTestingCreditCard(&card); - const DetailInputs& cc_inputs = - controller()->RequestedFieldsForSection(SECTION_CC); - const DetailInput& cc_number_input = cc_inputs[0]; - ASSERT_EQ(CREDIT_CARD_NUMBER, cc_number_input.type); - TestableAutofillDialogView* view = controller()->GetTestableView(); view->SetTextContentsOfInput( - cc_number_input, + CREDIT_CARD_NUMBER, card.GetRawInfo(CREDIT_CARD_NUMBER).substr(0, 1)); - view->ActivateInput(cc_number_input); + view->ActivateInput(CREDIT_CARD_NUMBER); EXPECT_FALSE(controller()->ShouldShowErrorBubble()); controller()->FocusMoved(); @@ -955,20 +950,11 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { controller()->set_use_validation(true); TestableAutofillDialogView* view = controller()->GetTestableView(); - - { - // Create some valid inputted billing data. - const DetailInput& cc_number = - controller()->RequestedFieldsForSection(SECTION_CC)[0]; - EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER); - view->SetTextContentsOfInput(cc_number, ASCIIToUTF16("4111111111111111")); - } + view->SetTextContentsOfInput(CREDIT_CARD_NUMBER, + ASCIIToUTF16("4111111111111111")); // Create some invalid, manually inputted shipping data. - const DetailInput& shipping_zip = - controller()->RequestedFieldsForSection(SECTION_SHIPPING)[5]; - ASSERT_EQ(ADDRESS_HOME_ZIP, shipping_zip.type); - view->SetTextContentsOfInput(shipping_zip, ASCIIToUTF16("shipping zip")); + view->SetTextContentsOfInput(ADDRESS_HOME_ZIP, ASCIIToUTF16("shipping zip")); // Switch to Wallet by simulating a successful server response. controller()->OnDidFetchWalletCookieValue(std::string()); @@ -976,31 +962,21 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_PreservedSections) { wallet::GetTestWalletItems(wallet::AMEX_DISALLOWED)); ASSERT_TRUE(controller()->IsPayingWithWallet()); - { - // The valid data should be preserved. - const DetailInput& cc_number = - controller()->RequestedFieldsForSection(SECTION_CC_BILLING)[0]; - EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER); - EXPECT_EQ(ASCIIToUTF16("4111111111111111"), - view->GetTextContentsOfInput(cc_number)); - } + // The valid data should be preserved. + EXPECT_EQ(ASCIIToUTF16("4111111111111111"), + view->GetTextContentsOfInput(CREDIT_CARD_NUMBER)); // The invalid data should be dropped. - EXPECT_TRUE(view->GetTextContentsOfInput(shipping_zip).empty()); + EXPECT_TRUE(view->GetTextContentsOfInput(ADDRESS_HOME_ZIP).empty()); // Switch back to Autofill. ui::MenuModel* account_chooser = controller()->MenuModelForAccountChooser(); account_chooser->ActivatedAt(account_chooser->GetItemCount() - 1); ASSERT_FALSE(controller()->IsPayingWithWallet()); - { - // The valid data should still be preserved when switched back. - const DetailInput& cc_number = - controller()->RequestedFieldsForSection(SECTION_CC)[0]; - EXPECT_EQ(cc_number.type, CREDIT_CARD_NUMBER); - EXPECT_EQ(ASCIIToUTF16("4111111111111111"), - view->GetTextContentsOfInput(cc_number)); - } + // The valid data should still be preserved when switched back. + EXPECT_EQ(ASCIIToUTF16("4111111111111111"), + view->GetTextContentsOfInput(CREDIT_CARD_NUMBER)); } #endif // defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) @@ -1224,21 +1200,18 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AddNewClearsComboboxes) { controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(0); EXPECT_TRUE(controller()->IsEditingExistingData(SECTION_CC)); - const DetailInputs& inputs = - controller()->RequestedFieldsForSection(SECTION_CC); - const DetailInput& cc_exp_month = inputs[1]; - ASSERT_EQ(CREDIT_CARD_EXP_MONTH, cc_exp_month.type); - // Get the contents of the combobox of the credit card's expiration month. TestableAutofillDialogView* view = controller()->GetTestableView(); - base::string16 cc_exp_month_text = view->GetTextContentsOfInput(cc_exp_month); + base::string16 cc_exp_month_text = + view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH); // Select "New X..." from the suggestion menu to clear the section's inputs. controller()->MenuModelForSection(SECTION_CC)->ActivatedAt(1); EXPECT_FALSE(controller()->IsEditingExistingData(SECTION_CC)); // Ensure that the credit card expiration month has changed. - EXPECT_NE(cc_exp_month_text, view->GetTextContentsOfInput(cc_exp_month)); + EXPECT_NE(cc_exp_month_text, + view->GetTextContentsOfInput(CREDIT_CARD_EXP_MONTH)); } IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, TabOpensToJustRight) { diff --git a/chrome/browser/ui/autofill/testable_autofill_dialog_view.h b/chrome/browser/ui/autofill/testable_autofill_dialog_view.h index 5ae09b8..13a23db 100644 --- a/chrome/browser/ui/autofill/testable_autofill_dialog_view.h +++ b/chrome/browser/ui/autofill/testable_autofill_dialog_view.h @@ -19,19 +19,19 @@ class TestableAutofillDialogView { // Simulates the user pressing 'Cancel' to abort the dialog. virtual void CancelForTesting() = 0; - // Returns the actual contents of the input which is modelled by |input|. - virtual base::string16 GetTextContentsOfInput(const DetailInput& input) = 0; + // Returns the actual contents of the input of |type|. + virtual base::string16 GetTextContentsOfInput(ServerFieldType type) = 0; - // Sets the actual contents of the input which is modelled by |input|. - virtual void SetTextContentsOfInput(const DetailInput& input, + // Sets the actual contents of the input of |type|. + virtual void SetTextContentsOfInput(ServerFieldType type, const base::string16& contents) = 0; // Sets the content of the extra field for a section. virtual void SetTextContentsOfSuggestionInput(DialogSection section, const base::string16& text) = 0; - // Simulates a user activatino of the input which is modelled by |input|. - virtual void ActivateInput(const DetailInput& input) = 0; + // Simulates a user activation of the input of |type|. + virtual void ActivateInput(ServerFieldType type) = 0; // Get the size of the entire view. virtual gfx::Size GetSize() const = 0; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h index c44e88e..37119f9 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h @@ -65,14 +65,13 @@ class AutofillDialogCocoa : public AutofillDialogView, // http://crbug.com/256864 virtual void SubmitForTesting() OVERRIDE; virtual void CancelForTesting() OVERRIDE; - virtual base::string16 GetTextContentsOfInput( - const DetailInput& input) OVERRIDE; - virtual void SetTextContentsOfInput(const DetailInput& input, + virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE; + virtual void SetTextContentsOfInput(ServerFieldType type, const base::string16& contents) OVERRIDE; virtual void SetTextContentsOfSuggestionInput( DialogSection section, const base::string16& text) OVERRIDE; - virtual void ActivateInput(const DetailInput& input) OVERRIDE; + virtual void ActivateInput(ServerFieldType type) OVERRIDE; virtual gfx::Size GetSize() const OVERRIDE; virtual content::WebContents* GetSignInWebContents() OVERRIDE; virtual bool IsShowingOverlay() const OVERRIDE; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm index cf1e7c4..f07d4c8 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm @@ -152,12 +152,12 @@ void AutofillDialogCocoa::CancelForTesting() { } base::string16 AutofillDialogCocoa::GetTextContentsOfInput( - const DetailInput& input) { + ServerFieldType type) { for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { DialogSection section = static_cast<DialogSection>(i); FieldValueMap contents; [sheet_delegate_ getInputs:&contents forSection:section]; - FieldValueMap::const_iterator it = contents.find(input.type); + FieldValueMap::const_iterator it = contents.find(type); if (it != contents.end()) return it->second; } @@ -167,10 +167,10 @@ base::string16 AutofillDialogCocoa::GetTextContentsOfInput( } void AutofillDialogCocoa::SetTextContentsOfInput( - const DetailInput& input, + ServerFieldType type, const base::string16& contents) { [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(contents) - forInput:input]; + forType:type]; } void AutofillDialogCocoa::SetTextContentsOfSuggestionInput( @@ -180,8 +180,8 @@ void AutofillDialogCocoa::SetTextContentsOfSuggestionInput( ofSuggestionForSection:section]; } -void AutofillDialogCocoa::ActivateInput(const DetailInput& input) { - [sheet_delegate_ activateFieldForInput:input]; +void AutofillDialogCocoa::ActivateInput(ServerFieldType type) { + [sheet_delegate_ activateFieldForType:type]; } gfx::Size AutofillDialogCocoa::GetSize() const { diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h index 58a829e..ee94e07 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h @@ -93,10 +93,10 @@ class AutofillDialogCocoa; @interface AutofillDialogWindowController (TestableAutofillDialogView) - (void)setTextContents:(NSString*)text - forInput:(const autofill::DetailInput&)input; + forType:(autofill::ServerFieldType)type; - (void)setTextContents:(NSString*)text ofSuggestionForSection:(autofill::DialogSection)section; -- (void)activateFieldForInput:(const autofill::DetailInput&)input; +- (void)activateFieldForType:(autofill::ServerFieldType)type; - (content::WebContents*)getSignInWebContents; - (BOOL)isShowingOverlay; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm index 716bb9a..6e66fed 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm @@ -466,11 +466,11 @@ const CGFloat kMinimumContentsHeight = 101; @implementation AutofillDialogWindowController (TestableAutofillDialogView) - (void)setTextContents:(NSString*)text - forInput:(const autofill::DetailInput&)input { + forType:(autofill::ServerFieldType)type { for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { autofill::DialogSection section = static_cast<autofill::DialogSection>(i); // TODO(groby): Need to find the section for an input directly - wasteful. - [[mainContainer_ sectionForId:section] setFieldValue:text forInput:input]; + [[mainContainer_ sectionForId:section] setFieldValue:text forType:type]; } } @@ -479,10 +479,10 @@ const CGFloat kMinimumContentsHeight = 101; [[mainContainer_ sectionForId:section] setSuggestionFieldValue:text]; } -- (void)activateFieldForInput:(const autofill::DetailInput&)input { +- (void)activateFieldForType:(autofill::ServerFieldType)type { for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { autofill::DialogSection section = static_cast<autofill::DialogSection>(i); - [[mainContainer_ sectionForId:section] activateFieldForInput:input]; + [[mainContainer_ sectionForId:section] activateFieldForType:type]; } } diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.h b/chrome/browser/ui/cocoa/autofill/autofill_section_container.h index f524993..b4bf70c7 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.h +++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.h @@ -112,17 +112,17 @@ class AutofillDialogViewDelegate; // Retrieve the field associated with the given type. - (NSControl<AutofillInputField>*)getField:(autofill::ServerFieldType)type; -// Sets the value for the field matching |input|. Does nothing if the field is +// Sets the value for the field matching |type|. Does nothing if the field is // not part of this section. - (void)setFieldValue:(NSString*)text - forInput:(const autofill::DetailInput&)input; + forType:(autofill::ServerFieldType)type; // Sets the value for the suggestion text field. - (void)setSuggestionFieldValue:(NSString*)text; -// Activates a given input field, determined by |input|. Does nothing if the +// Activates a given input field, determined by |type|. Does nothing if the // field is not part of this section. -- (void)activateFieldForInput:(const autofill::DetailInput&)input; +- (void)activateFieldForType:(autofill::ServerFieldType)type; @end diff --git a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm index 2afcb64..d67a1b3 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_section_container.mm @@ -702,25 +702,22 @@ bool ShouldOverwriteComboboxes(autofill::DialogSection section, } - (void)setFieldValue:(NSString*)text - forInput:(const autofill::DetailInput&)input { - if ([self detailInputForType:input.type] != &input) - return; - - NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; - [field setFieldValue:text]; + forType:(autofill::ServerFieldType)type { + NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type]; + if (field) + [field setFieldValue:text]; } - (void)setSuggestionFieldValue:(NSString*)text { [[suggestContainer_ inputField] setFieldValue:text]; } -- (void)activateFieldForInput:(const autofill::DetailInput&)input { - if ([self detailInputForType:input.type] != &input) - return; - - NSControl<AutofillInputField>* field = [inputs_ viewWithTag:input.type]; - [[field window] makeFirstResponder:field]; - [self textfieldEditedOrActivated:field edited:NO]; +- (void)activateFieldForType:(autofill::ServerFieldType)type { + NSControl<AutofillInputField>* field = [inputs_ viewWithTag:type]; + if (field) { + [[field window] makeFirstResponder:field]; + [self textfieldEditedOrActivated:field edited:NO]; + } } @end diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index 787694a..7f857a7 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -1443,12 +1443,12 @@ void AutofillDialogViews::CancelForTesting() { } base::string16 AutofillDialogViews::GetTextContentsOfInput( - const DetailInput& input) { - views::Textfield* textfield = TextfieldForType(input.type); + ServerFieldType type) { + views::Textfield* textfield = TextfieldForType(type); if (textfield) return textfield->text(); - views::Combobox* combobox = ComboboxForType(input.type); + views::Combobox* combobox = ComboboxForType(type); if (combobox) return combobox->model()->GetItemAt(combobox->selected_index()); @@ -1457,17 +1457,17 @@ base::string16 AutofillDialogViews::GetTextContentsOfInput( } void AutofillDialogViews::SetTextContentsOfInput( - const DetailInput& input, + ServerFieldType type, const base::string16& contents) { - views::Textfield* textfield = TextfieldForType(input.type); + views::Textfield* textfield = TextfieldForType(type); if (textfield) { textfield->SetText(contents); return; } - views::Combobox* combobox = ComboboxForType(input.type); + views::Combobox* combobox = ComboboxForType(type); if (combobox) { - SelectComboboxValueOrSetToDefault(combobox, input.initial_value); + SelectComboboxValueOrSetToDefault(combobox, contents); return; } @@ -1481,8 +1481,8 @@ void AutofillDialogViews::SetTextContentsOfSuggestionInput( SetText(text); } -void AutofillDialogViews::ActivateInput(const DetailInput& input) { - TextfieldEditedOrActivated(TextfieldForType(input.type), false); +void AutofillDialogViews::ActivateInput(ServerFieldType type) { + TextfieldEditedOrActivated(TextfieldForType(type), false); } gfx::Size AutofillDialogViews::GetSize() const { diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h index daf1a29..dbe4dd02 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h @@ -103,14 +103,13 @@ class AutofillDialogViews : public AutofillDialogView, // TestableAutofillDialogView implementation: virtual void SubmitForTesting() OVERRIDE; virtual void CancelForTesting() OVERRIDE; - virtual base::string16 GetTextContentsOfInput( - const DetailInput& input) OVERRIDE; - virtual void SetTextContentsOfInput(const DetailInput& input, + virtual base::string16 GetTextContentsOfInput(ServerFieldType type) OVERRIDE; + virtual void SetTextContentsOfInput(ServerFieldType type, const base::string16& contents) OVERRIDE; virtual void SetTextContentsOfSuggestionInput( DialogSection section, const base::string16& text) OVERRIDE; - virtual void ActivateInput(const DetailInput& input) OVERRIDE; + virtual void ActivateInput(ServerFieldType type) OVERRIDE; virtual gfx::Size GetSize() const OVERRIDE; virtual content::WebContents* GetSignInWebContents() OVERRIDE; virtual bool IsShowingOverlay() const OVERRIDE; |