diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 21:03:32 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 21:03:32 +0000 |
commit | 895044f91ab417ddaf19f5e176d744cc76f866bb (patch) | |
tree | 4c46a231915b4453341435e23f6f9e6c66b374d6 /chrome/browser/autofill | |
parent | fa9ed6a0cd30041c269398e99f3f34ef070d8666 (diff) | |
download | chromium_src-895044f91ab417ddaf19f5e176d744cc76f866bb.zip chromium_src-895044f91ab417ddaf19f5e176d744cc76f866bb.tar.gz chromium_src-895044f91ab417ddaf19f5e176d744cc76f866bb.tar.bz2 |
Fix for: Autofill on Windows does not work for the first autofillable page encountered.
BUG=51831
TEST=In the bug.
Review URL: http://codereview.chromium.org/3149005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57385 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 20 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 12 |
2 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 27113cb..e6ae19d 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -107,10 +107,14 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents) personal_data_ = tab_contents_->profile()->GetOriginalProfile()->GetPersonalDataManager(); download_manager_.SetObserver(this); + if (personal_data_) + personal_data_->SetObserver(this); } AutoFillManager::~AutoFillManager() { download_manager_.SetObserver(NULL); + if (personal_data_) + personal_data_->RemoveObserver(this); } // static @@ -159,6 +163,12 @@ void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) { if (!IsAutoFillEnabled()) return; + if (!personal_data_->IsDataLoaded()) { + // Profile data is in the process of loading: delay parsing of the forms. + delayed_forms_.push_back(forms); + return; + } + // No profiles or credit cards, no need to parse the forms. if (personal_data_->profiles().empty() && personal_data_->credit_cards().empty()) @@ -403,6 +413,14 @@ void AutoFillManager::OnHeuristicsRequestError( int http_error) { } +void AutoFillManager::OnPersonalDataLoaded() { + DCHECK(personal_data_->IsDataLoaded()); + while (!delayed_forms_.empty()) { + FormsSeen(delayed_forms_.front()); + delayed_forms_.pop_front(); + } +} + bool AutoFillManager::IsAutoFillEnabled() const { PrefService* prefs = tab_contents_->profile()->GetPrefs(); @@ -477,6 +495,8 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents, download_manager_(NULL), disable_download_manager_requests_(false) { DCHECK(tab_contents); + if (personal_data_) + personal_data_->SetObserver(this); } void AutoFillManager::GetProfileSuggestions(FormStructure* form, diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index 387e6df..c0e79fd 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -6,8 +6,9 @@ #define CHROME_BROWSER_AUTOFILL_AUTOFILL_MANAGER_H_ #pragma once -#include <vector> +#include <list> #include <string> +#include <vector> #include "base/scoped_ptr.h" #include "base/scoped_vector.h" @@ -34,7 +35,8 @@ extern const char* kAutoFillLearnMoreUrl; // Manages saving and restoring the user's personal information entered into web // forms. class AutoFillManager : public RenderViewHostDelegate::AutoFill, - public AutoFillDownloadManager::Observer { + public AutoFillDownloadManager::Observer, + public PersonalDataManager::Observer { public: explicit AutoFillManager(TabContents* tab_contents); virtual ~AutoFillManager(); @@ -76,6 +78,9 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, AutoFillDownloadManager::AutoFillRequestType request_type, int http_error); + // PersonalDataManager::Observer implementation: + virtual void OnPersonalDataLoaded(); + // Returns the value of the AutoFillEnabled pref. virtual bool IsAutoFillEnabled() const; @@ -202,6 +207,9 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, // Our copy of the form data. ScopedVector<FormStructure> form_structures_; + // Forms delayed for parsing, because personal data were not loaded yet. + std::list<std::vector<webkit_glue::FormData> > delayed_forms_; + // The form data the user has submitted. scoped_ptr<FormStructure> upload_form_structure_; |