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

Side by Side Diff: components/autofill/core/browser/autofill_manager.h

Issue 306053008: Rename AutofillManagerDelegate to AutofillClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more Android fix Created 6 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.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/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/strings/string16.h" 20 #include "base/strings/string16.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "components/autofill/core/browser/autocomplete_history_manager.h" 22 #include "components/autofill/core/browser/autocomplete_history_manager.h"
23 #include "components/autofill/core/browser/autofill_client.h"
23 #include "components/autofill/core/browser/autofill_download.h" 24 #include "components/autofill/core/browser/autofill_download.h"
24 #include "components/autofill/core/browser/autofill_driver.h" 25 #include "components/autofill/core/browser/autofill_driver.h"
25 #include "components/autofill/core/browser/autofill_manager_delegate.h"
26 #include "components/autofill/core/browser/form_structure.h" 26 #include "components/autofill/core/browser/form_structure.h"
27 #include "components/autofill/core/browser/personal_data_manager.h" 27 #include "components/autofill/core/browser/personal_data_manager.h"
28 #include "components/autofill/core/common/form_data.h" 28 #include "components/autofill/core/common/form_data.h"
29 29
30 class GURL; 30 class GURL;
31 31
32 namespace content { 32 namespace content {
33 class RenderViewHost; 33 class RenderViewHost;
34 class WebContents; 34 class WebContents;
35 } 35 }
36 36
37 namespace gfx { 37 namespace gfx {
38 class Rect; 38 class Rect;
39 class RectF; 39 class RectF;
40 } 40 }
41 41
42 namespace user_prefs { 42 namespace user_prefs {
43 class PrefRegistrySyncable; 43 class PrefRegistrySyncable;
44 } 44 }
45 45
46 namespace autofill { 46 namespace autofill {
47 47
48 class AutofillDataModel; 48 class AutofillDataModel;
49 class AutofillDownloadManager; 49 class AutofillDownloadManager;
50 class AutofillExternalDelegate; 50 class AutofillExternalDelegate;
51 class AutofillField; 51 class AutofillField;
52 class AutofillManagerDelegate; 52 class AutofillClient;
53 class AutofillManagerTestDelegate; 53 class AutofillManagerTestDelegate;
54 class AutofillMetrics; 54 class AutofillMetrics;
55 class AutofillProfile; 55 class AutofillProfile;
56 class AutofillType; 56 class AutofillType;
57 class CreditCard; 57 class CreditCard;
58 class FormStructureBrowserTest; 58 class FormStructureBrowserTest;
59 59
60 struct FormData; 60 struct FormData;
61 struct FormFieldData; 61 struct FormFieldData;
62 struct PasswordFormFillData; 62 struct PasswordFormFillData;
63 63
64 // Manages saving and restoring the user's personal information entered into web 64 // Manages saving and restoring the user's personal information entered into web
65 // forms. 65 // forms.
66 class AutofillManager : public AutofillDownloadManager::Observer { 66 class AutofillManager : public AutofillDownloadManager::Observer {
67 public: 67 public:
68 enum AutofillDownloadManagerState { 68 enum AutofillDownloadManagerState {
69 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, 69 ENABLE_AUTOFILL_DOWNLOAD_MANAGER,
70 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, 70 DISABLE_AUTOFILL_DOWNLOAD_MANAGER,
71 }; 71 };
72 72
73 // Registers our Enable/Disable Autofill pref. 73 // Registers our Enable/Disable Autofill pref.
74 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 74 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
75 75
76 AutofillManager(AutofillDriver* driver, 76 AutofillManager(AutofillDriver* driver,
77 autofill::AutofillManagerDelegate* delegate, 77 AutofillClient* client,
78 const std::string& app_locale, 78 const std::string& app_locale,
79 AutofillDownloadManagerState enable_download_manager); 79 AutofillDownloadManagerState enable_download_manager);
80 virtual ~AutofillManager(); 80 virtual ~AutofillManager();
81 81
82 // Sets an external delegate. 82 // Sets an external delegate.
83 void SetExternalDelegate(AutofillExternalDelegate* delegate); 83 void SetExternalDelegate(AutofillExternalDelegate* delegate);
84 84
85 void ShowAutofillSettings(); 85 void ShowAutofillSettings();
86 86
87 // Called from our external delegate so they cannot be private. 87 // Called from our external delegate so they cannot be private.
(...skipping 13 matching lines...) Expand all
101 // Remove the specified Autocomplete entry. 101 // Remove the specified Autocomplete entry.
102 void RemoveAutocompleteEntry(const base::string16& name, 102 void RemoveAutocompleteEntry(const base::string16& name,
103 const base::string16& value); 103 const base::string16& value);
104 104
105 // Returns the present form structures seen by Autofill manager. 105 // Returns the present form structures seen by Autofill manager.
106 const std::vector<FormStructure*>& GetFormStructures(); 106 const std::vector<FormStructure*>& GetFormStructures();
107 107
108 // Happens when the autocomplete dialog runs its callback when being closed. 108 // Happens when the autocomplete dialog runs its callback when being closed.
109 void RequestAutocompleteDialogClosed(); 109 void RequestAutocompleteDialogClosed();
110 110
111 autofill::AutofillManagerDelegate* delegate() const { 111 AutofillClient* client() const { return client_; }
112 return manager_delegate_;
113 }
114 112
115 const std::string& app_locale() const { return app_locale_; } 113 const std::string& app_locale() const { return app_locale_; }
116 114
117 // Only for testing. 115 // Only for testing.
118 void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); 116 void SetTestDelegate(AutofillManagerTestDelegate* delegate);
119 117
120 void OnFormsSeen(const std::vector<FormData>& forms, 118 void OnFormsSeen(const std::vector<FormData>& forms,
121 const base::TimeTicks& timestamp); 119 const base::TimeTicks& timestamp);
122 120
123 // Processes the submitted |form|, saving any new Autofill data and uploading 121 // Processes the submitted |form|, saving any new Autofill data and uploading
124 // the possible field types for the submitted fields to the crowdsourcing 122 // the possible field types for the submitted fields to the crowdsourcing
125 // server. Returns false if this form is not relevant for Autofill. 123 // server. Returns false if this form is not relevant for Autofill.
126 bool OnFormSubmitted(const FormData& form, 124 bool OnFormSubmitted(const FormData& form,
127 const base::TimeTicks& timestamp); 125 const base::TimeTicks& timestamp);
128 126
(...skipping 24 matching lines...) Expand all
153 151
154 // Resets cache. 152 // Resets cache.
155 virtual void Reset(); 153 virtual void Reset();
156 154
157 // Returns the value of the AutofillEnabled pref. 155 // Returns the value of the AutofillEnabled pref.
158 virtual bool IsAutofillEnabled() const; 156 virtual bool IsAutofillEnabled() const;
159 157
160 protected: 158 protected:
161 // Test code should prefer to use this constructor. 159 // Test code should prefer to use this constructor.
162 AutofillManager(AutofillDriver* driver, 160 AutofillManager(AutofillDriver* driver,
163 autofill::AutofillManagerDelegate* delegate, 161 AutofillClient* client,
164 PersonalDataManager* personal_data); 162 PersonalDataManager* personal_data);
165 163
166 // Uploads the form data to the Autofill server. 164 // Uploads the form data to the Autofill server.
167 virtual void UploadFormData(const FormStructure& submitted_form); 165 virtual void UploadFormData(const FormStructure& submitted_form);
168 166
169 // Logs quality metrics for the |submitted_form| and uploads the form data 167 // Logs quality metrics for the |submitted_form| and uploads the form data
170 // to the crowdsourcing server, if appropriate. 168 // to the crowdsourcing server, if appropriate.
171 virtual void UploadFormDataAsyncCallback( 169 virtual void UploadFormDataAsyncCallback(
172 const FormStructure* submitted_form, 170 const FormStructure* submitted_form,
173 const base::TimeTicks& load_time, 171 const base::TimeTicks& load_time,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 void UpdateInitialInteractionTimestamp( 267 void UpdateInitialInteractionTimestamp(
270 const base::TimeTicks& interaction_timestamp); 268 const base::TimeTicks& interaction_timestamp);
271 269
272 // Shared code to determine if |form| should be uploaded. 270 // Shared code to determine if |form| should be uploaded.
273 bool ShouldUploadForm(const FormStructure& form); 271 bool ShouldUploadForm(const FormStructure& form);
274 272
275 // Provides driver-level context to the shared code of the component. Must 273 // Provides driver-level context to the shared code of the component. Must
276 // outlive this object. 274 // outlive this object.
277 AutofillDriver* driver_; 275 AutofillDriver* driver_;
278 276
279 autofill::AutofillManagerDelegate* const manager_delegate_; 277 AutofillClient* const client_;
280 278
281 std::string app_locale_; 279 std::string app_locale_;
282 280
283 // The personal data manager, used to save and load personal data to/from the 281 // The personal data manager, used to save and load personal data to/from the
284 // web database. This is overridden by the AutofillManagerTest. 282 // web database. This is overridden by the AutofillManagerTest.
285 // Weak reference. 283 // Weak reference.
286 // May be NULL. NULL indicates OTR. 284 // May be NULL. NULL indicates OTR.
287 PersonalDataManager* personal_data_; 285 PersonalDataManager* personal_data_;
288 286
289 std::list<std::string> autofilled_form_signatures_; 287 std::list<std::string> autofilled_form_signatures_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 319
322 // GUID to ID mapping. We keep two maps to convert back and forth. 320 // GUID to ID mapping. We keep two maps to convert back and forth.
323 mutable std::map<PersonalDataManager::GUIDPair, int> guid_id_map_; 321 mutable std::map<PersonalDataManager::GUIDPair, int> guid_id_map_;
324 mutable std::map<int, PersonalDataManager::GUIDPair> id_guid_map_; 322 mutable std::map<int, PersonalDataManager::GUIDPair> id_guid_map_;
325 323
326 // Delegate to perform external processing (display, selection) on 324 // Delegate to perform external processing (display, selection) on
327 // our behalf. Weak. 325 // our behalf. Weak.
328 AutofillExternalDelegate* external_delegate_; 326 AutofillExternalDelegate* external_delegate_;
329 327
330 // Delegate used in test to get notifications on certain events. 328 // Delegate used in test to get notifications on certain events.
331 autofill::AutofillManagerTestDelegate* test_delegate_; 329 AutofillManagerTestDelegate* test_delegate_;
332 330
333 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_; 331 base::WeakPtrFactory<AutofillManager> weak_ptr_factory_;
334 332
335 friend class AutofillManagerTest; 333 friend class AutofillManagerTest;
336 friend class autofill::FormStructureBrowserTest; 334 friend class FormStructureBrowserTest;
337 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 335 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
338 DeterminePossibleFieldTypesForUpload); 336 DeterminePossibleFieldTypesForUpload);
339 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 337 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
340 DeterminePossibleFieldTypesForUploadStressTest); 338 DeterminePossibleFieldTypesForUploadStressTest);
341 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 339 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
342 DisabledAutofillDispatchesError); 340 DisabledAutofillDispatchesError);
343 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); 341 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount);
344 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); 342 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad);
345 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, DeveloperEngagement); 343 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, DeveloperEngagement);
346 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); 344 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
(...skipping 10 matching lines...) Expand all
357 UserHappinessFormLoadAndSubmission); 355 UserHappinessFormLoadAndSubmission);
358 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); 356 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
359 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 357 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
360 FormSubmittedAutocompleteEnabled); 358 FormSubmittedAutocompleteEnabled);
361 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 359 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
362 }; 360 };
363 361
364 } // namespace autofill 362 } // namespace autofill
365 363
366 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ 364 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698