diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 01:28:55 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 01:28:55 +0000 |
commit | 2cd7eb8743299ff81a2c7054650b21c5a11dd376 (patch) | |
tree | c9001e097fa526b0488385a08b6adc9b0c9f1584 /webkit/glue/webframe_impl.h | |
parent | 5c6f1c6b32f9da207706cf2d94560196e9d20303 (diff) | |
download | chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.zip chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.tar.gz chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.tar.bz2 |
A new implementation of the autofill using the editor client API.
This simplifies code as we don't need to listen for events on input elements, the editor client API is only triggered when the text changes.
The only quirk we have to work around is that when the editor client API notifies us that the text has changed, the selection is not set properly, preventing us from reliably finding out if the caret is at the end of the text.
To work around that issue, we post a task that does the autofill after the text change callback.
BUG=None
TEST=Trigger the autofill behavior with form and passwords.
Review URL: http://codereview.chromium.org/11479
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webframe_impl.h')
-rw-r--r-- | webkit/glue/webframe_impl.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index b3b241a..d50762d 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -33,7 +33,7 @@ #include "base/gfx/platform_canvas.h" #include "base/scoped_ptr.h" #include "base/task.h" -#include "webkit/glue/form_autocomplete_listener.h" +#include "webkit/glue/password_autocomplete_listener.h" #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webframeloaderclient_impl.h" @@ -271,14 +271,20 @@ class WebFrameImpl : public WebFrame { virtual bool IsReloadAllowingStaleData() const; - // Returns the listener used for autocomplete. Creates it and registers it on - // the frame body node on the first invocation. - webkit_glue::AutocompleteBodyListener* GetAutocompleteListener(); - - // Nulls the autocomplete listener for this frame. Useful as a frame might - // be reused (on reload for example), in which case a new body element is - // created and the existing autocomplete listener becomes useless. - void ClearAutocompleteListener(); + // Registers a listener for the specified user name input element. The + // listener will receive notifications for blur and when autocomplete should + // be triggered. + // The WebFrameImpl becomes the owner of the passed listener. + void RegisterPasswordListener( + PassRefPtr<WebCore::HTMLInputElement> user_name_input_element, + webkit_glue::PasswordAutocompleteListener* listener); + + // Returns the password autocomplete listener associated with the passed + // user name input element, or NULL if none available. + // Note that the returned listener is owner by the WebFrameImpl and should not + // be kept around as it is deleted when the page goes away. + webkit_glue::PasswordAutocompleteListener* GetPasswordListener( + WebCore::HTMLInputElement* user_name_input_element); protected: friend class WebFrameLoaderClient; @@ -440,14 +446,20 @@ class WebFrameImpl : public WebFrame { const WebCore::SubstituteData& data, bool replace); + // Clears the map of password listeners. + void ClearPasswordListeners(); + // In "printing" mode. Used as a state check. bool printing_; // For each printed page, the view of the document in pixels. Vector<WebCore::IntRect> pages_; - // The listener responsible for showing form autocomplete suggestions. - RefPtr<webkit_glue::AutocompleteBodyListener> form_autocomplete_listener_; + // The input fields that are interested in edit events and their associated + // listeners. + typedef HashMap<RefPtr<WebCore::HTMLInputElement>, + webkit_glue::PasswordAutocompleteListener*> PasswordListenerMap; + PasswordListenerMap password_listeners_; DISALLOW_COPY_AND_ASSIGN(WebFrameImpl); }; |