| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 std::vector<FormStructure*> import; | 431 std::vector<FormStructure*> import; |
| 432 import.push_back(upload_form_structure_.get()); | 432 import.push_back(upload_form_structure_.get()); |
| 433 if (!personal_data_->ImportFormData(import, this)) | 433 if (!personal_data_->ImportFormData(import, this)) |
| 434 return; | 434 return; |
| 435 | 435 |
| 436 // Did we get credit card info? | 436 // Did we get credit card info? |
| 437 AutoFillProfile* profile; | 437 AutoFillProfile* profile; |
| 438 CreditCard* credit_card; | 438 CreditCard* credit_card; |
| 439 personal_data_->GetImportedFormData(&profile, &credit_card); | 439 personal_data_->GetImportedFormData(&profile, &credit_card); |
| 440 | 440 |
| 441 if (credit_card) { | 441 if (!credit_card) { |
| 442 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this)); | |
| 443 } else { | |
| 444 UploadFormData(); | 442 UploadFormData(); |
| 443 return; |
| 444 } |
| 445 |
| 446 // Show an infobar to offer to save the credit card info. |
| 447 if (tab_contents_) { |
| 448 tab_contents_->AddInfoBar(new AutoFillCCInfoBarDelegate(tab_contents_, |
| 449 this)); |
| 445 } | 450 } |
| 446 } | 451 } |
| 447 | 452 |
| 448 void AutoFillManager::UploadFormData() { | 453 void AutoFillManager::UploadFormData() { |
| 449 if (!disable_download_manager_requests_ && upload_form_structure_.get()) { | 454 if (!disable_download_manager_requests_ && upload_form_structure_.get()) { |
| 450 bool was_autofilled = false; | 455 bool was_autofilled = false; |
| 451 // Check if the form among last 3 forms that were auto-filled. | 456 // Check if the form among last 3 forms that were auto-filled. |
| 452 // Clear older signatures. | 457 // Clear older signatures. |
| 453 std::list<std::string>::iterator it; | 458 std::list<std::string>::iterator it; |
| 454 int total_form_checked = 0; | 459 int total_form_checked = 0; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 809 |
| 805 // When receiving IDs (across processes) from the renderer we unpack credit card | 810 // When receiving IDs (across processes) from the renderer we unpack credit card |
| 806 // and profile IDs from a single integer. Credit card IDs are stored in the | 811 // and profile IDs from a single integer. Credit card IDs are stored in the |
| 807 // high word and profile IDs are stored in the low word. | 812 // high word and profile IDs are stored in the low word. |
| 808 // static | 813 // static |
| 809 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) { | 814 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) { |
| 810 *cc_id = id >> std::numeric_limits<unsigned short>::digits & | 815 *cc_id = id >> std::numeric_limits<unsigned short>::digits & |
| 811 std::numeric_limits<unsigned short>::max(); | 816 std::numeric_limits<unsigned short>::max(); |
| 812 *profile_id = id & std::numeric_limits<unsigned short>::max(); | 817 *profile_id = id & std::numeric_limits<unsigned short>::max(); |
| 813 } | 818 } |
| OLD | NEW |