OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_AUTOFILL_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "components/autofill/browser/autocheckout_manager.h" | 23 #include "components/autofill/browser/autocheckout_manager.h" |
24 #include "components/autofill/browser/autocomplete_history_manager.h" | 24 #include "components/autofill/browser/autocomplete_history_manager.h" |
25 #include "components/autofill/browser/autofill_download.h" | 25 #include "components/autofill/browser/autofill_download.h" |
26 #include "components/autofill/browser/autofill_manager_delegate.h" | 26 #include "components/autofill/browser/autofill_manager_delegate.h" |
27 #include "components/autofill/browser/field_types.h" | 27 #include "components/autofill/browser/field_types.h" |
28 #include "components/autofill/browser/form_structure.h" | 28 #include "components/autofill/browser/form_structure.h" |
29 #include "components/autofill/browser/personal_data_manager.h" | 29 #include "components/autofill/browser/personal_data_manager.h" |
30 #include "components/autofill/common/autocheckout_status.h" | 30 #include "components/autofill/common/autocheckout_status.h" |
31 #include "components/autofill/common/form_data.h" | 31 #include "components/autofill/common/form_data.h" |
32 #include "components/autofill/common/forms_seen_state.h" | 32 #include "components/autofill/common/forms_seen_state.h" |
33 #include "content/public/browser/web_contents_observer.h" | |
34 #include "content/public/common/ssl_status.h" | 33 #include "content/public/common/ssl_status.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
36 | 35 |
37 class GURL; | 36 class GURL; |
38 | 37 |
39 struct ViewHostMsg_FrameNavigate_Params; | |
40 | |
41 namespace content { | 38 namespace content { |
42 class RenderViewHost; | 39 class RenderViewHost; |
43 class WebContents; | 40 class WebContents; |
41 struct FrameNavigateParams; | |
42 struct LoadCommittedDetails; | |
44 } | 43 } |
45 | 44 |
46 namespace gfx { | 45 namespace gfx { |
47 class Rect; | 46 class Rect; |
48 class RectF; | 47 class RectF; |
49 } | 48 } |
50 | 49 |
51 namespace IPC { | 50 namespace IPC { |
52 class Message; | 51 class Message; |
53 } | 52 } |
54 | 53 |
55 namespace user_prefs { | 54 namespace user_prefs { |
56 class PrefRegistrySyncable; | 55 class PrefRegistrySyncable; |
57 } | 56 } |
58 | 57 |
59 namespace autofill { | 58 namespace autofill { |
60 | 59 |
60 class AutofillDriver; | |
61 class AutofillDataModel; | 61 class AutofillDataModel; |
62 class AutofillDownloadManager; | 62 class AutofillDownloadManager; |
63 class AutofillExternalDelegate; | 63 class AutofillExternalDelegate; |
64 class AutofillField; | 64 class AutofillField; |
65 class AutofillProfile; | 65 class AutofillProfile; |
66 class AutofillManagerDelegate; | 66 class AutofillManagerDelegate; |
67 class AutofillManagerTestDelegate; | 67 class AutofillManagerTestDelegate; |
68 class AutofillMetrics; | 68 class AutofillMetrics; |
69 class CreditCard; | 69 class CreditCard; |
70 class FormStructureBrowserTest; | 70 class FormStructureBrowserTest; |
71 | 71 |
72 struct FormData; | 72 struct FormData; |
73 struct FormFieldData; | 73 struct FormFieldData; |
74 struct PasswordFormFillData; | 74 struct PasswordFormFillData; |
75 | 75 |
76 // Manages saving and restoring the user's personal information entered into web | 76 // Manages saving and restoring the user's personal information entered into web |
77 // forms. | 77 // forms. |
78 class AutofillManager : public content::WebContentsObserver, | 78 class AutofillManager : public AutofillDownloadManager::Observer, |
79 public AutofillDownloadManager::Observer, | |
80 public base::SupportsUserData::Data { | 79 public base::SupportsUserData::Data { |
81 public: | 80 public: |
82 enum AutofillDownloadManagerState { | 81 enum AutofillDownloadManagerState { |
83 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, | 82 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, |
84 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, | 83 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
85 }; | 84 }; |
86 | 85 |
87 static void CreateForWebContentsAndDelegate( | 86 static void CreateForWebContentsAndDelegate( |
88 content::WebContents* contents, | 87 content::WebContents* contents, |
Ilya Sherman
2013/06/12 00:07:46
nit: Does the WebContents still need to be passed
blundell
2013/06/12 16:29:37
Eliminated this method as part of making the Autof
| |
88 AutofillDriver* driver, | |
89 autofill::AutofillManagerDelegate* delegate, | 89 autofill::AutofillManagerDelegate* delegate, |
90 const std::string& app_locale, | 90 const std::string& app_locale, |
91 AutofillDownloadManagerState enable_download_manager); | 91 AutofillDownloadManagerState enable_download_manager); |
92 static AutofillManager* FromWebContents(content::WebContents* contents); | 92 static AutofillManager* FromWebContents(content::WebContents* contents); |
93 | 93 |
94 // Registers our Enable/Disable Autofill pref. | 94 // Registers our Enable/Disable Autofill pref. |
95 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); | 95 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
96 | 96 |
97 // Set an external delegate. | 97 // Set an external delegate. |
98 void SetExternalDelegate(AutofillExternalDelegate* delegate); | 98 void SetExternalDelegate(AutofillExternalDelegate* delegate); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 | 137 |
138 autofill::AutofillManagerDelegate* delegate() const { | 138 autofill::AutofillManagerDelegate* delegate() const { |
139 return manager_delegate_; | 139 return manager_delegate_; |
140 } | 140 } |
141 | 141 |
142 const std::string& app_locale() const { return app_locale_; } | 142 const std::string& app_locale() const { return app_locale_; } |
143 | 143 |
144 // Only for testing. | 144 // Only for testing. |
145 void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); | 145 void SetTestDelegate(autofill::AutofillManagerTestDelegate* delegate); |
146 | 146 |
147 // TODO(blundell): Move the logic in these methods into AutofillDriver and | |
148 // eliminate these methods. | |
149 virtual void DidNavigateMainFrame( | |
150 const content::LoadCommittedDetails& details, | |
151 const content::FrameNavigateParams& params); | |
152 virtual bool OnMessageReceived(const IPC::Message& message); | |
153 | |
147 protected: | 154 protected: |
148 // Only test code should subclass AutofillManager. | 155 // Only test code should subclass AutofillManager. |
149 AutofillManager(content::WebContents* web_contents, | 156 AutofillManager(AutofillDriver* driver, |
150 autofill::AutofillManagerDelegate* delegate, | 157 autofill::AutofillManagerDelegate* delegate, |
151 const std::string& app_locale, | 158 const std::string& app_locale, |
152 AutofillDownloadManagerState enable_download_manager); | 159 AutofillDownloadManagerState enable_download_manager); |
153 virtual ~AutofillManager(); | 160 virtual ~AutofillManager(); |
154 | 161 |
155 // Test code should prefer to use this constructor. | 162 // Test code should prefer to use this constructor. |
156 AutofillManager(content::WebContents* web_contents, | 163 AutofillManager(AutofillDriver* driver, |
157 autofill::AutofillManagerDelegate* delegate, | 164 autofill::AutofillManagerDelegate* delegate, |
158 PersonalDataManager* personal_data); | 165 PersonalDataManager* personal_data); |
159 | 166 |
160 // Returns the value of the AutofillEnabled pref. | 167 // Returns the value of the AutofillEnabled pref. |
161 virtual bool IsAutofillEnabled() const; | 168 virtual bool IsAutofillEnabled() const; |
162 | 169 |
163 // Uploads the form data to the Autofill server. | 170 // Uploads the form data to the Autofill server. |
164 virtual void UploadFormData(const FormStructure& submitted_form); | 171 virtual void UploadFormData(const FormStructure& submitted_form); |
165 | 172 |
166 // Reset cache. | 173 // Reset cache. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 // server. Returns false if this form is not relevant for Autofill. | 221 // server. Returns false if this form is not relevant for Autofill. |
215 bool OnFormSubmitted(const FormData& form, | 222 bool OnFormSubmitted(const FormData& form, |
216 const base::TimeTicks& timestamp); | 223 const base::TimeTicks& timestamp); |
217 | 224 |
218 // Tell the renderer the current interactive autocomplete finished. | 225 // Tell the renderer the current interactive autocomplete finished. |
219 virtual void ReturnAutocompleteResult( | 226 virtual void ReturnAutocompleteResult( |
220 WebKit::WebFormElement::AutocompleteResult result, | 227 WebKit::WebFormElement::AutocompleteResult result, |
221 const FormData& form_data); | 228 const FormData& form_data); |
222 | 229 |
223 private: | 230 private: |
224 // content::WebContentsObserver: | |
225 virtual void DidNavigateMainFrame( | |
226 const content::LoadCommittedDetails& details, | |
227 const content::FrameNavigateParams& params) OVERRIDE; | |
228 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
229 | 231 |
230 // AutofillDownloadManager::Observer: | 232 // AutofillDownloadManager::Observer: |
231 virtual void OnLoadedServerPredictions( | 233 virtual void OnLoadedServerPredictions( |
232 const std::string& response_xml) OVERRIDE; | 234 const std::string& response_xml) OVERRIDE; |
233 | 235 |
234 void OnFormsSeen(const std::vector<FormData>& forms, | 236 void OnFormsSeen(const std::vector<FormData>& forms, |
235 const base::TimeTicks& timestamp, | 237 const base::TimeTicks& timestamp, |
236 autofill::FormsSeenState state); | 238 autofill::FormsSeenState state); |
237 void OnTextFieldDidChange(const FormData& form, | 239 void OnTextFieldDidChange(const FormData& form, |
238 const FormFieldData& field, | 240 const FormFieldData& field, |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 // |interaction_timestamp|, updates the cached timestamp. The latter check is | 338 // |interaction_timestamp|, updates the cached timestamp. The latter check is |
337 // needed because IPC messages can arrive out of order. | 339 // needed because IPC messages can arrive out of order. |
338 void UpdateInitialInteractionTimestamp( | 340 void UpdateInitialInteractionTimestamp( |
339 const base::TimeTicks& interaction_timestamp); | 341 const base::TimeTicks& interaction_timestamp); |
340 | 342 |
341 // Send our current field type predictions to the renderer. This is a no-op if | 343 // Send our current field type predictions to the renderer. This is a no-op if |
342 // the appropriate command-line flag is not set. | 344 // the appropriate command-line flag is not set. |
343 void SendAutofillTypePredictions( | 345 void SendAutofillTypePredictions( |
344 const std::vector<FormStructure*>& forms) const; | 346 const std::vector<FormStructure*>& forms) const; |
345 | 347 |
348 AutofillDriver* driver_; | |
Ilya Sherman
2013/06/12 00:07:46
nit: Please document this variable, including its
blundell
2013/06/12 16:29:37
Done. Additionally, your comment made me realize t
| |
349 | |
346 autofill::AutofillManagerDelegate* const manager_delegate_; | 350 autofill::AutofillManagerDelegate* const manager_delegate_; |
347 | 351 |
348 std::string app_locale_; | 352 std::string app_locale_; |
349 | 353 |
350 // The personal data manager, used to save and load personal data to/from the | 354 // The personal data manager, used to save and load personal data to/from the |
351 // web database. This is overridden by the AutofillManagerTest. | 355 // web database. This is overridden by the AutofillManagerTest. |
352 // Weak reference. | 356 // Weak reference. |
353 // May be NULL. NULL indicates OTR. | 357 // May be NULL. NULL indicates OTR. |
354 PersonalDataManager* personal_data_; | 358 PersonalDataManager* personal_data_; |
355 | 359 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
426 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 430 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
427 UserHappinessFormLoadAndSubmission); | 431 UserHappinessFormLoadAndSubmission); |
428 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 432 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
429 | 433 |
430 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 434 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
431 }; | 435 }; |
432 | 436 |
433 } // namespace autofill | 437 } // namespace autofill |
434 | 438 |
435 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ | 439 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_H_ |
OLD | NEW |