Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: components/autofill/browser/autofill_external_delegate.cc

Issue 16344003: [Autofill] Fix popup delegate to show warnings correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | components/autofill/browser/autofill_external_delegate_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "components/autofill/browser/autocomplete_history_manager.h" 6 #include "components/autofill/browser/autocomplete_history_manager.h"
7 #include "components/autofill/browser/autofill_external_delegate.h" 7 #include "components/autofill/browser/autofill_external_delegate.h"
8 #include "components/autofill/browser/autofill_manager.h" 8 #include "components/autofill/browser/autofill_manager.h"
9 #include "components/autofill/common/autofill_messages.h" 9 #include "components/autofill/common/autofill_messages.h"
10 #include "content/public/browser/navigation_controller.h" 10 #include "content/public/browser/navigation_controller.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const std::vector<base::string16>& autofill_icons, 84 const std::vector<base::string16>& autofill_icons,
85 const std::vector<int>& autofill_unique_ids) { 85 const std::vector<int>& autofill_unique_ids) {
86 if (query_id != autofill_query_id_) 86 if (query_id != autofill_query_id_)
87 return; 87 return;
88 88
89 std::vector<base::string16> values(autofill_values); 89 std::vector<base::string16> values(autofill_values);
90 std::vector<base::string16> labels(autofill_labels); 90 std::vector<base::string16> labels(autofill_labels);
91 std::vector<base::string16> icons(autofill_icons); 91 std::vector<base::string16> icons(autofill_icons);
92 std::vector<int> ids(autofill_unique_ids); 92 std::vector<int> ids(autofill_unique_ids);
93 93
94 // Add or hide warnings as appropriate.
95 ApplyAutofillWarnings(&values, &labels, &icons, &ids);
96
94 // Add a separator to go between the values and menu items. 97 // Add a separator to go between the values and menu items.
95 values.push_back(base::string16()); 98 values.push_back(base::string16());
96 labels.push_back(base::string16()); 99 labels.push_back(base::string16());
97 icons.push_back(base::string16()); 100 icons.push_back(base::string16());
98 ids.push_back(WebAutofillClient::MenuItemIDSeparator); 101 ids.push_back(WebAutofillClient::MenuItemIDSeparator);
99 102
100 ApplyAutofillWarnings(&values, &labels, &icons, &ids);
101
102 // Only include "Autofill Options" special menu item if we have Autofill 103 // Only include "Autofill Options" special menu item if we have Autofill
103 // suggestions. 104 // suggestions.
104 has_autofill_suggestion_ = false; 105 has_autofill_suggestion_ = false;
105 for (size_t i = 0; i < ids.size(); ++i) { 106 for (size_t i = 0; i < ids.size(); ++i) {
106 if (ids[i] > 0) { 107 if (ids[i] > 0) {
107 has_autofill_suggestion_ = true; 108 has_autofill_suggestion_ = true;
108 break; 109 break;
109 } 110 }
110 } 111 }
111 112
112 if (has_autofill_suggestion_) 113 if (has_autofill_suggestion_)
113 ApplyAutofillOptions(&values, &labels, &icons, &ids); 114 ApplyAutofillOptions(&values, &labels, &icons, &ids);
114 115
115 // Remove the separator if it is the last element. 116 // Remove the separator if it is the last element.
116 // It is possible for ids to be empty at this point if the vectors were 117 DCHECK_GT(ids.size(), 0U);
117 // cleared by ApplyAutofillWarnings (which can occur if we shouldn't 118 if (ids.back() == WebAutofillClient::MenuItemIDSeparator) {
118 // autocomplete or display warnings for this field).
119 if (!ids.empty() && ids.back() == WebAutofillClient::MenuItemIDSeparator) {
120 values.pop_back(); 119 values.pop_back();
121 labels.pop_back(); 120 labels.pop_back();
122 icons.pop_back(); 121 icons.pop_back();
123 ids.pop_back(); 122 ids.pop_back();
124 } 123 }
125 124
126 InsertDataListValues(&values, &labels, &icons, &ids); 125 InsertDataListValues(&values, &labels, &icons, &ids);
127 126
128 if (values.empty()) { 127 if (values.empty()) {
129 // No suggestions, any popup currently showing is obsolete. 128 // No suggestions, any popup currently showing is obsolete.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!*content::Details<bool>(details).ptr()) 382 if (!*content::Details<bool>(details).ptr())
384 autofill_manager_->delegate()->HideAutofillPopup(); 383 autofill_manager_->delegate()->HideAutofillPopup();
385 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 384 } else if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
386 autofill_manager_->delegate()->HideAutofillPopup(); 385 autofill_manager_->delegate()->HideAutofillPopup();
387 } else { 386 } else {
388 NOTREACHED(); 387 NOTREACHED();
389 } 388 }
390 } 389 }
391 390
392 } // namespace autofill 391 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/browser/autofill_external_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698