Chromium Code Reviews| 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 bool AutofillManager::ShouldShowAccessMacContacts( | |
| 245 const FormData& data, | |
| 246 const FormFieldData& fieldData) { | |
| 247 if (personal_data_->HasAccessMacContacts()) | |
| 248 return false; | |
| 249 | |
| 250 for (auto it : form_structures_) { | |
|
erikchen
2014/05/16 22:37:05
I couldn't find another way to get the type of the
| |
| 251 // The form does not match. | |
| 252 if (it->ToFormData().name != data.name) | |
| 253 continue; | |
| 254 for (size_t index = 0; index < it->field_count(); ++index) { | |
| 255 const AutofillField* field = it->field(index); | |
| 256 // The field does not match. | |
| 257 if (field->name != fieldData.name) | |
| 258 continue; | |
| 259 | |
| 260 switch (field->Type().group()) { | |
| 261 case ADDRESS_BILLING: | |
| 262 case ADDRESS_HOME: | |
| 263 case EMAIL: | |
| 264 case NAME: | |
| 265 case NAME_BILLING: | |
| 266 case PHONE_BILLING: | |
| 267 case PHONE_HOME: | |
| 268 return true; | |
| 269 case NO_GROUP: | |
| 270 case COMPANY: | |
| 271 case CREDIT_CARD: | |
| 272 case PASSWORD_FIELD: | |
| 273 return false; | |
| 274 } | |
| 275 } | |
| 276 } | |
| 277 | |
| 278 return false; | |
| 279 } | |
| 280 | |
| 281 void AutofillManager::AccessMacContacts() { | |
| 282 personal_data_->AccessMacContacts(); | |
| 283 } | |
| 284 | |
| 243 bool AutofillManager::OnFormSubmitted(const FormData& form, | 285 bool AutofillManager::OnFormSubmitted(const FormData& form, |
| 244 const TimeTicks& timestamp) { | 286 const TimeTicks& timestamp) { |
| 245 if (!IsValidFormData(form)) | 287 if (!IsValidFormData(form)) |
| 246 return false; | 288 return false; |
| 247 | 289 |
| 248 // Let Autocomplete know as well. | 290 // Let Autocomplete know as well. |
| 249 autocomplete_history_manager_->OnFormSubmitted(form); | 291 autocomplete_history_manager_->OnFormSubmitted(form); |
| 250 | 292 |
| 251 // Grab a copy of the form data. | 293 // Grab a copy of the form data. |
| 252 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); | 294 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1138 return false; | 1180 return false; |
| 1139 | 1181 |
| 1140 // Disregard forms that we wouldn't ever autofill in the first place. | 1182 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1141 if (!form.ShouldBeParsed(true)) | 1183 if (!form.ShouldBeParsed(true)) |
| 1142 return false; | 1184 return false; |
| 1143 | 1185 |
| 1144 return true; | 1186 return true; |
| 1145 } | 1187 } |
| 1146 | 1188 |
| 1147 } // namespace autofill | 1189 } // namespace autofill |
| OLD | NEW |