diff options
author | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 20:26:28 +0000 |
---|---|---|
committer | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 20:26:28 +0000 |
commit | 6f2ff8526c54090bf6afe9c80f2d63551231e997 (patch) | |
tree | 2cacbf423441a4f442e8ec01a176c519154c7112 /chrome/browser/autofill_manager.h | |
parent | 2b481f8d533c08824d3aeeeb9a0407b596077c16 (diff) | |
download | chromium_src-6f2ff8526c54090bf6afe9c80f2d63551231e997.zip chromium_src-6f2ff8526c54090bf6afe9c80f2d63551231e997.tar.gz chromium_src-6f2ff8526c54090bf6afe9c80f2d63551231e997.tar.bz2 |
Added functions to WebDatabase and WebDataService for recording frequent entries in text input elements in forms. Also added the class AutofillManager which gets instantiated once per WebContents and provides an API from which the database can be easily accessed to provide a list of possible desired values to be entered in a text field given what the user has already typed there.
Review URL: http://codereview.chromium.org/8845
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill_manager.h')
-rw-r--r-- | chrome/browser/autofill_manager.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/browser/autofill_manager.h b/chrome/browser/autofill_manager.h new file mode 100644 index 0000000..fac533f --- /dev/null +++ b/chrome/browser/autofill_manager.h @@ -0,0 +1,58 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_AUTOFILL_MANAGER_H_ +#define CHROME_BROWSER_AUTOFILL_MANAGER_H_ + +#include <map> +#include <string> + +#include "chrome/browser/webdata/web_data_service.h" +#include "chrome/browser/web_contents.h" +#include "webkit/glue/autofill_form.h" + +class Profile; + +// Per-tab autofill manager. Handles receiving form data from the renderer and +// the storing and retrieving of form data through WebDataService. +class AutofillManager : public WebDataServiceConsumer { + public: + explicit AutofillManager(WebContents* web_contents) + : query_is_pending_(false), web_contents_(web_contents) {} + virtual ~AutofillManager(); + + void ClearPendingQuery(); + + Profile* profile() { return web_contents_->profile(); } + + // Called when a form is submitted (i.e. when the user hits the submit button) + // to store the form entries in the profile's sql database. + void AutofillFormSubmitted(const AutofillForm& form); + + // Starts a query into the database for the values corresponding to name. + // OnWebDataServiceRequestDone gets called when the query completes. + void FetchValuesForName(const std::wstring& name, const std::wstring& prefix, + int limit); + + // WebDataServiceConsumer implementation. + virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, + const WDTypedResult* result); + + private: + void StoreFormEntriesInWebDatabase(const AutofillForm& form); + + WebContents* web_contents_; + + // When the manager makes a request from WebDataService, the database + // is queried on another thread, we record the query in this map until we + // get called back. + bool query_is_pending_; + WebDataService::Handle pending_query_handle_; + std::wstring pending_query_name_; + std::wstring pending_query_prefix_; + + DISALLOW_COPY_AND_ASSIGN(AutofillManager); +}; + +#endif // CHROME_BROWSER_AUTOFILL_MANAGER_H_ |