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

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

Issue 3160022: AutoFillManagerTest.GetProfileSuggestionsEmptyValue crashes in official build... (Closed) Base URL: svn://chrome-svn/chrome/trunk/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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 } // namespace 93 } // namespace
94 94
95 // TODO(jhawkins): Maybe this should be in a grd file? 95 // TODO(jhawkins): Maybe this should be in a grd file?
96 const char* kAutoFillLearnMoreUrl = 96 const char* kAutoFillLearnMoreUrl =
97 "http://www.google.com/support/chrome/bin/answer.py?answer=142893"; 97 "http://www.google.com/support/chrome/bin/answer.py?answer=142893";
98 98
99 AutoFillManager::AutoFillManager(TabContents* tab_contents) 99 AutoFillManager::AutoFillManager(TabContents* tab_contents)
100 : tab_contents_(tab_contents), 100 : tab_contents_(tab_contents),
101 personal_data_(NULL), 101 personal_data_(NULL),
102 download_manager_(tab_contents_->profile()) { 102 download_manager_(tab_contents_->profile()),
103 disable_download_manager_requests_(false) {
103 DCHECK(tab_contents); 104 DCHECK(tab_contents);
104 105
105 // |personal_data_| is NULL when using TestTabContents. 106 // |personal_data_| is NULL when using TestTabContents.
106 personal_data_ = 107 personal_data_ =
107 tab_contents_->profile()->GetOriginalProfile()->GetPersonalDataManager(); 108 tab_contents_->profile()->GetOriginalProfile()->GetPersonalDataManager();
108 download_manager_.SetObserver(this); 109 download_manager_.SetObserver(this);
109 } 110 }
110 111
111 AutoFillManager::~AutoFillManager() { 112 AutoFillManager::~AutoFillManager() {
112 download_manager_.SetObserver(NULL); 113 download_manager_.SetObserver(NULL);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 if (credit_card) { 445 if (credit_card) {
445 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this)); 446 cc_infobar_.reset(new AutoFillCCInfoBarDelegate(tab_contents_, this));
446 } else { 447 } else {
447 UploadFormData(); 448 UploadFormData();
448 } 449 }
449 } 450 }
450 451
451 void AutoFillManager::UploadFormData() { 452 void AutoFillManager::UploadFormData() {
452 // TODO(georgey): enable upload request when we make sure that our data is in 453 // TODO(georgey): enable upload request when we make sure that our data is in
453 // line with toolbar data: 454 // line with toolbar data:
454 // download_manager_.StartUploadRequest(upload_form_structure_, 455 // if (!disable_download_manager_requests_)
dhollowa 2010/08/17 20:44:02 Please log an M7 bug on this and add bug reference
GeorgeY 2010/08/17 21:18:46 Done: #52501
455 // form_is_autofilled); 456 // download_manager_.StartUploadRequest(upload_form_structure_,
457 // form_is_autofilled);
456 } 458 }
457 459
458 void AutoFillManager::OnInfoBarClosed(bool should_save) { 460 void AutoFillManager::OnInfoBarClosed(bool should_save) {
459 if (should_save) 461 if (should_save)
460 personal_data_->SaveImportedCreditCard(); 462 personal_data_->SaveImportedCreditCard();
461 UploadFormData(); 463 UploadFormData();
462 } 464 }
463 465
464 AutoFillManager::AutoFillManager() 466 AutoFillManager::AutoFillManager()
465 : tab_contents_(NULL), 467 : tab_contents_(NULL),
466 personal_data_(NULL), 468 personal_data_(NULL),
467 download_manager_(NULL) { 469 download_manager_(NULL),
470 disable_download_manager_requests_(false) {
468 } 471 }
469 472
470 AutoFillManager::AutoFillManager(TabContents* tab_contents, 473 AutoFillManager::AutoFillManager(TabContents* tab_contents,
471 PersonalDataManager* personal_data) 474 PersonalDataManager* personal_data)
472 : tab_contents_(tab_contents), 475 : tab_contents_(tab_contents),
473 personal_data_(personal_data), 476 personal_data_(personal_data),
474 download_manager_(NULL) { 477 download_manager_(NULL),
478 disable_download_manager_requests_(false) {
475 DCHECK(tab_contents); 479 DCHECK(tab_contents);
476 } 480 }
477 481
478 void AutoFillManager::GetProfileSuggestions(FormStructure* form, 482 void AutoFillManager::GetProfileSuggestions(FormStructure* form,
479 const FormField& field, 483 const FormField& field,
480 AutoFillType type, 484 AutoFillType type,
481 bool include_cc_labels, 485 bool include_cc_labels,
482 std::vector<string16>* values, 486 std::vector<string16>* values,
483 std::vector<string16>* labels, 487 std::vector<string16>* labels,
484 std::vector<string16>* icons, 488 std::vector<string16>* icons,
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 iter != forms.end(); ++iter) { 769 iter != forms.end(); ++iter) {
766 FormStructure* form_structure = new FormStructure(*iter); 770 FormStructure* form_structure = new FormStructure(*iter);
767 if (!form_structure->ShouldBeParsed()) 771 if (!form_structure->ShouldBeParsed())
768 continue; 772 continue;
769 773
770 DeterminePossibleFieldTypes(form_structure); 774 DeterminePossibleFieldTypes(form_structure);
771 form_structures_.push_back(form_structure); 775 form_structures_.push_back(form_structure);
772 } 776 }
773 777
774 // If none of the forms were parsed, no use querying the server. 778 // If none of the forms were parsed, no use querying the server.
775 if (!form_structures_.empty()) 779 if (!form_structures_.empty() && !disable_download_manager_requests_)
776 download_manager_.StartQueryRequest(form_structures_); 780 download_manager_.StartQueryRequest(form_structures_);
777 } 781 }
778 782
779 // When sending IDs (across processes) to the renderer we pack credit card and 783 // When sending IDs (across processes) to the renderer we pack credit card and
780 // profile IDs into a single integer. Credit card IDs are sent in the high 784 // profile IDs into a single integer. Credit card IDs are sent in the high
781 // word and profile IDs are sent in the low word. 785 // word and profile IDs are sent in the low word.
782 // static 786 // static
783 int AutoFillManager::PackIDs(int cc_id, int profile_id) { 787 int AutoFillManager::PackIDs(int cc_id, int profile_id) {
784 DCHECK(cc_id <= std::numeric_limits<unsigned short>::max()); 788 DCHECK(cc_id <= std::numeric_limits<unsigned short>::max());
785 DCHECK(profile_id <= std::numeric_limits<unsigned short>::max()); 789 DCHECK(profile_id <= std::numeric_limits<unsigned short>::max());
786 790
787 return cc_id << std::numeric_limits<unsigned short>::digits | profile_id; 791 return cc_id << std::numeric_limits<unsigned short>::digits | profile_id;
788 } 792 }
789 793
790 // When receiving IDs (across processes) from the renderer we unpack credit card 794 // When receiving IDs (across processes) from the renderer we unpack credit card
791 // and profile IDs from a single integer. Credit card IDs are stored in the 795 // and profile IDs from a single integer. Credit card IDs are stored in the
792 // high word and profile IDs are stored in the low word. 796 // high word and profile IDs are stored in the low word.
793 // static 797 // static
794 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) { 798 void AutoFillManager::UnpackIDs(int id, int* cc_id, int* profile_id) {
795 *cc_id = id >> std::numeric_limits<unsigned short>::digits & 799 *cc_id = id >> std::numeric_limits<unsigned short>::digits &
796 std::numeric_limits<unsigned short>::max(); 800 std::numeric_limits<unsigned short>::max();
797 *profile_id = id & std::numeric_limits<unsigned short>::max(); 801 *profile_id = id & std::numeric_limits<unsigned short>::max();
798 } 802 }
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