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

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

Issue 5703002: Add some basic success/failure UMA logging for autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forbid copying, assignments (just like in, school) Created 10 years 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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 #include <string> 10 #include <string>
11 #include <list> 11 #include <list>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
15 #include "base/scoped_vector.h" 15 #include "base/scoped_vector.h"
16 #include "chrome/browser/autofill/autofill_dialog.h" 16 #include "chrome/browser/autofill/autofill_dialog.h"
17 #include "chrome/browser/autofill/autofill_download.h" 17 #include "chrome/browser/autofill/autofill_download.h"
18 #include "chrome/browser/autofill/personal_data_manager.h" 18 #include "chrome/browser/autofill/personal_data_manager.h"
19 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 19 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
20 20
21 class AutoFillCCInfoBarDelegate; 21 class AutoFillCCInfoBarDelegate;
22 class AutoFillProfile; 22 class AutoFillProfile;
23 class AutoFillMetrics;
23 class CreditCard; 24 class CreditCard;
24 class FormStructure; 25 class FormStructure;
25 class PrefService; 26 class PrefService;
26 class TabContents; 27 class TabContents;
27 28
28 namespace webkit_glue { 29 namespace webkit_glue {
29 struct FormData; 30 struct FormData;
30 class FormField; 31 class FormField;
31 } // namespace webkit_glue 32 } // namespace webkit_glue
32 33
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); 70 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml);
70 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); 71 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature);
71 virtual void OnHeuristicsRequestError( 72 virtual void OnHeuristicsRequestError(
72 const std::string& form_signature, 73 const std::string& form_signature,
73 AutoFillDownloadManager::AutoFillRequestType request_type, 74 AutoFillDownloadManager::AutoFillRequestType request_type,
74 int http_error); 75 int http_error);
75 76
76 // Returns the value of the AutoFillEnabled pref. 77 // Returns the value of the AutoFillEnabled pref.
77 virtual bool IsAutoFillEnabled() const; 78 virtual bool IsAutoFillEnabled() const;
78 79
79 // Uses heuristics and existing personal data to determine the possible field
80 // types.
81 void DeterminePossibleFieldTypes(FormStructure* form_structure);
82
83 // Handles the form data submitted by the user. 80 // Handles the form data submitted by the user.
84 void HandleSubmit(); 81 void HandleSubmit();
85 82
86 // Uploads the form data to the AutoFill server. 83 // Uploads the form data to the AutoFill server.
87 void UploadFormData(); 84 void UploadFormData();
88 85
89 protected: 86 protected:
90 // For tests. 87 // For tests.
91 AutoFillManager(); 88 AutoFillManager();
92 AutoFillManager(TabContents* tab_contents, 89 AutoFillManager(TabContents* tab_contents,
93 PersonalDataManager* personal_data); 90 PersonalDataManager* personal_data);
94 91
95 void set_personal_data_manager(PersonalDataManager* personal_data) { 92 void set_personal_data_manager(PersonalDataManager* personal_data) {
96 personal_data_ = personal_data; 93 personal_data_ = personal_data;
97 } 94 }
98 95
96 const AutoFillMetrics* metric_logger() const {
97 return metric_logger_.get();
98 }
99 void set_metric_logger(const AutoFillMetrics* metric_logger);
100
99 // Maps GUIDs to and from IDs that are used to identify profiles and credit 101 // Maps GUIDs to and from IDs that are used to identify profiles and credit
100 // cards sent to and from the renderer process. 102 // cards sent to and from the renderer process.
101 virtual int GUIDToID(const std::string& guid); 103 virtual int GUIDToID(const std::string& guid);
102 virtual const std::string IDToGUID(int id); 104 virtual const std::string IDToGUID(int id);
103 105
104 // Methods for packing and unpacking credit card and profile IDs for sending 106 // Methods for packing and unpacking credit card and profile IDs for sending
105 // and receiving to and from the renderer process. 107 // and receiving to and from the renderer process.
106 int PackGUIDs(const std::string& cc_guid, const std::string& profile_guid); 108 int PackGUIDs(const std::string& cc_guid, const std::string& profile_guid);
107 void UnpackGUIDs(int id, std::string* cc_guid, std::string* profile_guid); 109 void UnpackGUIDs(int id, std::string* cc_guid, std::string* profile_guid);
108 110
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 webkit_glue::FormField* field); 157 webkit_glue::FormField* field);
156 158
157 // Set |field| argument's value for phone number based on contents of the 159 // Set |field| argument's value for phone number based on contents of the
158 // |profile|. 160 // |profile|.
159 void FillPhoneNumberField(const AutoFillProfile* profile, 161 void FillPhoneNumberField(const AutoFillProfile* profile,
160 webkit_glue::FormField* field); 162 webkit_glue::FormField* field);
161 163
162 // Parses the forms using heuristic matching and querying the AutoFill server. 164 // Parses the forms using heuristic matching and querying the AutoFill server.
163 void ParseForms(const std::vector<webkit_glue::FormData>& forms); 165 void ParseForms(const std::vector<webkit_glue::FormData>& forms);
164 166
165 // The following function is meant to be called from unit-test only. 167 // Uses existing personal data to determine possible field types for the
166 void set_disable_download_manager_requests(bool value) { 168 // |upload_form_structure_|.
167 disable_download_manager_requests_ = value; 169 void DeterminePossibleFieldTypesForUpload();
168 }
169 170
170 // The TabContents hosting this AutoFillManager. 171 // The TabContents hosting this AutoFillManager.
171 // Weak reference. 172 // Weak reference.
172 // May not be NULL. 173 // May not be NULL.
173 TabContents* tab_contents_; 174 TabContents* tab_contents_;
174 175
175 // The personal data manager, used to save and load personal data to/from the 176 // The personal data manager, used to save and load personal data to/from the
176 // web database. This is overridden by the AutoFillManagerTest. 177 // web database. This is overridden by the AutoFillManagerTest.
177 // Weak reference. 178 // Weak reference.
178 // May be NULL. NULL indicates OTR. 179 // May be NULL. NULL indicates OTR.
179 PersonalDataManager* personal_data_; 180 PersonalDataManager* personal_data_;
180 181
181 std::list<std::string> autofilled_forms_signatures_; 182 std::list<std::string> autofilled_forms_signatures_;
182 // Handles queries and uploads to AutoFill servers. 183 // Handles queries and uploads to AutoFill servers.
183 AutoFillDownloadManager download_manager_; 184 AutoFillDownloadManager download_manager_;
184 185
185 // Should be set to true in AutoFillManagerTest and other tests, false in 186 // Should be set to true in AutoFillManagerTest and other tests, false in
186 // AutoFillDownloadManagerTest and in non-test environment. Is false by 187 // AutoFillDownloadManagerTest and in non-test environment. Is false by
187 // default. 188 // default for the public constructor, and true by default for the test-only
189 // constructors.
188 bool disable_download_manager_requests_; 190 bool disable_download_manager_requests_;
189 191
192 // For logging UMA metrics. Overridden by metrics tests.
193 scoped_ptr<const AutoFillMetrics> metric_logger_;
194
190 // Our copy of the form data. 195 // Our copy of the form data.
191 ScopedVector<FormStructure> form_structures_; 196 ScopedVector<FormStructure> form_structures_;
192 197
193 // The form data the user has submitted. 198 // The form data the user has submitted.
194 scoped_ptr<FormStructure> upload_form_structure_; 199 scoped_ptr<FormStructure> upload_form_structure_;
195 200
196 // The InfoBar that asks for permission to store credit card information. 201 // The InfoBar that asks for permission to store credit card information.
197 // Deletes itself when closed. 202 // Deletes itself when closed.
198 AutoFillCCInfoBarDelegate* cc_infobar_; 203 AutoFillCCInfoBarDelegate* cc_infobar_;
199 204
200 // GUID to ID mapping. We keep two maps to convert back and forth. 205 // GUID to ID mapping. We keep two maps to convert back and forth.
201 std::map<std::string, int> guid_id_map_; 206 std::map<std::string, int> guid_id_map_;
202 std::map<int, std::string> id_guid_map_; 207 std::map<int, std::string> id_guid_map_;
203 208
204 friend class FormStructureBrowserTest; 209 friend class FormStructureBrowserTest;
205 friend class TestAutoFillManager;
206 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); 210 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm);
207 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm); 211 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm);
208 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm); 212 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm);
209 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAutoFilledForm); 213 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAutoFilledForm);
210 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillPhoneNumber); 214 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillPhoneNumber);
211 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesRemoveField); 215 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesRemoveField);
212 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField); 216 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField);
213 217
214 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); 218 DISALLOW_COPY_AND_ASSIGN(AutoFillManager);
215 }; 219 };
216 220
217 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 221 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_download_unittest.cc ('k') | chrome/browser/autofill/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698