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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 115 |
113 // Returns the value of the AutofillEnabled pref. | 116 // Returns the value of the AutofillEnabled pref. |
114 virtual bool IsAutofillEnabled() const; | 117 virtual bool IsAutofillEnabled() const; |
115 | 118 |
116 // Uploads the form data to the Autofill server. | 119 // Uploads the form data to the Autofill server. |
117 virtual void UploadFormData(const FormStructure& submitted_form); | 120 virtual void UploadFormData(const FormStructure& submitted_form); |
118 | 121 |
119 // Reset cache. | 122 // Reset cache. |
120 void Reset(); | 123 void Reset(); |
121 | 124 |
122 // Informs the renderer of the current password generation state. This is a | 125 // Informs the renderers of the current password generation state. |
123 // separate function to aid with testing. | 126 // This is a separate function to aid with testing. |
Garrett Casto
2012/05/11 23:01:28
I'm assuming that this is changed because of a syn
zysxqn
2012/05/11 23:52:51
Yes, I don't think I have intended to change this.
Garrett Casto
2012/05/14 20:24:11
It actually only informs one renderer, so changing
zysxqn
2012/05/14 20:47:34
Done.
| |
124 virtual void SendPasswordGenerationStateToRenderer( | 127 virtual void SendPasswordGenerationStateToRenderer( |
125 content::RenderViewHost* host, | 128 content::RenderViewHost* host, |
126 bool enabled); | 129 bool enabled); |
127 | 130 |
128 // Logs quality metrics for the |submitted_form| and uploads the form data | 131 // Logs quality metrics for the |submitted_form| and uploads the form data |
129 // to the crowdsourcing server, if appropriate. | 132 // to the crowdsourcing server, if appropriate. |
130 virtual void UploadFormDataAsyncCallback( | 133 virtual void UploadFormDataAsyncCallback( |
131 const FormStructure* submitted_form, | 134 const FormStructure* submitted_form, |
132 const base::TimeTicks& load_time, | 135 const base::TimeTicks& load_time, |
133 const base::TimeTicks& interaction_time, | 136 const base::TimeTicks& interaction_time, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // AutofillDownloadManager::Observer: | 173 // AutofillDownloadManager::Observer: |
171 virtual void OnLoadedServerPredictions( | 174 virtual void OnLoadedServerPredictions( |
172 const std::string& response_xml) OVERRIDE; | 175 const std::string& response_xml) OVERRIDE; |
173 | 176 |
174 // ProfileSyncServiceObserver: | 177 // ProfileSyncServiceObserver: |
175 virtual void OnStateChanged() OVERRIDE; | 178 virtual void OnStateChanged() OVERRIDE; |
176 | 179 |
177 // Register as an observer with the sync service. | 180 // Register as an observer with the sync service. |
178 void RegisterWithSyncService(); | 181 void RegisterWithSyncService(); |
179 | 182 |
183 // content::NotificationObserver override | |
184 virtual void Observe(int type, | |
185 const content::NotificationSource& source, | |
186 const content::NotificationDetails& details) OVERRIDE; | |
187 | |
180 // Determines what the current state of password generation is, and if it has | 188 // Determines what the current state of password generation is, and if it has |
181 // changed from |password_generation_enabled_|. If it has changed or if | 189 // changed from password_generation_enabled_. If it has changed or if |
Garrett Casto
2012/05/11 23:01:28
Same as above?
zysxqn
2012/05/11 23:52:51
Yes, again I don't think I have intended to change
| |
182 // |new_renderer| is true, it notifies the renderer of this change via | 190 // |new_renderer| is true, it notifies the renderer of this change via |
183 // SendPasswordGenerationStateToRenderer. | 191 // SendPasswordGenerationStateToRenderer. |
184 void UpdatePasswordGenerationState(content::RenderViewHost* host, | 192 void UpdatePasswordGenerationState(content::RenderViewHost* host, |
185 bool new_renderer); | 193 bool new_renderer); |
186 | 194 |
187 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, | 195 void OnFormsSeen(const std::vector<webkit::forms::FormData>& forms, |
188 const base::TimeTicks& timestamp); | 196 const base::TimeTicks& timestamp); |
189 void OnTextFieldDidChange(const webkit::forms::FormData& form, | 197 void OnTextFieldDidChange(const webkit::forms::FormData& form, |
190 const webkit::forms::FormField& field, | 198 const webkit::forms::FormField& field, |
191 const base::TimeTicks& timestamp); | 199 const base::TimeTicks& timestamp); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 // When the user first interacted with a potentially fillable form on this | 349 // When the user first interacted with a potentially fillable form on this |
342 // page. | 350 // page. |
343 base::TimeTicks initial_interaction_timestamp_; | 351 base::TimeTicks initial_interaction_timestamp_; |
344 // If password generation is enabled. We cache this value so that we don't | 352 // If password generation is enabled. We cache this value so that we don't |
345 // spam the renderer with messages during startup when the sync state | 353 // spam the renderer with messages during startup when the sync state |
346 // is changing rapidly. | 354 // is changing rapidly. |
347 bool password_generation_enabled_; | 355 bool password_generation_enabled_; |
348 // The ProfileSyncService associated with this tab. This may be NULL in | 356 // The ProfileSyncService associated with this tab. This may be NULL in |
349 // testing. | 357 // testing. |
350 base::WeakPtr<ProfileSyncService> sync_service_; | 358 base::WeakPtr<ProfileSyncService> sync_service_; |
359 // Listens for changes to the 'enabled' state for password generation. | |
360 PrefChangeRegistrar registrar_; | |
351 | 361 |
352 // Our copy of the form data. | 362 // Our copy of the form data. |
353 ScopedVector<FormStructure> form_structures_; | 363 ScopedVector<FormStructure> form_structures_; |
354 | 364 |
355 // GUID to ID mapping. We keep two maps to convert back and forth. | 365 // GUID to ID mapping. We keep two maps to convert back and forth. |
356 mutable std::map<GUIDPair, int> guid_id_map_; | 366 mutable std::map<GUIDPair, int> guid_id_map_; |
357 mutable std::map<int, GUIDPair> id_guid_map_; | 367 mutable std::map<int, GUIDPair> id_guid_map_; |
358 | 368 |
359 // Delegate to perform external processing (display, selection) on | 369 // Delegate to perform external processing (display, selection) on |
360 // our behalf. Weak. | 370 // our behalf. Weak. |
(...skipping 18 matching lines...) Expand all Loading... | |
379 TestTabContentsWithExternalDelegate); | 389 TestTabContentsWithExternalDelegate); |
380 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 390 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
381 UserHappinessFormLoadAndSubmission); | 391 UserHappinessFormLoadAndSubmission); |
382 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 392 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
383 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 393 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
384 | 394 |
385 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 395 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
386 }; | 396 }; |
387 | 397 |
388 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 398 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
OLD | NEW |