| 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 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class AutofillMetrics; | 34 class AutofillMetrics; |
| 35 class CreditCard; | 35 class CreditCard; |
| 36 class PersonalDataManager; | 36 class PersonalDataManager; |
| 37 class PrefService; | 37 class PrefService; |
| 38 class ProfileSyncService; | 38 class ProfileSyncService; |
| 39 class TabContents; | 39 class TabContents; |
| 40 | 40 |
| 41 struct ViewHostMsg_FrameNavigate_Params; | 41 struct ViewHostMsg_FrameNavigate_Params; |
| 42 | 42 |
| 43 namespace autofill { | 43 namespace autofill { |
| 44 class AutofillManagerDelegate; |
| 44 class PasswordGenerator; | 45 class PasswordGenerator; |
| 45 } | 46 } |
| 46 | 47 |
| 47 namespace content { | 48 namespace content { |
| 48 class RenderViewHost; | 49 class RenderViewHost; |
| 49 } | 50 } |
| 50 | 51 |
| 51 namespace gfx { | 52 namespace gfx { |
| 52 class Rect; | 53 class Rect; |
| 53 } | 54 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Manages saving and restoring the user's personal information entered into web | 69 // Manages saving and restoring the user's personal information entered into web |
| 69 // forms. | 70 // forms. |
| 70 class AutofillManager : public content::NotificationObserver, | 71 class AutofillManager : public content::NotificationObserver, |
| 71 public content::WebContentsObserver, | 72 public content::WebContentsObserver, |
| 72 public AutofillDownloadManager::Observer, | 73 public AutofillDownloadManager::Observer, |
| 73 public ProfileSyncServiceObserver, | 74 public ProfileSyncServiceObserver, |
| 74 public base::RefCounted<AutofillManager> { | 75 public base::RefCounted<AutofillManager> { |
| 75 public: | 76 public: |
| 76 explicit AutofillManager(TabContents* tab_contents); | 77 // Lifetime of |client| and |tab_contents| must exceed lifetime of |
| 78 // AutofillManager. |
| 79 explicit AutofillManager(autofill::AutofillManagerDelegate* delegate, |
| 80 TabContents* tab_contents); |
| 77 | 81 |
| 78 // Registers our Enable/Disable Autofill pref. | 82 // Registers our Enable/Disable Autofill pref. |
| 79 static void RegisterUserPrefs(PrefServiceBase* prefs); | 83 static void RegisterUserPrefs(PrefServiceBase* prefs); |
| 80 | 84 |
| 81 // Set our external delegate. | 85 // Set our external delegate. |
| 82 // TODO(jrg): consider passing delegate into the ctor. That won't | 86 // TODO(jrg): consider passing delegate into the ctor. That won't |
| 83 // work if the delegate has a pointer to the AutofillManager, but | 87 // work if the delegate has a pointer to the AutofillManager, but |
| 84 // future directions may not need such a pointer. | 88 // future directions may not need such a pointer. |
| 85 void SetExternalDelegate(AutofillExternalDelegate* delegate) { | 89 void SetExternalDelegate(AutofillExternalDelegate* delegate) { |
| 86 external_delegate_ = delegate; | 90 external_delegate_ = delegate; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 110 // Only test code should subclass AutofillManager. | 114 // Only test code should subclass AutofillManager. |
| 111 friend class base::RefCounted<AutofillManager>; | 115 friend class base::RefCounted<AutofillManager>; |
| 112 virtual ~AutofillManager(); | 116 virtual ~AutofillManager(); |
| 113 | 117 |
| 114 // The string/int pair is composed of the guid string and variant index | 118 // The string/int pair is composed of the guid string and variant index |
| 115 // respectively. The variant index is an index into the multi-valued item | 119 // respectively. The variant index is an index into the multi-valued item |
| 116 // (where applicable). | 120 // (where applicable). |
| 117 typedef std::pair<std::string, size_t> GUIDPair; | 121 typedef std::pair<std::string, size_t> GUIDPair; |
| 118 | 122 |
| 119 // Test code should prefer to use this constructor. | 123 // Test code should prefer to use this constructor. |
| 120 AutofillManager(TabContents* tab_contents, | 124 AutofillManager(autofill::AutofillManagerDelegate* delegate, |
| 125 TabContents* tab_contents, |
| 121 PersonalDataManager* personal_data); | 126 PersonalDataManager* personal_data); |
| 122 | 127 |
| 123 // Returns the value of the AutofillEnabled pref. | 128 // Returns the value of the AutofillEnabled pref. |
| 124 virtual bool IsAutofillEnabled() const; | 129 virtual bool IsAutofillEnabled() const; |
| 125 | 130 |
| 126 // Uploads the form data to the Autofill server. | 131 // Uploads the form data to the Autofill server. |
| 127 virtual void UploadFormData(const FormStructure& submitted_form); | 132 virtual void UploadFormData(const FormStructure& submitted_form); |
| 128 | 133 |
| 129 // Reset cache. | 134 // Reset cache. |
| 130 void Reset(); | 135 void Reset(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // |interaction_timestamp|, updates the cached timestamp. The latter check is | 319 // |interaction_timestamp|, updates the cached timestamp. The latter check is |
| 315 // needed because IPC messages can arrive out of order. | 320 // needed because IPC messages can arrive out of order. |
| 316 void UpdateInitialInteractionTimestamp( | 321 void UpdateInitialInteractionTimestamp( |
| 317 const base::TimeTicks& interaction_timestamp); | 322 const base::TimeTicks& interaction_timestamp); |
| 318 | 323 |
| 319 // Send our current field type predictions to the renderer. This is a no-op if | 324 // Send our current field type predictions to the renderer. This is a no-op if |
| 320 // the appropriate command-line flag is not set. | 325 // the appropriate command-line flag is not set. |
| 321 void SendAutofillTypePredictions( | 326 void SendAutofillTypePredictions( |
| 322 const std::vector<FormStructure*>& forms) const; | 327 const std::vector<FormStructure*>& forms) const; |
| 323 | 328 |
| 329 autofill::AutofillManagerDelegate* const manager_delegate_; |
| 330 |
| 324 // The owning TabContents. | 331 // The owning TabContents. |
| 325 TabContents* tab_contents_; | 332 TabContents* tab_contents_; |
| 326 | 333 |
| 327 // The personal data manager, used to save and load personal data to/from the | 334 // The personal data manager, used to save and load personal data to/from the |
| 328 // web database. This is overridden by the AutofillManagerTest. | 335 // web database. This is overridden by the AutofillManagerTest. |
| 329 // Weak reference. | 336 // Weak reference. |
| 330 // May be NULL. NULL indicates OTR. | 337 // May be NULL. NULL indicates OTR. |
| 331 PersonalDataManager* personal_data_; | 338 PersonalDataManager* personal_data_; |
| 332 | 339 |
| 333 std::list<std::string> autofilled_form_signatures_; | 340 std::list<std::string> autofilled_form_signatures_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 TestTabContentsWithExternalDelegate); | 410 TestTabContentsWithExternalDelegate); |
| 404 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 411 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 405 UserHappinessFormLoadAndSubmission); | 412 UserHappinessFormLoadAndSubmission); |
| 406 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 413 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
| 407 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 414 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
| 408 | 415 |
| 409 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 416 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 410 }; | 417 }; |
| 411 | 418 |
| 412 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 419 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |