| 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 11 matching lines...) Expand all Loading... |
| 47 // forms. | 48 // forms. |
| 48 class AutofillManager : public TabContentsObserver, | 49 class AutofillManager : public TabContentsObserver, |
| 49 public AutofillDownloadManager::Observer { | 50 public AutofillDownloadManager::Observer { |
| 50 public: | 51 public: |
| 51 explicit AutofillManager(TabContentsWrapper* tab_contents); | 52 explicit AutofillManager(TabContentsWrapper* tab_contents); |
| 52 virtual ~AutofillManager(); | 53 virtual ~AutofillManager(); |
| 53 | 54 |
| 54 // Registers our Enable/Disable Autofill pref. | 55 // Registers our Enable/Disable Autofill pref. |
| 55 static void RegisterUserPrefs(PrefService* prefs); | 56 static void RegisterUserPrefs(PrefService* prefs); |
| 56 | 57 |
| 58 // Set our external delegate. |
| 59 // TODO(jrg): consider passing delegate into the ctor. That won't |
| 60 // work if the delegate has a pointer to the AutofillManager, but |
| 61 // future directions may not need such a pointer. |
| 62 void SetExternalDelegate(AutofillExternalDelegate* delegate) { |
| 63 external_delegate_ = delegate; |
| 64 } |
| 65 |
| 57 protected: | 66 protected: |
| 58 // Only test code should subclass AutofillManager. | 67 // Only test code should subclass AutofillManager. |
| 59 | 68 |
| 60 // The string/int pair is composed of the guid string and variant index | 69 // The string/int pair is composed of the guid string and variant index |
| 61 // respectively. The variant index is an index into the multi-valued item | 70 // respectively. The variant index is an index into the multi-valued item |
| 62 // (where applicable). | 71 // (where applicable). |
| 63 typedef std::pair<std::string, size_t> GUIDPair; | 72 typedef std::pair<std::string, size_t> GUIDPair; |
| 64 | 73 |
| 65 // Test code should prefer to use this constructor. | 74 // Test code should prefer to use this constructor. |
| 66 AutofillManager(TabContentsWrapper* tab_contents, | 75 AutofillManager(TabContentsWrapper* tab_contents, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 // Methods for packing and unpacking credit card and profile IDs for sending | 92 // Methods for packing and unpacking credit card and profile IDs for sending |
| 84 // and receiving to and from the renderer process. | 93 // and receiving to and from the renderer process. |
| 85 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; | 94 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const; |
| 86 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; | 95 void UnpackGUIDs(int id, GUIDPair* cc_guid, GUIDPair* profile_guid) const; |
| 87 | 96 |
| 88 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } | 97 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } |
| 89 void set_metric_logger(const AutofillMetrics* metric_logger); | 98 void set_metric_logger(const AutofillMetrics* metric_logger); |
| 90 | 99 |
| 91 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } | 100 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } |
| 92 | 101 |
| 102 // Called from our external delegate so it cannot be private. |
| 103 void OnFillAutoFillFormData(int query_id, |
| 104 const webkit_glue::FormData& form, |
| 105 const webkit_glue::FormField& field, |
| 106 int unique_id); |
| 107 |
| 108 // Exposed for testing. |
| 109 AutofillExternalDelegate* external_delegate() { |
| 110 return external_delegate_; |
| 111 } |
| 112 |
| 93 private: | 113 private: |
| 94 // TabContentsObserver: | 114 // TabContentsObserver: |
| 95 virtual void DidNavigateMainFramePostCommit( | 115 virtual void DidNavigateMainFramePostCommit( |
| 96 const content::LoadCommittedDetails& details, | 116 const content::LoadCommittedDetails& details, |
| 97 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 117 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
| 98 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 118 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 99 | 119 |
| 100 // AutofillDownloadManager::Observer: | 120 // AutofillDownloadManager::Observer: |
| 101 virtual void OnLoadedServerPredictions( | 121 virtual void OnLoadedServerPredictions( |
| 102 const std::string& response_xml) OVERRIDE; | 122 const std::string& response_xml) OVERRIDE; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // page. | 281 // page. |
| 262 base::TimeTicks initial_interaction_timestamp_; | 282 base::TimeTicks initial_interaction_timestamp_; |
| 263 | 283 |
| 264 // Our copy of the form data. | 284 // Our copy of the form data. |
| 265 ScopedVector<FormStructure> form_structures_; | 285 ScopedVector<FormStructure> form_structures_; |
| 266 | 286 |
| 267 // GUID to ID mapping. We keep two maps to convert back and forth. | 287 // GUID to ID mapping. We keep two maps to convert back and forth. |
| 268 mutable std::map<GUIDPair, int> guid_id_map_; | 288 mutable std::map<GUIDPair, int> guid_id_map_; |
| 269 mutable std::map<int, GUIDPair> id_guid_map_; | 289 mutable std::map<int, GUIDPair> id_guid_map_; |
| 270 | 290 |
| 291 // Delegate to perform external processing (display, selection) on |
| 292 // our behalf. Weak. |
| 293 AutofillExternalDelegate* external_delegate_; |
| 294 |
| 271 friend class AutofillManagerTest; | 295 friend class AutofillManagerTest; |
| 272 friend class FormStructureBrowserTest; | 296 friend class FormStructureBrowserTest; |
| 273 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 297 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 274 DeterminePossibleFieldTypesForUpload); | 298 DeterminePossibleFieldTypesForUpload); |
| 275 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 299 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 276 DeterminePossibleFieldTypesForUploadStressTest); | 300 DeterminePossibleFieldTypesForUploadStressTest); |
| 277 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); | 301 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AddressSuggestionsCount); |
| 278 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); | 302 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtPageLoad); |
| 279 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 303 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 280 NoQualityMetricsForNonAutofillableForms); | 304 NoQualityMetricsForNonAutofillableForms); |
| 281 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics); | 305 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetrics); |
| 282 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); | 306 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsForFailure); |
| 283 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); | 307 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, QualityMetricsWithExperimentId); |
| 284 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); | 308 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, SaneMetricsWithCacheMismatch); |
| 309 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, TestExternalDelegate); |
| 310 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 311 TestTabContentsWithExternalDelegate); |
| 285 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, | 312 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, |
| 286 UserHappinessFormLoadAndSubmission); | 313 UserHappinessFormLoadAndSubmission); |
| 287 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); | 314 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, UserHappinessFormInteraction); |
| 288 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); | 315 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FormFillDuration); |
| 289 | 316 |
| 290 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 317 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 291 }; | 318 }; |
| 292 | 319 |
| 293 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 320 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |