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

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

Issue 8680040: Group forms-related files in webkit/glue in a forms/ subdirectory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + another build fix Created 9 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
« no previous file with comments | « chrome/browser/autofill/autofill_field.cc ('k') | chrome/browser/autofill/autofill_manager.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 26 matching lines...) Expand all
37 struct ViewHostMsg_FrameNavigate_Params; 37 struct ViewHostMsg_FrameNavigate_Params;
38 38
39 namespace gfx { 39 namespace gfx {
40 class Rect; 40 class Rect;
41 }; 41 };
42 42
43 namespace IPC { 43 namespace IPC {
44 class Message; 44 class Message;
45 } 45 }
46 46
47 namespace webkit_glue { 47 namespace webkit {
48 namespace forms {
48 struct FormData; 49 struct FormData;
49 struct FormField; 50 struct FormField;
50 } 51 }
52 }
51 53
52 // Manages saving and restoring the user's personal information entered into web 54 // Manages saving and restoring the user's personal information entered into web
53 // forms. 55 // forms.
54 class AutofillManager : public TabContentsObserver, 56 class AutofillManager : public TabContentsObserver,
55 public AutofillDownloadManager::Observer, 57 public AutofillDownloadManager::Observer,
56 public base::RefCounted<AutofillManager> { 58 public base::RefCounted<AutofillManager> {
57 public: 59 public:
58 explicit AutofillManager(TabContentsWrapper* tab_contents); 60 explicit AutofillManager(TabContentsWrapper* tab_contents);
59 61
60 // Registers our Enable/Disable Autofill pref. 62 // Registers our Enable/Disable Autofill pref.
61 static void RegisterUserPrefs(PrefService* prefs); 63 static void RegisterUserPrefs(PrefService* prefs);
62 64
63 // Set our external delegate. 65 // Set our external delegate.
64 // TODO(jrg): consider passing delegate into the ctor. That won't 66 // TODO(jrg): consider passing delegate into the ctor. That won't
65 // work if the delegate has a pointer to the AutofillManager, but 67 // work if the delegate has a pointer to the AutofillManager, but
66 // future directions may not need such a pointer. 68 // future directions may not need such a pointer.
67 void SetExternalDelegate(AutofillExternalDelegate* delegate) { 69 void SetExternalDelegate(AutofillExternalDelegate* delegate) {
68 external_delegate_ = delegate; 70 external_delegate_ = delegate;
69 } 71 }
70 72
71 // Called from our external delegate so they cannot be private. 73 // Called from our external delegate so they cannot be private.
72 void OnFillAutofillFormData(int query_id, 74 void OnFillAutofillFormData(int query_id,
73 const webkit_glue::FormData& form, 75 const webkit::forms::FormData& form,
74 const webkit_glue::FormField& field, 76 const webkit::forms::FormField& field,
75 int unique_id); 77 int unique_id);
76 void OnDidShowAutofillSuggestions(bool is_new_popup); 78 void OnDidShowAutofillSuggestions(bool is_new_popup);
77 void OnDidFillAutofillFormData(const base::TimeTicks& timestamp); 79 void OnDidFillAutofillFormData(const base::TimeTicks& timestamp);
78 80
79 protected: 81 protected:
80 // Only test code should subclass AutofillManager. 82 // Only test code should subclass AutofillManager.
81 friend class base::RefCounted<AutofillManager>; 83 friend class base::RefCounted<AutofillManager>;
82 virtual ~AutofillManager(); 84 virtual ~AutofillManager();
83 85
84 // The string/int pair is composed of the guid string and variant index 86 // The string/int pair is composed of the guid string and variant index
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } 125 ScopedVector<FormStructure>* form_structures() { return &form_structures_; }
124 126
125 // Exposed for testing. 127 // Exposed for testing.
126 AutofillExternalDelegate* external_delegate() { 128 AutofillExternalDelegate* external_delegate() {
127 return external_delegate_; 129 return external_delegate_;
128 } 130 }
129 131
130 // Processes the submitted |form|, saving any new Autofill data and uploading 132 // Processes the submitted |form|, saving any new Autofill data and uploading
131 // the possible field types for the submitted fields to the crowdsouring 133 // the possible field types for the submitted fields to the crowdsouring
132 // server. Returns false if this form is not relevant for Autofill. 134 // server. Returns false if this form is not relevant for Autofill.
133 bool OnFormSubmitted(const webkit_glue::FormData& form, 135 bool OnFormSubmitted(const webkit::forms::FormData& form,
134 const base::TimeTicks& timestamp); 136 const base::TimeTicks& timestamp);
135 137
136 private: 138 private:
137 // TabContentsObserver: 139 // TabContentsObserver:
138 virtual void DidNavigateMainFrame( 140 virtual void DidNavigateMainFrame(
139 const content::LoadCommittedDetails& details, 141 const content::LoadCommittedDetails& details,
140 const content::FrameNavigateParams& params) OVERRIDE; 142 const content::FrameNavigateParams& params) OVERRIDE;
141 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 143 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
142 144
143 // AutofillDownloadManager::Observer: 145 // AutofillDownloadManager::Observer:
144 virtual void OnLoadedServerPredictions( 146 virtual void OnLoadedServerPredictions(
145 const std::string& response_xml) OVERRIDE; 147 const std::string& response_xml) OVERRIDE;
146 148
147 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, 149 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms,
148 const base::TimeTicks& timestamp); 150 const base::TimeTicks& timestamp);
149 void OnTextFieldDidChange(const webkit_glue::FormData& form, 151 void OnTextFieldDidChange(const webkit::forms::FormData& form,
150 const webkit_glue::FormField& field, 152 const webkit::forms::FormField& field,
151 const base::TimeTicks& timestamp); 153 const base::TimeTicks& timestamp);
152 154
153 // The |bounding_box| is a window relative value. 155 // The |bounding_box| is a window relative value.
154 void OnQueryFormFieldAutofill(int query_id, 156 void OnQueryFormFieldAutofill(int query_id,
155 const webkit_glue::FormData& form, 157 const webkit::forms::FormData& form,
156 const webkit_glue::FormField& field, 158 const webkit::forms::FormField& field,
157 const gfx::Rect& bounding_box, 159 const gfx::Rect& bounding_box,
158 bool display_warning); 160 bool display_warning);
159 void OnShowAutofillDialog(); 161 void OnShowAutofillDialog();
160 void OnDidPreviewAutofillFormData(); 162 void OnDidPreviewAutofillFormData();
161 void OnDidEndTextFieldEditing(); 163 void OnDidEndTextFieldEditing();
162 void OnHideAutofillPopup(); 164 void OnHideAutofillPopup();
163 165
164 // Fills |host| with the RenderViewHost for this tab. 166 // Fills |host| with the RenderViewHost for this tab.
165 // Returns false if Autofill is disabled or if the host is unavailable. 167 // Returns false if Autofill is disabled or if the host is unavailable.
166 bool GetHost(const std::vector<AutofillProfile*>& profiles, 168 bool GetHost(const std::vector<AutofillProfile*>& profiles,
167 const std::vector<CreditCard*>& credit_cards, 169 const std::vector<CreditCard*>& credit_cards,
168 RenderViewHost** host) const WARN_UNUSED_RESULT; 170 RenderViewHost** host) const WARN_UNUSED_RESULT;
169 171
170 // Unpacks |unique_id| and fills |profile| or |credit_card| with the 172 // Unpacks |unique_id| and fills |profile| or |credit_card| with the
171 // appropriate data source. Returns false if the unpacked id cannot be found. 173 // appropriate data source. Returns false if the unpacked id cannot be found.
172 bool GetProfileOrCreditCard(int unique_id, 174 bool GetProfileOrCreditCard(int unique_id,
173 const std::vector<AutofillProfile*>& profiles, 175 const std::vector<AutofillProfile*>& profiles,
174 const std::vector<CreditCard*>& credit_cards, 176 const std::vector<CreditCard*>& credit_cards,
175 const AutofillProfile** profile, 177 const AutofillProfile** profile,
176 const CreditCard** credit_card, 178 const CreditCard** credit_card,
177 size_t* variant) const WARN_UNUSED_RESULT; 179 size_t* variant) const WARN_UNUSED_RESULT;
178 180
179 // Fills |form_structure| cached element corresponding to |form|. 181 // Fills |form_structure| cached element corresponding to |form|.
180 // Returns false if the cached element was not found. 182 // Returns false if the cached element was not found.
181 bool FindCachedForm(const webkit_glue::FormData& form, 183 bool FindCachedForm(const webkit::forms::FormData& form,
182 FormStructure** form_structure) const WARN_UNUSED_RESULT; 184 FormStructure** form_structure) const WARN_UNUSED_RESULT;
183 185
184 // Fills |form_structure| and |autofill_field| with the cached elements 186 // Fills |form_structure| and |autofill_field| with the cached elements
185 // corresponding to |form| and |field|. This might have the side-effect of 187 // corresponding to |form| and |field|. This might have the side-effect of
186 // updating the cache. Returns false if the |form| is not autofillable, or if 188 // updating the cache. Returns false if the |form| is not autofillable, or if
187 // it is not already present in the cache and the cache is full. 189 // it is not already present in the cache and the cache is full.
188 bool GetCachedFormAndField(const webkit_glue::FormData& form, 190 bool GetCachedFormAndField(const webkit::forms::FormData& form,
189 const webkit_glue::FormField& field, 191 const webkit::forms::FormField& field,
190 FormStructure** form_structure, 192 FormStructure** form_structure,
191 AutofillField** autofill_field) WARN_UNUSED_RESULT; 193 AutofillField** autofill_field) WARN_UNUSED_RESULT;
192 194
193 // Re-parses |live_form| and adds the result to |form_structures_|. 195 // Re-parses |live_form| and adds the result to |form_structures_|.
194 // |cached_form| should be a pointer to the existing version of the form, or 196 // |cached_form| should be a pointer to the existing version of the form, or
195 // NULL if no cached version exists. The updated form is then written into 197 // NULL if no cached version exists. The updated form is then written into
196 // |updated_form|. Returns false if the cache could not be updated. 198 // |updated_form|. Returns false if the cache could not be updated.
197 bool UpdateCachedForm(const webkit_glue::FormData& live_form, 199 bool UpdateCachedForm(const webkit::forms::FormData& live_form,
198 const FormStructure* cached_form, 200 const FormStructure* cached_form,
199 FormStructure** updated_form) WARN_UNUSED_RESULT; 201 FormStructure** updated_form) WARN_UNUSED_RESULT;
200 202
201 // Returns a list of values from the stored profiles that match |type| and the 203 // Returns a list of values from the stored profiles that match |type| and the
202 // value of |field| and returns the labels of the matching profiles. |labels| 204 // value of |field| and returns the labels of the matching profiles. |labels|
203 // is filled with the Profile label. 205 // is filled with the Profile label.
204 void GetProfileSuggestions(FormStructure* form, 206 void GetProfileSuggestions(FormStructure* form,
205 const webkit_glue::FormField& field, 207 const webkit::forms::FormField& field,
206 AutofillFieldType type, 208 AutofillFieldType type,
207 std::vector<string16>* values, 209 std::vector<string16>* values,
208 std::vector<string16>* labels, 210 std::vector<string16>* labels,
209 std::vector<string16>* icons, 211 std::vector<string16>* icons,
210 std::vector<int>* unique_ids) const; 212 std::vector<int>* unique_ids) const;
211 213
212 // Returns a list of values from the stored credit cards that match |type| and 214 // Returns a list of values from the stored credit cards that match |type| and
213 // the value of |field| and returns the labels of the matching credit cards. 215 // the value of |field| and returns the labels of the matching credit cards.
214 void GetCreditCardSuggestions(FormStructure* form, 216 void GetCreditCardSuggestions(FormStructure* form,
215 const webkit_glue::FormField& field, 217 const webkit::forms::FormField& field,
216 AutofillFieldType type, 218 AutofillFieldType type,
217 std::vector<string16>* values, 219 std::vector<string16>* values,
218 std::vector<string16>* labels, 220 std::vector<string16>* labels,
219 std::vector<string16>* icons, 221 std::vector<string16>* icons,
220 std::vector<int>* unique_ids) const; 222 std::vector<int>* unique_ids) const;
221 223
222 // Set |field|'s value based on |type| and contents of the |credit_card|. 224 // Set |field|'s value based on |type| and contents of the |credit_card|.
223 void FillCreditCardFormField(const CreditCard& credit_card, 225 void FillCreditCardFormField(const CreditCard& credit_card,
224 AutofillFieldType type, 226 AutofillFieldType type,
225 webkit_glue::FormField* field); 227 webkit::forms::FormField* field);
226 228
227 // Set |field|'s value based on |cached_field|'s type and contents of the 229 // Set |field|'s value based on |cached_field|'s type and contents of the
228 // |profile|. The |variant| parameter specifies which value in a multi-valued 230 // |profile|. The |variant| parameter specifies which value in a multi-valued
229 // profile. 231 // profile.
230 void FillFormField(const AutofillProfile& profile, 232 void FillFormField(const AutofillProfile& profile,
231 const AutofillField& cached_field, 233 const AutofillField& cached_field,
232 size_t variant, 234 size_t variant,
233 webkit_glue::FormField* field); 235 webkit::forms::FormField* field);
234 236
235 // Set |field|'s value for phone number based on contents of the |profile|. 237 // Set |field|'s value for phone number based on contents of the |profile|.
236 // The |cached_field| specifies the type of the phone and whether this is a 238 // The |cached_field| specifies the type of the phone and whether this is a
237 // phone prefix or suffix. The |variant| parameter specifies which value in a 239 // phone prefix or suffix. The |variant| parameter specifies which value in a
238 // multi-valued profile. 240 // multi-valued profile.
239 void FillPhoneNumberField(const AutofillProfile& profile, 241 void FillPhoneNumberField(const AutofillProfile& profile,
240 const AutofillField& cached_field, 242 const AutofillField& cached_field,
241 size_t variant, 243 size_t variant,
242 webkit_glue::FormField* field); 244 webkit::forms::FormField* field);
243 245
244 // Parses the forms using heuristic matching and querying the Autofill server. 246 // Parses the forms using heuristic matching and querying the Autofill server.
245 void ParseForms(const std::vector<webkit_glue::FormData>& forms); 247 void ParseForms(const std::vector<webkit::forms::FormData>& forms);
246 248
247 // Imports the form data, submitted by the user, into |personal_data_|. 249 // Imports the form data, submitted by the user, into |personal_data_|.
248 void ImportFormData(const FormStructure& submitted_form); 250 void ImportFormData(const FormStructure& submitted_form);
249 251
250 // If |initial_interaction_timestamp_| is unset or is set to a later time than 252 // If |initial_interaction_timestamp_| is unset or is set to a later time than
251 // |interaction_timestamp|, updates the cached timestamp. The latter check is 253 // |interaction_timestamp|, updates the cached timestamp. The latter check is
252 // needed because IPC messages can arrive out of order. 254 // needed because IPC messages can arrive out of order.
253 void UpdateInitialInteractionTimestamp( 255 void UpdateInitialInteractionTimestamp(
254 const base::TimeTicks& interaction_timestamp); 256 const base::TimeTicks& interaction_timestamp);
255 257
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 TestTabContentsWithExternalDelegate); 330 TestTabContentsWithExternalDelegate);
329 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, 331 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
330 UserHappinessFormLoadAndSubmission); 332 UserHappinessFormLoadAndSubmission);
331 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); 333 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
332 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); 334 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
333 335
334 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 336 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
335 }; 337 };
336 338
337 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 339 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_field.cc ('k') | chrome/browser/autofill/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698