diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 02:25:08 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 02:25:08 +0000 |
commit | 9c4bf23a4cde497b8bad3f89b60457841470618c (patch) | |
tree | 9674d3732608fb126f685bd9b780fe5a8bd7fe14 /webkit/forms | |
parent | 57dcbc4dd5cbb0f88b348b775ad0a2b130bcafdd (diff) | |
download | chromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.zip chromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.tar.gz chromium_src-9c4bf23a4cde497b8bad3f89b60457841470618c.tar.bz2 |
Group forms-related files in webkit/glue in a forms/ subdirectory.
BUG=none
TEST=compiles
Review URL: http://codereview.chromium.org/8680040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/forms')
-rw-r--r-- | webkit/forms/OWNERS | 2 | ||||
-rw-r--r-- | webkit/forms/form_data.cc | 38 | ||||
-rw-r--r-- | webkit/forms/form_data.h | 44 | ||||
-rw-r--r-- | webkit/forms/form_data_predictions.cc | 24 | ||||
-rw-r--r-- | webkit/forms/form_data_predictions.h | 37 | ||||
-rw-r--r-- | webkit/forms/form_field.cc | 69 | ||||
-rw-r--r-- | webkit/forms/form_field.h | 65 | ||||
-rw-r--r-- | webkit/forms/form_field_predictions.cc | 25 | ||||
-rw-r--r-- | webkit/forms/form_field_predictions.h | 33 | ||||
-rw-r--r-- | webkit/forms/password_form.cc | 38 | ||||
-rw-r--r-- | webkit/forms/password_form.h | 151 | ||||
-rw-r--r-- | webkit/forms/password_form_dom_manager.cc | 66 | ||||
-rw-r--r-- | webkit/forms/password_form_dom_manager.h | 67 | ||||
-rw-r--r-- | webkit/forms/webkit_forms_export.h | 26 |
14 files changed, 685 insertions, 0 deletions
diff --git a/webkit/forms/OWNERS b/webkit/forms/OWNERS new file mode 100644 index 0000000..27f4c6e --- /dev/null +++ b/webkit/forms/OWNERS @@ -0,0 +1,2 @@ +dhollowa@chromium.org +isherman@chromium.org diff --git a/webkit/forms/form_data.cc b/webkit/forms/form_data.cc new file mode 100644 index 0000000..ea85146 --- /dev/null +++ b/webkit/forms/form_data.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/form_data.h" + +#include "base/string_util.h" + +namespace webkit { +namespace forms { + +FormData::FormData() + : user_submitted(false) { +} + +FormData::FormData(const FormData& data) + : name(data.name), + method(data.method), + origin(data.origin), + action(data.action), + user_submitted(data.user_submitted), + fields(data.fields) { +} + +FormData::~FormData() { +} + +bool FormData::operator==(const FormData& form) const { + return (name == form.name && + StringToLowerASCII(method) == StringToLowerASCII(form.method) && + origin == form.origin && + action == form.action && + user_submitted == form.user_submitted && + fields == form.fields); +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/form_data.h b/webkit/forms/form_data.h new file mode 100644 index 0000000..da9b0e8 --- /dev/null +++ b/webkit/forms/form_data.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_FORM_DATA_H__ +#define WEBKIT_FORMS_FORM_DATA_H__ + +#include <vector> + +#include "base/string16.h" +#include "googleurl/src/gurl.h" +#include "webkit/forms/form_field.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace webkit { +namespace forms { + +// Holds information about a form to be filled and/or submitted. +struct WEBKIT_FORMS_EXPORT FormData { + // The name of the form. + string16 name; + // GET or POST. + string16 method; + // The URL (minus query parameters) containing the form. + GURL origin; + // The action target of the form. + GURL action; + // true if this form was submitted by a user gesture and not javascript. + bool user_submitted; + // A vector of all the input fields in the form. + std::vector<FormField> fields; + + FormData(); + FormData(const FormData& data); + ~FormData(); + + // Used by FormStructureTest. + bool operator==(const FormData& form) const; +}; + +} // namespace forms +} // namespace webkit + +#endif // WEBKIT_FORMS_FORM_DATA_H__ diff --git a/webkit/forms/form_data_predictions.cc b/webkit/forms/form_data_predictions.cc new file mode 100644 index 0000000..62d9a0e --- /dev/null +++ b/webkit/forms/form_data_predictions.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/form_data_predictions.h" + +namespace webkit { +namespace forms { + +FormDataPredictions::FormDataPredictions() { +} + +FormDataPredictions::FormDataPredictions(const FormDataPredictions& other) + : data(other.data), + signature(other.signature), + experiment_id(other.experiment_id), + fields(other.fields) { +} + +FormDataPredictions::~FormDataPredictions() { +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/form_data_predictions.h b/webkit/forms/form_data_predictions.h new file mode 100644 index 0000000..df3015a --- /dev/null +++ b/webkit/forms/form_data_predictions.h @@ -0,0 +1,37 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_FORM_DATA_PREDICTIONS_H__ +#define WEBKIT_FORMS_FORM_DATA_PREDICTIONS_H__ + +#include <string> +#include <vector> + +#include "webkit/forms/form_data.h" +#include "webkit/forms/form_field_predictions.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace webkit { +namespace forms { + +// Holds information about a form to be filled and/or submitted. +struct WEBKIT_FORMS_EXPORT FormDataPredictions { + // Data for this form. + FormData data; + // The form signature for communication with the crowdsourcing server. + std::string signature; + // The experiment id for the server predictions. + std::string experiment_id; + // The form fields and their predicted field types. + std::vector<FormFieldPredictions> fields; + + FormDataPredictions(); + FormDataPredictions(const FormDataPredictions& other); + ~FormDataPredictions(); +}; + +} // namespace forms +} // namespace webkit + +#endif // WEBKIT_FORMS_FORM_DATA_PREDICTIONS_H__ diff --git a/webkit/forms/form_field.cc b/webkit/forms/form_field.cc new file mode 100644 index 0000000..1c9a0a7 --- /dev/null +++ b/webkit/forms/form_field.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/form_field.h" + +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" + +using WebKit::WebFormControlElement; +using WebKit::WebElement; +using WebKit::WebInputElement; +using WebKit::WebOptionElement; +using WebKit::WebSelectElement; +using WebKit::WebVector; + +namespace webkit { +namespace forms { + +FormField::FormField() + : max_length(0), + is_autofilled(false), + is_focusable(false), + should_autocomplete(false) { +} + +FormField::~FormField() { +} + +bool FormField::operator==(const FormField& field) const { + // A FormField stores a value, but the value is not part of the identity of + // the field, so we don't want to compare the values. + return (label == field.label && + name == field.name && + form_control_type == field.form_control_type && + autocomplete_type == field.autocomplete_type && + max_length == field.max_length); +} + +bool FormField::operator!=(const FormField& field) const { + return !operator==(field); +} + +std::ostream& operator<<(std::ostream& os, const FormField& field) { + return os + << UTF16ToUTF8(field.label) + << " " + << UTF16ToUTF8(field.name) + << " " + << UTF16ToUTF8(field.value) + << " " + << UTF16ToUTF8(field.form_control_type) + << " " + << UTF16ToUTF8(field.autocomplete_type) + << " " + << field.max_length + << " " + << (field.is_autofilled ? "true" : "false") + << " " + << (field.is_focusable ? "true" : "false") + << " " + << (field.should_autocomplete ? "true" : "false"); +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/form_field.h b/webkit/forms/form_field.h new file mode 100644 index 0000000..d1b17c0 --- /dev/null +++ b/webkit/forms/form_field.h @@ -0,0 +1,65 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_FORM_FIELD_H_ +#define WEBKIT_FORMS_FORM_FIELD_H_ + +#include <vector> + +#include "base/string16.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace webkit { +namespace forms { + +// Stores information about a field in a form. +struct WEBKIT_FORMS_EXPORT FormField { + FormField(); + virtual ~FormField(); + + // Equality tests for identity which does not include |value| or + // |is_autofilled|. + // TODO(dhollowa): These operators need to be revised when we implement field + // ids. + bool operator==(const FormField& field) const; + bool operator!=(const FormField& field) const; + + string16 label; + string16 name; + string16 value; + string16 form_control_type; + string16 autocomplete_type; + size_t max_length; + bool is_autofilled; + bool is_focusable; + bool should_autocomplete; + + // For the HTML snippet |<option value="US">United States</option>|, the + // value is "US" and the contents are "United States". + std::vector<string16> option_values; + std::vector<string16> option_contents; +}; + +// So we can compare FormFields with EXPECT_EQ(). +WEBKIT_FORMS_EXPORT std::ostream& operator<<(std::ostream& os, + const FormField& field); + +} // namespace forms +} // namespace webkit + +// Prefer to use this macro in place of |EXPECT_EQ()| for comparing |FormField|s +// in test code. +#define EXPECT_FORM_FIELD_EQUALS(expected, actual) \ + do { \ + EXPECT_EQ(expected.label, actual.label); \ + EXPECT_EQ(expected.name, actual.name); \ + EXPECT_EQ(expected.value, actual.value); \ + EXPECT_EQ(expected.form_control_type, actual.form_control_type); \ + EXPECT_EQ(expected.autocomplete_type, actual.autocomplete_type); \ + EXPECT_EQ(expected.max_length, actual.max_length); \ + EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \ + } while (0) + +#endif // WEBKIT_FORMS_FORM_FIELD_H_ diff --git a/webkit/forms/form_field_predictions.cc b/webkit/forms/form_field_predictions.cc new file mode 100644 index 0000000..3f0cd1e --- /dev/null +++ b/webkit/forms/form_field_predictions.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/form_field_predictions.h" + +namespace webkit { +namespace forms { + +FormFieldPredictions::FormFieldPredictions() { +} + +FormFieldPredictions::FormFieldPredictions(const FormFieldPredictions& other) + : field(other.field), + signature(other.signature), + heuristic_type(other.heuristic_type), + server_type(other.server_type), + overall_type(other.overall_type) { +} + +FormFieldPredictions::~FormFieldPredictions() { +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/form_field_predictions.h b/webkit/forms/form_field_predictions.h new file mode 100644 index 0000000..95f2d82 --- /dev/null +++ b/webkit/forms/form_field_predictions.h @@ -0,0 +1,33 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_FORM_FIELD_PREDICTIONS_H_ +#define WEBKIT_FORMS_FORM_FIELD_PREDICTIONS_H_ + +#include <string> +#include <vector> + +#include "webkit/forms/form_field.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace webkit { +namespace forms { + +// Stores information about a field in a form. +struct WEBKIT_FORMS_EXPORT FormFieldPredictions { + FormFieldPredictions(); + FormFieldPredictions(const FormFieldPredictions& other); + ~FormFieldPredictions(); + + FormField field; + std::string signature; + std::string heuristic_type; + std::string server_type; + std::string overall_type; +}; + +} // namespace forms +} // namespace webkit + +#endif // WEBKIT_FORMS_FORM_FIELD_PREDICTIONS_H_ diff --git a/webkit/forms/password_form.cc b/webkit/forms/password_form.cc new file mode 100644 index 0000000..0d9ad04 --- /dev/null +++ b/webkit/forms/password_form.cc @@ -0,0 +1,38 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/password_form.h" + +namespace webkit { +namespace forms { + +PasswordForm::PasswordForm() + : scheme(SCHEME_HTML), + ssl_valid(false), + preferred(false), + blacklisted_by_user(false) { +} + +PasswordForm::PasswordForm(const WebKit::WebPasswordFormData& web_password_form) + : scheme(SCHEME_HTML), + signon_realm(web_password_form.signonRealm.utf8()), + origin(web_password_form.origin), + action(web_password_form.action), + submit_element(web_password_form.submitElement), + username_element(web_password_form.userNameElement), + username_value(web_password_form.userNameValue), + password_element(web_password_form.passwordElement), + password_value(web_password_form.passwordValue), + old_password_element(web_password_form.oldPasswordElement), + old_password_value(web_password_form.oldPasswordValue), + ssl_valid(false), + preferred(false), + blacklisted_by_user(false) { +} + +PasswordForm::~PasswordForm() { +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/password_form.h b/webkit/forms/password_form.h new file mode 100644 index 0000000..dc2df54 --- /dev/null +++ b/webkit/forms/password_form.h @@ -0,0 +1,151 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_PASSWORD_FORM_H__ +#define WEBKIT_FORMS_PASSWORD_FORM_H__ + +#include <map> +#include <string> + +#include "base/time.h" +#include "googleurl/src/gurl.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace webkit { +namespace forms { + +// The PasswordForm struct encapsulates information about a login form, +// which can be an HTML form or a dialog with username/password text fields. +// +// The Web Data database stores saved username/passwords and associated form +// metdata using a PasswordForm struct, typically one that was created from +// a parsed HTMLFormElement or LoginDialog, but the saved entries could have +// also been created by imported data from another browser. +// +// The PasswordManager implements a fuzzy-matching algorithm to compare saved +// PasswordForm entries against PasswordForms that were created from a parsed +// HTML or dialog form. As one might expect, the more data contained in one +// of the saved PasswordForms, the better the job the PasswordManager can do +// in matching it against the actual form it was saved on, and autofill +// accurately. But it is not always possible, especially when importing from +// other browsers with different data models, to copy over all the information +// about a particular "saved password entry" to our PasswordForm +// representation. +// +// The field descriptions in the struct specification below are intended to +// describe which fields are not strictly required when adding a saved password +// entry to the database and how they can affect the matching process. + +struct WEBKIT_FORMS_EXPORT PasswordForm { + // Enum to differentiate between HTML form based authentication, and dialogs + // using basic or digest schemes. Default is SCHEME_HTML. Only PasswordForms + // of the same Scheme will be matched/autofilled against each other. + enum Scheme { + SCHEME_HTML, + SCHEME_BASIC, + SCHEME_DIGEST, + SCHEME_OTHER + } scheme; + + // The "Realm" for the sign-on (scheme, host, port for SCHEME_HTML, and + // contains the HTTP realm for dialog-based forms). + // The signon_realm is effectively the primary key used for retrieving + // data from the database, so it must not be empty. + std::string signon_realm; + + // The URL (minus query parameters) containing the form. This is the primary + // data used by the PasswordManager to decide (in longest matching prefix + // fashion) whether or not a given PasswordForm result from the database is a + // good fit for a particular form on a page, so it must not be empty. + GURL origin; + + // The action target of the form. This is the primary data used by the + // PasswordManager for form autofill; that is, the action of the saved + // credentials must match the action of the form on the page to be autofilled. + // If this is empty / not available, it will result in a "restricted" + // IE-like autofill policy, where we wait for the user to type in his + // username before autofilling the password. In these cases, after successful + // login the action URL will automatically be assigned by the + // PasswordManager. + // + // When parsing an HTML form, this must always be set. + GURL action; + + // The name of the submit button used. Optional; only used in scoring + // of PasswordForm results from the database to make matches as tight as + // possible. + // + // When parsing an HTML form, this must always be set. + string16 submit_element; + + // The name of the username input element. Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + string16 username_element; + + // The username. Optional. + // + // When parsing an HTML form, this is typically empty unless the site + // has implemented some form of autofill. + string16 username_value; + + // The name of the password input element, Optional (improves scoring). + // + // When parsing an HTML form, this must always be set. + string16 password_element; + + // The password. Required. + // + // When parsing an HTML form, this is typically empty. + string16 password_value; + + // If the form was a change password form, the name of the + // 'old password' input element. Optional. + string16 old_password_element; + + // The old password. Optional. + string16 old_password_value; + + // Whether or not this login was saved under an HTTPS session with a valid + // SSL cert. We will never match or autofill a PasswordForm where + // ssl_valid == true with a PasswordForm where ssl_valid == false. This means + // passwords saved under HTTPS will never get autofilled onto an HTTP page. + // When importing, this should be set to true if the page URL is HTTPS, thus + // giving it "the benefit of the doubt" that the SSL cert was valid when it + // was saved. Default to false. + bool ssl_valid; + + // True if this PasswordForm represents the last username/password login the + // user selected to log in to the site. If there is only one saved entry for + // the site, this will always be true, but when there are multiple entries + // the PasswordManager ensures that only one of them has a preferred bit set + // to true. Default to false. + // + // When parsing an HTML form, this is not used. + bool preferred; + + // When the login was saved (by chrome). + // + // When parsing an HTML form, this is not used. + base::Time date_created; + + // Tracks if the user opted to never remember passwords for this form. Default + // to false. + // + // When parsing an HTML form, this is not used. + bool blacklisted_by_user; + + PasswordForm(); + PasswordForm(const WebKit::WebPasswordFormData& web_password_form); + ~PasswordForm(); +}; + +// Map username to PasswordForm* for convenience. See password_form_manager.h. +typedef std::map<string16, PasswordForm*> PasswordFormMap; + +} // namespace forms +} // namespace webkit + +#endif // WEBKIT_FORMS_PASSWORD_FORM_H__ diff --git a/webkit/forms/password_form_dom_manager.cc b/webkit/forms/password_form_dom_manager.cc new file mode 100644 index 0000000..5cf367d --- /dev/null +++ b/webkit/forms/password_form_dom_manager.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2011 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. + +#include "webkit/forms/password_form_dom_manager.h" + +#include "base/logging.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebPasswordFormData.h" +#include "webkit/forms/form_field.h" + +using WebKit::WebFormElement; +using WebKit::WebInputElement; +using WebKit::WebPasswordFormData; + +namespace webkit { +namespace forms { + +PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { +} + +PasswordFormFillData::~PasswordFormFillData() { +} + +PasswordForm* PasswordFormDomManager::CreatePasswordForm( + const WebFormElement& webform) { + WebPasswordFormData web_password_form(webform); + if (web_password_form.isValid()) + return new PasswordForm(web_password_form); + return NULL; +} + +// static +void PasswordFormDomManager::InitFillData( + const PasswordForm& form_on_page, + const PasswordFormMap& matches, + const PasswordForm* const preferred_match, + bool wait_for_username_before_autofill, + PasswordFormFillData* result) { + // Note that many of the |FormField| members are not initialized for + // |username_field| and |password_field| because they are currently not used + // by the password autocomplete code. + FormField username_field; + username_field.name = form_on_page.username_element; + username_field.value = preferred_match->username_value; + FormField password_field; + password_field.name = form_on_page.password_element; + password_field.value = preferred_match->password_value; + + // Fill basic form data. + result->basic_data.origin = form_on_page.origin; + result->basic_data.action = form_on_page.action; + result->basic_data.fields.push_back(username_field); + result->basic_data.fields.push_back(password_field); + result->wait_for_username = wait_for_username_before_autofill; + + // Copy additional username/value pairs. + PasswordFormMap::const_iterator iter; + for (iter = matches.begin(); iter != matches.end(); iter++) { + if (iter->second != preferred_match) + result->additional_logins[iter->first] = iter->second->password_value; + } +} + +} // namespace forms +} // namespace webkit diff --git a/webkit/forms/password_form_dom_manager.h b/webkit/forms/password_form_dom_manager.h new file mode 100644 index 0000000..7354ded --- /dev/null +++ b/webkit/forms/password_form_dom_manager.h @@ -0,0 +1,67 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_PASSWORD_FORM_DOM_MANAGER_H_ +#define WEBKIT_FORMS_PASSWORD_FORM_DOM_MANAGER_H_ + +#include <map> + +#include "webkit/forms/form_data.h" +#include "webkit/forms/password_form.h" +#include "webkit/forms/webkit_forms_export.h" + +namespace WebKit { +class WebForm; +} + +namespace webkit { +namespace forms { + +// 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 WEBKIT_FORMS_EXPORT PasswordFormFillData { + typedef std::map<string16, string16> LoginCollection; + + 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 + // to identify..which sucks. + WEBKIT_FORMS_EXPORT static PasswordForm* CreatePasswordForm( + const WebKit::WebFormElement& form); + + // Create a FillData structure in preparation for autofilling a form, + // from basic_data identifying which form to fill, and a collection of + // matching stored logins to use as username/password values. + // preferred_match should equal (address) one of matches. + // wait_for_username_before_autofill is true if we should not autofill + // anything until the user typed in a valid username and blurred the field. + WEBKIT_FORMS_EXPORT static void InitFillData(const PasswordForm& form_on_page, + const PasswordFormMap& matches, + const PasswordForm* const preferred_match, + bool wait_for_username_before_autofill, + PasswordFormFillData* result); + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(PasswordFormDomManager); +}; + +} // namespace forms +} // namespace webkit + +#endif // WEBKIT_FORMS_PASSWORD_FORM_DOM_MANAGER_H__ diff --git a/webkit/forms/webkit_forms_export.h b/webkit/forms/webkit_forms_export.h new file mode 100644 index 0000000..d3cbe8f --- /dev/null +++ b/webkit/forms/webkit_forms_export.h @@ -0,0 +1,26 @@ +// Copyright (c) 2011 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 WEBKIT_FORMS_WEBKIT_FORMS_EXPORT_H_ +#define WEBKIT_FORMS_WEBKIT_FORMS_EXPORT_H_ +#pragma once + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(WEBKIT_FORMS_IMPLEMENTATION) +#define WEBKIT_FORMS_EXPORT __declspec(dllexport) +#else +#define WEBKIT_FORMS_EXPORT __declspec(dllimport) +#endif // defined(WEBKIT_FORMS_IMPLEMENTATION) + +#else // defined(WIN32) +#define WEBKIT_FORMS_EXPORT __attribute__((visibility("default"))) +#endif + +#else // defined(COMPONENT_BUILD) +#define WEBKIT_FORMS_EXPORT +#endif + +#endif // WEBKIT_FORMS_WEBKIT_FORMS_EXPORT_H_ |