Chromium Code Reviews| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | |
| 10 #include <set> | 11 #include <set> |
| 11 #include <string> | 12 #include <string> |
| 12 #include <vector> | 13 #include <vector> |
| 13 | 14 |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/scoped_vector.h" | |
| 18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 20 #include "components/autofill/core/browser/autofill_field.h" | 20 #include "components/autofill/core/browser/autofill_field.h" |
| 21 #include "components/autofill/core/browser/autofill_type.h" | 21 #include "components/autofill/core/browser/autofill_type.h" |
| 22 #include "components/autofill/core/browser/field_types.h" | 22 #include "components/autofill/core/browser/field_types.h" |
| 23 #include "components/autofill/core/browser/proto/server.pb.h" | 23 #include "components/autofill/core/browser/proto/server.pb.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 enum UploadRequired { | 26 enum UploadRequired { |
| 27 UPLOAD_NOT_REQUIRED, | 27 UPLOAD_NOT_REQUIRED, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 39 | 39 |
| 40 namespace autofill { | 40 namespace autofill { |
| 41 | 41 |
| 42 struct FormData; | 42 struct FormData; |
| 43 struct FormDataPredictions; | 43 struct FormDataPredictions; |
| 44 | 44 |
| 45 // FormStructure stores a single HTML form together with the values entered | 45 // FormStructure stores a single HTML form together with the values entered |
| 46 // in the fields along with additional information needed by Autofill. | 46 // in the fields along with additional information needed by Autofill. |
| 47 class FormStructure { | 47 class FormStructure { |
| 48 public: | 48 public: |
| 49 using FieldsVector = std::vector<std::unique_ptr<AutofillField>>; | |
|
vabr (Chromium)
2017/01/02 08:30:21
nit: I'm not completely sure if this alias is help
Avi (use Gerrit)
2017/01/02 20:32:03
Done.
| |
| 50 | |
| 49 explicit FormStructure(const FormData& form); | 51 explicit FormStructure(const FormData& form); |
| 50 virtual ~FormStructure(); | 52 virtual ~FormStructure(); |
| 51 | 53 |
| 52 // Runs several heuristics against the form fields to determine their possible | 54 // Runs several heuristics against the form fields to determine their possible |
| 53 // types. | 55 // types. |
| 54 void DetermineHeuristicTypes(); | 56 void DetermineHeuristicTypes(); |
| 55 | 57 |
| 56 // Encodes the proto |upload| request from this FormStructure. | 58 // Encodes the proto |upload| request from this FormStructure. |
| 57 // In some cases, a |login_form_signature| is included as part of the upload. | 59 // In some cases, a |login_form_signature| is included as part of the upload. |
| 58 // This field is empty when sending upload requests for non-login forms. | 60 // This field is empty when sending upload requests for non-login forms. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 size_t field_count() const; | 183 size_t field_count() const; |
| 182 | 184 |
| 183 // Returns the number of fields that are part of the form signature and that | 185 // Returns the number of fields that are part of the form signature and that |
| 184 // are included in queries to the Autofill server. | 186 // are included in queries to the Autofill server. |
| 185 size_t active_field_count() const; | 187 size_t active_field_count() const; |
| 186 | 188 |
| 187 // Returns the number of fields that are able to be autofilled. | 189 // Returns the number of fields that are able to be autofilled. |
| 188 size_t autofill_count() const { return autofill_count_; } | 190 size_t autofill_count() const { return autofill_count_; } |
| 189 | 191 |
| 190 // Used for iterating over the fields. | 192 // Used for iterating over the fields. |
| 191 std::vector<AutofillField*>::const_iterator begin() const { | 193 FieldsVector::const_iterator begin() const { return fields_.begin(); } |
| 192 return fields_.begin(); | 194 FieldsVector::const_iterator end() const { return fields_.end(); } |
| 193 } | |
| 194 std::vector<AutofillField*>::const_iterator end() const { | |
| 195 return fields_.end(); | |
| 196 } | |
| 197 | 195 |
| 198 const base::string16& form_name() const { return form_name_; } | 196 const base::string16& form_name() const { return form_name_; } |
| 199 | 197 |
| 200 const GURL& source_url() const { return source_url_; } | 198 const GURL& source_url() const { return source_url_; } |
| 201 | 199 |
| 202 const GURL& target_url() const { return target_url_; } | 200 const GURL& target_url() const { return target_url_; } |
| 203 | 201 |
| 204 bool has_author_specified_types() { return has_author_specified_types_; } | 202 bool has_author_specified_types() { return has_author_specified_types_; } |
| 205 | 203 |
| 206 bool has_author_specified_sections() { | 204 bool has_author_specified_sections() { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 // The source URL. | 265 // The source URL. |
| 268 GURL source_url_; | 266 GURL source_url_; |
| 269 | 267 |
| 270 // The target URL. | 268 // The target URL. |
| 271 GURL target_url_; | 269 GURL target_url_; |
| 272 | 270 |
| 273 // The number of fields able to be auto-filled. | 271 // The number of fields able to be auto-filled. |
| 274 size_t autofill_count_; | 272 size_t autofill_count_; |
| 275 | 273 |
| 276 // A vector of all the input fields in the form. | 274 // A vector of all the input fields in the form. |
| 277 ScopedVector<AutofillField> fields_; | 275 FieldsVector fields_; |
| 278 | 276 |
| 279 // The number of fields that are part of the form signature and that are | 277 // The number of fields that are part of the form signature and that are |
| 280 // included in queries to the Autofill server. | 278 // included in queries to the Autofill server. |
| 281 size_t active_field_count_; | 279 size_t active_field_count_; |
| 282 | 280 |
| 283 // Whether the server expects us to always upload, never upload, or default | 281 // Whether the server expects us to always upload, never upload, or default |
| 284 // to the stored upload rates. | 282 // to the stored upload rates. |
| 285 UploadRequired upload_required_; | 283 UploadRequired upload_required_; |
| 286 | 284 |
| 287 // Whether the form includes any field types explicitly specified by the site | 285 // Whether the form includes any field types explicitly specified by the site |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 312 // The unique signature for this form, composed of the target url domain, | 310 // The unique signature for this form, composed of the target url domain, |
| 313 // the form name, and the form field names in a 64-bit hash. | 311 // the form name, and the form field names in a 64-bit hash. |
| 314 FormSignature form_signature_; | 312 FormSignature form_signature_; |
| 315 | 313 |
| 316 DISALLOW_COPY_AND_ASSIGN(FormStructure); | 314 DISALLOW_COPY_AND_ASSIGN(FormStructure); |
| 317 }; | 315 }; |
| 318 | 316 |
| 319 } // namespace autofill | 317 } // namespace autofill |
| 320 | 318 |
| 321 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ | 319 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_STRUCTURE_H_ |
| OLD | NEW |