Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 // forms. | 47 // forms. |
| 48 class AutofillManager : public TabContentsObserver, | 48 class AutofillManager : public TabContentsObserver, |
| 49 public AutofillDownloadManager::Observer { | 49 public AutofillDownloadManager::Observer { |
| 50 public: | 50 public: |
| 51 explicit AutofillManager(TabContentsWrapper* tab_contents); | 51 explicit AutofillManager(TabContentsWrapper* tab_contents); |
| 52 virtual ~AutofillManager(); | 52 virtual ~AutofillManager(); |
| 53 | 53 |
| 54 // Registers our Enable/Disable Autofill pref. | 54 // Registers our Enable/Disable Autofill pref. |
| 55 static void RegisterUserPrefs(PrefService* prefs); | 55 static void RegisterUserPrefs(PrefService* prefs); |
| 56 | 56 |
| 57 // TabContentsObserver implementation. | 57 protected: |
| 58 virtual void DidNavigateMainFramePostCommit( | 58 // Only test code should subclass AutofillManager. |
| 59 const content::LoadCommittedDetails& details, | |
| 60 const ViewHostMsg_FrameNavigate_Params& params); | |
| 61 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 62 | 59 |
| 63 // AutofillDownloadManager::Observer implementation: | 60 // The string/int pair is composed of the guid string and variant index |
| 64 virtual void OnLoadedServerPredictions(const std::string& response_xml); | 61 // respectively. The variant index is an index into the multi-valued item |
| 65 virtual void OnUploadedPossibleFieldTypes(); | 62 // (where applicable). |
| 66 virtual void OnServerRequestError( | 63 typedef std::pair<std::string, size_t> GUIDPair; |
| 67 const std::string& form_signature, | 64 |
| 68 AutofillDownloadManager::AutofillRequestType request_type, | 65 // Test code should prefer to use this constructor. |
| 69 int http_error); | 66 AutofillManager(TabContentsWrapper* tab_contents, |
| 67 PersonalDataManager* personal_data); | |
| 70 | 68 |
| 71 // Returns the value of the AutofillEnabled pref. | 69 // Returns the value of the AutofillEnabled pref. |
| 72 virtual bool IsAutofillEnabled() const; | 70 virtual bool IsAutofillEnabled() const; |
| 73 | 71 |
| 74 // Imports the form data, submitted by the user, into |personal_data_|. | |
| 75 void ImportFormData(const FormStructure& submitted_form); | |
| 76 | |
| 77 // Uploads the form data to the Autofill server. | 72 // Uploads the form data to the Autofill server. |
| 78 virtual void UploadFormData(const FormStructure& submitted_form); | 73 virtual void UploadFormData(const FormStructure& submitted_form); |
| 79 | 74 |
| 80 // Reset cache. | 75 // Reset cache. |
| 81 void Reset(); | 76 void Reset(); |
| 82 | 77 |
| 83 protected: | |
| 84 // For tests: | |
| 85 | |
| 86 // The string/int pair is composed of the guid string and variant index | |
| 87 // respectively. The variant index is an index into the multi-valued item | |
| 88 // (where applicable). | |
| 89 typedef std::pair<std::string, size_t> GUIDPair; | |
| 90 | |
| 91 AutofillManager(TabContentsWrapper* tab_contents, | |
| 92 PersonalDataManager* personal_data); | |
| 93 | |
| 94 void set_personal_data_manager(PersonalDataManager* personal_data) { | |
| 95 personal_data_ = personal_data; | |
| 96 } | |
| 97 | |
| 98 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } | |
| 99 void set_metric_logger(const AutofillMetrics* metric_logger); | |
| 100 | |
| 101 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } | |
| 102 | |
| 103 // Maps GUIDs to and from IDs that are used to identify profiles and credit | 78 // Maps GUIDs to and from IDs that are used to identify profiles and credit |
| 104 // cards sent to and from the renderer process. | 79 // cards sent to and from the renderer process. |
| 105 virtual int GUIDToID(const GUIDPair& guid) const; | 80 virtual int GUIDToID(const GUIDPair& guid) const; |
| 106 virtual const GUIDPair IDToGUID(int id) const; | 81 virtual const GUIDPair IDToGUID(int id) const; |
| 107 | 82 |
| 108 // Methods for packing and unpacking credit card and profile IDs for sending | 83 // Methods for packing and unpacking credit card and profile IDs for sending |
| 109 // and receiving to and from the renderer process. | 84 // and receiving to and from the renderer process. |
| 110 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; | 85 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; |
| 111 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; | 86 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; |
| 112 | 87 |
| 88 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } | |
| 89 void set_metric_logger(const AutofillMetrics* metric_logger); | |
| 90 | |
| 91 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } | |
| 92 | |
| 113 private: | 93 private: |
| 94 // TabContentsObserver: | |
| 95 virtual void DidNavigateMainFramePostCommit( | |
| 96 const content::LoadCommittedDetails& details, | |
| 97 const ViewHostMsg_FrameNavigate_Params& params); | |
|
dhollowa
2011/10/26 15:58:33
OVERRIDE with these virtual methods.
Ilya Sherman
2011/10/26 23:06:32
Done.
| |
| 98 virtual bool OnMessageReceived(const IPC::Message& message); | |
| 99 | |
| 100 // AutofillDownloadManager::Observer: | |
| 101 virtual void OnLoadedServerPredictions(const std::string& response_xml); | |
| 102 | |
| 114 void OnFormSubmitted(const webkit_glue::FormData& form, | 103 void OnFormSubmitted(const webkit_glue::FormData& form, |
| 115 const base::TimeTicks& timestamp); | 104 const base::TimeTicks& timestamp); |
| 116 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, | 105 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, |
| 117 const base::TimeTicks& timestamp); | 106 const base::TimeTicks& timestamp); |
| 118 void OnTextFieldDidChange(const webkit_glue::FormData& form, | 107 void OnTextFieldDidChange(const webkit_glue::FormData& form, |
| 119 const webkit_glue::FormField& field, | 108 const webkit_glue::FormField& field, |
| 120 const base::TimeTicks& timestamp); | 109 const base::TimeTicks& timestamp); |
| 121 void OnQueryFormFieldAutofill(int query_id, | 110 void OnQueryFormFieldAutofill(int query_id, |
| 122 const webkit_glue::FormData& form, | 111 const webkit_glue::FormData& form, |
| 123 const webkit_glue::FormField& field); | 112 const webkit_glue::FormField& field); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 size_t variant, | 199 size_t variant, |
| 211 webkit_glue::FormField* field); | 200 webkit_glue::FormField* field); |
| 212 | 201 |
| 213 // Parses the forms using heuristic matching and querying the Autofill server. | 202 // Parses the forms using heuristic matching and querying the Autofill server. |
| 214 void ParseForms(const std::vector<webkit_glue::FormData>& forms); | 203 void ParseForms(const std::vector<webkit_glue::FormData>& forms); |
| 215 | 204 |
| 216 // Uses existing personal data to determine possible field types for the | 205 // Uses existing personal data to determine possible field types for the |
| 217 // |submitted_form|. | 206 // |submitted_form|. |
| 218 void DeterminePossibleFieldTypesForUpload(FormStructure* submitted_form); | 207 void DeterminePossibleFieldTypesForUpload(FormStructure* submitted_form); |
| 219 | 208 |
| 209 // Imports the form data, submitted by the user, into |personal_data_|. | |
| 210 void ImportFormData(const FormStructure& submitted_form); | |
| 211 | |
| 220 // If |initial_interaction_timestamp_| is unset or is set to a later time than | 212 // If |initial_interaction_timestamp_| is unset or is set to a later time than |
| 221 // |interaction_timestamp|, updates the cached timestamp. The latter check is | 213 // |interaction_timestamp|, updates the cached timestamp. The latter check is |
| 222 // needed because IPC messages can arrive out of order. | 214 // needed because IPC messages can arrive out of order. |
| 223 void UpdateInitialInteractionTimestamp( | 215 void UpdateInitialInteractionTimestamp( |
| 224 const base::TimeTicks& interaction_timestamp); | 216 const base::TimeTicks& interaction_timestamp); |
| 225 | 217 |
| 226 // Send our current field type predictions to the renderer. This is a no-op if | 218 // Send our current field type predictions to the renderer. This is a no-op if |
| 227 // the appropriate command-line flag is not set. | 219 // the appropriate command-line flag is not set. |
| 228 void SendAutofillTypePredictions( | 220 void SendAutofillTypePredictions( |
| 229 const std::vector<FormStructure*>& forms) const; | 221 const std::vector<FormStructure*>& forms) const; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); | 283 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); |
| 292 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 284 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 293 UserHappinessFormLoadAndSubmission); | 285 UserHappinessFormLoadAndSubmission); |
| 294 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 286 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
| 295 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 287 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
| 296 | 288 |
| 297 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 289 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 298 }; | 290 }; |
| 299 | 291 |
| 300 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 292 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |