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

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: fix external delegate 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 FormData; 40 struct FormData;
42 struct FormFieldData; 41 struct FormFieldData;
43 struct PasswordFormFillData; 42 struct PasswordFormFillData;
44 struct ViewHostMsg_FrameNavigate_Params; 43 struct ViewHostMsg_FrameNavigate_Params;
45 44
46 namespace autofill { 45 namespace autofill {
47 class AutofillManagerDelegate; 46 class AutofillManagerDelegate;
48 class PasswordGenerator; 47 class PasswordGenerator;
49 } 48 }
50 49
51 namespace content { 50 namespace content {
52 class RenderViewHost; 51 class RenderViewHost;
52 class WebContents;
53
53 struct PasswordForm; 54 struct PasswordForm;
54 } 55 }
55 56
56 namespace gfx { 57 namespace gfx {
57 class Rect; 58 class Rect;
58 } 59 }
59 60
60 namespace IPC { 61 namespace IPC {
61 class Message; 62 class Message;
62 } 63 }
63 64
64 // Manages saving and restoring the user's personal information entered into web 65 // Manages saving and restoring the user's personal information entered into web
65 // forms. 66 // forms.
66 class AutofillManager : public content::NotificationObserver, 67 class AutofillManager : public content::NotificationObserver,
67 public content::WebContentsObserver, 68 public content::WebContentsObserver,
68 public AutofillDownloadManager::Observer, 69 public AutofillDownloadManager::Observer,
69 public ProfileSyncServiceObserver, 70 public ProfileSyncServiceObserver,
70 public base::RefCounted<AutofillManager> { 71 public base::RefCounted<AutofillManager> {
71 public: 72 public:
72 // Lifetime of |client| and |tab_contents| must exceed lifetime of 73 static void CreateForWebContentsAndDelegate(
73 // AutofillManager. 74 content::WebContents* contents,
74 explicit AutofillManager(autofill::AutofillManagerDelegate* delegate, 75 autofill::AutofillManagerDelegate* delegate);
75 TabContents* tab_contents); 76 static AutofillManager* FromWebContents(content::WebContents* contents);
76 77
77 // Registers our Enable/Disable Autofill pref. 78 // Registers our Enable/Disable Autofill pref.
78 static void RegisterUserPrefs(PrefServiceBase* prefs); 79 static void RegisterUserPrefs(PrefServiceBase* prefs);
79 80
80 // Set our external delegate. 81 // Set our external delegate.
81 // TODO(jrg): consider passing delegate into the ctor. That won't 82 // TODO(jrg): consider passing delegate into the ctor. That won't
82 // work if the delegate has a pointer to the AutofillManager, but 83 // work if the delegate has a pointer to the AutofillManager, but
83 // future directions may not need such a pointer. 84 // future directions may not need such a pointer.
84 void SetExternalDelegate(AutofillExternalDelegate* delegate) { 85 void SetExternalDelegate(AutofillExternalDelegate* delegate) {
85 external_delegate_ = delegate; 86 external_delegate_ = delegate;
(...skipping 15 matching lines...) Expand all
101 int max_length, 102 int max_length,
102 const content::PasswordForm& form); 103 const content::PasswordForm& form);
103 104
104 // Remove the credit card or Autofill profile that matches |unique_id| 105 // Remove the credit card or Autofill profile that matches |unique_id|
105 // from the database. 106 // from the database.
106 void RemoveAutofillProfileOrCreditCard(int unique_id); 107 void RemoveAutofillProfileOrCreditCard(int unique_id);
107 108
108 protected: 109 protected:
109 // Only test code should subclass AutofillManager. 110 // Only test code should subclass AutofillManager.
110 friend class base::RefCounted<AutofillManager>; 111 friend class base::RefCounted<AutofillManager>;
112
113 AutofillManager(content::WebContents* web_contents,
114 autofill::AutofillManagerDelegate* delegate);
111 virtual ~AutofillManager(); 115 virtual ~AutofillManager();
112 116
113 // The string/int pair is composed of the guid string and variant index 117 // The string/int pair is composed of the guid string and variant index
114 // respectively. The variant index is an index into the multi-valued item 118 // respectively. The variant index is an index into the multi-valued item
115 // (where applicable). 119 // (where applicable).
116 typedef std::pair<std::string, size_t> GUIDPair; 120 typedef std::pair<std::string, size_t> GUIDPair;
117 121
118 // Test code should prefer to use this constructor. 122 // Test code should prefer to use this constructor.
119 AutofillManager(autofill::AutofillManagerDelegate* delegate, 123 AutofillManager(content::WebContents* web_contents,
120 TabContents* tab_contents, 124 autofill::AutofillManagerDelegate* delegate,
121 PersonalDataManager* personal_data); 125 PersonalDataManager* personal_data);
122 126
123 // Returns the value of the AutofillEnabled pref. 127 // Returns the value of the AutofillEnabled pref.
124 virtual bool IsAutofillEnabled() const; 128 virtual bool IsAutofillEnabled() const;
125 129
126 // Uploads the form data to the Autofill server. 130 // Uploads the form data to the Autofill server.
127 virtual void UploadFormData(const FormStructure& submitted_form); 131 virtual void UploadFormData(const FormStructure& submitted_form);
128 132
129 // Reset cache. 133 // Reset cache.
130 void Reset(); 134 void Reset();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 void UpdateInitialInteractionTimestamp( 320 void UpdateInitialInteractionTimestamp(
317 const base::TimeTicks& interaction_timestamp); 321 const base::TimeTicks& interaction_timestamp);
318 322
319 // Send our current field type predictions to the renderer. This is a no-op if 323 // Send our current field type predictions to the renderer. This is a no-op if
320 // the appropriate command-line flag is not set. 324 // the appropriate command-line flag is not set.
321 void SendAutofillTypePredictions( 325 void SendAutofillTypePredictions(
322 const std::vector<FormStructure*>& forms) const; 326 const std::vector<FormStructure*>& forms) const;
323 327
324 autofill::AutofillManagerDelegate* const manager_delegate_; 328 autofill::AutofillManagerDelegate* const manager_delegate_;
325 329
326 // The owning TabContents.
327 TabContents* tab_contents_;
328
329 // The personal data manager, used to save and load personal data to/from the 330 // The personal data manager, used to save and load personal data to/from the
330 // web database. This is overridden by the AutofillManagerTest. 331 // web database. This is overridden by the AutofillManagerTest.
331 // Weak reference. 332 // Weak reference.
332 // May be NULL. NULL indicates OTR. 333 // May be NULL. NULL indicates OTR.
333 PersonalDataManager* personal_data_; 334 PersonalDataManager* personal_data_;
334 335
335 std::list<std::string> autofilled_form_signatures_; 336 std::list<std::string> autofilled_form_signatures_;
336 // Handles queries and uploads to Autofill servers. 337 // Handles queries and uploads to Autofill servers.
337 AutofillDownloadManager download_manager_; 338 AutofillDownloadManager download_manager_;
338 339
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 TestTabContentsWithExternalDelegate); 406 TestTabContentsWithExternalDelegate);
406 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, 407 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest,
407 UserHappinessFormLoadAndSubmission); 408 UserHappinessFormLoadAndSubmission);
408 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); 409 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction);
409 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); 410 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration);
410 411
411 DISALLOW_COPY_AND_ASSIGN(AutofillManager); 412 DISALLOW_COPY_AND_ASSIGN(AutofillManager);
412 }; 413 };
413 414
414 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 415 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_external_delegate_unittest.cc ('k') | chrome/browser/autofill/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698