| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autofill/autofill_manager.h" | 5 #include "chrome/browser/autofill/autofill_manager.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 10 #include <utility> |
| 9 | 11 |
| 10 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 12 #include "base/string16.h" | 14 #include "base/string16.h" |
| 13 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 16 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 15 #include "chrome/browser/autofill/autofill_dialog.h" | 17 #include "chrome/browser/autofill/autofill_dialog.h" |
| 16 #include "chrome/browser/autofill/autofill_metrics.h" | 18 #include "chrome/browser/autofill/autofill_metrics.h" |
| 17 #include "chrome/browser/autofill/form_structure.h" | 19 #include "chrome/browser/autofill/form_structure.h" |
| 18 #include "chrome/browser/autofill/phone_number.h" | 20 #include "chrome/browser/autofill/phone_number.h" |
| 19 #include "chrome/browser/autofill/select_control_handler.h" | 21 #include "chrome/browser/autofill/select_control_handler.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/renderer_host/render_view_host.h" | 24 #include "chrome/browser/renderer_host/render_view_host.h" |
| 23 #include "chrome/browser/tab_contents/tab_contents.h" | 25 #include "chrome/browser/tab_contents/tab_contents.h" |
| 24 #include "chrome/common/chrome_switches.h" | |
| 25 #include "chrome/common/guid.h" | 26 #include "chrome/common/guid.h" |
| 26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "webkit/glue/form_data.h" | 30 #include "webkit/glue/form_data.h" |
| 30 #include "webkit/glue/form_field.h" | 31 #include "webkit/glue/form_field.h" |
| 31 | 32 |
| 32 using webkit_glue::FormData; | 33 using webkit_glue::FormData; |
| 33 using webkit_glue::FormField; | 34 using webkit_glue::FormField; |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // We only send a fraction of the forms to upload server. | 38 // We only send a fraction of the forms to upload server. |
| 38 // The rate for positive/negative matches potentially could be different. | 39 // The rate for positive/negative matches potentially could be different. |
| 39 const double kAutoFillPositiveUploadRateDefaultValue = 0.01; | 40 const double kAutoFillPositiveUploadRateDefaultValue = 0.01; |
| 40 const double kAutoFillNegativeUploadRateDefaultValue = 0.01; | 41 const double kAutoFillNegativeUploadRateDefaultValue = 0.01; |
| 41 | 42 |
| 42 const string16::value_type kCreditCardPrefix[] = {'*',0}; | 43 const string16::value_type kCreditCardPrefix[] = {'*', 0}; |
| 43 const string16::value_type kLabelSeparator[] = {';',' ','*',0}; | 44 const string16::value_type kLabelSeparator[] = {';', ' ', '*', 0}; |
| 44 | 45 |
| 45 // Removes duplicate suggestions whilst preserving their original order. | 46 // Removes duplicate suggestions whilst preserving their original order. |
| 46 void RemoveDuplicateSuggestions(std::vector<string16>* values, | 47 void RemoveDuplicateSuggestions(std::vector<string16>* values, |
| 47 std::vector<string16>* labels, | 48 std::vector<string16>* labels, |
| 48 std::vector<string16>* icons, | 49 std::vector<string16>* icons, |
| 49 std::vector<int>* unique_ids) { | 50 std::vector<int>* unique_ids) { |
| 50 DCHECK_EQ(values->size(), labels->size()); | 51 DCHECK_EQ(values->size(), labels->size()); |
| 51 DCHECK_EQ(values->size(), icons->size()); | 52 DCHECK_EQ(values->size(), icons->size()); |
| 52 DCHECK_EQ(values->size(), unique_ids->size()); | 53 DCHECK_EQ(values->size(), unique_ids->size()); |
| 53 | 54 |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 return std::string(); | 811 return std::string(); |
| 811 | 812 |
| 812 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); | 813 std::map<int, std::string>::const_iterator iter = id_guid_map_.find(id); |
| 813 if (iter == id_guid_map_.end()) { | 814 if (iter == id_guid_map_.end()) { |
| 814 NOTREACHED(); | 815 NOTREACHED(); |
| 815 return std::string(); | 816 return std::string(); |
| 816 } | 817 } |
| 817 | 818 |
| 818 return iter->second; | 819 return iter->second; |
| 819 } | 820 } |
| OLD | NEW |