Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1235)

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 3157025: Merge 56435 - AutoFillManagerTest.GetProfileSuggestionsEmptyValue crashes in ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 } // namespace 92 } // namespace
93 93
94 // TODO(jhawkins): Maybe this should be in a grd file? 94 // TODO(jhawkins): Maybe this should be in a grd file?
95 const char* kAutoFillLearnMoreUrl = 95 const char* kAutoFillLearnMoreUrl =
96 "http://www.google.com/support/chrome/bin/answer.py?answer=142893"; 96 "http://www.google.com/support/chrome/bin/answer.py?answer=142893";
97 97
98 AutoFillManager::AutoFillManager(TabContents* tab_contents) 98 AutoFillManager::AutoFillManager(TabContents* tab_contents)
99 : tab_contents_(tab_contents), 99 : tab_contents_(tab_contents),
100 personal_data_(NULL), 100 personal_data_(NULL),
101 download_manager_(tab_contents_->profile()) { 101 download_manager_(tab_contents_->profile()),
102 disable_download_manager_requests_(false) {
102 DCHECK(tab_contents); 103 DCHECK(tab_contents);
103 104
104 // |personal_data_| is NULL when using TestTabContents. 105 // |personal_data_| is NULL when using TestTabContents.
105 personal_data_ = 106 personal_data_ =
106 tab_contents_->profile()->GetOriginalProfile()->GetPersonalDataManager(); 107 tab_contents_->profile()->GetOriginalProfile()->GetPersonalDataManager();
107 download_manager_.SetObserver(this); 108 download_manager_.SetObserver(this);
108 } 109 }
109 110
110 AutoFillManager::~AutoFillManager() { 111 AutoFillManager::~AutoFillManager() {
111 download_manager_.SetObserver(NULL); 112 download_manager_.SetObserver(NULL);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 443
443 if (credit_card) { 444 if (credit_card) {
444 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this)); 445 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this));
445 } else { 446 } else {
446 UploadFormData(); 447 UploadFormData();
447 } 448 }
448 } 449 }
449 450
450 void AutoFillManager::UploadFormData() { 451 void AutoFillManager::UploadFormData() {
451 // TODO(georgey): enable upload request when we make sure that our data is in 452 // TODO(georgey): enable upload request when we make sure that our data is in
452 // line with toolbar data: 453 // line with toolbar data (bug #52501):
453 // download_manager_.StartUploadRequest(upload_form_structure_, 454 // if (!disable_download_manager_requests_)
454 // form_is_autofilled); 455 // download_manager_.StartUploadRequest(upload_form_structure_,
456 // form_is_autofilled);
455 } 457 }
456 458
457 void AutoFillManager::OnInfoBarClosed(bool should_save) { 459 void AutoFillManager::OnInfoBarClosed(bool should_save) {
458 if (should_save) 460 if (should_save)
459 personal_data_->SaveImportedCreditCard(); 461 personal_data_->SaveImportedCreditCard();
460 UploadFormData(); 462 UploadFormData();
461 } 463 }
462 464
463 AutoFillManager::AutoFillManager() 465 AutoFillManager::AutoFillManager()
464 : tab_contents_(NULL), 466 : tab_contents_(NULL),
465 personal_data_(NULL), 467 personal_data_(NULL),
466 download_manager_(NULL) { 468 download_manager_(NULL),
469 disable_download_manager_requests_(false) {
467 } 470 }
468 471
469 AutoFillManager::AutoFillManager(TabContents* tab_contents, 472 AutoFillManager::AutoFillManager(TabContents* tab_contents,
470 PersonalDataManager* personal_data) 473 PersonalDataManager* personal_data)
471 : tab_contents_(tab_contents), 474 : tab_contents_(tab_contents),
472 personal_data_(personal_data), 475 personal_data_(personal_data),
473 download_manager_(NULL) { 476 download_manager_(NULL),
477 disable_download_manager_requests_(false) {
474 DCHECK(tab_contents); 478 DCHECK(tab_contents);
475 } 479 }
476 480
477 void AutoFillManager::GetProfileSuggestions(FormStructure* form, 481 void AutoFillManager::GetProfileSuggestions(FormStructure* form,
478 const FormField& field, 482 const FormField& field,
479 AutoFillType type, 483 AutoFillType type,
480 bool include_cc_labels, 484 bool include_cc_labels,
481 std::vector<string16>* values, 485 std::vector<string16>* values,
482 std::vector<string16>* labels, 486 std::vector<string16>* labels,
483 std::vector<string16>* icons, 487 std::vector<string16>* icons,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 iter != forms.end(); ++iter) { 768 iter != forms.end(); ++iter) {
765 FormStructure* form_structure = new FormStructure(*iter); 769 FormStructure* form_structure = new FormStructure(*iter);
766 if (!form_structure->ShouldBeParsed()) 770 if (!form_structure->ShouldBeParsed())
767 continue; 771 continue;
768 772
769 DeterminePossibleFieldTypes(form_structure); 773 DeterminePossibleFieldTypes(form_structure);
770 form_structures_.push_back(form_structure); 774 form_structures_.push_back(form_structure);
771 } 775 }
772 776
773 // If none of the forms were parsed, no use querying the server. 777 // If none of the forms were parsed, no use querying the server.
774 if (!form_structures_.empty()) 778 if (!form_structures_.empty() && !disable_download_manager_requests_)
775 download_manager_.StartQueryRequest(form_structures_); 779 download_manager_.StartQueryRequest(form_structures_);
776 } 780 }
777 781
778 // When sending IDs (across processes) to the renderer we pack credit card and 782 // When sending IDs (across processes) to the renderer we pack credit card and
779 // profile IDs into a single integer. Credit card IDs are sent in the high 783 // profile IDs into a single integer. Credit card IDs are sent in the high
780 // word and profile IDs are sent in the low word. 784 // word and profile IDs are sent in the low word.
781 // static 785 // static
782 int AutoFillManager::PackIDs(int cc_id, int profile_id) { 786 int AutoFillManager::PackIDs(int cc_id, int profile_id) {
783 DCHECK(cc_id <= std::numeric_limits<unsigned short>::max()); 787 DCHECK(cc_id <= std::numeric_limits<unsigned short>::max());
784 DCHECK(profile_id <= std::numeric_limits<unsigned short>::max()); 788 DCHECK(profile_id <= std::numeric_limits<unsigned short>::max());
785 789
786 return cc_id << std::numeric_limits<unsigned short>::digits | profile_id; 790 return cc_id << std::numeric_limits<unsigned short>::digits | profile_id;
787 } 791 }
788 792
789 // When receiving IDs (across processes) from the renderer we unpack credit card 793 // When receiving IDs (across processes) from the renderer we unpack credit card
790 // and profile IDs from a single integer. Credit card IDs are stored in the 794 // and profile IDs from a single integer. Credit card IDs are stored in the
791 // high word and profile IDs are stored in the low word. 795 // high word and profile IDs are stored in the low word.
792 // static 796 // static
793 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) { 797 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) {
794 *cc_id = id >> std::numeric_limits<unsigned short>::digits & 798 *cc_id = id >> std::numeric_limits<unsigned short>::digits &
795 std::numeric_limits<unsigned short>::max(); 799 std::numeric_limits<unsigned short>::max();
796 *profile_id = id & std::numeric_limits<unsigned short>::max(); 800 *profile_id = id & std::numeric_limits<unsigned short>::max();
797 } 801 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698