OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_external_delegate.h" | 5 #include "components/autofill/core/browser/autofill_external_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS; | 302 suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS; |
303 if (IsKeyboardAccessoryEnabled()) | 303 if (IsKeyboardAccessoryEnabled()) |
304 suggestions->back().icon = base::ASCIIToUTF16("settings"); | 304 suggestions->back().icon = base::ASCIIToUTF16("settings"); |
305 } | 305 } |
306 | 306 |
307 void AutofillExternalDelegate::InsertDataListValues( | 307 void AutofillExternalDelegate::InsertDataListValues( |
308 std::vector<Suggestion>* suggestions) { | 308 std::vector<Suggestion>* suggestions) { |
309 if (data_list_values_.empty()) | 309 if (data_list_values_.empty()) |
310 return; | 310 return; |
311 | 311 |
312 // Go through the list of autocomplete values and remove them if they are in | |
313 // the list of datalist values. | |
314 std::set<base::string16> datalist_set(data_list_values_.begin(), | |
Evan Stade
2015/11/19 03:13:03
please keep datalist/data_list consistent
Mathieu
2015/11/19 13:22:17
Done.
| |
315 data_list_values_.end()); | |
316 for (auto iter = suggestions->begin(); iter != suggestions->end();) { | |
Evan Stade
2015/11/19 03:13:03
std::remove_if(suggestions->begin(),
Evan Stade
2015/11/19 03:19:51
note that you might have to put a & or something i
vabr (Chromium)
2015/11/19 08:26:04
Please use [&datalist_set], not just [&], because
Mathieu
2015/11/19 13:22:16
Done.
Mathieu
2015/11/19 13:22:17
Done.
Mathieu
2015/11/19 13:22:17
Done.
| |
317 if (datalist_set.count(iter->value) && | |
vabr (Chromium)
2015/11/19 08:26:04
optional: While using .count() results in succinct
Mathieu
2015/11/19 13:22:17
Ah thanks! Done.
| |
318 iter->frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { | |
319 iter = suggestions->erase(iter); | |
320 continue; | |
321 } | |
322 ++iter; | |
323 } | |
324 | |
312 #if !defined(OS_ANDROID) | 325 #if !defined(OS_ANDROID) |
313 // Insert the separator between the datalist and Autofill values (if there | 326 // Insert the separator between the datalist and Autofill/Autocomplete values |
314 // are any). | 327 // (if there are any). |
315 if (!suggestions->empty()) { | 328 if (!suggestions->empty()) { |
316 suggestions->insert(suggestions->begin(), Suggestion()); | 329 suggestions->insert(suggestions->begin(), Suggestion()); |
317 (*suggestions)[0].frontend_id = POPUP_ITEM_ID_SEPARATOR; | 330 (*suggestions)[0].frontend_id = POPUP_ITEM_ID_SEPARATOR; |
318 } | 331 } |
319 #endif | 332 #endif |
320 | 333 |
321 // Insert the datalist elements at the beginning. | 334 // Insert the datalist elements at the beginning. |
322 suggestions->insert(suggestions->begin(), data_list_values_.size(), | 335 suggestions->insert(suggestions->begin(), data_list_values_.size(), |
323 Suggestion()); | 336 Suggestion()); |
324 for (size_t i = 0; i < data_list_values_.size(); i++) { | 337 for (size_t i = 0; i < data_list_values_.size(); i++) { |
325 (*suggestions)[i].value = data_list_values_[i]; | 338 (*suggestions)[i].value = data_list_values_[i]; |
326 (*suggestions)[i].label = data_list_labels_[i]; | 339 (*suggestions)[i].label = data_list_labels_[i]; |
327 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; | 340 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; |
328 } | 341 } |
329 } | 342 } |
330 | 343 |
331 } // namespace autofill | 344 } // namespace autofill |
OLD | NEW |