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 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/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
21 #include "base/string16.h" | 21 #include "base/string16.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "chrome/browser/autofill/autofill_download.h" | 23 #include "chrome/browser/autofill/autofill_download.h" |
24 #include "chrome/browser/autofill/field_types.h" | 24 #include "chrome/browser/autofill/field_types.h" |
25 #include "chrome/browser/autofill/form_structure.h" | 25 #include "chrome/browser/autofill/form_structure.h" |
26 #include "chrome/browser/prefs/pref_change_registrar.h" | |
26 #include "chrome/browser/sync/profile_sync_service_observer.h" | 27 #include "chrome/browser/sync/profile_sync_service_observer.h" |
28 #include "content/public/browser/notification_observer.h" | |
27 #include "content/public/browser/web_contents_observer.h" | 29 #include "content/public/browser/web_contents_observer.h" |
28 | 30 |
29 class AutofillExternalDelegate; | 31 class AutofillExternalDelegate; |
30 class AutofillField; | 32 class AutofillField; |
31 class AutofillProfile; | 33 class AutofillProfile; |
32 class AutofillMetrics; | 34 class AutofillMetrics; |
33 class CreditCard; | 35 class CreditCard; |
34 class PersonalDataManager; | 36 class PersonalDataManager; |
35 class PrefService; | 37 class PrefService; |
36 class ProfileSyncService; | 38 class ProfileSyncService; |
(...skipping 16 matching lines...) Expand all Loading... | |
53 namespace webkit { | 55 namespace webkit { |
54 namespace forms { | 56 namespace forms { |
55 struct FormData; | 57 struct FormData; |
56 struct FormField; | 58 struct FormField; |
57 struct PasswordFormFillData; | 59 struct PasswordFormFillData; |
58 } | 60 } |
59 } | 61 } |
60 | 62 |
61 // Manages saving and restoring the user's personal information entered into web | 63 // Manages saving and restoring the user's personal information entered into web |
62 // forms. | 64 // forms. |
63 class AutofillManager : public content::WebContentsObserver, | 65 class AutofillManager : public content::NotificationObserver, |
66 public content::WebContentsObserver, | |
64 public AutofillDownloadManager::Observer, | 67 public AutofillDownloadManager::Observer, |
65 public ProfileSyncServiceObserver, | 68 public ProfileSyncServiceObserver, |
66 public base::RefCounted<AutofillManager> { | 69 public base::RefCounted<AutofillManager> { |
67 public: | 70 public: |
68 explicit AutofillManager(TabContentsWrapper* tab_contents); | 71 explicit AutofillManager(TabContentsWrapper* tab_contents); |
69 | 72 |
70 // Registers our Enable/Disable Autofill pref. | 73 // Registers our Enable/Disable Autofill pref. |
71 static void RegisterUserPrefs(PrefService* prefs); | 74 static void RegisterUserPrefs(PrefService* prefs); |
72 | 75 |
73 // Set our external delegate. | 76 // Set our external delegate. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 111 |
109 // Returns the value of the AutofillEnabled pref. | 112 // Returns the value of the AutofillEnabled pref. |
110 virtual bool IsAutofillEnabled() const; | 113 virtual bool IsAutofillEnabled() const; |
111 | 114 |
112 // Uploads the form data to the Autofill server. | 115 // Uploads the form data to the Autofill server. |
113 virtual void UploadFormData(const FormStructure& submitted_form); | 116 virtual void UploadFormData(const FormStructure& submitted_form); |
114 | 117 |
115 // Reset cache. | 118 // Reset cache. |
116 void Reset(); | 119 void Reset(); |
117 | 120 |
118 // Informs the renderer of the current password generation state. This is a | 121 // Informs the renderers of the current password generation state for use |
119 // separate function to aid with testing. | 122 // in password generation. This is a separate function to aid with testing. |
Ilya Sherman
2012/05/01 22:27:48
nit: Please remove "for use in password generation
zysxqn
2012/05/03 00:57:24
Done.
| |
120 virtual void SendPasswordGenerationStateToRenderer( | 123 virtual void SendPasswordGenerationStateToRenderer( |
121 content::RenderViewHost* host, | 124 content::RenderViewHost* host, |
122 bool enabled); | 125 bool enabled); |
123 | 126 |
127 | |
Ilya Sherman
2012/05/01 22:27:48
nit: Please remove this extra blank line.
zysxqn
2012/05/03 00:57:24
Done.
| |
124 // Logs quality metrics for the |submitted_form| and uploads the form data | 128 // Logs quality metrics for the |submitted_form| and uploads the form data |
125 // to the crowdsourcing server, if appropriate. | 129 // to the crowdsourcing server, if appropriate. |
126 virtual void UploadFormDataAsyncCallback( | 130 virtual void UploadFormDataAsyncCallback( |
127 const FormStructure* submitted_form, | 131 const FormStructure* submitted_form, |
128 const base::TimeTicks& load_time, | 132 const base::TimeTicks& load_time, |
129 const base::TimeTicks& interaction_time, | 133 const base::TimeTicks& interaction_time, |
130 const base::TimeTicks& submission_time); | 134 const base::TimeTicks& submission_time); |
131 | 135 |
132 // Maps GUIDs to and from IDs that are used to identify profiles and credit | 136 // Maps GUIDs to and from IDs that are used to identify profiles and credit |
133 // cards sent to and from the renderer process. | 137 // cards sent to and from the renderer process. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 // AutofillDownloadManager::Observer: | 170 // AutofillDownloadManager::Observer: |
167 virtual void OnLoadedServerPredictions( | 171 virtual void OnLoadedServerPredictions( |
168 const std::string& response_xml) OVERRIDE; | 172 const std::string& response_xml) OVERRIDE; |
169 | 173 |
170 // ProfileSyncServiceObserver: | 174 // ProfileSyncServiceObserver: |
171 virtual void OnStateChanged() OVERRIDE; | 175 virtual void OnStateChanged() OVERRIDE; |
172 | 176 |
173 // Register as an observer with the sync service. | 177 // Register as an observer with the sync service. |
174 void RegisterWithSyncService(); | 178 void RegisterWithSyncService(); |
175 | 179 |
176 // Determines what the current state of password generation is, and if it has | 180 // content::NotificationObserver override |
177 // changed from |password_generation_enabled_|. If it has changed or if | 181 virtual void Observe(int type, |
182 const content::NotificationSource& source, | |
183 const content::NotificationDetails& details) OVERRIDE; | |
184 | |
185 // Determines that the current state of password generation is, and if it | |
Ilya Sherman
2012/05/01 22:27:48
nit: "that" -> "what"
zysxqn
2012/05/03 00:57:24
Done.
| |
186 // has changed from password_generation_enabled_. If it has changed or if | |
178 // |new_renderer| is true, it notifies the renderer of this change via | 187 // |new_renderer| is true, it notifies the renderer of this change via |
179 // SendPasswordGenerationStateToRenderer. | 188 // SendPasswordGenerationStateToRenderer. |
180 void UpdatePasswordGenerationState(content::RenderViewHost* host, | 189 void UpdatePasswordGenerationState(content::RenderViewHost* host, |
181 bool new_renderer); | 190 bool new_renderer); |
182 | 191 |
183 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, | 192 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, |
184 const base::TimeTicks& timestamp); | 193 const base::TimeTicks& timestamp); |
185 void OnTextFieldDidChange(const webkit::forms::FormData& form, | 194 void OnTextFieldDidChange(const webkit::forms::FormData& form, |
186 const webkit::forms::FormField& field, | 195 const webkit::forms::FormField& field, |
187 const base::TimeTicks& timestamp); | 196 const base::TimeTicks& timestamp); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 bool user_did_type_; | 339 bool user_did_type_; |
331 // Has the user autofilled a form on this page? | 340 // Has the user autofilled a form on this page? |
332 bool user_did_autofill_; | 341 bool user_did_autofill_; |
333 // Has the user edited a field that was previously autofilled? | 342 // Has the user edited a field that was previously autofilled? |
334 bool user_did_edit_autofilled_field_; | 343 bool user_did_edit_autofilled_field_; |
335 // When the page finished loading. | 344 // When the page finished loading. |
336 base::TimeTicks forms_loaded_timestamp_; | 345 base::TimeTicks forms_loaded_timestamp_; |
337 // When the user first interacted with a potentially fillable form on this | 346 // When the user first interacted with a potentially fillable form on this |
338 // page. | 347 // page. |
339 base::TimeTicks initial_interaction_timestamp_; | 348 base::TimeTicks initial_interaction_timestamp_; |
340 // If password generation is enabled. We cache this value so that we don't | |
341 // spam the renderer with messages during startup when the sync state | |
342 // is changing rapidly. | |
343 bool password_generation_enabled_; | |
344 // The ProfileSyncService associated with this tab. This may be NULL in | 349 // The ProfileSyncService associated with this tab. This may be NULL in |
345 // testing. | 350 // testing. |
346 base::WeakPtr<ProfileSyncService> sync_service_; | 351 base::WeakPtr<ProfileSyncService> sync_service_; |
352 // If password generation should be enabled. We cache this value so that we | |
Ilya Sherman
2012/05/01 22:27:48
nit: "should be" -> "is"
zysxqn
2012/05/03 00:57:24
Done.
| |
353 // don't spam the renderer with messages during startup when the underlying | |
354 // states are changing rapidly. | |
355 bool password_generation_enabled_; | |
Ilya Sherman
2012/05/01 22:27:48
nit: Should this perhaps be a BooleanPrefMember in
zysxqn
2012/05/03 00:57:24
Since it is actually affected by three things: pre
Ilya Sherman
2012/05/04 06:04:50
Ok, that makes sense -- I hadn't noticed when I wr
| |
356 // Handle preference change event. | |
Ilya Sherman
2012/05/01 22:27:48
nit: This comment is currently redundant with the
zysxqn
2012/05/03 00:57:24
Done.
| |
357 PrefChangeRegistrar registrar_; | |
347 | 358 |
348 // Our copy of the form data. | 359 // Our copy of the form data. |
349 ScopedVector<FormStructure> form_structures_; | 360 ScopedVector<FormStructure> form_structures_; |
350 | 361 |
351 // GUID to ID mapping. We keep two maps to convert back and forth. | 362 // GUID to ID mapping. We keep two maps to convert back and forth. |
352 mutable std::map<GUIDPair, int> guid_id_map_; | 363 mutable std::map<GUIDPair, int> guid_id_map_; |
353 mutable std::map<int, GUIDPair> id_guid_map_; | 364 mutable std::map<int, GUIDPair> id_guid_map_; |
354 | 365 |
355 // Delegate to perform external processing (display, selection) on | 366 // Delegate to perform external processing (display, selection) on |
356 // our behalf. Weak. | 367 // our behalf. Weak. |
(...skipping 18 matching lines...) Expand all Loading... | |
375 TestTabContentsWithExternalDelegate); | 386 TestTabContentsWithExternalDelegate); |
376 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 387 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
377 UserHappinessFormLoadAndSubmission); | 388 UserHappinessFormLoadAndSubmission); |
378 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 389 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
379 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 390 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
380 | 391 |
381 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 392 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
382 }; | 393 }; |
383 | 394 |
384 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 395 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
OLD | NEW |