| 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 <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 namespace WebKit { | 14 namespace blink { |
| 15 class WebDocument; | 15 class WebDocument; |
| 16 class WebFormElement; | 16 class WebFormElement; |
| 17 class WebFrame; | 17 class WebFrame; |
| 18 class WebInputElement; | 18 class WebInputElement; |
| 19 class WebSelectElement; | 19 class WebSelectElement; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace autofill { | 22 namespace autofill { |
| 23 | 23 |
| 24 struct FormData; | 24 struct FormData; |
| 25 struct FormDataPredictions; | 25 struct FormDataPredictions; |
| 26 | 26 |
| 27 // Manages the forms in a RenderView. | 27 // Manages the forms in a RenderView. |
| 28 class FormCache { | 28 class FormCache { |
| 29 public: | 29 public: |
| 30 FormCache(); | 30 FormCache(); |
| 31 ~FormCache(); | 31 ~FormCache(); |
| 32 | 32 |
| 33 // Scans the DOM in |frame| extracting and storing forms. | 33 // Scans the DOM in |frame| extracting and storing forms. |
| 34 // Fills |forms| with extracted forms. | 34 // Fills |forms| with extracted forms. |
| 35 void ExtractForms(const WebKit::WebFrame& frame, | 35 void ExtractForms(const blink::WebFrame& frame, |
| 36 std::vector<FormData>* forms); | 36 std::vector<FormData>* forms); |
| 37 | 37 |
| 38 // Scans the DOM in |frame| extracting and storing forms. | 38 // Scans the DOM in |frame| extracting and storing forms. |
| 39 // Fills |forms| with extracted forms and |web_form_elements| with associated | 39 // Fills |forms| with extracted forms and |web_form_elements| with associated |
| 40 // web form elements. Returns true if there are unextracted forms due to | 40 // web form elements. Returns true if there are unextracted forms due to |
| 41 // |minimum_required_fields| limit, else false. | 41 // |minimum_required_fields| limit, else false. |
| 42 bool ExtractFormsAndFormElements( | 42 bool ExtractFormsAndFormElements( |
| 43 const WebKit::WebFrame& frame, | 43 const blink::WebFrame& frame, |
| 44 size_t minimum_required_fields, | 44 size_t minimum_required_fields, |
| 45 std::vector<FormData>* forms, | 45 std::vector<FormData>* forms, |
| 46 std::vector<WebKit::WebFormElement>* web_form_elements); | 46 std::vector<blink::WebFormElement>* web_form_elements); |
| 47 | 47 |
| 48 // Resets the forms for the specified |frame|. | 48 // Resets the forms for the specified |frame|. |
| 49 void ResetFrame(const WebKit::WebFrame& frame); | 49 void ResetFrame(const blink::WebFrame& frame); |
| 50 | 50 |
| 51 // Clears the values of all input elements in the form that contains | 51 // Clears the values of all input elements in the form that contains |
| 52 // |element|. Returns false if the form is not found. | 52 // |element|. Returns false if the form is not found. |
| 53 bool ClearFormWithElement(const WebKit::WebInputElement& element); | 53 bool ClearFormWithElement(const blink::WebInputElement& element); |
| 54 | 54 |
| 55 // For each field in the |form|, sets the field's placeholder text to the | 55 // For each field in the |form|, sets the field's placeholder text to the |
| 56 // field's overall predicted type. Also sets the title to include the field's | 56 // field's overall predicted type. Also sets the title to include the field's |
| 57 // heuristic type, server type, and signature; as well as the form's signature | 57 // heuristic type, server type, and signature; as well as the form's signature |
| 58 // and the experiment id for the server predictions. | 58 // and the experiment id for the server predictions. |
| 59 bool ShowPredictions(const FormDataPredictions& form); | 59 bool ShowPredictions(const FormDataPredictions& form); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // The cached web frames. | 62 // The cached web frames. |
| 63 std::set<WebKit::WebDocument> web_documents_; | 63 std::set<blink::WebDocument> web_documents_; |
| 64 | 64 |
| 65 // The cached initial values for <select> elements. | 65 // The cached initial values for <select> elements. |
| 66 std::map<const WebKit::WebSelectElement, base::string16> | 66 std::map<const blink::WebSelectElement, base::string16> |
| 67 initial_select_values_; | 67 initial_select_values_; |
| 68 | 68 |
| 69 // The cached initial values for checkable <input> elements. | 69 // The cached initial values for checkable <input> elements. |
| 70 std::map<const WebKit::WebInputElement, bool> initial_checked_state_; | 70 std::map<const blink::WebInputElement, bool> initial_checked_state_; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(FormCache); | 72 DISALLOW_COPY_AND_ASSIGN(FormCache); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 } // namespace autofill | 75 } // namespace autofill |
| 76 | 76 |
| 77 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ | 77 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_FORM_CACHE_H_ |
| OLD | NEW |