| Index: chrome/browser/autofill/autofill_manager_unittest.cc | 
| diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc | 
| index 264dc808f15d1f7cc1ab1b488d056fdba511a5e2..7964dae2fe7e347c96304f8eeeb9cca0f97879a2 100644 | 
| --- a/chrome/browser/autofill/autofill_manager_unittest.cc | 
| +++ b/chrome/browser/autofill/autofill_manager_unittest.cc | 
| @@ -4,6 +4,7 @@ | 
|  | 
| #include <vector> | 
|  | 
| +#include "app/l10n_util.h" | 
| #include "base/ref_counted.h" | 
| #include "base/scoped_ptr.h" | 
| #include "base/scoped_vector.h" | 
| @@ -23,6 +24,7 @@ | 
| #include "chrome/common/pref_names.h" | 
| #include "chrome/common/render_messages.h" | 
| #include "googleurl/src/gurl.h" | 
| +#include "grit/generated_resources.h" | 
| #include "testing/gtest/include/gtest/gtest.h" | 
| #include "webkit/glue/form_data.h" | 
| #include "webkit/glue/form_field.h" | 
| @@ -59,6 +61,14 @@ class TestPersonalDataManager : public PersonalDataManager { | 
| web_profiles_->push_back(profile); | 
| } | 
|  | 
| +  void ClearAutoFillProfiles() { | 
| +    web_profiles_.reset(); | 
| +  } | 
| + | 
| +  void ClearCreditCards() { | 
| +    credit_cards_.reset(); | 
| +  } | 
| + | 
| private: | 
| void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) { | 
| AutoFillProfile* profile = new AutoFillProfile; | 
| @@ -110,7 +120,8 @@ class TestAutoFillManager : public AutoFillManager { | 
| public: | 
| TestAutoFillManager(TabContents* tab_contents, | 
| TestPersonalDataManager* personal_manager) | 
| -      : AutoFillManager(tab_contents, NULL) { | 
| +      : AutoFillManager(tab_contents, NULL), | 
| +        autofill_enabled_(true) { | 
| test_personal_data_ = personal_manager; | 
| set_personal_data_manager(personal_manager); | 
| // Download manager requests are disabled for purposes of this unit-test. | 
| @@ -118,7 +129,11 @@ class TestAutoFillManager : public AutoFillManager { | 
| set_disable_download_manager_requests(true); | 
| } | 
|  | 
| -  virtual bool IsAutoFillEnabled() const { return true; } | 
| +  virtual bool IsAutoFillEnabled() const { return autofill_enabled_; } | 
| + | 
| +  void set_autofill_enabled(bool autofill_enabled) { | 
| +    autofill_enabled_ = autofill_enabled; | 
| +  } | 
|  | 
| AutoFillProfile* GetLabeledProfile(const char* label) { | 
| return test_personal_data_->GetLabeledProfile(label); | 
| @@ -130,6 +145,7 @@ class TestAutoFillManager : public AutoFillManager { | 
|  | 
| private: | 
| TestPersonalDataManager* test_personal_data_; | 
| +  bool autofill_enabled_; | 
|  | 
| DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager); | 
| }; | 
| @@ -293,11 +309,12 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -338,11 +355,12 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "E", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -394,8 +412,198 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsUnknownFields) { | 
|  | 
| autofill_test::CreateTestFormField( | 
| "Username", "username", "", "text", &field); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| EXPECT_FALSE( | 
| -      autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +      autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| +} | 
| + | 
| +// Test that we return no suggestions when autofill is disabled. | 
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsAutofillDisabledByUser) { | 
| +  FormData form; | 
| +  CreateTestAddressFormData(&form); | 
| + | 
| +  // Set up our FormStructures. | 
| +  std::vector<FormData> forms; | 
| +  forms.push_back(form); | 
| +  autofill_manager_->FormsSeen(forms); | 
| + | 
| +  // Disable AutoFill. | 
| +  autofill_manager_->set_autofill_enabled(false); | 
| + | 
| +  // The page ID sent to the AutoFillManager from the RenderView, used to send | 
| +  // an IPC message back to the renderer. | 
| +  const int kPageID = 1; | 
| + | 
| +  webkit_glue::FormField field; | 
| +  autofill_test::CreateTestFormField( | 
| +      "First Name", "firstname", "", "text", &field); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| +} | 
| + | 
| +// Test that we return a warning explaining that autofill suggestions are | 
| +// unavailable when the website specifies autocomplete="off". | 
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsAutofillDisabledByForm) { | 
| +  FormData form; | 
| +  CreateTestAddressFormData(&form); | 
| + | 
| +  // Set up our FormStructures. | 
| +  std::vector<FormData> forms; | 
| +  forms.push_back(form); | 
| +  autofill_manager_->FormsSeen(forms); | 
| + | 
| +  // The page ID sent to the AutoFillManager from the RenderView, used to send | 
| +  // an IPC message back to the renderer. | 
| +  const int kPageID = 1; | 
| + | 
| +  webkit_glue::FormField field; | 
| +  autofill_test::CreateTestFormField( | 
| +      "First Name", "firstname", "", "text", &field); | 
| +  rvh()->ResetAutoFillState(kPageID, true); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, true)); | 
| + | 
| +  // No suggestions provided, so send an empty vector as the results. | 
| +  // This triggers the combined message send. | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
| + | 
| +  // Test that we sent the right message to the renderer. | 
| +  int page_id = 0; | 
| +  std::vector<string16> values; | 
| +  std::vector<string16> labels; | 
| +  std::vector<string16> icons; | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID, page_id); | 
| +  ASSERT_EQ(1U, values.size()); | 
| +  EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED), | 
| +            values[0]); | 
| +  ASSERT_EQ(1U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  ASSERT_EQ(1U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| + | 
| +  // Clear the test profiles and try again -- we shouldn't return a warning. | 
| +  process()->sink().ClearMessages(); | 
| +  const int kPageID2 = 2; | 
| +  rvh()->ResetAutoFillState(kPageID2, true); | 
| + | 
| +  test_personal_data_->ClearAutoFillProfiles(); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, true)); | 
| + | 
| +  // Now add some Autocomplete suggestions. We should now return the same | 
| +  // warning as before. | 
| +  std::vector<string16> suggestions; | 
| +  suggestions.push_back(ASCIIToUTF16("Jay")); | 
| +  suggestions.push_back(ASCIIToUTF16("Jason")); | 
| +  rvh()->AutocompleteSuggestionsReturned(suggestions); | 
| + | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID2, page_id); | 
| +  ASSERT_EQ(1U, values.size()); | 
| +  EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED), | 
| +            values[0]); | 
| +  ASSERT_EQ(1U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  ASSERT_EQ(1U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| +} | 
| + | 
| +// Test that we return no warning when autofill is disabled by the user and also | 
| +// the website specifies autocomplete="off". | 
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsAutofillDisabledByBoth) { | 
| +  FormData form; | 
| +  CreateTestAddressFormData(&form); | 
| + | 
| +  // Set up our FormStructures. | 
| +  std::vector<FormData> forms; | 
| +  forms.push_back(form); | 
| +  autofill_manager_->FormsSeen(forms); | 
| + | 
| +  // Disable AutoFill. | 
| +  autofill_manager_->set_autofill_enabled(false); | 
| + | 
| +  // The page ID sent to the AutoFillManager from the RenderView, used to send | 
| +  // an IPC message back to the renderer. | 
| +  const int kPageID = 1; | 
| + | 
| +  webkit_glue::FormField field; | 
| +  autofill_test::CreateTestFormField( | 
| +      "First Name", "firstname", "", "text", &field); | 
| +  rvh()->ResetAutoFillState(kPageID, true); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, true)); | 
| +} | 
| + | 
| +// Test that we return a warning explaining that autofill suggestions are | 
| +// unavailable when the form method is GET rather than POST. | 
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsMethodGet) { | 
| +  FormData form; | 
| +  CreateTestAddressFormData(&form); | 
| +  form.method = ASCIIToUTF16("GET"); | 
| + | 
| +  // Set up our FormStructures. | 
| +  std::vector<FormData> forms; | 
| +  forms.push_back(form); | 
| +  autofill_manager_->FormsSeen(forms); | 
| + | 
| +  // The page ID sent to the AutoFillManager from the RenderView, used to send | 
| +  // an IPC message back to the renderer. | 
| +  const int kPageID = 1; | 
| + | 
| +  webkit_glue::FormField field; | 
| +  autofill_test::CreateTestFormField( | 
| +      "First Name", "firstname", "", "text", &field); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| + | 
| +  // No suggestions provided, so send an empty vector as the results. | 
| +  // This triggers the combined message send. | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
| + | 
| +  // Test that we sent the right message to the renderer. | 
| +  int page_id = 0; | 
| +  std::vector<string16> values; | 
| +  std::vector<string16> labels; | 
| +  std::vector<string16> icons; | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID, page_id); | 
| +  ASSERT_EQ(1U, values.size()); | 
| +  EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED), | 
| +            values[0]); | 
| +  ASSERT_EQ(1U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  ASSERT_EQ(1U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| + | 
| +  // Now add some Autocomplete suggestions. We should show the autocomplete | 
| +  // suggestions rather than the warning. | 
| +  process()->sink().ClearMessages(); | 
| +  const int kPageID2 = 2; | 
| +  rvh()->ResetAutoFillState(kPageID2, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| + | 
| +  std::vector<string16> suggestions; | 
| +  suggestions.push_back(ASCIIToUTF16("Jay")); | 
| +  suggestions.push_back(ASCIIToUTF16("Jason")); | 
| +  rvh()->AutocompleteSuggestionsReturned(suggestions); | 
| + | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID2, page_id); | 
| +  ASSERT_EQ(2U, values.size()); | 
| +  EXPECT_EQ(ASCIIToUTF16("Jay"), values[0]); | 
| +  EXPECT_EQ(ASCIIToUTF16("Jason"), values[1]); | 
| +  ASSERT_EQ(2U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  EXPECT_EQ(string16(), labels[1]); | 
| +  ASSERT_EQ(2U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| +  EXPECT_EQ(string16(), icons[1]); | 
| + | 
| +  // Now clear the test profiles and try again -- we shouldn't return a warning. | 
| +  test_personal_data_->ClearAutoFillProfiles(); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| } | 
|  | 
| // Test that we return all credit card profile suggestions when all form fields | 
| @@ -416,11 +624,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "Card Number", "cardnumber", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -459,11 +668,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "Card Number", "cardnumber", "4", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -499,11 +709,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "Name on Card", "nameoncard", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -524,8 +735,8 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 
| EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]); | 
| } | 
|  | 
| -// Test that we return no credit card profile suggestions when the form is not | 
| -// https. | 
| +// Test that we return a warning explaining that credit card profile suggestions | 
| +// are unavailable when the form is not https. | 
| TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 
| FormData form; | 
| CreateTestCreditCardFormData(&form, false); | 
| @@ -542,8 +753,57 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "Card Number", "cardnumber", "", "text", &field); | 
| -  EXPECT_FALSE( | 
| -      autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| + | 
| +  // No suggestions provided, so send an empty vector as the results. | 
| +  // This triggers the combined message send. | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
| + | 
| +  // Test that we sent the right message to the renderer. | 
| +  int page_id = 0; | 
| +  std::vector<string16> values; | 
| +  std::vector<string16> labels; | 
| +  std::vector<string16> icons; | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID, page_id); | 
| +  ASSERT_EQ(1U, values.size()); | 
| +  EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), | 
| +            values[0]); | 
| +  ASSERT_EQ(1U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  ASSERT_EQ(1U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| + | 
| +  // Now add some Autocomplete suggestions. We should show the autocomplete | 
| +  // suggestions rather than the warning. | 
| +  process()->sink().ClearMessages(); | 
| +  const int kPageID2 = 2; | 
| +  rvh()->ResetAutoFillState(kPageID2, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| + | 
| +  std::vector<string16> suggestions; | 
| +  suggestions.push_back(ASCIIToUTF16("Jay")); | 
| +  suggestions.push_back(ASCIIToUTF16("Jason")); | 
| +  rvh()->AutocompleteSuggestionsReturned(suggestions); | 
| + | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID2, page_id); | 
| +  ASSERT_EQ(2U, values.size()); | 
| +  EXPECT_EQ(ASCIIToUTF16("Jay"), values[0]); | 
| +  EXPECT_EQ(ASCIIToUTF16("Jason"), values[1]); | 
| +  ASSERT_EQ(2U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  EXPECT_EQ(string16(), labels[1]); | 
| +  ASSERT_EQ(2U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| +  EXPECT_EQ(string16(), icons[1]); | 
| + | 
| +  // Clear the test credit cards and try again -- we shouldn't return a warning. | 
| +  test_personal_data_->ClearCreditCards(); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| } | 
|  | 
| // Test that we return profile and credit card suggestions for combined forms. | 
| @@ -564,11 +824,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right address suggestions to the renderer. | 
| int page_id = 0; | 
| @@ -593,11 +854,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { | 
| process()->sink().ClearMessages(); | 
| autofill_test::CreateTestFormField( | 
| "Card Number", "cardnumber", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the credit card suggestions to the renderer. | 
| page_id = 0; | 
| @@ -616,7 +878,9 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) { | 
| } | 
|  | 
| // Test that for non-https forms with both address and credit card fields, we | 
| -// only return address suggestions. | 
| +// only return address suggestions. Instead of credit card suggestions, we | 
| +// should return a warning explaining that credit card profile suggestions are | 
| +// unavailable when the form is not https. | 
| TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 
| FormData form; | 
| CreateTestAddressFormData(&form); | 
| @@ -634,11 +898,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right address suggestions to the renderer. | 
| int page_id = 0; | 
| @@ -660,10 +925,31 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 
| EXPECT_EQ(string16(), icons[0]); | 
| EXPECT_EQ(string16(), icons[1]); | 
|  | 
| +  process()->sink().ClearMessages(); | 
| autofill_test::CreateTestFormField( | 
| "Card Number", "cardnumber", "", "text", &field); | 
| -  EXPECT_FALSE( | 
| -      autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| + | 
| +  // No suggestions provided, so send an empty vector as the results. | 
| +  // This triggers the combined message send. | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
| + | 
| +  // Test that we sent the right message to the renderer. | 
| +  EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels, | 
| +                                            &icons)); | 
| +  EXPECT_EQ(kPageID, page_id); | 
| +  ASSERT_EQ(1U, values.size()); | 
| +  EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), | 
| +            values[0]); | 
| +  ASSERT_EQ(1U, labels.size()); | 
| +  EXPECT_EQ(string16(), labels[0]); | 
| +  ASSERT_EQ(1U, icons.size()); | 
| +  EXPECT_EQ(string16(), icons[0]); | 
| + | 
| +  // Clear the test credit cards and try again -- we shouldn't return a warning. | 
| +  test_personal_data_->ClearCreditCards(); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
| } | 
|  | 
| // Test that we correctly combine autofill and autocomplete suggestions. | 
| @@ -683,14 +969,15 @@ TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false)); | 
|  | 
| // Add some Autocomplete suggestions. | 
| // This triggers the combined message send. | 
| std::vector<string16> suggestions; | 
| suggestions.push_back(ASCIIToUTF16("Jay")); | 
| suggestions.push_back(ASCIIToUTF16("Jason")); | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, suggestions); | 
| +  rvh()->AutocompleteSuggestionsReturned(suggestions); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -735,11 +1022,12 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFieldIsAutoFilled) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -778,14 +1066,15 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "Some Field", "somefield", "", "text", &field); | 
| -  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(true, field, false)); | 
|  | 
| // Add some Autocomplete suggestions. | 
| // This triggers the combined message send. | 
| std::vector<string16> suggestions; | 
| suggestions.push_back(ASCIIToUTF16("one")); | 
| suggestions.push_back(ASCIIToUTF16("two")); | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, suggestions); | 
| +  rvh()->AutocompleteSuggestionsReturned(suggestions); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
| @@ -830,11 +1119,12 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { | 
| webkit_glue::FormField field; | 
| autofill_test::CreateTestFormField( | 
| "First Name", "firstname", "", "text", &field); | 
| -  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); | 
| +  rvh()->ResetAutoFillState(kPageID, false); | 
| +  EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field, false)); | 
|  | 
| // No suggestions provided, so send an empty vector as the results. | 
| // This triggers the combined message send. | 
| -  rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); | 
| +  rvh()->AutocompleteSuggestionsReturned(std::vector<string16>()); | 
|  | 
| // Test that we sent the right message to the renderer. | 
| int page_id = 0; | 
|  |