From 679782384a0cb99c6a496bf0acbb7fee246ec5be Mon Sep 17 00:00:00 2001 From: "isherman@chromium.org" Date: Mon, 20 Jun 2011 20:21:42 +0000 Subject: Revert 89716 - Add a debugging flag to annotate web forms with their Autofill field type predictions. BUG=none TEST=none Review URL: http://codereview.chromium.org/7187029 TBR=isherman@chromium.org Review URL: http://codereview.chromium.org/7204037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89720 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 10 ------ chrome/browser/about_flags.cc | 7 ---- chrome/browser/autofill/autofill_manager.cc | 22 ++----------- chrome/browser/autofill/form_structure.cc | 44 ------------------------- chrome/browser/autofill/form_structure.h | 13 +------- chrome/common/autofill_messages.h | 21 ------------ chrome/common/chrome_switches.cc | 3 -- chrome/common/chrome_switches.h | 1 - chrome/renderer/autofill/autofill_agent.cc | 11 ------- chrome/renderer/autofill/autofill_agent.h | 8 ----- chrome/renderer/autofill/form_manager.cc | 51 ++--------------------------- chrome/renderer/autofill/form_manager.h | 7 ---- 12 files changed, 5 insertions(+), 193 deletions(-) (limited to 'chrome') diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 371eacdf..3173b14 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4317,12 +4317,6 @@ Keep your key file in a safe place. You will need it to create new versions of y Preload the default search engine for Instant. - - Show Autofill predictions - - - Annotates web forms with Autofill field type predictions as placeholder text. - @@ -7586,10 +7580,6 @@ Keep your key file in a safe place. You will need it to create new versions of y About Autofill - - - heuristic type: $1NAME_FIRST\nserver type: $2NAME_FIRST\nfield signature: $312345678\nform signature: $41234567812345678\nexperiment id: "$5ar1" - diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index d1b6b0e..c6ceafc 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -336,13 +336,6 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE("") #endif }, - { - "show-autofill-type-predictions", - IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_NAME, - IDS_FLAGS_SHOW_AUTOFILL_TYPE_PREDICTIONS_DESCRIPTION, - kOsAll, - SINGLE_VALUE_TYPE(switches::kShowAutofillTypePredictions) - }, }; const Experiment* experiments = kExperiments; diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index c2744cb..e450918 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -11,7 +11,6 @@ #include #include -#include "base/command_line.h" #include "base/logging.h" #include "base/string16.h" #include "base/string_util.h" @@ -34,7 +33,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/autofill_messages.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/guid.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" @@ -47,11 +45,9 @@ #include "ipc/ipc_message_macros.h" #include "ui/base/l10n/l10n_util.h" #include "webkit/glue/form_data.h" -#include "webkit/glue/form_data_predictions.h" #include "webkit/glue/form_field.h" using webkit_glue::FormData; -using webkit_glue::FormDataPredictions; using webkit_glue::FormField; namespace { @@ -631,24 +627,9 @@ void AutofillManager::OnDidShowAutofillSuggestions() { void AutofillManager::OnLoadedServerPredictions( const std::string& response_xml) { - // Parse and store the server predictions. FormStructure::ParseQueryResponse(response_xml, form_structures_.get(), *metric_logger_); - - // If the corresponding flag is set, annotate forms with the predicted types. - RenderViewHost* host; - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kShowAutofillTypePredictions) || - !GetHost(personal_data_->profiles(), personal_data_->credit_cards(), - &host)) { - return; - } - - std::vector forms; - FormStructure::GetFieldTypePredictions(form_structures_.get(), &forms); - host->Send(new AutofillMsg_FieldTypePredictionsAvailable(host->routing_id(), - forms)); } void AutofillManager::OnUploadedPossibleFieldTypes() { @@ -735,7 +716,8 @@ AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, DCHECK(tab_contents); } -void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { +void AutofillManager::set_metric_logger( + const AutofillMetrics* metric_logger) { metric_logger_.reset(metric_logger); } diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index e981394..8a804a5 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -9,22 +9,15 @@ #include "base/sha1.h" #include "base/stringprintf.h" #include "base/string_number_conversions.h" -#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autofill/autofill_metrics.h" -#include "chrome/browser/autofill/autofill_type.h" #include "chrome/browser/autofill/autofill_xml_parser.h" #include "chrome/browser/autofill/field_types.h" #include "chrome/browser/autofill/form_field.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" -#include "webkit/glue/form_data.h" -#include "webkit/glue/form_data_predictions.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_predictions.h" using webkit_glue::FormData; -using webkit_glue::FormDataPredictions; -using webkit_glue::FormFieldPredictions; namespace { @@ -309,43 +302,6 @@ void FormStructure::ParseQueryResponse(const std::string& response_xml, metric_logger.LogServerQueryMetric(metric); } -// static -void FormStructure::GetFieldTypePredictions( - const std::vector& form_structures, - std::vector* forms) { - forms->clear(); - forms->reserve(form_structures.size()); - for (size_t i = 0; i < form_structures.size(); ++i) { - FormStructure* form_structure = form_structures[i]; - FormDataPredictions form; - form.data.name = form_structure->form_name_; - form.data.method = - ASCIIToUTF16((form_structure->method_ == POST) ? "POST" : "GET"); - form.data.origin = form_structure->source_url_; - form.data.action = form_structure->target_url_; - form.signature = form_structure->FormSignature(); - form.experiment_id = form_structure->server_experiment_id_; - - for (std::vector::const_iterator field = - form_structure->fields_.begin(); - field != form_structure->fields_.end(); ++field) { - form.data.fields.push_back(webkit_glue::FormField(**field)); - - FormFieldPredictions annotated_field; - annotated_field.signature = (*field)->FieldSignature(); - annotated_field.heuristic_type = - AutofillType::FieldTypeToString((*field)->heuristic_type()); - annotated_field.server_type = - AutofillType::FieldTypeToString((*field)->server_type()); - annotated_field.overall_type = - AutofillType::FieldTypeToString((*field)->type()); - form.fields.push_back(annotated_field); - } - - forms->push_back(form); - } -} - std::string FormStructure::FormSignature() const { std::string scheme(target_url_.scheme()); std::string host(target_url_.host()); diff --git a/chrome/browser/autofill/form_structure.h b/chrome/browser/autofill/form_structure.h index d94be92..0d8ddd7 100644 --- a/chrome/browser/autofill/form_structure.h +++ b/chrome/browser/autofill/form_structure.h @@ -15,7 +15,7 @@ #include "chrome/browser/autofill/autofill_type.h" #include "chrome/browser/autofill/field_types.h" #include "googleurl/src/gurl.h" - +#include "webkit/glue/form_data.h" enum RequestMethod { GET, @@ -34,11 +34,6 @@ namespace buzz { class XmlElement; } -namespace webkit_glue { -struct FormData; -struct FormDataPredictions; -} - // FormStructure stores a single HTML form together with the values entered // in the fields along with additional information needed by Autofill. class FormStructure { @@ -70,12 +65,6 @@ class FormStructure { const std::vector& forms, const AutofillMetrics& metric_logger); - // Fills |forms| with the details from the given |form_structures| and their - // fields' predicted types. - static void GetFieldTypePredictions( - const std::vector& form_structures, - std::vector* forms); - // The unique signature for this form, composed of the target url domain, // the form name, and the form field names in a 64-bit hash. std::string FormSignature() const; diff --git a/chrome/common/autofill_messages.h b/chrome/common/autofill_messages.h index eb3fc88..250ae17 100644 --- a/chrome/common/autofill_messages.h +++ b/chrome/common/autofill_messages.h @@ -9,9 +9,7 @@ #include "content/common/webkit_param_traits.h" #include "ipc/ipc_message_macros.h" #include "webkit/glue/form_data.h" -#include "webkit/glue/form_data_predictions.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_predictions.h" #include "webkit/glue/password_form.h" #include "webkit/glue/password_form_dom_manager.h" @@ -27,14 +25,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormField) IPC_STRUCT_TRAITS_MEMBER(option_strings) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormFieldPredictions) - IPC_STRUCT_TRAITS_MEMBER(field) - IPC_STRUCT_TRAITS_MEMBER(signature) - IPC_STRUCT_TRAITS_MEMBER(heuristic_type) - IPC_STRUCT_TRAITS_MEMBER(server_type) - IPC_STRUCT_TRAITS_MEMBER(overall_type) -IPC_STRUCT_TRAITS_END() - IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormData) IPC_STRUCT_TRAITS_MEMBER(name) IPC_STRUCT_TRAITS_MEMBER(method) @@ -44,13 +34,6 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormData) IPC_STRUCT_TRAITS_MEMBER(fields) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormDataPredictions) - IPC_STRUCT_TRAITS_MEMBER(data) - IPC_STRUCT_TRAITS_MEMBER(signature) - IPC_STRUCT_TRAITS_MEMBER(experiment_id) - IPC_STRUCT_TRAITS_MEMBER(fields) -IPC_STRUCT_TRAITS_END() - IPC_STRUCT_TRAITS_BEGIN(webkit_glue::PasswordFormFillData) IPC_STRUCT_TRAITS_MEMBER(basic_data) IPC_STRUCT_TRAITS_MEMBER(additional_logins) @@ -79,10 +62,6 @@ IPC_MESSAGE_ROUTED2(AutofillMsg_FormDataFilled, IPC_MESSAGE_ROUTED1(AutofillMsg_FillPasswordForm, webkit_glue::PasswordFormFillData) -// Send the heuristic and server field type predictions to the renderer. -IPC_MESSAGE_ROUTED1( - AutofillMsg_FieldTypePredictionsAvailable, - std::vector /* forms */) // Autofill messages sent from the renderer to the browser. diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index fb3f1e4..8c709fb 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -891,9 +891,6 @@ const char kSearchInOmniboxHint[] = "search-in-omnibox-hint"; // The LSID of the account to use for the service process. const char kServiceAccountLsid[] = "service-account-lsid"; -// Annotate forms with Autofill field type predictions. -const char kShowAutofillTypePredictions[] = "show-autofill-type-predictions"; - // See kHideIcons. const char kShowIcons[] = "show-icons"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 7871120..f16db7e 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -242,7 +242,6 @@ extern const char kSbDisableDownloadProtection[]; extern const char kSdchFilter[]; extern const char kSearchInOmniboxHint[]; extern const char kServiceAccountLsid[]; -extern const char kShowAutofillTypePredictions[]; extern const char kShowCompositedLayerBorders[]; extern const char kShowCompositedLayerTree[]; extern const char kShowFPSCounter[]; diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc index ab4c061..5418dca 100644 --- a/chrome/renderer/autofill/autofill_agent.cc +++ b/chrome/renderer/autofill/autofill_agent.cc @@ -20,7 +20,6 @@ #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "webkit/glue/form_data.h" -#include "webkit/glue/form_data_predictions.h" #include "webkit/glue/form_field.h" #include "webkit/glue/password_form.h" @@ -32,7 +31,6 @@ using WebKit::WebKeyboardEvent; using WebKit::WebNode; using WebKit::WebString; using webkit_glue::FormData; -using webkit_glue::FormDataPredictions; namespace { @@ -66,8 +64,6 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned) IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled) - IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, - OnFieldTypePredictionsAvailable) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -309,13 +305,6 @@ void AutofillAgent::OnFormDataFilled(int query_id, Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id())); } -void AutofillAgent::OnFieldTypePredictionsAvailable( - const std::vector& forms) { - for (size_t i = 0; i < forms.size(); ++i) { - form_manager_.ShowPredictions(forms[i]); - } -} - void AutofillAgent::ShowSuggestions(const WebInputElement& element, bool autofill_on_empty_values, bool requires_caret_at_end, diff --git a/chrome/renderer/autofill/autofill_agent.h b/chrome/renderer/autofill/autofill_agent.h index 921744d..6996d31 100644 --- a/chrome/renderer/autofill/autofill_agent.h +++ b/chrome/renderer/autofill/autofill_agent.h @@ -16,12 +16,6 @@ #include "content/renderer/render_view_observer.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutoFillClient.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" -#include "webkit/glue/form_data.h" -#include "webkit/glue/form_field.h" - -namespace webkit_glue { -struct FormDataPredictions; -} namespace autofill { @@ -93,8 +87,6 @@ class AutofillAgent : public RenderViewObserver, const std::vector& icons, const std::vector& unique_ids); void OnFormDataFilled(int query_id, const webkit_glue::FormData& form); - void OnFieldTypePredictionsAvailable( - const std::vector& forms); // Called in a posted task by textFieldDidChange() to work-around a WebKit bug // http://bugs.webkit.org/show_bug.cgi?id=16976 diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc index 0adfbae..c94bfa0 100644 --- a/chrome/renderer/autofill/form_manager.cc +++ b/chrome/renderer/autofill/form_manager.cc @@ -9,7 +9,6 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "grit/generated_resources.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" @@ -22,13 +21,12 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" -#include "ui/base/l10n/l10n_util.h" #include "webkit/glue/form_data.h" -#include "webkit/glue/form_data_predictions.h" #include "webkit/glue/form_field.h" -#include "webkit/glue/form_field_predictions.h" #include "webkit/glue/web_io_operators.h" +using webkit_glue::FormData; +using webkit_glue::FormField; using WebKit::WebDocument; using WebKit::WebElement; using WebKit::WebFormControlElement; @@ -42,10 +40,6 @@ using WebKit::WebOptionElement; using WebKit::WebSelectElement; using WebKit::WebString; using WebKit::WebVector; -using webkit_glue::FormData; -using webkit_glue::FormDataPredictions; -using webkit_glue::FormField; -using webkit_glue::FormFieldPredictions; namespace { @@ -802,47 +796,6 @@ void FormManager::PreviewForm(const FormData& form, const WebNode& node) { &PreviewFormField); } -bool FormManager::ShowPredictions(const FormDataPredictions& form) { - FormElement* form_element = NULL; - if (!FindCachedFormElement(form.data, &form_element)) - return false; - - DCHECK_EQ(form.data.fields.size(), form.fields.size()); - for (size_t i = 0, j = 0; - i < form_element->control_elements.size() && j < form.fields.size(); - ++i) { - WebFormControlElement* element = &form_element->control_elements[i]; - string16 element_name(element->nameForAutofill()); - - // Search forward in the |form| for a corresponding field. - size_t k = j; - while (k < form.fields.size() && element_name != form.data.fields[k].name) - k++; - - if (k >= form.fields.size()) - continue; - - DCHECK_EQ(form.data.fields[k].name, element_name); - - std::string placeholder = form.fields[k].overall_type; - string16 title = l10n_util::GetStringFUTF16( - IDS_AUTOFILL_SHOW_PREDICTIONS_TITLE, - UTF8ToUTF16(form.fields[k].heuristic_type), - UTF8ToUTF16(form.fields[k].server_type), - UTF8ToUTF16(form.fields[k].signature), - UTF8ToUTF16(form.signature), - UTF8ToUTF16(form.experiment_id)); - if (!element->hasAttribute("placeholder")) - element->setAttribute("placeholder", WebString(UTF8ToUTF16(placeholder))); - element->setAttribute("title", WebString(title)); - - // We found a matching form field so move on to the next. - ++j; - } - - return true; -} - bool FormManager::ClearFormWithNode(const WebNode& node) { FormElement* form_element = NULL; if (!FindCachedFormElementWithNode(node, &form_element)) diff --git a/chrome/renderer/autofill/form_manager.h b/chrome/renderer/autofill/form_manager.h index b32dcb5..8ef30ac 100644 --- a/chrome/renderer/autofill/form_manager.h +++ b/chrome/renderer/autofill/form_manager.h @@ -16,7 +16,6 @@ namespace webkit_glue { struct FormData; -struct FormDataPredictions; struct FormField; } // namespace webkit_glue @@ -99,12 +98,6 @@ class FormManager { void PreviewForm(const webkit_glue::FormData& form, const WebKit::WebNode &node); - // For each field in the |form|, sets the field's placeholder text to the - // field's overall predicted type. Also sets the title to include the field's - // heuristic type, server type, and signature; as well as the form's signature - // and the experiment id for the server predictions. - bool ShowPredictions(const webkit_glue::FormDataPredictions& form); - // Clears the values of all input elements in the form that contains |node|. // Returns false if the form is not found. bool ClearFormWithNode(const WebKit::WebNode& node); -- cgit v1.1