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

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

Issue 8353025: External autofill delegates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback Created 9 years, 1 month 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) 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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/string16.h" 19 #include "base/string16.h"
20 #include "base/time.h" 20 #include "base/time.h"
21 #include "chrome/browser/autofill/autofill_download.h" 21 #include "chrome/browser/autofill/autofill_download.h"
22 #include "chrome/browser/autofill/field_types.h" 22 #include "chrome/browser/autofill/field_types.h"
23 #include "chrome/browser/autofill/form_structure.h" 23 #include "chrome/browser/autofill/form_structure.h"
24 #include "content/browser/tab_contents/tab_contents_observer.h" 24 #include "content/browser/tab_contents/tab_contents_observer.h"
25 25
26 class AutofillExternalDelegate;
26 class AutofillField; 27 class AutofillField;
27 class AutofillProfile; 28 class AutofillProfile;
28 class AutofillMetrics; 29 class AutofillMetrics;
29 class CreditCard; 30 class CreditCard;
30 class PersonalDataManager; 31 class PersonalDataManager;
31 class PrefService; 32 class PrefService;
32 class RenderViewHost; 33 class RenderViewHost;
33 class TabContentsWrapper; 34 class TabContentsWrapper;
34 35
35 struct ViewHostMsg_FrameNavigate_Params; 36 struct ViewHostMsg_FrameNavigate_Params;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 // Imports the form data, submitted by the user, into |personal_data_|. 75 // Imports the form data, submitted by the user, into |personal_data_|.
75 void ImportFormData(const FormStructure& submitted_form); 76 void ImportFormData(const FormStructure& submitted_form);
76 77
77 // Uploads the form data to the Autofill server. 78 // Uploads the form data to the Autofill server.
78 virtual void UploadFormData(const FormStructure& submitted_form); 79 virtual void UploadFormData(const FormStructure& submitted_form);
79 80
80 // Reset cache. 81 // Reset cache.
81 void Reset(); 82 void Reset();
82 83
84 // Set our external delegate.
85 void SetExternalDelegate(AutofillExternalDelegate* delegate) {
86 external_delegate_ = delegate;
87 }
Ilya Sherman 2011/10/27 11:01:55 nit: Can this be passed into the constructor rathe
John Grabowski 2011/10/27 17:42:21 One platform's likely implementation of the extern
Ilya Sherman 2011/10/27 21:17:24 Sure, let's add a TODO just to keep this in the ba
88
83 protected: 89 protected:
84 // For tests: 90 // For tests:
85 91
86 // The string/int pair is composed of the guid string and variant index 92 // The string/int pair is composed of the guid string and variant index
87 // respectively. The variant index is an index into the multi-valued item 93 // respectively. The variant index is an index into the multi-valued item
88 // (where applicable). 94 // (where applicable).
89 typedef std::pair<std::string, size_t> GUIDPair; 95 typedef std::pair<std::string, size_t> GUIDPair;
90 96
91 AutofillManager(TabContentsWrapper* tab_contents, 97 AutofillManager(TabContentsWrapper* tab_contents,
92 PersonalDataManager* personal_data); 98 PersonalDataManager* personal_data);
(...skipping 10 matching lines...) Expand all
103 // Maps GUIDs to and from IDs that are used to identify profiles and credit 109 // Maps GUIDs to and from IDs that are used to identify profiles and credit
104 // cards sent to and from the renderer process. 110 // cards sent to and from the renderer process.
105 virtual int GUIDToID(const GUIDPair& guid) const; 111 virtual int GUIDToID(const GUIDPair& guid) const;
106 virtual const GUIDPair IDToGUID(int id) const; 112 virtual const GUIDPair IDToGUID(int id) const;
107 113
108 // Methods for packing and unpacking credit card and profile IDs for sending 114 // Methods for packing and unpacking credit card and profile IDs for sending
109 // and receiving to and from the renderer process. 115 // and receiving to and from the renderer process.
110 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; 116 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const;
111 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; 117 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const;
112 118
119 // Called from our external delegate so it cannot be private.
120 void OnFillAutoFillFormData(int query_id,
121 const webkit_glue::FormData& form,
122 const webkit_glue::FormField& field,
123 int unique_id);
124
125 // Exposed for testing.
126 AutofillExternalDelegate* external_delegate() {
127 return external_delegate_;
128 }
129
113 private: 130 private:
114 void OnFormSubmitted(const webkit_glue::FormData& form, 131 void OnFormSubmitted(const webkit_glue::FormData& form,
115 const base::TimeTicks& timestamp); 132 const base::TimeTicks& timestamp);
116 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, 133 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms,
117 const base::TimeTicks& timestamp); 134 const base::TimeTicks& timestamp);
118 void OnTextFieldDidChange(const webkit_glue::FormData& form, 135 void OnTextFieldDidChange(const webkit_glue::FormData& form,
119 const webkit_glue::FormField& field, 136 const webkit_glue::FormField& field,
120 const base::TimeTicks& timestamp); 137 const base::TimeTicks& timestamp);
121 void OnQueryFormFieldAutofill(int query_id, 138 void OnQueryFormFieldAutofill(int query_id,
122 const webkit_glue::FormData& form, 139 const webkit_glue::FormData& form,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // page. 285 // page.
269 base::TimeTicks initial_interaction_timestamp_; 286 base::TimeTicks initial_interaction_timestamp_;
270 287
271 // Our copy of the form data. 288 // Our copy of the form data.
272 ScopedVector<FormStructure> form_structures_; 289 ScopedVector<FormStructure> form_structures_;
273 290
274 // GUID to ID mapping. We keep two maps to convert back and forth. 291 // GUID to ID mapping. We keep two maps to convert back and forth.
275 mutable std::map<GUIDPair, int> guid_id_map_; 292 mutable std::map<GUIDPair, int> guid_id_map_;
276 mutable std::map<int, GUIDPair> id_guid_map_; 293 mutable std::map<int, GUIDPair> id_guid_map_;
277 294
295 // Delegate to perform external processing (display, selection) on
296 // our behalf. Weak.
297 AutofillExternalDelegate* external_delegate_;
298
278 friend class AutofillManagerTest; 299 friend class AutofillManagerTest;
279 friend class FormStructureBrowserTest; 300 friend class FormStructureBrowserTest;
280 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 301 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
281 DeterminePossibleFieldTypesForUpload); 302 DeterminePossibleFieldTypesForUpload);
282 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 303 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
283 DeterminePossibleFieldTypesForUploadStressTest); 304 DeterminePossibleFieldTypesForUploadStressTest);
284 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); 305 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount);
285 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); 306 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad);
286 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, 307 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
287 NoQualityMetricsForNonAutofillableForms); 308 NoQualityMetricsForNonAutofillableForms);
288 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics); 309 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics);
289 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); 310 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure);
290 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); 311 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId);
291 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); 312 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch);
313 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestExternalDelegate);
314 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
315 TestTabContentsWithExternalDelegate);
292 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, 316 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
293 UserHappinessFormLoadAndSubmission); 317 UserHappinessFormLoadAndSubmission);
294 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); 318 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
295 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); 319 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
296 320
297 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 321 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
298 }; 322 };
299 323
300 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 324 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698