diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 19:36:16 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 19:36:16 +0000 |
commit | e768baf6ebf5a49cc19d58d1761321b175c82c18 (patch) | |
tree | c29fb1ebcef46d9ad929ed1fd68f954a04f97b06 /webkit/glue | |
parent | a850e9592bb1a8c43275116ff565c91b4b1cb66b (diff) | |
download | chromium_src-e768baf6ebf5a49cc19d58d1761321b175c82c18.zip chromium_src-e768baf6ebf5a49cc19d58d1761321b175c82c18.tar.gz chromium_src-e768baf6ebf5a49cc19d58d1761321b175c82c18.tar.bz2 |
Separate the PasswordManagerDelegate out of PasswordManager.
Previously, anyone who included tab_contents.h would bring in a bunch of
implementation details of the password manager from webkit_glue. This breaks
the delegate interface out of the rest of password manager system and makes
FillData not an inner-class so anyone can forward declare FillData instead of
having to include the header to meet a delegate interface.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2877022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/dom_operations.cc | 3 | ||||
-rw-r--r-- | webkit/glue/dom_operations.h | 8 | ||||
-rw-r--r-- | webkit/glue/password_form_dom_manager.cc | 8 | ||||
-rw-r--r-- | webkit/glue/password_form_dom_manager.h | 38 | ||||
-rw-r--r-- | webkit/glue/webpasswordautocompletelistener_impl.cc | 6 | ||||
-rw-r--r-- | webkit/glue/webpasswordautocompletelistener_impl.h | 5 | ||||
-rw-r--r-- | webkit/glue/webpasswordautocompletelistener_unittest.cc | 3 |
7 files changed, 41 insertions, 30 deletions
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 017c3c6..82e5e3a 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -19,6 +19,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/form_data.h" +#include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/webpasswordautocompletelistener_impl.h" using WebKit::WebAnimationController; @@ -272,7 +273,7 @@ static void FindFormElements(WebView* view, } void FillPasswordForm(WebView* view, - const PasswordFormDomManager::FillData& data) { + const PasswordFormFillData& data) { FormElementsList forms; // We own the FormElements* in forms. FindFormElements(view, data.basic_data, &forms); diff --git a/webkit/glue/dom_operations.h b/webkit/glue/dom_operations.h index b8915be..664add0 100644 --- a/webkit/glue/dom_operations.h +++ b/webkit/glue/dom_operations.h @@ -11,19 +11,23 @@ #include "gfx/size.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/password_form_dom_manager.h" namespace WebKit { +class WebDocument; +class WebElement; +class WebString; class WebView; } // A collection of operations that access the underlying WebKit DOM directly. namespace webkit_glue { +struct PasswordFormFillData; + // Fill matching password forms and trigger autocomplete in the case of multiple // matching logins. void FillPasswordForm(WebKit::WebView* view, - const PasswordFormDomManager::FillData& data); + const PasswordFormFillData& data); // Structure for storage the result of getting all savable resource links // for current page. The consumer of the SavableResourcesResult is responsible diff --git a/webkit/glue/password_form_dom_manager.cc b/webkit/glue/password_form_dom_manager.cc index 5db9138..adbb8dd 100644 --- a/webkit/glue/password_form_dom_manager.cc +++ b/webkit/glue/password_form_dom_manager.cc @@ -15,6 +15,12 @@ using WebKit::WebPasswordFormData; namespace webkit_glue { +PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { +} + +PasswordFormFillData::~PasswordFormFillData() { +} + PasswordForm* PasswordFormDomManager::CreatePasswordForm( const WebFormElement& webform) { WebPasswordFormData web_password_form(webform); @@ -29,7 +35,7 @@ void PasswordFormDomManager::InitFillData( const PasswordFormMap& matches, const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, - PasswordFormDomManager::FillData* result) { + PasswordFormFillData* result) { DCHECK(preferred_match); // Fill basic form data. result->basic_data.origin = form_on_page.origin; diff --git a/webkit/glue/password_form_dom_manager.h b/webkit/glue/password_form_dom_manager.h index 8704573..63a6f45 100644 --- a/webkit/glue/password_form_dom_manager.h +++ b/webkit/glue/password_form_dom_manager.h @@ -16,27 +16,27 @@ class GURL; namespace webkit_glue { -class PasswordFormDomManager { - public: +// Structure used for autofilling password forms. +// basic_data identifies the HTML form on the page and preferred username/ +// password for login, while +// additional_logins is a list of other matching user/pass pairs for the form. +// wait_for_username tells us whether we need to wait for the user to enter +// a valid username before we autofill the password. By default, this is off +// unless the PasswordManager determined there is an additional risk +// associated with this form. This can happen, for example, if action URI's +// of the observed form and our saved representation don't match up. +struct PasswordFormFillData { typedef std::map<string16, string16> LoginCollection; - // Structure used for autofilling password forms. - // basic_data identifies the HTML form on the page and preferred username/ - // password for login, while - // additional_logins is a list of other matching user/pass pairs for the form. - // wait_for_username tells us whether we need to wait for the user to enter - // a valid username before we autofill the password. By default, this is off - // unless the PasswordManager determined there is an additional risk - // associated with this form. This can happen, for example, if action URI's - // of the observed form and our saved representation don't match up. - struct FillData { - FormData basic_data; - LoginCollection additional_logins; - bool wait_for_username; - FillData() : wait_for_username(false) { - } - }; + FormData basic_data; + LoginCollection additional_logins; + bool wait_for_username; + PasswordFormFillData(); + ~PasswordFormFillData(); +}; +class PasswordFormDomManager { + public: // Create a PasswordForm from DOM form. Webkit doesn't allow storing // custom metadata to DOM nodes, so we have to do this every time an event // happens with a given form and compare against previously Create'd forms @@ -53,7 +53,7 @@ class PasswordFormDomManager { const PasswordFormMap& matches, const PasswordForm* const preferred_match, bool wait_for_username_before_autofill, - FillData* result); + PasswordFormFillData* result); private: DISALLOW_IMPLICIT_CONSTRUCTORS(PasswordFormDomManager); }; diff --git a/webkit/glue/webpasswordautocompletelistener_impl.cc b/webkit/glue/webpasswordautocompletelistener_impl.cc index 5caeae1..6f6e754 100644 --- a/webkit/glue/webpasswordautocompletelistener_impl.cc +++ b/webkit/glue/webpasswordautocompletelistener_impl.cc @@ -74,7 +74,7 @@ void WebInputElementDelegate::RefreshAutofillPopup( WebPasswordAutocompleteListenerImpl::WebPasswordAutocompleteListenerImpl( WebInputElementDelegate* username_delegate, WebInputElementDelegate* password_delegate, - const PasswordFormDomManager::FillData& data) + const PasswordFormFillData& data) : password_delegate_(password_delegate), username_delegate_(username_delegate), data_(data) { @@ -144,7 +144,7 @@ void WebPasswordAutocompleteListenerImpl::performInlineAutocomplete( } // Scan additional logins for a match. - for (PasswordFormDomManager::LoginCollection::iterator it = + for (PasswordFormFillData::LoginCollection::iterator it = data_.additional_logins.begin(); it != data_.additional_logins.end(); ++it) { @@ -185,7 +185,7 @@ void WebPasswordAutocompleteListenerImpl::GetSuggestions( if (StartsWith(data_.basic_data.fields[0].value(), input, false)) suggestions->push_back(data_.basic_data.fields[0].value()); - for (PasswordFormDomManager::LoginCollection::iterator it = + for (PasswordFormFillData::LoginCollection::iterator it = data_.additional_logins.begin(); it != data_.additional_logins.end(); ++it) { diff --git a/webkit/glue/webpasswordautocompletelistener_impl.h b/webkit/glue/webpasswordautocompletelistener_impl.h index ca4604b..4fea455 100644 --- a/webkit/glue/webpasswordautocompletelistener_impl.h +++ b/webkit/glue/webpasswordautocompletelistener_impl.h @@ -19,7 +19,6 @@ using WebKit::WebString; namespace webkit_glue { - // A proxy interface to a WebInputElement for inline autocomplete. The proxy // is overridden by webpasswordautocompletelistener_unittest. class WebInputElementDelegate { @@ -49,7 +48,7 @@ class WebPasswordAutocompleteListenerImpl : WebPasswordAutocompleteListenerImpl( WebInputElementDelegate* username_element, WebInputElementDelegate* password_element, - const PasswordFormDomManager::FillData& data); + const PasswordFormFillData& data); ~WebPasswordAutocompleteListenerImpl() { } @@ -77,7 +76,7 @@ class WebPasswordAutocompleteListenerImpl : scoped_ptr<WebInputElementDelegate> username_delegate_; // Contains the extra logins for matching on delta/blur. - PasswordFormDomManager::FillData data_; + PasswordFormFillData data_; DISALLOW_COPY_AND_ASSIGN(WebPasswordAutocompleteListenerImpl); }; diff --git a/webkit/glue/webpasswordautocompletelistener_unittest.cc b/webkit/glue/webpasswordautocompletelistener_unittest.cc index a07a07e..5a05d46 100644 --- a/webkit/glue/webpasswordautocompletelistener_unittest.cc +++ b/webkit/glue/webpasswordautocompletelistener_unittest.cc @@ -16,6 +16,7 @@ using WebKit::WebString; using webkit_glue::FormField; using webkit_glue::PasswordFormDomManager; +using webkit_glue::PasswordFormFillData; using webkit_glue::WebInputElementDelegate; using webkit_glue::WebPasswordAutocompleteListenerImpl; @@ -124,7 +125,7 @@ class PasswordManagerAutocompleteTests : public testing::Test { string16 password1_; string16 username2_; string16 password2_; - PasswordFormDomManager::FillData data_; + PasswordFormFillData data_; TestWebInputElementDelegate* username_delegate_; TestWebInputElementDelegate* password_delegate_; |