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

Side by Side Diff: chrome/browser/autofill/autofill_manager.h

Issue 10987100: Switch AutofillManager to be UserData on WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 (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 18 matching lines...) Expand all
29 #include "content/public/browser/web_contents_observer.h" 29 #include "content/public/browser/web_contents_observer.h"
30 30
31 class AutofillExternalDelegate; 31 class AutofillExternalDelegate;
32 class AutofillField; 32 class AutofillField;
33 class AutofillProfile; 33 class AutofillProfile;
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;
40 39
41 struct ViewHostMsg_FrameNavigate_Params; 40 struct ViewHostMsg_FrameNavigate_Params;
42 41
43 namespace autofill { 42 namespace autofill {
44 class AutofillManagerDelegate; 43 class AutofillManagerDelegate;
45 class PasswordGenerator; 44 class PasswordGenerator;
46 } 45 }
47 46
48 namespace content { 47 namespace content {
49 class RenderViewHost; 48 class RenderViewHost;
49 class WebContents;
50 } 50 }
51 51
52 namespace gfx { 52 namespace gfx {
53 class Rect; 53 class Rect;
54 } 54 }
55 55
56 namespace IPC { 56 namespace IPC {
57 class Message; 57 class Message;
58 } 58 }
59 59
60 namespace webkit { 60 namespace webkit {
61 namespace forms { 61 namespace forms {
62 struct FormData; 62 struct FormData;
63 struct FormField; 63 struct FormField;
64 struct PasswordForm; 64 struct PasswordForm;
65 struct PasswordFormFillData; 65 struct PasswordFormFillData;
66 } 66 }
67 } 67 }
68 68
69 // 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
70 // forms. 70 // forms.
71 class AutofillManager : public content::NotificationObserver, 71 class AutofillManager : public content::NotificationObserver,
72 public content::WebContentsObserver, 72 public content::WebContentsObserver,
73 public AutofillDownloadManager::Observer, 73 public AutofillDownloadManager::Observer,
74 public ProfileSyncServiceObserver, 74 public ProfileSyncServiceObserver,
75 public base::RefCounted<AutofillManager> { 75 public base::RefCounted<AutofillManager> {
76 public: 76 public:
77 // Lifetime of |client| and |tab_contents| must exceed lifetime of 77 static void CreateForWebContentsAndDelegate(
78 // AutofillManager. 78 content::WebContents* contents,
79 explicit AutofillManager(autofill::AutofillManagerDelegate* delegate, 79 autofill::AutofillManagerDelegate* delegate);
80 TabContents* tab_contents); 80 static AutofillManager* FromWebContents(content::WebContents* contents);
81 81
82 // Registers our Enable/Disable Autofill pref. 82 // Registers our Enable/Disable Autofill pref.
83 static void RegisterUserPrefs(PrefServiceBase* prefs); 83 static void RegisterUserPrefs(PrefServiceBase* prefs);
84 84
85 // Set our external delegate. 85 // Set our external delegate.
86 // TODO(jrg): consider passing delegate into the ctor. That won't 86 // TODO(jrg): consider passing delegate into the ctor. That won't
87 // work if the delegate has a pointer to the AutofillManager, but 87 // work if the delegate has a pointer to the AutofillManager, but
88 // future directions may not need such a pointer. 88 // future directions may not need such a pointer.
89 void SetExternalDelegate(AutofillExternalDelegate* delegate) { 89 void SetExternalDelegate(AutofillExternalDelegate* delegate) {
90 external_delegate_ = delegate; 90 external_delegate_ = delegate;
(...skipping 15 matching lines...) Expand all
106 int max_length, 106 int max_length,
107 const webkit::forms::PasswordForm& form); 107 const webkit::forms::PasswordForm& form);
108 108
109 // Remove the credit card or Autofill profile that matches |unique_id| 109 // Remove the credit card or Autofill profile that matches |unique_id|
110 // from the database. 110 // from the database.
111 void RemoveAutofillProfileOrCreditCard(int unique_id); 111 void RemoveAutofillProfileOrCreditCard(int unique_id);
112 112
113 protected: 113 protected:
114 // Only test code should subclass AutofillManager. 114 // Only test code should subclass AutofillManager.
115 friend class base::RefCounted<AutofillManager>; 115 friend class base::RefCounted<AutofillManager>;
116
117 AutofillManager(content::WebContents* web_contents,
118 autofill::AutofillManagerDelegate* delegate);
116 virtual ~AutofillManager(); 119 virtual ~AutofillManager();
117 120
118 // The string/int pair is composed of the guid string and variant index 121 // The string/int pair is composed of the guid string and variant index
119 // respectively. The variant index is an index into the multi-valued item 122 // respectively. The variant index is an index into the multi-valued item
120 // (where applicable). 123 // (where applicable).
121 typedef std::pair<std::string, size_t> GUIDPair; 124 typedef std::pair<std::string, size_t> GUIDPair;
122 125
123 // Test code should prefer to use this constructor. 126 // Test code should prefer to use this constructor.
124 AutofillManager(autofill::AutofillManagerDelegate* delegate, 127 AutofillManager(content::WebContents* web_contents,
125 TabContents* tab_contents, 128 autofill::AutofillManagerDelegate* delegate,
126 PersonalDataManager* personal_data); 129 PersonalDataManager* personal_data);
127 130
128 // Returns the value of the AutofillEnabled pref. 131 // Returns the value of the AutofillEnabled pref.
129 virtual bool IsAutofillEnabled() const; 132 virtual bool IsAutofillEnabled() const;
130 133
131 // Uploads the form data to the Autofill server. 134 // Uploads the form data to the Autofill server.
132 virtual void UploadFormData(const FormStructure& submitted_form); 135 virtual void UploadFormData(const FormStructure& submitted_form);
133 136
134 // Reset cache. 137 // Reset cache.
135 void Reset(); 138 void Reset();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void UpdateInitialInteractionTimestamp( 324 void UpdateInitialInteractionTimestamp(
322 const base::TimeTicks& interaction_timestamp); 325 const base::TimeTicks& interaction_timestamp);
323 326
324 // Send our current field type predictions to the renderer. This is a no-op if 327 // Send our current field type predictions to the renderer. This is a no-op if
325 // the appropriate command-line flag is not set. 328 // the appropriate command-line flag is not set.
326 void SendAutofillTypePredictions( 329 void SendAutofillTypePredictions(
327 const std::vector<FormStructure*>& forms) const; 330 const std::vector<FormStructure*>& forms) const;
328 331
329 autofill::AutofillManagerDelegate* const manager_delegate_; 332 autofill::AutofillManagerDelegate* const manager_delegate_;
330 333
331 // The owning TabContents.
332 TabContents* tab_contents_;
333
334 // 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
335 // web database. This is overridden by the AutofillManagerTest. 335 // web database. This is overridden by the AutofillManagerTest.
336 // Weak reference. 336 // Weak reference.
337 // May be NULL. NULL indicates OTR. 337 // May be NULL. NULL indicates OTR.
338 PersonalDataManager* personal_data_; 338 PersonalDataManager* personal_data_;
339 339
340 std::list<std::string> autofilled_form_signatures_; 340 std::list<std::string> autofilled_form_signatures_;
341 // Handles queries and uploads to Autofill servers. 341 // Handles queries and uploads to Autofill servers.
342 AutofillDownloadManager download_manager_; 342 AutofillDownloadManager download_manager_;
343 343
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 TestTabContentsWithExternalDelegate); 410 TestTabContentsWithExternalDelegate);
411 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, 411 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
412 UserHappinessFormLoadAndSubmission); 412 UserHappinessFormLoadAndSubmission);
413 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); 413 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
414 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); 414 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
415 415
416 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 416 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
417 }; 417 };
418 418
419 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 419 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698