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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 void AutofillExternalDelegate::InsertDataListValues( | 336 void AutofillExternalDelegate::InsertDataListValues( |
337 std::vector<Suggestion>* suggestions) { | 337 std::vector<Suggestion>* suggestions) { |
338 if (data_list_values_.empty()) | 338 if (data_list_values_.empty()) |
339 return; | 339 return; |
340 | 340 |
341 // Go through the list of autocomplete values and remove them if they are in | 341 // Go through the list of autocomplete values and remove them if they are in |
342 // the list of datalist values. | 342 // the list of datalist values. |
343 std::set<base::string16> data_list_set(data_list_values_.begin(), | 343 std::set<base::string16> data_list_set(data_list_values_.begin(), |
344 data_list_values_.end()); | 344 data_list_values_.end()); |
345 suggestions->erase( | 345 suggestions->erase( |
346 std::remove_if(suggestions->begin(), suggestions->end(), | 346 std::remove_if( |
347 [&data_list_set](const Suggestion& suggestion) { | 347 suggestions->begin(), suggestions->end(), |
348 return suggestion.frontend_id == | 348 [&data_list_set](const Suggestion& suggestion) { |
349 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY && | 349 return suggestion.frontend_id == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY && |
350 ContainsKey(data_list_set, suggestion.value); | 350 base::ContainsKey(data_list_set, suggestion.value); |
351 }), | 351 }), |
352 suggestions->end()); | 352 suggestions->end()); |
353 | 353 |
354 #if !defined(OS_ANDROID) | 354 #if !defined(OS_ANDROID) |
355 // Insert the separator between the datalist and Autofill/Autocomplete values | 355 // Insert the separator between the datalist and Autofill/Autocomplete values |
356 // (if there are any). | 356 // (if there are any). |
357 if (!suggestions->empty()) { | 357 if (!suggestions->empty()) { |
358 suggestions->insert(suggestions->begin(), Suggestion()); | 358 suggestions->insert(suggestions->begin(), Suggestion()); |
359 (*suggestions)[0].frontend_id = POPUP_ITEM_ID_SEPARATOR; | 359 (*suggestions)[0].frontend_id = POPUP_ITEM_ID_SEPARATOR; |
360 } | 360 } |
361 #endif | 361 #endif |
362 | 362 |
363 // Insert the datalist elements at the beginning. | 363 // Insert the datalist elements at the beginning. |
364 suggestions->insert(suggestions->begin(), data_list_values_.size(), | 364 suggestions->insert(suggestions->begin(), data_list_values_.size(), |
365 Suggestion()); | 365 Suggestion()); |
366 for (size_t i = 0; i < data_list_values_.size(); i++) { | 366 for (size_t i = 0; i < data_list_values_.size(); i++) { |
367 (*suggestions)[i].value = data_list_values_[i]; | 367 (*suggestions)[i].value = data_list_values_[i]; |
368 (*suggestions)[i].label = data_list_labels_[i]; | 368 (*suggestions)[i].label = data_list_labels_[i]; |
369 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; | 369 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 } // namespace autofill | 373 } // namespace autofill |
OLD | NEW |