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

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

Issue 3226001: Detecting form locale (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Unit test for top websites Created 10 years, 3 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector> 9 #include <vector>
10 #include <string> 10 #include <string>
11 #include <list> 11 #include <list>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/scoped_ptr.h" 14 #include "base/scoped_ptr.h"
15 #include "base/scoped_vector.h" 15 #include "base/scoped_vector.h"
16 #include "chrome/browser/autofill/autofill_dialog.h" 16 #include "chrome/browser/autofill/autofill_dialog.h"
17 #include "chrome/browser/autofill/autofill_download.h" 17 #include "chrome/browser/autofill/autofill_download.h"
18 #include "chrome/browser/autofill/autofill_locale_model.h"
18 #include "chrome/browser/autofill/personal_data_manager.h" 19 #include "chrome/browser/autofill/personal_data_manager.h"
19 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 20 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
21 #include "chrome/common/notification_observer.h"
22 #include "chrome/common/notification_registrar.h"
20 23
21 class AutoFillCCInfoBarDelegate; 24 class AutoFillCCInfoBarDelegate;
22 class AutoFillProfile; 25 class AutoFillProfile;
23 class CreditCard; 26 class CreditCard;
24 class FormStructure; 27 class FormStructure;
28 class NotificationDetails;
29 class NotificationSource;
30 class NotificationType;
25 class PrefService; 31 class PrefService;
26 class TabContents; 32 class TabContents;
27 33
28 namespace webkit_glue { 34 namespace webkit_glue {
29 struct FormData; 35 struct FormData;
30 class FormField; 36 class FormField;
31 } // namespace webkit_glue 37 } // namespace webkit_glue
32 38
33 // TODO(jhawkins): Maybe this should be in a grd file? 39 // TODO(jhawkins): Maybe this should be in a grd file?
34 extern const char* kAutoFillLearnMoreUrl; 40 extern const char* kAutoFillLearnMoreUrl;
35 41
36 // Manages saving and restoring the user's personal information entered into web 42 // Manages saving and restoring the user's personal information entered into web
37 // forms. 43 // forms.
38 class AutoFillManager : public RenderViewHostDelegate::AutoFill, 44 class AutoFillManager : public RenderViewHostDelegate::AutoFill,
39 public AutoFillDownloadManager::Observer { 45 public AutoFillDownloadManager::Observer,
46 public NotificationObserver {
40 public: 47 public:
41 explicit AutoFillManager(TabContents* tab_contents); 48 explicit AutoFillManager(TabContents* tab_contents);
42 virtual ~AutoFillManager(); 49 virtual ~AutoFillManager();
43 50
44 // Registers our browser prefs. 51 // Registers our browser prefs.
45 static void RegisterBrowserPrefs(PrefService* prefs); 52 static void RegisterBrowserPrefs(PrefService* prefs);
46 53
47 // Registers our Enable/Disable AutoFill pref. 54 // Registers our Enable/Disable AutoFill pref.
48 static void RegisterUserPrefs(PrefService* prefs); 55 static void RegisterUserPrefs(PrefService* prefs);
49 56
(...skipping 19 matching lines...) Expand all
69 virtual void Reset(); 76 virtual void Reset();
70 77
71 // AutoFillDownloadManager::Observer implementation: 78 // AutoFillDownloadManager::Observer implementation:
72 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); 79 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml);
73 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); 80 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature);
74 virtual void OnHeuristicsRequestError( 81 virtual void OnHeuristicsRequestError(
75 const std::string& form_signature, 82 const std::string& form_signature,
76 AutoFillDownloadManager::AutoFillRequestType request_type, 83 AutoFillDownloadManager::AutoFillRequestType request_type,
77 int http_error); 84 int http_error);
78 85
86 // NotificationObserver implementation:
87 virtual void Observe(NotificationType type,
88 const NotificationSource& source,
89 const NotificationDetails& details);
90
79 // Returns the value of the AutoFillEnabled pref. 91 // Returns the value of the AutoFillEnabled pref.
80 virtual bool IsAutoFillEnabled() const; 92 virtual bool IsAutoFillEnabled() const;
81 93
82 // Uses heuristics and existing personal data to determine the possible field 94 // Uses heuristics and existing personal data to determine the possible field
83 // types. 95 // types.
84 void DeterminePossibleFieldTypes(FormStructure* form_structure); 96 void DeterminePossibleFieldTypes(FormStructure* form_structure);
85 97
86 // Handles the form data submitted by the user. 98 // Handles the form data submitted by the user.
87 void HandleSubmit(); 99 void HandleSubmit();
88 100
89 // Uploads the form data to the AutoFill server. 101 // Uploads the form data to the AutoFill server.
90 void UploadFormData(); 102 void UploadFormData();
91 103
92 protected: 104 protected:
93 // For tests. 105 // For tests.
94 AutoFillManager(); 106 AutoFillManager();
95 AutoFillManager(TabContents* tab_contents, 107 AutoFillManager(TabContents* tab_contents,
96 PersonalDataManager* personal_data); 108 PersonalDataManager* personal_data);
97 109
98 void set_personal_data_manager(PersonalDataManager* personal_data) { 110 void set_personal_data_manager(PersonalDataManager* personal_data) {
99 personal_data_ = personal_data; 111 personal_data_ = personal_data;
100 } 112 }
101 113
114 const ScopedVector<FormStructure>* form_structures() const {
115 return &form_structures_;
116 }
117
102 private: 118 private:
103 // Returns a list of values from the stored profiles that match |type| and the 119 // Returns a list of values from the stored profiles that match |type| and the
104 // value of |field| and returns the labels of the matching profiles. |labels| 120 // value of |field| and returns the labels of the matching profiles. |labels|
105 // is filled with the Profile label and possibly the last four digits of a 121 // is filled with the Profile label and possibly the last four digits of a
106 // corresponding credit card: 'Home; *1258' - Home is the Profile label and 122 // corresponding credit card: 'Home; *1258' - Home is the Profile label and
107 // 1258 is the last four digits of the credit card. If |include_cc_labels| is 123 // 1258 is the last four digits of the credit card. If |include_cc_labels| is
108 // true, check for billing fields and append CC digits to the labels; 124 // true, check for billing fields and append CC digits to the labels;
109 // otherwise, regular profiles are returned for billing address fields. 125 // otherwise, regular profiles are returned for billing address fields.
110 void GetProfileSuggestions(FormStructure* form, 126 void GetProfileSuggestions(FormStructure* form,
111 const webkit_glue::FormField& field, 127 const webkit_glue::FormField& field,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // The personal data manager, used to save and load personal data to/from the 204 // The personal data manager, used to save and load personal data to/from the
189 // web database. This is overridden by the AutoFillManagerTest. 205 // web database. This is overridden by the AutoFillManagerTest.
190 // Weak reference. 206 // Weak reference.
191 // May be NULL. NULL indicates OTR. 207 // May be NULL. NULL indicates OTR.
192 PersonalDataManager* personal_data_; 208 PersonalDataManager* personal_data_;
193 209
194 std::list<std::string> autofilled_forms_signatures_; 210 std::list<std::string> autofilled_forms_signatures_;
195 // Handles queries and uploads to AutoFill servers. 211 // Handles queries and uploads to AutoFill servers.
196 AutoFillDownloadManager download_manager_; 212 AutoFillDownloadManager download_manager_;
197 213
214 // Handles registration and unregistration for tab language detection
215 // notifications.
216 NotificationRegistrar notification_registrar_;
217
218 // A locale model for the forms in this tab.
219 AutoFillLocaleModel locale_model_;
220
198 // Should be set to true in AutoFillManagerTest and other tests, false in 221 // Should be set to true in AutoFillManagerTest and other tests, false in
199 // AutoFillDownloadManagerTest and in non-test environment. Is false by 222 // AutoFillDownloadManagerTest and in non-test environment. Is false by
200 // default. 223 // default.
201 bool disable_download_manager_requests_; 224 bool disable_download_manager_requests_;
202 225
203 // Our copy of the form data. 226 // Our copy of the form data.
204 ScopedVector<FormStructure> form_structures_; 227 ScopedVector<FormStructure> form_structures_;
205 228
206 // The form data the user has submitted. 229 // The form data the user has submitted.
207 scoped_ptr<FormStructure> upload_form_structure_; 230 scoped_ptr<FormStructure> upload_form_structure_;
208 231
209 // The InfoBar that asks for permission to store credit card information. 232 // The InfoBar that asks for permission to store credit card information.
210 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_; 233 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_;
211 234
212 friend class TestAutoFillManager; 235 friend class TestAutoFillManager;
213 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); 236 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm);
214 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon); 237 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon);
215 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon); 238 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon);
216 239
217 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); 240 DISALLOW_COPY_AND_ASSIGN(AutoFillManager);
218 }; 241 };
219 242
220 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ 243 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_locale_model_unittest.cc ('k') | chrome/browser/autofill/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698