diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-03 00:30:59 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-03 00:30:59 +0000 |
commit | b143821ab651df119648c0a201b6ab4bf616a500 (patch) | |
tree | bb9946d52d2d1937bbfc3d2de641a0fabca80c3f /chrome/browser | |
parent | 89098b14454bd3e9ec38c98084e1e0488de67fb3 (diff) | |
download | chromium_src-b143821ab651df119648c0a201b6ab4bf616a500.zip chromium_src-b143821ab651df119648c0a201b6ab4bf616a500.tar.gz chromium_src-b143821ab651df119648c0a201b6ab4bf616a500.tar.bz2 |
AutoFill: Use the FormManager cache to send forms to the AutoFillManager.
Remove the FormFieldValues class and replace its usage with FormData.
BUG=38325,33032
TEST=none
Review URL: http://codereview.chromium.org/1606005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete_history_manager.cc | 13 | ||||
-rw-r--r-- | chrome/browser/autocomplete_history_manager.h | 9 | ||||
-rw-r--r-- | chrome/browser/autofill/address_field_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_download_unittest.cc | 89 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 28 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 8 | ||||
-rw-r--r-- | chrome/browser/autofill/credit_card_field_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.cc | 16 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure.h | 3 | ||||
-rw-r--r-- | chrome/browser/autofill/form_structure_unittest.cc | 345 | ||||
-rw-r--r-- | chrome/browser/autofill/phone_field_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/account_creation_view.cc | 20 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 27 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 13 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 10 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_win.cc | 2 |
16 files changed, 287 insertions, 302 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc index 280ea85..7626f9c 100644 --- a/chrome/browser/autocomplete_history_manager.cc +++ b/chrome/browser/autocomplete_history_manager.cc @@ -12,7 +12,9 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_data.h" + +using webkit_glue::FormData; // Limit on the number of suggestions to appear in the pop-up menu under an // text input element in a form. @@ -48,8 +50,7 @@ Profile* AutocompleteHistoryManager::profile() { return tab_contents_->profile(); } -void AutocompleteHistoryManager::FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) { +void AutocompleteHistoryManager::FormSubmitted(const FormData& form) { StoreFormEntriesInWebDatabase(form); } @@ -101,7 +102,7 @@ void AutocompleteHistoryManager::OnWebDataServiceRequestDone( } void AutocompleteHistoryManager::StoreFormEntriesInWebDatabase( - const webkit_glue::FormFieldValues& form) { + const FormData& form) { if (!*form_autofill_enabled_) return; @@ -114,8 +115,8 @@ void AutocompleteHistoryManager::StoreFormEntriesInWebDatabase( // - text field std::vector<webkit_glue::FormField> values; for (std::vector<webkit_glue::FormField>::const_iterator iter = - form.elements.begin(); - iter != form.elements.end(); ++iter) { + form.fields.begin(); + iter != form.fields.end(); ++iter) { if (!iter->value().empty() && !iter->name().empty() && iter->form_control_type() == ASCIIToUTF16("text")) diff --git a/chrome/browser/autocomplete_history_manager.h b/chrome/browser/autocomplete_history_manager.h index 1d6966f..2f8fe5e 100644 --- a/chrome/browser/autocomplete_history_manager.h +++ b/chrome/browser/autocomplete_history_manager.h @@ -12,8 +12,8 @@ #include "chrome/browser/webdata/web_data_service.h" namespace webkit_glue { -class FormFieldValues; -} +struct FormData; +} // namespace webkit_glue class Profile; class TabContents; @@ -30,8 +30,7 @@ class AutocompleteHistoryManager Profile* profile(); // RenderViewHostDelegate::Autocomplete implementation. - virtual void FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form); + virtual void FormSubmitted(const webkit_glue::FormData& form); virtual bool GetAutocompleteSuggestions(int query_id, const string16& name, const string16& prefix); @@ -44,7 +43,7 @@ class AutocompleteHistoryManager private: void CancelPendingQuery(); - void StoreFormEntriesInWebDatabase(const webkit_glue::FormFieldValues& form); + void StoreFormEntriesInWebDatabase(const webkit_glue::FormData& form); void SendSuggestions(const WDTypedResult* suggestions); TabContents* tab_contents_; diff --git a/chrome/browser/autofill/address_field_unittest.cc b/chrome/browser/autofill/address_field_unittest.cc index bbcbcf2..322e697 100644 --- a/chrome/browser/autofill/address_field_unittest.cc +++ b/chrome/browser/autofill/address_field_unittest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/autofill/address_field.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_field.h" namespace { diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc index e1df3b8..fe09261a 100644 --- a/chrome/browser/autofill/autofill_download_unittest.cc +++ b/chrome/browser/autofill/autofill_download_unittest.cc @@ -11,8 +11,9 @@ #include "net/url_request/url_request_status.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_data.h" +using webkit_glue::FormData; using WebKit::WebInputElement; // This tests AutoFillDownloadManager. AutoFillDownloadTestHelper implements @@ -99,52 +100,52 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) { TestURLFetcherFactory factory; URLFetcher::set_factory(&factory); - webkit_glue::FormFieldValues values; - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"), - ASCIIToUTF16("email2"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); + FormData form; + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), + ASCIIToUTF16("username"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email"), + ASCIIToUTF16("email"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("email2"), + ASCIIToUTF16("email2"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), + ASCIIToUTF16("password"), + string16(), + ASCIIToUTF16("password"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); - FormStructure *form = new FormStructure(values); + FormStructure *form_structure = new FormStructure(form); ScopedVector<FormStructure> form_structures; - form_structures.push_back(form); + form_structures.push_back(form_structure); - values.elements.clear(); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"), - ASCIIToUTF16("address2"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("city"), - ASCIIToUTF16("address2"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - form = new FormStructure(values); - form_structures.push_back(form); + form.fields.clear(); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address"), + ASCIIToUTF16("address"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("address2"), + ASCIIToUTF16("address2"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("city"), + ASCIIToUTF16("address2"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + form_structure = new FormStructure(form); + form_structures.push_back(form_structure); // Request with id 0. EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures)); diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 5bed021..b651a97 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -19,7 +19,9 @@ #include "chrome/common/pref_names.h" #include "webkit/glue/form_data.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_values.h" + +using webkit_glue::FormData; +using webkit_glue::FormField; namespace { // We only send a fraction of the forms to upload server. @@ -68,8 +70,7 @@ void AutoFillManager::RegisterUserPrefs(PrefService* prefs) { kAutoFillNegativeUploadRateDefaultValue); } -void AutoFillManager::FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) { +void AutoFillManager::FormSubmitted(const FormData& form) { if (!IsAutoFillEnabled()) return; @@ -95,29 +96,22 @@ void AutoFillManager::FormFieldValuesSubmitted( } } -void AutoFillManager::FormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms) { +void AutoFillManager::FormsSeen(const std::vector<FormData>& forms) { if (!IsAutoFillEnabled()) return; - for (std::vector<webkit_glue::FormFieldValues>::const_iterator iter = + for (std::vector<FormData>::const_iterator iter = forms.begin(); iter != forms.end(); ++iter) { FormStructure* form_structure = new FormStructure(*iter); DeterminePossibleFieldTypes(form_structure); form_structures_.push_back(form_structure); } - - // Only query the server for form data if the user has profile or - // credit card data set up. - if (!personal_data_->profiles().empty() || - !personal_data_->credit_cards().empty()) { - download_manager_.StartQueryRequest(form_structures_); - } + download_manager_.StartQueryRequest(form_structures_); } -bool AutoFillManager::GetAutoFillSuggestions( - int query_id, const webkit_glue::FormField& field) { +bool AutoFillManager::GetAutoFillSuggestions(int query_id, + const FormField& field) { if (!IsAutoFillEnabled()) return false; @@ -225,7 +219,7 @@ bool AutoFillManager::GetAutoFillSuggestions( } bool AutoFillManager::FillAutoFillFormData(int query_id, - const webkit_glue::FormData& form, + const FormData& form, const string16& name, const string16& label) { if (!IsAutoFillEnabled()) @@ -275,7 +269,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id, if (!profile && !credit_card) return false; - webkit_glue::FormData result = form; + FormData result = form; for (std::vector<FormStructure*>::const_iterator iter = form_structures_.begin(); iter != form_structures_.end(); ++iter) { diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index d89d5da..b9eafbf 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -18,8 +18,7 @@ namespace webkit_glue { struct FormData; class FormField; -class FormFieldValues; -} +} // namespace webkit_glue class AutoFillInfoBarDelegate; class AutoFillProfile; @@ -45,10 +44,9 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, static void RegisterUserPrefs(PrefService* prefs); // RenderViewHostDelegate::AutoFill implementation: - virtual void FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form); + virtual void FormSubmitted(const webkit_glue::FormData& form); virtual void FormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms); + const std::vector<webkit_glue::FormData>& forms); virtual bool GetAutoFillSuggestions(int query_id, const webkit_glue::FormField& field); virtual bool FillAutoFillFormData(int query_id, diff --git a/chrome/browser/autofill/credit_card_field_unittest.cc b/chrome/browser/autofill/credit_card_field_unittest.cc index efadf7a..dbd9923 100644 --- a/chrome/browser/autofill/credit_card_field_unittest.cc +++ b/chrome/browser/autofill/credit_card_field_unittest.cc @@ -6,7 +6,7 @@ #include "base/scoped_vector.h" #include "chrome/browser/autofill/credit_card_field.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_field.h" namespace { diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index d0f2a71..bb91ec9 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -14,10 +14,8 @@ #include "third_party/libjingle/files/talk/xmllite/xmlelement.h" #include "webkit/glue/form_data.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_values.h" using webkit_glue::FormData; -using webkit_glue::FormFieldValues; namespace { @@ -59,14 +57,14 @@ static std::string Hash64Bit(const std::string& str) { } // namespace -FormStructure::FormStructure(const FormFieldValues& values) - : form_name_(UTF16ToUTF8(values.form_name)), - source_url_(values.source_url), - target_url_(values.target_url) { +FormStructure::FormStructure(const FormData& form) + : form_name_(UTF16ToUTF8(form.name)), + source_url_(form.origin), + target_url_(form.action) { // Copy the form fields. std::vector<webkit_glue::FormField>::const_iterator field; - for (field = values.elements.begin(); - field != values.elements.end(); field++) { + for (field = form.fields.begin(); + field != form.fields.end(); field++) { // We currently only handle text and select fields. This prevents us from // thinking we can autofill other types of controls, e.g., password, hidden, // submit. @@ -87,7 +85,7 @@ FormStructure::FormStructure(const FormFieldValues& values) // Terminate the vector with a NULL item. fields_.push_back(NULL); - std::string method = UTF16ToUTF8(values.method); + std::string method = UTF16ToUTF8(form.method); if (method == kFormMethodPost) { method_ = POST; } else { diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h index bb20885..4028117 100644 --- a/chrome/browser/autofill/form_structure.h +++ b/chrome/browser/autofill/form_structure.h @@ -20,7 +20,6 @@ namespace buzz { namespace webkit_glue { struct FormData; -class FormFieldValues; } // namespace webkit_glue enum RequestMethod { @@ -38,7 +37,7 @@ enum UploadRequired { // in the fields along with additional information needed by AutoFill. class FormStructure { public: - explicit FormStructure(const webkit_glue::FormFieldValues& values); + explicit FormStructure(const webkit_glue::FormData& form); // Encodes the XML upload request from this FormStructure. bool EncodeUploadRequest(bool auto_fill_used, diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc index f528d24..cfc535a 100644 --- a/chrome/browser/autofill/form_structure_unittest.cc +++ b/chrome/browser/autofill/form_structure_unittest.cc @@ -8,28 +8,29 @@ #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_data.h" +using webkit_glue::FormData; using WebKit::WebInputElement; namespace { TEST(FormStructureTest, FieldCount) { - webkit_glue::FormFieldValues values; - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - FormStructure form_structure(values); + FormData form; + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), + ASCIIToUTF16("username"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), + ASCIIToUTF16("password"), + string16(), + ASCIIToUTF16("password"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + FormStructure form_structure(form); // Only text fields are counted. EXPECT_EQ(1U, form_structure.field_count()); @@ -37,96 +38,96 @@ TEST(FormStructureTest, FieldCount) { TEST(FormStructureTest, IsAutoFillable) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; + FormData form; // We need at least three text fields to be auto-fillable. - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), - ASCIIToUTF16("username"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), - ASCIIToUTF16("password"), - string16(), - ASCIIToUTF16("password"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("username"), + ASCIIToUTF16("username"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("password"), + ASCIIToUTF16("password"), + string16(), + ASCIIToUTF16("password"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + form_structure.reset(new FormStructure(form)); EXPECT_FALSE(form_structure->IsAutoFillable()); // We now have three text fields. - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"))); - form_structure.reset(new FormStructure(values)); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), + ASCIIToUTF16("firstname"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), + ASCIIToUTF16("lastname"), + string16(), + ASCIIToUTF16("text"))); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // The method must be 'post'. - values.method = ASCIIToUTF16("get"); - form_structure.reset(new FormStructure(values)); + form.method = ASCIIToUTF16("get"); + form_structure.reset(new FormStructure(form)); EXPECT_FALSE(form_structure->IsAutoFillable()); // The target cannot include http(s)://*/search... - values.method = ASCIIToUTF16("post"); - values.target_url = GURL("http://google.com/search?q=hello"); - form_structure.reset(new FormStructure(values)); + form.method = ASCIIToUTF16("post"); + form.action = GURL("http://google.com/search?q=hello"); + form_structure.reset(new FormStructure(form)); EXPECT_FALSE(form_structure->IsAutoFillable()); // But search can be in the URL. - values.target_url = GURL("http://search.com/?q=hello"); - form_structure.reset(new FormStructure(values)); + form.action = GURL("http://search.com/?q=hello"); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); } TEST(FormStructureTest, HeuristicsContactInfo) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; - - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - ASCIIToUTF16("firstname"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - ASCIIToUTF16("lastname"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), - ASCIIToUTF16("email"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), - ASCIIToUTF16("phone"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), - ASCIIToUTF16("fax"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - ASCIIToUTF16("address"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("City"), - ASCIIToUTF16("city"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), - ASCIIToUTF16("zipcode"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + FormData form; + + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), + ASCIIToUTF16("firstname"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), + ASCIIToUTF16("lastname"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), + ASCIIToUTF16("email"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), + ASCIIToUTF16("phone"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), + ASCIIToUTF16("fax"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), + ASCIIToUTF16("address"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("City"), + ASCIIToUTF16("city"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), + ASCIIToUTF16("zipcode"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // Expect the correct number of fields. @@ -173,60 +174,60 @@ TEST(FormStructureTest, HeuristicsContactInfo) { TEST(FormStructureTest, HeuristicsSample8) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; + FormData form; - values.method = ASCIIToUTF16("post"); - values.elements.push_back( + form.method = ASCIIToUTF16("post"); + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Your First Name:"), ASCIIToUTF16("bill.first"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Your Last Name:"), ASCIIToUTF16("bill.last"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Street Address Line 1:"), ASCIIToUTF16("bill.street1"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Street Address Line 2:"), ASCIIToUTF16("bill.street2"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("City:"), ASCIIToUTF16("bill.city"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("State (U.S.):"), ASCIIToUTF16("bill.state"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Zip/Postal Code:"), ASCIIToUTF16("BillTo.PostalCode"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Country:"), ASCIIToUTF16("bill.country"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Phone Number:"), ASCIIToUTF16("BillTo.Phone"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), string16(), ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // Check that heuristics are initialized as UNKNOWN_TYPE. @@ -272,47 +273,47 @@ TEST(FormStructureTest, HeuristicsSample8) { TEST(FormStructureTest, HeuristicsSample6) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; + FormData form; - values.method = ASCIIToUTF16("post"); - values.elements.push_back( + form.method = ASCIIToUTF16("post"); + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("E-mail address"), ASCIIToUTF16("email"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Full name"), ASCIIToUTF16("name"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Company"), ASCIIToUTF16("company"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Address"), ASCIIToUTF16("address"), string16(), ASCIIToUTF16("text"))); - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("City"), ASCIIToUTF16("city"), string16(), ASCIIToUTF16("text"))); // TODO(jhawkins): Add state select control. - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(ASCIIToUTF16("Zip Code"), ASCIIToUTF16("Home.PostalCode"), string16(), ASCIIToUTF16("text"))); // TODO(jhawkins): Phone number. - values.elements.push_back( + form.fields.push_back( webkit_glue::FormField(string16(), ASCIIToUTF16("Submit"), ASCIIToUTF16("continue"), ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // Check that heuristics are initialized as UNKNOWN_TYPE. @@ -354,46 +355,46 @@ TEST(FormStructureTest, HeuristicsSample6) { // that input element ids (or |name| fields) are missing. TEST(FormStructureTest, HeuristicsLabelsOnly) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; - - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), - string16(), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + FormData form; + + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("First Name"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Last Name"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("EMail"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Phone"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Fax"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Address"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Zip code"), + string16(), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // Expect the correct number of fields. @@ -440,34 +441,34 @@ TEST(FormStructureTest, HeuristicsLabelsOnly) { TEST(FormStructureTest, HeuristicsCreditCardInfo) { scoped_ptr<FormStructure> form_structure; - webkit_glue::FormFieldValues values; + FormData form; - values.method = ASCIIToUTF16("post"); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), + form.method = ASCIIToUTF16("post"); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Name on Card"), ASCIIToUTF16("name on card"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Card Number"), ASCIIToUTF16("card_number"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Month"), ASCIIToUTF16("ccmonth"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Exp Year"), ASCIIToUTF16("ccyear"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"), + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(ASCIIToUTF16("Verification"), ASCIIToUTF16("verification"), - string16(), - ASCIIToUTF16("text"))); - values.elements.push_back(webkit_glue::FormField(string16(), - ASCIIToUTF16("Submit"), - string16(), - ASCIIToUTF16("submit"))); - form_structure.reset(new FormStructure(values)); + string16(), + ASCIIToUTF16("text"))); + form.fields.push_back(webkit_glue::FormField(string16(), + ASCIIToUTF16("Submit"), + string16(), + ASCIIToUTF16("submit"))); + form_structure.reset(new FormStructure(form)); EXPECT_TRUE(form_structure->IsAutoFillable()); // Expect the correct number of fields. diff --git a/chrome/browser/autofill/phone_field_unittest.cc b/chrome/browser/autofill/phone_field_unittest.cc index e12e894..2a4c8c7 100644 --- a/chrome/browser/autofill/phone_field_unittest.cc +++ b/chrome/browser/autofill/phone_field_unittest.cc @@ -7,7 +7,7 @@ #include "chrome/browser/autofill/phone_field.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_field.h" namespace { diff --git a/chrome/browser/chromeos/login/account_creation_view.cc b/chrome/browser/chromeos/login/account_creation_view.cc index 1de0634..1af6c06 100644 --- a/chrome/browser/chromeos/login/account_creation_view.cc +++ b/chrome/browser/chromeos/login/account_creation_view.cc @@ -15,7 +15,9 @@ #include "gfx/canvas.h" #include "ipc/ipc_message.h" #include "views/border.h" -#include "webkit/glue/form_field_values.h" +#include "webkit/glue/form_data.h" + +using webkit_glue::FormData; namespace chromeos { @@ -37,17 +39,16 @@ class AccountCreationTabContents : public TabContents, return this; } - virtual void FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) { - if (UTF16ToASCII(form.form_name) == kCreateAccountFormName) { + virtual void FormSubmitted(const FormData& form) { + if (UTF16ToASCII(form.name) == kCreateAccountFormName) { std::string user_name; std::string domain; - for (size_t i = 0; i < form.elements.size(); i++) { - std::string name = UTF16ToASCII(form.elements[i].name()); + for (size_t i = 0; i < form.fields.size(); i++) { + std::string name = UTF16ToASCII(form.fields[i].name()); if (name == kEmailFieldName) { - user_name = UTF16ToASCII(form.elements[i].value()); + user_name = UTF16ToASCII(form.fields[i].value()); } else if (name == kDomainFieldName) { - domain = UTF16ToASCII(form.elements[i].value()); + domain = UTF16ToASCII(form.fields[i].value()); } } if (!user_name.empty()) { @@ -59,8 +60,7 @@ class AccountCreationTabContents : public TabContents, } } - virtual void FormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms) { + virtual void FormsSeen(const std::vector<FormData>& forms) { } virtual bool GetAutoFillSuggestions( diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 9f70534..35bfec5 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -43,8 +43,8 @@ #include "net/base/net_util.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/WebKit/chromium/public/WebFindOptions.h" +#include "webkit/glue/form_data.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_values.h" #if defined(OS_WIN) // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. @@ -52,7 +52,10 @@ #endif using base::TimeDelta; +using webkit_glue::FormData; +using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; +using webkit_glue::WebApplicationInfo; using WebKit::WebConsoleMessage; using WebKit::WebDragOperation; using WebKit::WebDragOperationNone; @@ -767,8 +770,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnMsgShowModalHTMLDialog) IPC_MESSAGE_HANDLER(ViewHostMsg_FormsSeen, OnMsgFormsSeen) IPC_MESSAGE_HANDLER(ViewHostMsg_PasswordFormsSeen, OnMsgPasswordFormsSeen) - IPC_MESSAGE_HANDLER(ViewHostMsg_FormFieldValuesSubmitted, - OnMsgFormFieldValuesSubmitted) + IPC_MESSAGE_HANDLER(ViewHostMsg_FormSubmitted, OnMsgFormSubmitted) IPC_MESSAGE_HANDLER(ViewHostMsg_StartDragging, OnMsgStartDragging) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateDragCursor, OnUpdateDragCursor) IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) @@ -1353,8 +1355,7 @@ void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); } -void RenderViewHost::OnMsgFormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms) { +void RenderViewHost::OnMsgFormsSeen(const std::vector<FormData>& forms) { RenderViewHostDelegate::AutoFill* autofill_delegate = delegate_->GetAutoFillDelegate(); if (autofill_delegate) @@ -1362,21 +1363,20 @@ void RenderViewHost::OnMsgFormsSeen( } void RenderViewHost::OnMsgPasswordFormsSeen( - const std::vector<webkit_glue::PasswordForm>& forms) { + const std::vector<PasswordForm>& forms) { delegate_->PasswordFormsSeen(forms); } -void RenderViewHost::OnMsgFormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) { +void RenderViewHost::OnMsgFormSubmitted(const FormData& form) { RenderViewHostDelegate::Autocomplete* autocomplete_delegate = delegate_->GetAutocompleteDelegate(); if (autocomplete_delegate) - autocomplete_delegate->FormFieldValuesSubmitted(form); + autocomplete_delegate->FormSubmitted(form); RenderViewHostDelegate::AutoFill* autofill_delegate = delegate_->GetAutoFillDelegate(); if (autofill_delegate) - autofill_delegate->FormFieldValuesSubmitted(form); + autofill_delegate->FormSubmitted(form); } void RenderViewHost::OnMsgStartDragging( @@ -1516,8 +1516,7 @@ void RenderViewHost::OnReceivedSavableResourceLinksForCurrentPage( } void RenderViewHost::OnDidGetApplicationInfo( - int32 page_id, - const webkit_glue::WebApplicationInfo& info) { + int32 page_id, const WebApplicationInfo& info) { RenderViewHostDelegate::BrowserIntegration* integration_delegate = delegate_->GetBrowserIntegrationDelegate(); if (integration_delegate) @@ -1590,7 +1589,7 @@ void RenderViewHost::OnRemoveAutofillEntry(const string16& field_name, } void RenderViewHost::OnFillAutoFillFormData(int query_id, - const webkit_glue::FormData& form, + const FormData& form, const string16& name, const string16& label) { RenderViewHostDelegate::AutoFill* autofill_delegate = @@ -1619,7 +1618,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned( } void RenderViewHost::AutoFillFormDataFilled(int query_id, - const webkit_glue::FormData& form) { + const FormData& form) { Send(new ViewMsg_AutoFillFormDataFilled(routing_id(), query_id, form)); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 045acee..3f8586d 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -19,7 +19,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" #include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextDirection.h" -#include "webkit/glue/form_field_values.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/window_open_disposition.h" @@ -42,17 +41,17 @@ struct UserMetricsAction; namespace gfx { class Point; -} +} // namespace gfx namespace webkit_glue { +struct FormData; class FormField; -class FormFieldValues; struct WebApplicationInfo; -} +} // namespace webkit_glue namespace WebKit { struct WebMediaPlayerAction; -} +} // namespace WebKit class URLRequestContextGetter; @@ -542,10 +541,10 @@ class RenderViewHost : public RenderWidgetHost { const std::string& json_arguments, IPC::Message* reply_msg); void OnMsgFormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms); + const std::vector<webkit_glue::FormData>& forms); void OnMsgPasswordFormsSeen( const std::vector<webkit_glue::PasswordForm>& forms); - void OnMsgFormFieldValuesSubmitted(const webkit_glue::FormFieldValues& forms); + void OnMsgFormSubmitted(const webkit_glue::FormData& forms); void OnMsgStartDragging(const WebDropData& drop_data, WebKit::WebDragOperationsMask operations_allowed, const SkBitmap& image, diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 332fd24..f522a6dc 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -61,7 +61,6 @@ class Message; namespace webkit_glue { struct FormData; class FormField; -class FormFieldValues; struct PasswordForm; struct WebApplicationInfo; } @@ -374,8 +373,7 @@ class RenderViewHostDelegate { class Autocomplete { public: // Forms fillable by Autocomplete have been detected in the page. - virtual void FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) = 0; + virtual void FormSubmitted(const webkit_glue::FormData& form) = 0; // Called to retrieve a list of suggestions from the web database given // the name of the field |field_name| and what the user has already typed @@ -401,13 +399,11 @@ class RenderViewHostDelegate { class AutoFill { public: // Called when the user submits a form. - virtual void FormFieldValuesSubmitted( - const webkit_glue::FormFieldValues& form) = 0; + virtual void FormSubmitted(const webkit_glue::FormData& form) = 0; // Called when the frame has finished loading and there are forms in the // frame. - virtual void FormsSeen( - const std::vector<webkit_glue::FormFieldValues>& forms) = 0; + virtual void FormsSeen(const std::vector<webkit_glue::FormData>& forms) = 0; // Called to retrieve a list of AutoFill suggestions from the web database // given the name of the field and what the user has already typed in the diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 37c338a..d70b674 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -1459,7 +1459,7 @@ LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM, LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { LRESULT reference_result = static_cast<LRESULT>(0L); - // TODO(ctguil): http://crbug.com/25564 Disabling accessibility in the + // TODO(jcampan): http://b/issue?id=1432077 Disabling accessibility in the // renderer is a temporary work-around until that bug is fixed. if (!renderer_accessible_) return reference_result; |