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

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

Issue 545175: Add the ability to save and remove AutoFill profiles from the AutoFillDialog.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/autofill/autofill_dialog.h" 10 #include "chrome/browser/autofill/autofill_dialog.h"
11 #include "chrome/browser/autofill/autofill_infobar_delegate.h" 11 #include "chrome/browser/autofill/autofill_infobar_delegate.h"
12 #include "chrome/browser/autofill/form_structure.h" 12 #include "chrome/browser/autofill/form_structure.h"
13 #include "chrome/browser/autofill/personal_data_manager.h"
14 #include "chrome/browser/profile.h" 13 #include "chrome/browser/profile.h"
15 #include "chrome/browser/tab_contents/tab_contents.h" 14 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
18 #include "chrome/common/pref_service.h" 17 #include "chrome/common/pref_service.h"
19 #include "webkit/glue/form_field_values.h" 18 #include "webkit/glue/form_field_values.h"
20 19
21 AutoFillManager::AutoFillManager(TabContents* tab_contents) 20 AutoFillManager::AutoFillManager(TabContents* tab_contents)
22 : tab_contents_(tab_contents), 21 : tab_contents_(tab_contents),
23 infobar_(NULL) { 22 infobar_(NULL) {
(...skipping 30 matching lines...) Expand all
54 bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown); 53 bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown);
55 if (!infobar_shown) { 54 if (!infobar_shown) {
56 // Ask the user for permission to save form information. 55 // Ask the user for permission to save form information.
57 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); 56 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this));
58 } else if (autofill_enabled) { 57 } else if (autofill_enabled) {
59 HandleSubmit(); 58 HandleSubmit();
60 } 59 }
61 } 60 }
62 61
63 void AutoFillManager::OnAutoFillDialogApply( 62 void AutoFillManager::OnAutoFillDialogApply(
64 const std::vector<AutoFillProfile>& profiles, 63 std::vector<AutoFillProfile>* profiles,
65 const std::vector<CreditCard>& credit_cards) { 64 std::vector<CreditCard>* credit_cards) {
66 // TODO(jhawkins): Pass the profile data onto the PersonalDataManager. 65 // Save the personal data.
66 personal_data_->SetProfiles(profiles);
67 // TODO(jhawkins): Set the credit cards.
68
69 HandleSubmit();
70 }
71
72 void AutoFillManager::OnPersonalDataLoaded() {
73 // We might have been alerted that the PersonalDataManager has loaded, so
74 // remove ourselves as observer.
75 personal_data_->RemoveObserver(this);
76
77 // TODO(jhawkins): Actually send in the real credit cards from the personal
78 // data manager.
79 std::vector<CreditCard*> credit_cards;
80 ShowAutoFillDialog(this, personal_data_->profiles(), credit_cards);
67 } 81 }
68 82
69 void AutoFillManager::DeterminePossibleFieldTypes( 83 void AutoFillManager::DeterminePossibleFieldTypes(
70 FormStructure* form_structure) { 84 FormStructure* form_structure) {
71 // TODO(jhawkins): Update field text. 85 // TODO(jhawkins): Update field text.
72 86
73 form_structure->GetHeuristicAutoFillTypes(); 87 form_structure->GetHeuristicAutoFillTypes();
74 88
75 for (size_t i = 0; i < form_structure->field_count(); i++) { 89 for (size_t i = 0; i < form_structure->field_count(); i++) {
76 const AutoFillField* field = form_structure->field(i); 90 const AutoFillField* field = form_structure->field(i);
77 FieldTypeSet field_types; 91 FieldTypeSet field_types;
78 personal_data_->GetPossibleFieldTypes(field->value(), &field_types); 92 personal_data_->GetPossibleFieldTypes(field->value(), &field_types);
79 form_structure->set_possible_types(i, field_types); 93 form_structure->set_possible_types(i, field_types);
80 } 94 }
81 } 95 }
82 96
83 void AutoFillManager::HandleSubmit() { 97 void AutoFillManager::HandleSubmit() {
84 // If there wasn't enough data to import then we don't want to send an upload 98 // If there wasn't enough data to import then we don't want to send an upload
85 // to the server. 99 // to the server.
86 if (!personal_data_->ImportFormData(form_structures_, this)) 100 if (!personal_data_->ImportFormData(form_structures_, this))
87 return; 101 return;
88 102
89 UploadFormData(); 103 UploadFormData();
90 } 104 }
91 105
92 void AutoFillManager::OnInfoBarAccepted() { 106 void AutoFillManager::OnInfoBarAccepted() {
93 PrefService* prefs = tab_contents_->profile()->GetPrefs(); 107 PrefService* prefs = tab_contents_->profile()->GetPrefs();
94 prefs->SetBoolean(prefs::kAutoFillEnabled, true); 108 prefs->SetBoolean(prefs::kAutoFillEnabled, true);
95 109
96 // TODO(jhawkins): Actually send in the real profiles and credit cards from 110 // If the personal data manager has not loaded the data yet, set ourselves as
97 // the personal data manager. 111 // its observer so that we can listen for the OnPersonalDataLoaded signal.
98 std::vector<AutoFillProfile> profiles; 112 if (!personal_data_->IsDataLoaded())
99 std::vector<CreditCard> credit_cards; 113 personal_data_->SetObserver(this);
100 ShowAutoFillDialog(this, profiles, credit_cards); 114 else
101 115 OnPersonalDataLoaded();
102 HandleSubmit();
103 } 116 }
104 117
105 void AutoFillManager::SaveFormData() { 118 void AutoFillManager::SaveFormData() {
106 // TODO(jhawkins): Save the form data to the web database. 119 // TODO(jhawkins): Save the form data to the web database.
107 } 120 }
108 121
109 void AutoFillManager::UploadFormData() { 122 void AutoFillManager::UploadFormData() {
110 std::string xml; 123 std::string xml;
111 bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml); 124 bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml);
112 DCHECK(ok); 125 DCHECK(ok);
113 126
114 // TODO(jhawkins): Initiate the upload request thread. 127 // TODO(jhawkins): Initiate the upload request thread.
115 } 128 }
116 129
117 void AutoFillManager::Reset() { 130 void AutoFillManager::Reset() {
118 upload_form_structure_.reset(); 131 upload_form_structure_.reset();
119 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698