| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 19 #include "base/string16.h" | 19 #include "base/string16.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "chrome/browser/autofill/autofill_download.h" | 21 #include "chrome/browser/autofill/autofill_download.h" |
| 22 #include "chrome/browser/autofill/field_types.h" | 22 #include "chrome/browser/autofill/field_types.h" |
| 23 #include "chrome/browser/autofill/form_structure.h" | 23 #include "chrome/browser/autofill/form_structure.h" |
| 24 #include "content/browser/tab_contents/tab_contents_observer.h" | 24 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 25 | 25 |
| 26 class AutofillExternalDelegate; |
| 26 class AutofillField; | 27 class AutofillField; |
| 27 class AutofillProfile; | 28 class AutofillProfile; |
| 28 class AutofillMetrics; | 29 class AutofillMetrics; |
| 29 class CreditCard; | 30 class CreditCard; |
| 30 class PersonalDataManager; | 31 class PersonalDataManager; |
| 31 class PrefService; | 32 class PrefService; |
| 32 class RenderViewHost; | 33 class RenderViewHost; |
| 33 class TabContentsWrapper; | 34 class TabContentsWrapper; |
| 34 | 35 |
| 35 struct ViewHostMsg_FrameNavigate_Params; | 36 struct ViewHostMsg_FrameNavigate_Params; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 74 |
| 74 // Imports the form data, submitted by the user, into |personal_data_|. | 75 // Imports the form data, submitted by the user, into |personal_data_|. |
| 75 void ImportFormData(const FormStructure& submitted_form); | 76 void ImportFormData(const FormStructure& submitted_form); |
| 76 | 77 |
| 77 // Uploads the form data to the Autofill server. | 78 // Uploads the form data to the Autofill server. |
| 78 virtual void UploadFormData(const FormStructure& submitted_form); | 79 virtual void UploadFormData(const FormStructure& submitted_form); |
| 79 | 80 |
| 80 // Reset cache. | 81 // Reset cache. |
| 81 void Reset(); | 82 void Reset(); |
| 82 | 83 |
| 84 // Set our external delegate. |
| 85 void SetExternalDelegate(AutofillExternalDelegate* delegate) { |
| 86 external_delegate_ = delegate; |
| 87 } |
| 88 |
| 83 protected: | 89 protected: |
| 84 // For tests: | 90 // For tests: |
| 85 | 91 |
| 86 // The string/int pair is composed of the guid string and variant index | 92 // 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 | 93 // respectively. The variant index is an index into the multi-valued item |
| 88 // (where applicable). | 94 // (where applicable). |
| 89 typedef std::pair<std::string, size_t> GUIDPair; | 95 typedef std::pair<std::string, size_t> GUIDPair; |
| 90 | 96 |
| 91 AutofillManager(TabContentsWrapper* tab_contents, | 97 AutofillManager(TabContentsWrapper* tab_contents, |
| 92 PersonalDataManager* personal_data); | 98 PersonalDataManager* personal_data); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 103 // Maps GUIDs to and from IDs that are used to identify profiles and credit | 109 // Maps GUIDs to and from IDs that are used to identify profiles and credit |
| 104 // cards sent to and from the renderer process. | 110 // cards sent to and from the renderer process. |
| 105 virtual int GUIDToID(const GUIDPair& guid) const; | 111 virtual int GUIDToID(const GUIDPair& guid) const; |
| 106 virtual const GUIDPair IDToGUID(int id) const; | 112 virtual const GUIDPair IDToGUID(int id) const; |
| 107 | 113 |
| 108 // Methods for packing and unpacking credit card and profile IDs for sending | 114 // Methods for packing and unpacking credit card and profile IDs for sending |
| 109 // and receiving to and from the renderer process. | 115 // and receiving to and from the renderer process. |
| 110 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; | 116 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; |
| 111 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; | 117 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; |
| 112 | 118 |
| 119 // Called from our external delegate so it cannot be private. |
| 120 void OnFillAutoFillFormData(int query_id, |
| 121 const webkit_glue::FormData& form, |
| 122 const webkit_glue::FormField& field, |
| 123 int unique_id); |
| 124 |
| 125 // Exposed for testing. |
| 126 AutofillExternalDelegate* external_delegate() { |
| 127 return external_delegate_; |
| 128 } |
| 129 |
| 113 private: | 130 private: |
| 114 void OnFormSubmitted(const webkit_glue::FormData& form, | 131 void OnFormSubmitted(const webkit_glue::FormData& form, |
| 115 const base::TimeTicks& timestamp); | 132 const base::TimeTicks& timestamp); |
| 116 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, | 133 void OnFormsSeen(const std::vector<webkit_glue::FormData>& forms, |
| 117 const base::TimeTicks& timestamp); | 134 const base::TimeTicks& timestamp); |
| 118 void OnTextFieldDidChange(const webkit_glue::FormData& form, | 135 void OnTextFieldDidChange(const webkit_glue::FormData& form, |
| 119 const webkit_glue::FormField& field, | 136 const webkit_glue::FormField& field, |
| 120 const base::TimeTicks& timestamp); | 137 const base::TimeTicks& timestamp); |
| 121 void OnQueryFormFieldAutofill(int query_id, | 138 void OnQueryFormFieldAutofill(int query_id, |
| 122 const webkit_glue::FormData& form, | 139 const webkit_glue::FormData& form, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // page. | 285 // page. |
| 269 base::TimeTicks initial_interaction_timestamp_; | 286 base::TimeTicks initial_interaction_timestamp_; |
| 270 | 287 |
| 271 // Our copy of the form data. | 288 // Our copy of the form data. |
| 272 ScopedVector<FormStructure> form_structures_; | 289 ScopedVector<FormStructure> form_structures_; |
| 273 | 290 |
| 274 // GUID to ID mapping. We keep two maps to convert back and forth. | 291 // GUID to ID mapping. We keep two maps to convert back and forth. |
| 275 mutable std::map<GUIDPair, int> guid_id_map_; | 292 mutable std::map<GUIDPair, int> guid_id_map_; |
| 276 mutable std::map<int, GUIDPair> id_guid_map_; | 293 mutable std::map<int, GUIDPair> id_guid_map_; |
| 277 | 294 |
| 295 // Delegate to perform external processing (display, selection) on |
| 296 // our behalf. Weak. |
| 297 AutofillExternalDelegate* external_delegate_; |
| 298 |
| 278 friend class AutofillManagerTest; | 299 friend class AutofillManagerTest; |
| 279 friend class FormStructureBrowserTest; | 300 friend class FormStructureBrowserTest; |
| 280 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 301 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 281 DeterminePossibleFieldTypesForUpload); | 302 DeterminePossibleFieldTypesForUpload); |
| 282 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 303 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 283 DeterminePossibleFieldTypesForUploadStressTest); | 304 DeterminePossibleFieldTypesForUploadStressTest); |
| 284 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); | 305 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); |
| 285 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); | 306 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); |
| 286 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 307 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 287 NoQualityMetricsForNonAutofillableForms); | 308 NoQualityMetricsForNonAutofillableForms); |
| 288 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics); | 309 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics); |
| 289 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); | 310 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); |
| 290 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); | 311 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); |
| 291 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); | 312 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); |
| 313 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestExternalDelegate); |
| 314 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestTabContents); |
| 292 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 315 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 293 UserHappinessFormLoadAndSubmission); | 316 UserHappinessFormLoadAndSubmission); |
| 294 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 317 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
| 295 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 318 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
| 296 | 319 |
| 297 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 320 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 298 }; | 321 }; |
| 299 | 322 |
| 300 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 323 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |