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_PASSWORD_AUTOFILL_AGENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/autofill/content/common/autofill_agent.mojom.h" | 13 #include "components/autofill/content/common/autofill_agent.mojom.h" |
14 #include "components/autofill/content/common/autofill_driver.mojom.h" | 14 #include "components/autofill/content/common/autofill_driver.mojom.h" |
15 #include "components/autofill/content/renderer/autofill_agent.h" | 15 #include "components/autofill/content/renderer/autofill_agent.h" |
16 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 16 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
17 #include "components/autofill/content/renderer/provisionally_saved_password_form
.h" | 17 #include "components/autofill/content/renderer/provisionally_saved_password_form
.h" |
18 #include "components/autofill/core/common/form_data_predictions.h" | 18 #include "components/autofill/core/common/form_data_predictions.h" |
19 #include "components/autofill/core/common/password_form.h" | 19 #include "components/autofill/core/common/password_form.h" |
20 #include "components/autofill/core/common/password_form_field_prediction_map.h" | 20 #include "components/autofill/core/common/password_form_field_prediction_map.h" |
21 #include "components/autofill/core/common/password_form_fill_data.h" | 21 #include "components/autofill/core/common/password_form_fill_data.h" |
22 #include "content/public/renderer/render_frame_observer.h" | 22 #include "content/public/renderer/render_frame_observer.h" |
23 #include "content/public/renderer/render_view_observer.h" | 23 #include "content/public/renderer/render_view_observer.h" |
24 #include "mojo/public/cpp/bindings/binding.h" | 24 #include "mojo/public/cpp/bindings/binding.h" |
25 #include "services/service_manager/public/cpp/bind_source_info.h" | 25 #include "services/service_manager/public/cpp/bind_source_info.h" |
26 #include "third_party/WebKit/public/web/WebInputElement.h" | 26 #include "third_party/WebKit/public/web/WebInputElement.h" |
27 | 27 |
28 namespace blink { | 28 namespace blink { |
| 29 class WebFormElementObserver; |
29 class WebInputElement; | 30 class WebInputElement; |
30 class WebSecurityOrigin; | 31 class WebSecurityOrigin; |
31 } | 32 } |
32 | 33 |
33 namespace autofill { | 34 namespace autofill { |
34 | 35 |
35 // Names of HTML attributes to show form and field signatures for debugging. | 36 // Names of HTML attributes to show form and field signatures for debugging. |
36 const char kDebugAttributeForFormSignature[] = "form_signature"; | 37 const char kDebugAttributeForFormSignature[] = "form_signature"; |
37 const char kDebugAttributeForFieldSignature[] = "field_signature"; | 38 const char kDebugAttributeForFieldSignature[] = "field_signature"; |
38 | 39 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Called when the focused node has changed. | 141 // Called when the focused node has changed. |
141 void FocusedNodeHasChanged(const blink::WebNode& node); | 142 void FocusedNodeHasChanged(const blink::WebNode& node); |
142 | 143 |
143 bool logging_state_active() const { return logging_state_active_; } | 144 bool logging_state_active() const { return logging_state_active_; } |
144 | 145 |
145 protected: | 146 protected: |
146 virtual bool OriginCanAccessPasswordManager( | 147 virtual bool OriginCanAccessPasswordManager( |
147 const blink::WebSecurityOrigin& origin); | 148 const blink::WebSecurityOrigin& origin); |
148 | 149 |
149 private: | 150 private: |
| 151 class FormElementObserverCallback; |
| 152 |
150 // Ways to restrict which passwords are saved in ProvisionallySavePassword. | 153 // Ways to restrict which passwords are saved in ProvisionallySavePassword. |
151 enum ProvisionallySaveRestriction { | 154 enum ProvisionallySaveRestriction { |
152 RESTRICTION_NONE, | 155 RESTRICTION_NONE, |
153 RESTRICTION_NON_EMPTY_PASSWORD | 156 RESTRICTION_NON_EMPTY_PASSWORD |
154 }; | 157 }; |
155 | 158 |
156 struct PasswordInfo { | 159 struct PasswordInfo { |
157 blink::WebInputElement password_field; | 160 blink::WebInputElement password_field; |
158 PasswordFormFillData fill_data; | 161 PasswordFormFillData fill_data; |
159 // The user manually edited the password more recently than the username was | 162 // The user manually edited the password more recently than the username was |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // user has just been interacting with before the form save. |form| or |input| | 254 // user has just been interacting with before the form save. |form| or |input| |
252 // can be null but not both at the same time. For example: if the form is | 255 // can be null but not both at the same time. For example: if the form is |
253 // unowned, |form| will be null; if the user has submitted the form, |input| | 256 // unowned, |form| will be null; if the user has submitted the form, |input| |
254 // will be null. | 257 // will be null. |
255 void ProvisionallySavePassword(std::unique_ptr<PasswordForm> password_form, | 258 void ProvisionallySavePassword(std::unique_ptr<PasswordForm> password_form, |
256 const blink::WebFormElement& form, | 259 const blink::WebFormElement& form, |
257 const blink::WebInputElement& input, | 260 const blink::WebInputElement& input, |
258 ProvisionallySaveRestriction restriction); | 261 ProvisionallySaveRestriction restriction); |
259 | 262 |
260 // Helper function called when same-document navigation completed | 263 // Helper function called when same-document navigation completed |
261 void OnSameDocumentNavigationCompleted(bool is_inpage_navigation); | 264 void OnSameDocumentNavigationCompleted( |
| 265 PasswordForm::SubmissionIndicatorEvent event); |
262 | 266 |
263 const mojom::AutofillDriverPtr& GetAutofillDriver(); | 267 const mojom::AutofillDriverPtr& GetAutofillDriver(); |
264 | 268 |
265 // The logins we have filled so far with their associated info. | 269 // The logins we have filled so far with their associated info. |
266 WebInputToPasswordInfoMap web_input_to_password_info_; | 270 WebInputToPasswordInfoMap web_input_to_password_info_; |
267 // A (sort-of) reverse map to |login_to_password_info_|. | 271 // A (sort-of) reverse map to |login_to_password_info_|. |
268 PasswordToLoginMap password_to_username_; | 272 PasswordToLoginMap password_to_username_; |
269 | 273 |
270 // Set if the user might be submitting a password form on the current page, | 274 // Set if the user might be submitting a password form on the current page, |
271 // but the submit may still fail (i.e. doesn't pass JavaScript validation). | 275 // but the submit may still fail (i.e. doesn't pass JavaScript validation). |
(...skipping 29 matching lines...) Expand all Loading... |
301 // Contains server predictions for username, password and/or new password | 305 // Contains server predictions for username, password and/or new password |
302 // fields for individual forms. | 306 // fields for individual forms. |
303 FormsPredictionsMap form_predictions_; | 307 FormsPredictionsMap form_predictions_; |
304 | 308 |
305 AutofillAgent* autofill_agent_; // Weak reference. | 309 AutofillAgent* autofill_agent_; // Weak reference. |
306 | 310 |
307 mojom::PasswordManagerDriverPtr password_manager_driver_; | 311 mojom::PasswordManagerDriverPtr password_manager_driver_; |
308 | 312 |
309 mojo::Binding<mojom::PasswordAutofillAgent> binding_; | 313 mojo::Binding<mojom::PasswordAutofillAgent> binding_; |
310 | 314 |
| 315 blink::WebFormElementObserver* form_element_observer_; |
| 316 |
311 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 317 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
312 }; | 318 }; |
313 | 319 |
314 } // namespace autofill | 320 } // namespace autofill |
315 | 321 |
316 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 322 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
OLD | NEW |