| 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> | 9 #include <list> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 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/personal_data_manager.h" | 18 #include "chrome/browser/autofill/personal_data_manager.h" |
| 19 #include "ipc/ipc_channel.h" | 19 #include "chrome/browser/tab_contents/web_navigation_observer.h" |
| 20 | 20 |
| 21 class AutoFillCCInfoBarDelegate; | 21 class AutoFillCCInfoBarDelegate; |
| 22 class AutoFillProfile; | 22 class AutoFillProfile; |
| 23 class AutoFillMetrics; | 23 class AutoFillMetrics; |
| 24 class CreditCard; | 24 class CreditCard; |
| 25 class FormStructure; | 25 class FormStructure; |
| 26 class PrefService; | 26 class PrefService; |
| 27 class RenderViewHost; | 27 class RenderViewHost; |
| 28 class TabContents; | |
| 29 | 28 |
| 30 namespace webkit_glue { | 29 namespace webkit_glue { |
| 31 struct FormData; | 30 struct FormData; |
| 32 class FormField; | 31 class FormField; |
| 33 } // namespace webkit_glue | 32 } // namespace webkit_glue |
| 34 | 33 |
| 35 // Manages saving and restoring the user's personal information entered into web | 34 // Manages saving and restoring the user's personal information entered into web |
| 36 // forms. | 35 // forms. |
| 37 class AutoFillManager : public IPC::Channel::Listener, | 36 class AutoFillManager : public WebNavigationObserver, |
| 38 public AutoFillDownloadManager::Observer { | 37 public AutoFillDownloadManager::Observer { |
| 39 public: | 38 public: |
| 40 explicit AutoFillManager(TabContents* tab_contents); | 39 explicit AutoFillManager(TabContents* tab_contents); |
| 41 virtual ~AutoFillManager(); | 40 virtual ~AutoFillManager(); |
| 42 | 41 |
| 43 // Registers our browser prefs. | 42 // Registers our browser prefs. |
| 44 static void RegisterBrowserPrefs(PrefService* prefs); | 43 static void RegisterBrowserPrefs(PrefService* prefs); |
| 45 | 44 |
| 46 // Registers our Enable/Disable AutoFill pref. | 45 // Registers our Enable/Disable AutoFill pref. |
| 47 static void RegisterUserPrefs(PrefService* prefs); | 46 static void RegisterUserPrefs(PrefService* prefs); |
| 48 | 47 |
| 49 // Returns the TabContents hosting this AutoFillManager. | 48 // Returns the TabContents hosting this AutoFillManager. |
| 50 TabContents* tab_contents() const { return tab_contents_; } | 49 TabContents* tab_contents() const { return tab_contents_; } |
| 51 | 50 |
| 52 // IPC::Channel::Listener implementation. | 51 // WebNavigationObserver implementation. |
| 52 virtual void DidNavigateMainFramePostCommit( |
| 53 const NavigationController::LoadCommittedDetails& details, |
| 54 const ViewHostMsg_FrameNavigate_Params& params); |
| 55 virtual void TranslateStarted(); |
| 53 virtual bool OnMessageReceived(const IPC::Message& message); | 56 virtual bool OnMessageReceived(const IPC::Message& message); |
| 54 | 57 |
| 55 // Called by the AutoFillCCInfoBarDelegate when the user interacts with the | 58 // Called by the AutoFillCCInfoBarDelegate when the user interacts with the |
| 56 // infobar. | 59 // infobar. |
| 57 virtual void OnInfoBarClosed(bool should_save); | 60 virtual void OnInfoBarClosed(bool should_save); |
| 58 | 61 |
| 59 // AutoFillDownloadManager::Observer implementation: | 62 // AutoFillDownloadManager::Observer implementation: |
| 60 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); | 63 virtual void OnLoadedAutoFillHeuristics(const std::string& heuristic_xml); |
| 61 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); | 64 virtual void OnUploadedAutoFillHeuristics(const std::string& form_signature); |
| 62 virtual void OnHeuristicsRequestError( | 65 virtual void OnHeuristicsRequestError( |
| 63 const std::string& form_signature, | 66 const std::string& form_signature, |
| 64 AutoFillDownloadManager::AutoFillRequestType request_type, | 67 AutoFillDownloadManager::AutoFillRequestType request_type, |
| 65 int http_error); | 68 int http_error); |
| 66 | 69 |
| 67 // Returns the value of the AutoFillEnabled pref. | 70 // Returns the value of the AutoFillEnabled pref. |
| 68 virtual bool IsAutoFillEnabled() const; | 71 virtual bool IsAutoFillEnabled() const; |
| 69 | 72 |
| 70 // Handles the form data submitted by the user. | 73 // Handles the form data submitted by the user. |
| 71 void HandleSubmit(); | 74 void HandleSubmit(); |
| 72 | 75 |
| 73 // Uploads the form data to the AutoFill server. | 76 // Uploads the form data to the AutoFill server. |
| 74 void UploadFormData(); | 77 void UploadFormData(); |
| 75 | 78 |
| 76 // Reset cache. | |
| 77 void Reset(); | |
| 78 | |
| 79 protected: | 79 protected: |
| 80 // For tests. | 80 // For tests. |
| 81 AutoFillManager(); | 81 AutoFillManager(); |
| 82 AutoFillManager(TabContents* tab_contents, | 82 AutoFillManager(TabContents* tab_contents, |
| 83 PersonalDataManager* personal_data); | 83 PersonalDataManager* personal_data); |
| 84 | 84 |
| 85 // Reset cache. |
| 86 void Reset(); |
| 87 |
| 85 void set_personal_data_manager(PersonalDataManager* personal_data) { | 88 void set_personal_data_manager(PersonalDataManager* personal_data) { |
| 86 personal_data_ = personal_data; | 89 personal_data_ = personal_data; |
| 87 } | 90 } |
| 88 | 91 |
| 89 const AutoFillMetrics* metric_logger() const { | 92 const AutoFillMetrics* metric_logger() const { |
| 90 return metric_logger_.get(); | 93 return metric_logger_.get(); |
| 91 } | 94 } |
| 92 void set_metric_logger(const AutoFillMetrics* metric_logger); | 95 void set_metric_logger(const AutoFillMetrics* metric_logger); |
| 93 | 96 |
| 94 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } | 97 ScopedVector<FormStructure>* form_structures() { return &form_structures_; } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField); | 229 FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FormChangesAddField); |
| 227 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetrics); | 230 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetrics); |
| 228 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, | 231 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, |
| 229 NoQualityMetricsForNonAutoFillableForms); | 232 NoQualityMetricsForNonAutoFillableForms); |
| 230 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetricsForFailure); | 233 FRIEND_TEST_ALL_PREFIXES(AutoFillMetricsTest, QualityMetricsForFailure); |
| 231 | 234 |
| 232 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); | 235 DISALLOW_COPY_AND_ASSIGN(AutoFillManager); |
| 233 }; | 236 }; |
| 234 | 237 |
| 235 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ | 238 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ |
| OLD | NEW |