| OLD | NEW | 
|    1 // Copyright 2013 The Chromium Authors. All rights reserved. |    1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |    5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 
|    6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |    6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 
|    7  |    7  | 
|    8 #include <set> |    8 #include <set> | 
|    9 #include <string> |    9 #include <string> | 
|   10 #include <vector> |   10 #include <vector> | 
|   11  |   11  | 
|   12 #include "base/callback.h" |   12 #include "base/callback.h" | 
|   13 #include "base/gtest_prod_util.h" |   13 #include "base/gtest_prod_util.h" | 
|   14 #include "base/memory/scoped_ptr.h" |   14 #include "base/memory/scoped_ptr.h" | 
|   15 #include "base/memory/scoped_vector.h" |   15 #include "base/memory/scoped_vector.h" | 
|   16 #include "base/strings/string16.h" |   16 #include "base/strings/string16.h" | 
|   17 #include "components/autofill/core/browser/autofill_field.h" |   17 #include "components/autofill/core/browser/autofill_field.h" | 
|   18 #include "components/autofill/core/browser/autofill_type.h" |   18 #include "components/autofill/core/browser/autofill_type.h" | 
|   19 #include "components/autofill/core/browser/field_types.h" |   19 #include "components/autofill/core/browser/field_types.h" | 
|   20 #include "components/autofill/core/common/web_element_descriptor.h" |   20 #include "components/autofill/core/common/web_element_descriptor.h" | 
|   21 #include "url/gurl.h" |   21 #include "url/gurl.h" | 
|   22  |   22  | 
|   23 enum RequestMethod { |  | 
|   24   GET, |  | 
|   25   POST |  | 
|   26 }; |  | 
|   27  |  | 
|   28 enum UploadRequired { |   23 enum UploadRequired { | 
|   29   UPLOAD_NOT_REQUIRED, |   24   UPLOAD_NOT_REQUIRED, | 
|   30   UPLOAD_REQUIRED, |   25   UPLOAD_REQUIRED, | 
|   31   USE_UPLOAD_RATES |   26   USE_UPLOAD_RATES | 
|   32 }; |   27 }; | 
|   33  |   28  | 
|   34 namespace base { |   29 namespace base { | 
|   35 class TimeTicks; |   30 class TimeTicks; | 
|   36 } |   31 } | 
|   37  |   32  | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   89   // fields' predicted types. |   84   // fields' predicted types. | 
|   90   static void GetFieldTypePredictions( |   85   static void GetFieldTypePredictions( | 
|   91       const std::vector<FormStructure*>& form_structures, |   86       const std::vector<FormStructure*>& form_structures, | 
|   92       std::vector<FormDataPredictions>* forms); |   87       std::vector<FormDataPredictions>* forms); | 
|   93  |   88  | 
|   94   // The unique signature for this form, composed of the target url domain, |   89   // The unique signature for this form, composed of the target url domain, | 
|   95   // the form name, and the form field names in a 64-bit hash. |   90   // the form name, and the form field names in a 64-bit hash. | 
|   96   std::string FormSignature() const; |   91   std::string FormSignature() const; | 
|   97  |   92  | 
|   98   // Runs a quick heuristic to rule out forms that are obviously not |   93   // Runs a quick heuristic to rule out forms that are obviously not | 
|   99   // auto-fillable, like google/yahoo/msn search, etc. The requirement that the |   94   // auto-fillable, like google/yahoo/msn search, etc. | 
|  100   // form's method be POST is only applied if |require_method_post| is true. |   95   bool IsAutofillable() const; | 
|  101   bool IsAutofillable(bool require_method_post) const; |  | 
|  102  |   96  | 
|  103   // Resets |autofill_count_| and counts the number of auto-fillable fields. |   97   // Resets |autofill_count_| and counts the number of auto-fillable fields. | 
|  104   // This is used when we receive server data for form fields.  At that time, |   98   // This is used when we receive server data for form fields.  At that time, | 
|  105   // we may have more known fields than just the number of fields we matched |   99   // we may have more known fields than just the number of fields we matched | 
|  106   // heuristically. |  100   // heuristically. | 
|  107   void UpdateAutofillCount(); |  101   void UpdateAutofillCount(); | 
|  108  |  102  | 
|  109   // Returns true if this form matches the structural requirements for Autofill. |  103   // Returns true if this form matches the structural requirements for Autofill. | 
|  110   // The requirement that the form's method be POST is only applied if |  104   bool ShouldBeParsed() const; | 
|  111   // |require_method_post| is true. |  | 
|  112   bool ShouldBeParsed(bool require_method_post) const; |  | 
|  113  |  105  | 
|  114   // Returns true if we should query the crowdsourcing server to determine this |  106   // Returns true if we should query the crowdsourcing server to determine this | 
|  115   // form's field types.  If the form includes author-specified types, this will |  107   // form's field types.  If the form includes author-specified types, this will | 
|  116   // return false. |  108   // return false. | 
|  117   bool ShouldBeCrowdsourced() const; |  109   bool ShouldBeCrowdsourced() const; | 
|  118  |  110  | 
|  119   // Sets the field types to be those set for |cached_form|. |  111   // Sets the field types to be those set for |cached_form|. | 
|  120   void UpdateFromCache(const FormStructure& cached_form); |  112   void UpdateFromCache(const FormStructure& cached_form); | 
|  121  |  113  | 
|  122   // Logs quality metrics for |this|, which should be a user-submitted form. |  114   // Logs quality metrics for |this|, which should be a user-submitted form. | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  247  |  239  | 
|  248   // The names of the form input elements, that are part of the form signature. |  240   // The names of the form input elements, that are part of the form signature. | 
|  249   // The string starts with "&" and the names are also separated by the "&" |  241   // The string starts with "&" and the names are also separated by the "&" | 
|  250   // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" |  242   // character. E.g.: "&form_input1_name&form_input2_name&...&form_inputN_name" | 
|  251   std::string form_signature_field_names_; |  243   std::string form_signature_field_names_; | 
|  252  |  244  | 
|  253   // Whether the server expects us to always upload, never upload, or default |  245   // Whether the server expects us to always upload, never upload, or default | 
|  254   // to the stored upload rates. |  246   // to the stored upload rates. | 
|  255   UploadRequired upload_required_; |  247   UploadRequired upload_required_; | 
|  256  |  248  | 
|  257   // GET or POST. |  | 
|  258   RequestMethod method_; |  | 
|  259  |  | 
|  260   // Whether the form includes any field types explicitly specified by the site |  249   // Whether the form includes any field types explicitly specified by the site | 
|  261   // author, via the |autocompletetype| attribute. |  250   // author, via the |autocompletetype| attribute. | 
|  262   bool has_author_specified_types_; |  251   bool has_author_specified_types_; | 
|  263  |  252  | 
|  264   DISALLOW_COPY_AND_ASSIGN(FormStructure); |  253   DISALLOW_COPY_AND_ASSIGN(FormStructure); | 
|  265 }; |  254 }; | 
|  266  |  255  | 
|  267 }  // namespace autofill |  256 }  // namespace autofill | 
|  268  |  257  | 
|  269 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |  258 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 
| OLD | NEW |