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_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <map> | 10 #include <map> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 23 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
24 #include "components/autofill/core/browser/autofill_data_model.h" | 24 #include "components/autofill/core/browser/autofill_data_model.h" |
25 #include "components/autofill/core/browser/autofill_external_delegate.h" | 25 #include "components/autofill/core/browser/autofill_external_delegate.h" |
26 #include "components/autofill/core/browser/autofill_field.h" | 26 #include "components/autofill/core/browser/autofill_field.h" |
27 #include "components/autofill/core/browser/autofill_manager_delegate.h" | 27 #include "components/autofill/core/browser/autofill_manager_delegate.h" |
28 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" | 28 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" |
29 #include "components/autofill/core/browser/autofill_metrics.h" | 29 #include "components/autofill/core/browser/autofill_metrics.h" |
30 #include "components/autofill/core/browser/autofill_profile.h" | 30 #include "components/autofill/core/browser/autofill_profile.h" |
31 #include "components/autofill/core/browser/autofill_type.h" | 31 #include "components/autofill/core/browser/autofill_type.h" |
32 #include "components/autofill/core/browser/credit_card.h" | 32 #include "components/autofill/core/browser/credit_card.h" |
33 #include "components/autofill/core/browser/field_types.h" | |
33 #include "components/autofill/core/browser/form_structure.h" | 34 #include "components/autofill/core/browser/form_structure.h" |
34 #include "components/autofill/core/browser/personal_data_manager.h" | 35 #include "components/autofill/core/browser/personal_data_manager.h" |
35 #include "components/autofill/core/browser/phone_number.h" | 36 #include "components/autofill/core/browser/phone_number.h" |
36 #include "components/autofill/core/browser/phone_number_i18n.h" | 37 #include "components/autofill/core/browser/phone_number_i18n.h" |
37 #include "components/autofill/core/browser/popup_item_ids.h" | 38 #include "components/autofill/core/browser/popup_item_ids.h" |
38 #include "components/autofill/core/common/autofill_data_validation.h" | 39 #include "components/autofill/core/common/autofill_data_validation.h" |
39 #include "components/autofill/core/common/autofill_pref_names.h" | 40 #include "components/autofill/core/common/autofill_pref_names.h" |
40 #include "components/autofill/core/common/autofill_switches.h" | 41 #include "components/autofill/core/common/autofill_switches.h" |
41 #include "components/autofill/core/common/form_data.h" | 42 #include "components/autofill/core/common/form_data.h" |
42 #include "components/autofill/core/common/form_data_predictions.h" | 43 #include "components/autofill/core/common/form_data_predictions.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // work if the delegate has a pointer to the AutofillManager, but | 234 // work if the delegate has a pointer to the AutofillManager, but |
234 // future directions may not need such a pointer. | 235 // future directions may not need such a pointer. |
235 external_delegate_ = delegate; | 236 external_delegate_ = delegate; |
236 autocomplete_history_manager_->SetExternalDelegate(delegate); | 237 autocomplete_history_manager_->SetExternalDelegate(delegate); |
237 } | 238 } |
238 | 239 |
239 void AutofillManager::ShowAutofillSettings() { | 240 void AutofillManager::ShowAutofillSettings() { |
240 manager_delegate_->ShowAutofillSettings(); | 241 manager_delegate_->ShowAutofillSettings(); |
241 } | 242 } |
242 | 243 |
244 #if defined(OS_MACOSX) | |
245 bool AutofillManager::HasPromptedForAccessToAddressBook() { | |
246 // Return 'true' to prevent the UI from prompting the user for access to the | |
247 // address book again. | |
248 if (!personal_data_) | |
249 return true; | |
250 return personal_data_->HasPromptedForAccessToAddressBook(); | |
251 } | |
252 | |
253 bool AutofillManager::FieldSupportsAddressBookAutofill( | |
254 const FormData& data, | |
255 const FormFieldData& fieldData) { | |
Ilya Sherman
2014/05/21 11:29:15
nit: "fieldData" -> "field" or "field_data"
erikchen
2014/05/21 22:00:54
ack, thanks. I've been writing too much ObjC.
| |
256 for (auto it : form_structures_) { | |
Ilya Sherman
2014/05/21 11:29:15
C++ files should not use auto. It's fine to keep
erikchen
2014/05/21 22:00:54
I've moved this logic into personal_data_manager_m
Ilya Sherman
2014/05/22 15:13:59
Chromium in general still supports non C++11 compl
| |
257 // The form does not match. | |
258 if (it->ToFormData().name != data.name) | |
259 continue; | |
260 for (size_t index = 0; index < it->field_count(); ++index) { | |
261 const AutofillField* field = it->field(index); | |
262 // The field does not match. | |
263 if (field->name != fieldData.name) | |
264 continue; | |
265 | |
266 switch (field->Type().group()) { | |
267 case ADDRESS_BILLING: | |
268 case ADDRESS_HOME: | |
269 case EMAIL: | |
270 case NAME: | |
271 case NAME_BILLING: | |
272 case PHONE_BILLING: | |
273 case PHONE_HOME: | |
274 return true; | |
275 case NO_GROUP: | |
276 case COMPANY: | |
277 case CREDIT_CARD: | |
278 case PASSWORD_FIELD: | |
279 return false; | |
280 } | |
281 } | |
282 } | |
283 | |
284 return false; | |
285 } | |
286 | |
287 void AutofillManager::AccessAddressBook() { | |
288 if (!personal_data_) | |
289 return; | |
290 personal_data_->AccessAddressBook(); | |
291 } | |
292 #endif // defined(OS_MACOSX) | |
Ilya Sherman
2014/05/21 11:29:15
I'd prefer to not make any changes to the Autofill
erikchen
2014/05/21 22:00:54
The method ShouldShowAccessAddressBookSuggestion n
| |
293 | |
243 bool AutofillManager::OnFormSubmitted(const FormData& form, | 294 bool AutofillManager::OnFormSubmitted(const FormData& form, |
244 const TimeTicks& timestamp) { | 295 const TimeTicks& timestamp) { |
245 if (!IsValidFormData(form)) | 296 if (!IsValidFormData(form)) |
246 return false; | 297 return false; |
247 | 298 |
248 // Let Autocomplete know as well. | 299 // Let Autocomplete know as well. |
249 autocomplete_history_manager_->OnFormSubmitted(form); | 300 autocomplete_history_manager_->OnFormSubmitted(form); |
250 | 301 |
251 // Grab a copy of the form data. | 302 // Grab a copy of the form data. |
252 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); | 303 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 return false; | 1189 return false; |
1139 | 1190 |
1140 // Disregard forms that we wouldn't ever autofill in the first place. | 1191 // Disregard forms that we wouldn't ever autofill in the first place. |
1141 if (!form.ShouldBeParsed(true)) | 1192 if (!form.ShouldBeParsed(true)) |
1142 return false; | 1193 return false; |
1143 | 1194 |
1144 return true; | 1195 return true; |
1145 } | 1196 } |
1146 | 1197 |
1147 } // namespace autofill | 1198 } // namespace autofill |
OLD | NEW |