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

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

Issue 555023: Notify the AutoFillManager when the user clicks "Apply" or "OK". Adds an Aut... (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/credit_card.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_infobar_delegate.h" 11 #include "chrome/browser/autofill/autofill_infobar_delegate.h"
11 #include "chrome/browser/autofill/form_structure.h" 12 #include "chrome/browser/autofill/form_structure.h"
12 #include "chrome/browser/autofill/personal_data_manager.h" 13 #include "chrome/browser/autofill/personal_data_manager.h"
13 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
14 #include "chrome/browser/tab_contents/tab_contents.h" 15 #include "chrome/browser/tab_contents/tab_contents.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/common/pref_service.h" 18 #include "chrome/common/pref_service.h"
18 #include "webkit/glue/form_field_values.h" 19 #include "webkit/glue/form_field_values.h"
19 20
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 bool autofill_enabled = prefs->GetBoolean(prefs::kAutoFillEnabled); 53 bool autofill_enabled = prefs->GetBoolean(prefs::kAutoFillEnabled);
53 bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown); 54 bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown);
54 if (!infobar_shown) { 55 if (!infobar_shown) {
55 // Ask the user for permission to save form information. 56 // Ask the user for permission to save form information.
56 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); 57 infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this));
57 } else if (autofill_enabled) { 58 } else if (autofill_enabled) {
58 HandleSubmit(); 59 HandleSubmit();
59 } 60 }
60 } 61 }
61 62
63 void AutoFillManager::OnAutoFillDialogApply(
64 const std::vector<AutoFillProfile>& profiles,
65 const std::vector<CreditCard>& credit_cards) {
66 // TODO(jhawkins): Pass the profile data onto the PersonalDataManager.
67 }
68
62 void AutoFillManager::DeterminePossibleFieldTypes( 69 void AutoFillManager::DeterminePossibleFieldTypes(
63 FormStructure* form_structure) { 70 FormStructure* form_structure) {
64 // TODO(jhawkins): Update field text. 71 // TODO(jhawkins): Update field text.
65 72
66 form_structure->GetHeuristicAutoFillTypes(); 73 form_structure->GetHeuristicAutoFillTypes();
67 74
68 for (size_t i = 0; i < form_structure->field_count(); i++) { 75 for (size_t i = 0; i < form_structure->field_count(); i++) {
69 const AutoFillField* field = form_structure->field(i); 76 const AutoFillField* field = form_structure->field(i);
70 FieldTypeSet field_types; 77 FieldTypeSet field_types;
71 personal_data_->GetPossibleFieldTypes(field->value(), &field_types); 78 personal_data_->GetPossibleFieldTypes(field->value(), &field_types);
72 form_structure->set_possible_types(i, field_types); 79 form_structure->set_possible_types(i, field_types);
73 } 80 }
74 } 81 }
75 82
76 void AutoFillManager::HandleSubmit() { 83 void AutoFillManager::HandleSubmit() {
77 // If there wasn't enough data to import then we don't want to send an upload 84 // If there wasn't enough data to import then we don't want to send an upload
78 // to the server. 85 // to the server.
79 if (!personal_data_->ImportFormData(form_structures_, this)) 86 if (!personal_data_->ImportFormData(form_structures_, this))
80 return; 87 return;
81 88
82 UploadFormData(); 89 UploadFormData();
83 } 90 }
84 91
85 void AutoFillManager::OnInfoBarAccepted() { 92 void AutoFillManager::OnInfoBarAccepted() {
86 PrefService* prefs = tab_contents_->profile()->GetPrefs(); 93 PrefService* prefs = tab_contents_->profile()->GetPrefs();
87 prefs->SetBoolean(prefs::kAutoFillEnabled, true); 94 prefs->SetBoolean(prefs::kAutoFillEnabled, true);
88 95
89 // TODO(jhawkins): AutoFillDialog 96 // TODO(jhawkins): Actually send in the real profiles and credit cards from
97 // the personal data manager.
98 std::vector<AutoFillProfile> profiles;
99 std::vector<CreditCard> credit_cards;
100 ShowAutoFillDialog(this, profiles, credit_cards);
90 101
91 HandleSubmit(); 102 HandleSubmit();
92 } 103 }
93 104
94 void AutoFillManager::SaveFormData() { 105 void AutoFillManager::SaveFormData() {
95 // TODO(jhawkins): Save the form data to the web database. 106 // TODO(jhawkins): Save the form data to the web database.
96 } 107 }
97 108
98 void AutoFillManager::UploadFormData() { 109 void AutoFillManager::UploadFormData() {
99 std::string xml; 110 std::string xml;
100 bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml); 111 bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml);
101 DCHECK(ok); 112 DCHECK(ok);
102 113
103 // TODO(jhawkins): Initiate the upload request thread. 114 // TODO(jhawkins): Initiate the upload request thread.
104 } 115 }
105 116
106 void AutoFillManager::Reset() { 117 void AutoFillManager::Reset() {
107 upload_form_structure_.reset(); 118 upload_form_structure_.reset();
108 } 119 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/credit_card.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698