| 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_CONTENT_RENDERER_FORM_CACHE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "components/autofill/core/common/form_data.h" | 16 #include "components/autofill/core/common/form_data.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 class WebFormControlElement; | 19 class WebFormControlElement; |
| 20 class WebFrame; | |
| 21 class WebInputElement; | 20 class WebInputElement; |
| 21 class WebLocalFrame; |
| 22 class WebSelectElement; | 22 class WebSelectElement; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace autofill { | 25 namespace autofill { |
| 26 | 26 |
| 27 struct FormDataPredictions; | 27 struct FormDataPredictions; |
| 28 | 28 |
| 29 // Manages the forms in a single RenderFrame. | 29 // Manages the forms in a single RenderFrame. |
| 30 class FormCache { | 30 class FormCache { |
| 31 public: | 31 public: |
| 32 explicit FormCache(const blink::WebFrame& frame); | 32 explicit FormCache(const blink::WebLocalFrame& frame); |
| 33 ~FormCache(); | 33 ~FormCache(); |
| 34 | 34 |
| 35 // Scans the DOM in |frame_| extracting and storing forms that have not been | 35 // Scans the DOM in |frame_| extracting and storing forms that have not been |
| 36 // seen before. Returns the extracted forms. | 36 // seen before. Returns the extracted forms. |
| 37 std::vector<FormData> ExtractNewForms(); | 37 std::vector<FormData> ExtractNewForms(); |
| 38 | 38 |
| 39 // Resets the forms. | 39 // Resets the forms. |
| 40 void Reset(); | 40 void Reset(); |
| 41 | 41 |
| 42 // Clears the values of all input elements in the form that contains | 42 // Clears the values of all input elements in the form that contains |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 // |log_deprecation_messages| is set. | 55 // |log_deprecation_messages| is set. |
| 56 size_t ScanFormControlElements( | 56 size_t ScanFormControlElements( |
| 57 const std::vector<blink::WebFormControlElement>& control_elements, | 57 const std::vector<blink::WebFormControlElement>& control_elements, |
| 58 bool log_deprecation_messages); | 58 bool log_deprecation_messages); |
| 59 | 59 |
| 60 // Saves initial state of checkbox and select elements. | 60 // Saves initial state of checkbox and select elements. |
| 61 void SaveInitialValues( | 61 void SaveInitialValues( |
| 62 const std::vector<blink::WebFormControlElement>& control_elements); | 62 const std::vector<blink::WebFormControlElement>& control_elements); |
| 63 | 63 |
| 64 // The frame this FormCache is associated with. | 64 // The frame this FormCache is associated with. |
| 65 const blink::WebFrame& frame_; | 65 const blink::WebLocalFrame& frame_; |
| 66 | 66 |
| 67 // The cached forms. Used to prevent re-extraction of forms. | 67 // The cached forms. Used to prevent re-extraction of forms. |
| 68 std::set<FormData> parsed_forms_; | 68 std::set<FormData> parsed_forms_; |
| 69 | 69 |
| 70 // The synthetic FormData is for all the fieldsets in the document without a | 70 // The synthetic FormData is for all the fieldsets in the document without a |
| 71 // form owner. | 71 // form owner. |
| 72 FormData synthetic_form_; | 72 FormData synthetic_form_; |
| 73 | 73 |
| 74 // The cached initial values for <select> elements. | 74 // The cached initial values for <select> elements. |
| 75 std::map<const blink::WebSelectElement, base::string16> | 75 std::map<const blink::WebSelectElement, base::string16> |
| 76 initial_select_values_; | 76 initial_select_values_; |
| 77 | 77 |
| 78 // The cached initial values for checkable <input> elements. | 78 // The cached initial values for checkable <input> elements. |
| 79 std::map<const blink::WebInputElement, bool> initial_checked_state_; | 79 std::map<const blink::WebInputElement, bool> initial_checked_state_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(FormCache); | 81 DISALLOW_COPY_AND_ASSIGN(FormCache); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace autofill | 84 } // namespace autofill |
| 85 | 85 |
| 86 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ | 86 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
| OLD | NEW |