| OLD | NEW |
| 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 <list> |
| 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 #include <string> | |
| 11 | 12 |
| 12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 13 #include "base/scoped_vector.h" | 14 #include "base/scoped_vector.h" |
| 14 #include "chrome/browser/autofill/autofill_dialog.h" | 15 #include "chrome/browser/autofill/autofill_dialog.h" |
| 15 #include "chrome/browser/autofill/autofill_download.h" | 16 #include "chrome/browser/autofill/autofill_download.h" |
| 16 #include "chrome/browser/autofill/personal_data_manager.h" | 17 #include "chrome/browser/autofill/personal_data_manager.h" |
| 17 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 18 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 18 | 19 |
| 19 class AutoFillCCInfoBarDelegate; | 20 class AutoFillCCInfoBarDelegate; |
| 20 class AutoFillProfile; | 21 class AutoFillProfile; |
| 21 class CreditCard; | 22 class CreditCard; |
| 22 class FormStructure; | 23 class FormStructure; |
| 23 class PrefService; | 24 class PrefService; |
| 24 class TabContents; | 25 class TabContents; |
| 25 | 26 |
| 26 namespace webkit_glue { | 27 namespace webkit_glue { |
| 27 struct FormData; | 28 struct FormData; |
| 28 class FormField; | 29 class FormField; |
| 29 } // namespace webkit_glue | 30 } // namespace webkit_glue |
| 30 | 31 |
| 31 // TODO(jhawkins): Maybe this should be in a grd file? | 32 // TODO(jhawkins): Maybe this should be in a grd file? |
| 32 extern const char* kAutoFillLearnMoreUrl; | 33 extern const char* kAutoFillLearnMoreUrl; |
| 33 | 34 |
| 34 // Manages saving and restoring the user's personal information entered into web | 35 // Manages saving and restoring the user's personal information entered into web |
| 35 // forms. | 36 // forms. |
| 36 class AutoFillManager : public RenderViewHostDelegate::AutoFill, | 37 class AutoFillManager : public RenderViewHostDelegate::AutoFill, |
| 37 public AutoFillDownloadManager::Observer { | 38 public AutoFillDownloadManager::Observer, |
| 39 public PersonalDataManager::Observer { |
| 38 public: | 40 public: |
| 39 explicit AutoFillManager(TabContents* tab_contents); | 41 explicit AutoFillManager(TabContents* tab_contents); |
| 40 virtual ~AutoFillManager(); | 42 virtual ~AutoFillManager(); |
| 41 | 43 |
| 42 // Registers our browser prefs. | 44 // Registers our browser prefs. |
| 43 static void RegisterBrowserPrefs(PrefService* prefs); | 45 static void RegisterBrowserPrefs(PrefService* prefs); |
| 44 | 46 |
| 45 // Registers our Enable/Disable AutoFill pref. | 47 // Registers our Enable/Disable AutoFill pref. |
| 46 static void RegisterUserPrefs(PrefService* prefs); | 48 static void RegisterUserPrefs(PrefService* prefs); |
| 47 | 49 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 virtual void Reset(); | 71 virtual void Reset(); |
| 70 | 72 |
| 71 // AutoFillDownloadManager::Observer implementation: | 73 // AutoFillDownloadManager::Observer implementation: |
| 72 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); | 74 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); |
| 73 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); | 75 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); |
| 74 virtual void OnHeuristicsRequestError( | 76 virtual void OnHeuristicsRequestError( |
| 75 const std::string& form_signature, | 77 const std::string& form_signature, |
| 76 AutoFillDownloadManager::AutoFillRequestType request_type, | 78 AutoFillDownloadManager::AutoFillRequestType request_type, |
| 77 int http_error); | 79 int http_error); |
| 78 | 80 |
| 81 // PersonalDataManager::Observer implementation: |
| 82 virtual void OnPersonalDataLoaded(); |
| 83 |
| 79 // Returns the value of the AutoFillEnabled pref. | 84 // Returns the value of the AutoFillEnabled pref. |
| 80 virtual bool IsAutoFillEnabled() const; | 85 virtual bool IsAutoFillEnabled() const; |
| 81 | 86 |
| 82 // Uses heuristics and existing personal data to determine the possible field | 87 // Uses heuristics and existing personal data to determine the possible field |
| 83 // types. | 88 // types. |
| 84 void DeterminePossibleFieldTypes(FormStructure* form_structure); | 89 void DeterminePossibleFieldTypes(FormStructure* form_structure); |
| 85 | 90 |
| 86 // Handles the form data submitted by the user. | 91 // Handles the form data submitted by the user. |
| 87 void HandleSubmit(); | 92 void HandleSubmit(); |
| 88 | 93 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 AutoFillDownloadManager download_manager_; | 200 AutoFillDownloadManager download_manager_; |
| 196 | 201 |
| 197 // Should be set to true in AutoFillManagerTest and other tests, false in | 202 // Should be set to true in AutoFillManagerTest and other tests, false in |
| 198 // AutoFillDownloadManagerTest and in non-test environment. Is false by | 203 // AutoFillDownloadManagerTest and in non-test environment. Is false by |
| 199 // default. | 204 // default. |
| 200 bool disable_download_manager_requests_; | 205 bool disable_download_manager_requests_; |
| 201 | 206 |
| 202 // Our copy of the form data. | 207 // Our copy of the form data. |
| 203 ScopedVector<FormStructure> form_structures_; | 208 ScopedVector<FormStructure> form_structures_; |
| 204 | 209 |
| 210 // Forms delayed for parsing, because personal data were not loaded yet. |
| 211 std::list<std::vector<webkit_glue::FormData> > delayed_forms_; |
| 212 |
| 205 // The form data the user has submitted. | 213 // The form data the user has submitted. |
| 206 scoped_ptr<FormStructure> upload_form_structure_; | 214 scoped_ptr<FormStructure> upload_form_structure_; |
| 207 | 215 |
| 208 // The InfoBar that asks for permission to store credit card information. | 216 // The InfoBar that asks for permission to store credit card information. |
| 209 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_; | 217 scoped_ptr<AutoFillCCInfoBarDelegate> cc_infobar_; |
| 210 | 218 |
| 211 friend class TestAutoFillManager; | 219 friend class TestAutoFillManager; |
| 212 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); | 220 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm); |
| 213 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon); | 221 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon); |
| 214 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon); | 222 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon); |
| 215 | 223 |
| 216 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); | 224 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); |
| 217 }; | 225 }; |
| 218 | 226 |
| 219 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 227 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |