diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 22:41:20 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-10 22:41:20 +0000 |
commit | 1cf47dd588567f66cebdab0078e2a1d5a38a9c5e (patch) | |
tree | 4ac8ff9d83140956738e9be36588f7028043cae8 /chrome/browser/autofill | |
parent | ff0aa753808fca0e8b3ff5717ed2104bfccd5232 (diff) | |
download | chromium_src-1cf47dd588567f66cebdab0078e2a1d5a38a9c5e.zip chromium_src-1cf47dd588567f66cebdab0078e2a1d5a38a9c5e.tar.gz chromium_src-1cf47dd588567f66cebdab0078e2a1d5a38a9c5e.tar.bz2 |
AutoFill: Implement the 'AutoFill Options...' entry in the AutoFill suggestions
popup.
BUG=45144
TEST=none
Review URL: http://codereview.chromium.org/2773005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 22 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 1 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager_unittest.cc | 31 |
3 files changed, 24 insertions, 30 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 8733f39..5113e75 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -166,9 +166,7 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id, if (values.empty()) return false; - // TODO(jhawkins): If the default profile is in this list, set it as the - // default suggestion index. - host->AutoFillSuggestionsReturned(query_id, values, labels, -1); + host->AutoFillSuggestionsReturned(query_id, values, labels); return true; } @@ -279,6 +277,14 @@ bool AutoFillManager::FillAutoFillFormData(int query_id, return true; } +void AutoFillManager::ShowAutoFillDialog() { + ::ShowAutoFillDialog(tab_contents_->GetContentNativeView(), + personal_data_, + tab_contents_->profile()->GetOriginalProfile(), + NULL, + NULL); +} + void AutoFillManager::OnInfoBarClosed() { PrefService* prefs = tab_contents_->profile()->GetPrefs(); prefs->SetBoolean(prefs::kAutoFillEnabled, true); @@ -299,11 +305,11 @@ void AutoFillManager::OnInfoBarAccepted() { // TODO(dhollowa) Now that we aren't immediately saving the imported form // data, we should store the profile and CC in the AFM instead of the PDM. personal_data_->GetImportedFormData(&profile, &credit_card); - ShowAutoFillDialog(tab_contents_->GetContentNativeView(), - personal_data_, - tab_contents_->profile()->GetOriginalProfile(), - profile, - credit_card); + ::ShowAutoFillDialog(tab_contents_->GetContentNativeView(), + personal_data_, + tab_contents_->profile()->GetOriginalProfile(), + profile, + credit_card); } void AutoFillManager::OnInfoBarCancelled() { diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index 9c7579e..31c03d2 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -54,6 +54,7 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, const webkit_glue::FormData& form, const string16& value, const string16& label); + virtual void ShowAutoFillDialog(); // Called by the AutoFillInfoBarDelegate when the user closes the infobar. virtual void OnInfoBarClosed(); diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index e8ecac3..c1d7c72 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -203,15 +203,13 @@ class AutoFillManagerTest : public RenderViewHostTestHarness { bool GetAutoFillSuggestionsMessage(int *page_id, std::vector<string16>* values, - std::vector<string16>* labels, - int* default_idx) { + std::vector<string16>* labels) { const uint32 kMsgID = ViewMsg_AutoFillSuggestionsReturned::ID; const IPC::Message* message = process()->sink().GetFirstMessageMatching(kMsgID); if (!message) return false; - Tuple4<int, std::vector<string16>, std::vector<string16>, int> - autofill_param; + Tuple3<int, std::vector<string16>, std::vector<string16> > autofill_param; ViewMsg_AutoFillSuggestionsReturned::Read(message, &autofill_param); if (page_id) *page_id = autofill_param.a; @@ -219,8 +217,6 @@ class AutoFillManagerTest : public RenderViewHostTestHarness { *values = autofill_param.b; if (labels) *labels = autofill_param.c; - if (default_idx) - *default_idx = autofill_param.d; return true; } @@ -267,8 +263,7 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) { int page_id = 0; std::vector<string16> values; std::vector<string16> labels; - int idx = 0; - EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); EXPECT_EQ(kPageID, page_id); ASSERT_EQ(2U, values.size()); EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]); @@ -276,7 +271,6 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) { ASSERT_EQ(2U, labels.size()); EXPECT_EQ(ASCIIToUTF16("Home"), labels[0]); EXPECT_EQ(ASCIIToUTF16("Work"), labels[1]); - EXPECT_EQ(-1, idx); } TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) { @@ -300,14 +294,12 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) { int page_id = 0; std::vector<string16> values; std::vector<string16> labels; - int idx = 0; - EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); EXPECT_EQ(kPageID, page_id); ASSERT_EQ(1U, values.size()); EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]); ASSERT_EQ(1U, labels.size()); EXPECT_EQ(ASCIIToUTF16("Home"), labels[0]); - EXPECT_EQ(-1, idx); } TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { @@ -331,8 +323,7 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { int page_id = 0; std::vector<string16> values; std::vector<string16> labels; - int idx = 0; - EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); EXPECT_EQ(kPageID, page_id); ASSERT_EQ(2U, values.size()); EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]); @@ -340,7 +331,6 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { ASSERT_EQ(2U, labels.size()); EXPECT_EQ(ASCIIToUTF16("First"), labels[0]); EXPECT_EQ(ASCIIToUTF16("Second"), labels[1]); - EXPECT_EQ(-1, idx); } TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { @@ -364,14 +354,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { int page_id = 0; std::vector<string16> values; std::vector<string16> labels; - int idx = 0; - EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); EXPECT_EQ(kPageID, page_id); ASSERT_EQ(1U, values.size()); EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]); ASSERT_EQ(1U, labels.size()); EXPECT_EQ(ASCIIToUTF16("First"), labels[0]); - EXPECT_EQ(-1, idx); } TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { @@ -391,18 +379,17 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { int page_id = 0; std::vector<string16> values; std::vector<string16> labels; - int idx = 0; CreateTestFormField("Name on Card", "nameoncard", "", "text", &field); EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, field)); - EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); CreateTestFormField("Expiration Date", "ccmonth", "", "text", &field); EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, field)); - EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); CreateTestFormField("", "ccyear", "", "text", &field); EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, field)); - EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, &idx)); + EXPECT_FALSE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); } TEST_F(AutoFillManagerTest, FillCreditCardForm) { |