| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "chrome/browser/autofill/autofill_dialog.h" | 11 #include "chrome/browser/autofill/autofill_dialog.h" |
| 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 12 #include "chrome/browser/autofill/form_structure.h" | 13 #include "chrome/browser/autofill/form_structure.h" |
| 13 #include "chrome/browser/pref_service.h" | 14 #include "chrome/browser/pref_service.h" |
| 14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/renderer_host/render_view_host.h" | 16 #include "chrome/browser/renderer_host/render_view_host.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 17 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "webkit/glue/form_data.h" | 20 #include "webkit/glue/form_data.h" |
| 20 #include "webkit/glue/form_field.h" | 21 #include "webkit/glue/form_field.h" |
| 21 | 22 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 void AutoFillManager::HandleSubmit() { | 396 void AutoFillManager::HandleSubmit() { |
| 396 // If there wasn't enough data to import then we don't want to send an upload | 397 // If there wasn't enough data to import then we don't want to send an upload |
| 397 // to the server. | 398 // to the server. |
| 398 // TODO(jhawkins): Import form data from |form_structures_|. That will | 399 // TODO(jhawkins): Import form data from |form_structures_|. That will |
| 399 // require querying the FormManager for updated field values. | 400 // require querying the FormManager for updated field values. |
| 400 std::vector<FormStructure*> import; | 401 std::vector<FormStructure*> import; |
| 401 import.push_back(upload_form_structure_.get()); | 402 import.push_back(upload_form_structure_.get()); |
| 402 if (!personal_data_->ImportFormData(import, this)) | 403 if (!personal_data_->ImportFormData(import, this)) |
| 403 return; | 404 return; |
| 404 | 405 |
| 405 UploadFormData(); | 406 // Did we get credit card info? |
| 407 AutoFillProfile* profile; |
| 408 CreditCard* credit_card; |
| 409 personal_data_->GetImportedFormData(&profile, &credit_card); |
| 410 |
| 411 if (credit_card) { |
| 412 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this)); |
| 413 } else { |
| 414 UploadFormData(); |
| 415 } |
| 406 } | 416 } |
| 407 | 417 |
| 408 void AutoFillManager::UploadFormData() { | 418 void AutoFillManager::UploadFormData() { |
| 409 // TODO(georgey): enable upload request when we make sure that our data is in | 419 // TODO(georgey): enable upload request when we make sure that our data is in |
| 410 // line with toolbar data: | 420 // line with toolbar data: |
| 411 // download_manager_.StartUploadRequest(upload_form_structure_, | 421 // download_manager_.StartUploadRequest(upload_form_structure_, |
| 412 // form_is_autofilled); | 422 // form_is_autofilled); |
| 413 } | 423 } |
| 414 | 424 |
| 425 void AutoFillManager::OnInfoBarClosed(bool should_save) { |
| 426 if (should_save) |
| 427 personal_data_->SaveImportedCreditCard(); |
| 428 UploadFormData(); |
| 429 } |
| 430 |
| 415 AutoFillManager::AutoFillManager() | 431 AutoFillManager::AutoFillManager() |
| 416 : tab_contents_(NULL), | 432 : tab_contents_(NULL), |
| 417 personal_data_(NULL), | 433 personal_data_(NULL), |
| 418 download_manager_(NULL) { | 434 download_manager_(NULL) { |
| 419 } | 435 } |
| 420 | 436 |
| 421 AutoFillManager::AutoFillManager(TabContents* tab_contents, | 437 AutoFillManager::AutoFillManager(TabContents* tab_contents, |
| 422 PersonalDataManager* personal_data) | 438 PersonalDataManager* personal_data) |
| 423 : tab_contents_(tab_contents), | 439 : tab_contents_(tab_contents), |
| 424 personal_data_(personal_data), | 440 personal_data_(personal_data), |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 field->set_value(number); | 613 field->set_value(number); |
| 598 } else if (has_valid_suffix_and_prefix && | 614 } else if (has_valid_suffix_and_prefix && |
| 599 field->size() == kAutoFillPhoneNumberSuffixCount) { | 615 field->size() == kAutoFillPhoneNumberSuffixCount) { |
| 600 number = number.substr(kAutoFillPhoneNumberSuffixOffset, | 616 number = number.substr(kAutoFillPhoneNumberSuffixOffset, |
| 601 kAutoFillPhoneNumberSuffixCount); | 617 kAutoFillPhoneNumberSuffixCount); |
| 602 field->set_value(number); | 618 field->set_value(number); |
| 603 } else { | 619 } else { |
| 604 field->set_value(number); | 620 field->set_value(number); |
| 605 } | 621 } |
| 606 } | 622 } |
| OLD | NEW |