summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill_manager.cc
diff options
context:
space:
mode:
authorpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-08 02:38:04 +0000
committerpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-08 02:38:04 +0000
commitf0961cfdecddaaac9c89fb65c67ba3377d066043 (patch)
tree61ad1f994b2130b8fbc67555d08319c14fa5793b /chrome/browser/autofill_manager.cc
parentd893ab9643e5284db08087bc7514f59e37d6b319 (diff)
downloadchromium_src-f0961cfdecddaaac9c89fb65c67ba3377d066043.zip
chromium_src-f0961cfdecddaaac9c89fb65c67ba3377d066043.tar.gz
chromium_src-f0961cfdecddaaac9c89fb65c67ba3377d066043.tar.bz2
Review URL: http://codereview.chromium.org/10237
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5059 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill_manager.cc')
-rw-r--r--chrome/browser/autofill_manager.cc56
1 files changed, 14 insertions, 42 deletions
diff --git a/chrome/browser/autofill_manager.cc b/chrome/browser/autofill_manager.cc
index 9493992..af8589b 100644
--- a/chrome/browser/autofill_manager.cc
+++ b/chrome/browser/autofill_manager.cc
@@ -8,21 +8,15 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/web_contents.h"
-AutofillManager::AutofillManager(WebContents* web_contents) :
- web_contents_(web_contents),
- pending_query_handle_(0),
- node_id_(0),
- request_id_(0) {
- form_autofill_enabled_.Init(prefs::kFormAutofillEnabled,
- profile()->GetPrefs(), NULL);
-}
-
AutofillManager::~AutofillManager() {
- CancelPendingQuery();
+ ClearPendingQuery();
}
-void AutofillManager::CancelPendingQuery() {
- if (pending_query_handle_) {
+void AutofillManager::ClearPendingQuery() {
+ pending_query_name_.clear();
+ pending_query_prefix_.clear();
+
+ if (query_is_pending_) {
WebDataService* web_data_service =
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service) {
@@ -32,10 +26,7 @@ void AutofillManager::CancelPendingQuery() {
web_data_service->CancelRequest(pending_query_handle_);
}
pending_query_handle_ = 0;
-}
-
-Profile* AutofillManager::profile() {
- return web_contents_->profile();
+ query_is_pending_ = false;
}
void AutofillManager::AutofillFormSubmitted(const AutofillForm& form) {
@@ -44,12 +35,7 @@ void AutofillManager::AutofillFormSubmitted(const AutofillForm& form) {
void AutofillManager::FetchValuesForName(const std::wstring& name,
const std::wstring& prefix,
- int limit,
- int64 node_id,
- int request_id) {
- if (!*form_autofill_enabled_)
- return;
-
+ int limit) {
WebDataService* web_data_service =
profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (!web_data_service) {
@@ -57,22 +43,17 @@ void AutofillManager::FetchValuesForName(const std::wstring& name,
return;
}
- CancelPendingQuery();
-
- node_id_ = node_id;
- request_id_ = request_id;
+ ClearPendingQuery();
pending_query_handle_ = web_data_service->
GetFormValuesForElementName(name, prefix, limit, this);
+ pending_query_name_ = name;
+ pending_query_prefix_ = prefix;
}
void AutofillManager::OnWebDataServiceRequestDone(WebDataService::Handle h,
const WDTypedResult* result) {
- DCHECK(pending_query_handle_);
- pending_query_handle_ = 0;
-
- if (!*form_autofill_enabled_)
- return;
+ DCHECK(query_is_pending_);
DCHECK(result);
if (!result)
@@ -80,27 +61,18 @@ void AutofillManager::OnWebDataServiceRequestDone(WebDataService::Handle h,
switch (result->GetType()) {
case AUTOFILL_VALUE_RESULT: {
- RenderViewHost* host = web_contents_->render_view_host();
- if (!host)
- return;
- const WDResult<std::vector<std::wstring> >* r =
- static_cast<const WDResult<std::vector<std::wstring> >*>(result);
- std::vector<std::wstring> suggestions = r->GetValue();
- host->AutofillSuggestionsReturned(suggestions, node_id_, request_id_, -1);
break;
}
-
default:
NOTREACHED();
break;
}
+
+ ClearPendingQuery();
}
void AutofillManager::StoreFormEntriesInWebDatabase(
const AutofillForm& form) {
- if (!*form_autofill_enabled_)
- return;
-
if (profile()->IsOffTheRecord())
return;