| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_RENDERER_FORM_MANAGER_H_ | 5 #ifndef CHROME_RENDERER_FORM_MANAGER_H_ |
| 6 #define CHROME_RENDERER_FORM_MANAGER_H_ | 6 #define CHROME_RENDERER_FORM_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // the name of the form to fill out, and the number of elements and values | 78 // the name of the form to fill out, and the number of elements and values |
| 79 // must match the number of stored elements in the form. | 79 // must match the number of stored elements in the form. |
| 80 // TODO(jhawkins): Is matching on name alone good enough? It's possible to | 80 // TODO(jhawkins): Is matching on name alone good enough? It's possible to |
| 81 // store multiple forms with the same names from different frames. | 81 // store multiple forms with the same names from different frames. |
| 82 bool FillForm(const webkit_glue::FormData& form); | 82 bool FillForm(const webkit_glue::FormData& form); |
| 83 | 83 |
| 84 // Resets the stored set of forms. | 84 // Resets the stored set of forms. |
| 85 void Reset(); | 85 void Reset(); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 // A map of WebFormControlElements keyed by each element's name. | 88 // Stores the WebFormElement and the form control elements for a form. |
| 89 typedef std::map<string16, WebKit::WebFormControlElement> | |
| 90 FormControlElementMap; | |
| 91 | |
| 92 // Stores the WebFormElement and the map of form control elements for each | |
| 93 // form. | |
| 94 struct FormElement { | 89 struct FormElement { |
| 95 WebKit::WebFormElement form_element; | 90 WebKit::WebFormElement form_element; |
| 96 FormControlElementMap control_elements; | 91 std::vector<WebKit::WebFormControlElement> control_elements; |
| 97 }; | 92 }; |
| 98 | 93 |
| 99 // A map of vectors of FormElements keyed by the WebFrame containing each | 94 // A map of vectors of FormElements keyed by the WebFrame containing each |
| 100 // form. | 95 // form. |
| 101 typedef std::map<const WebKit::WebFrame*, std::vector<FormElement*> > | 96 typedef std::map<const WebKit::WebFrame*, std::vector<FormElement*> > |
| 102 WebFrameFormElementMap; | 97 WebFrameFormElementMap; |
| 103 | 98 |
| 104 // Converts a FormElement to FormData storage. Returns false if the form does | 99 // Converts a FormElement to FormData storage. Returns false if the form does |
| 105 // not meet all the requirements in the requirements mask. | 100 // not meet all the requirements in the requirements mask. |
| 106 // TODO(jhawkins): Modify FormElement so we don't need |frame|. | 101 // TODO(jhawkins): Modify FormElement so we don't need |frame|. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 121 static string16 InferLabelForElement( | 116 static string16 InferLabelForElement( |
| 122 const WebKit::WebFormControlElement& element); | 117 const WebKit::WebFormControlElement& element); |
| 123 | 118 |
| 124 // The map of form elements. | 119 // The map of form elements. |
| 125 WebFrameFormElementMap form_elements_map_; | 120 WebFrameFormElementMap form_elements_map_; |
| 126 | 121 |
| 127 DISALLOW_COPY_AND_ASSIGN(FormManager); | 122 DISALLOW_COPY_AND_ASSIGN(FormManager); |
| 128 }; | 123 }; |
| 129 | 124 |
| 130 #endif // CHROME_RENDERER_FORM_MANAGER_H_ | 125 #endif // CHROME_RENDERER_FORM_MANAGER_H_ |
| OLD | NEW |