From 9150291ada22937b7df835dd0e4c12f2d198c370 Mon Sep 17 00:00:00 2001 From: "dhollowa@chromium.org" Date: Mon, 20 Sep 2010 18:55:36 +0000 Subject: Autofill profile pop-up should trigger for mouse double-clicks Removes the cancellation logic for separated AutoFill and Autocomplete. This is no longer needed. The recent refactoring of the popup handling causes this logic to always hit the "cancel" scenario and thus return only Autocomplete suggestions and never AutoFill suggestions. But in fact, we get the Autocomplete-only results in the correct cases by virtue of the field type queried. BUG=54875 TEST=AutoFillManagerTest.GetFieldSuggestions* Review URL: http://codereview.chromium.org/3405015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59950 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/autofill/autofill_manager_unittest.cc | 21 +++++++++++++-------- chrome/browser/renderer_host/render_view_host.cc | 14 -------------- chrome/browser/renderer_host/render_view_host.h | 1 - 3 files changed, 13 insertions(+), 23 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index 7d78a9b..c84d482 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -662,28 +662,33 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { // The page ID sent to the AutoFillManager from the RenderView, used to send // an IPC message back to the renderer. const int kPageID = 1; - const int kAlternatePageID = 0; webkit_glue::FormField field; autofill_unittest::CreateTestFormField( - "First Name", "firstname", "", "text", &field); - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); + "Some Field", "somefield", "", "text", &field); + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); // No suggestions provided, so send an empty vector as the results. // This triggers the combined message send. // In this case, we're simulating a cancel of Autocomplete with a different // page ID and an empty vector of suggestions. - rvh()->AutocompleteSuggestionsReturned(kAlternatePageID, - std::vector()); + std::vector suggestions; + suggestions.push_back(ASCIIToUTF16("one")); + suggestions.push_back(ASCIIToUTF16("two")); + rvh()->AutocompleteSuggestionsReturned(kPageID, suggestions); // Test that we sent the right message to the renderer. int page_id = 0; std::vector values; std::vector labels; EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); - EXPECT_EQ(kAlternatePageID, page_id); - ASSERT_EQ(0U, values.size()); - ASSERT_EQ(0U, labels.size()); + EXPECT_EQ(kPageID, page_id); + ASSERT_EQ(2U, values.size()); + ASSERT_EQ(2U, labels.size()); + EXPECT_EQ(ASCIIToUTF16("one"), values[0]); + EXPECT_EQ(string16(), labels[0]); + EXPECT_EQ(ASCIIToUTF16("two"), values[1]); + EXPECT_EQ(string16(), labels[1]); } TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index b973cd4..1cad374 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -132,7 +132,6 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, sudden_termination_allowed_(false), session_storage_namespace_(session_storage), is_extension_process_(false), - autofill_query_id_(0), save_accessibility_tree_for_testing_(false) { if (!session_storage_namespace_) { session_storage_namespace_ = @@ -1726,7 +1725,6 @@ void RenderViewHost::AutoFillSuggestionsReturned( const std::vector& labels, const std::vector& icons, const std::vector& unique_ids) { - autofill_query_id_ = query_id; autofill_values_.assign(names.begin(), names.end()); autofill_labels_.assign(labels.begin(), labels.end()); autofill_icons_.assign(icons.begin(), icons.end()); @@ -1735,18 +1733,6 @@ void RenderViewHost::AutoFillSuggestionsReturned( void RenderViewHost::AutocompleteSuggestionsReturned( int query_id, const std::vector& suggestions) { - // When query IDs match we are responding to an AutoFill and Autocomplete - // combined query response. - // Otherwise Autocomplete is canceling, so we only send suggestions (usually - // an empty list). - if (autofill_query_id_ != query_id) { - // Autocomplete is canceling. - autofill_values_.clear(); - autofill_labels_.clear(); - autofill_icons_.clear(); - autofill_unique_ids_.clear(); - } - // Combine AutoFill and Autocomplete values into values and labels. for (size_t i = 0; i < suggestions.size(); ++i) { bool unique = true; diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 47d337a..6d3d156 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -755,7 +755,6 @@ class RenderViewHost : public RenderWidgetHost { // AutoFill and Autocomplete suggestions. We accumulate these separately and // send them back to the renderer together. - int autofill_query_id_; std::vector autofill_values_; std::vector autofill_labels_; std::vector autofill_icons_; -- cgit v1.1