Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_PROVISIONALLY_SAVED_PASSWORD_FORM_H _ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PROVISIONALLY_SAVED_PASSWORD_FORM_H _ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PROVISIONALLY_SAVED_PASSWORD_FORM_H _ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PROVISIONALLY_SAVED_PASSWORD_FORM_H _ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/autofill/core/common/password_form.h" | |
| 11 #include "third_party/WebKit/public/web/WebInputElement.h" | 12 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 12 | 13 |
| 13 namespace autofill { | 14 namespace autofill { |
| 14 | 15 |
| 15 struct PasswordForm; | 16 struct PasswordForm; |
| 16 | 17 |
| 17 // Represents a possibly submitted password form. | 18 // Represents a possibly submitted password form. |
| 18 class ProvisionallySavedPasswordForm { | 19 class ProvisionallySavedPasswordForm { |
| 19 public: | 20 public: |
| 20 ProvisionallySavedPasswordForm(); | 21 ProvisionallySavedPasswordForm(); |
| 21 ~ProvisionallySavedPasswordForm(); | 22 ~ProvisionallySavedPasswordForm(); |
| 22 | 23 |
| 23 // Sets the PasswordForm and web elements that were used in the PasswordForm | 24 // Sets the PasswordForm and web elements that were used in the PasswordForm |
| 24 // update. | 25 // update. |
| 25 void Set(std::unique_ptr<PasswordForm> password_form, | 26 void Set(std::unique_ptr<PasswordForm> password_form, |
| 26 const blink::WebFormElement& form_element, | 27 const blink::WebFormElement& form_element, |
| 27 const blink::WebInputElement& input_element); | 28 const blink::WebInputElement& input_element); |
| 28 void Reset(); | 29 void Reset(); |
| 29 | 30 |
| 30 // Returns true if the instance has |password_form_| set, but the actual | 31 // Returns true if the instance has |password_form_| set, but the actual |
| 31 // password data may be invalid (e.g. empty username or password). | 32 // password data may be invalid (e.g. empty username or password). |
| 32 bool IsSet() const; | 33 bool IsSet() const; |
| 33 // Returns true if |password_form_| has enough information that it is likely | 34 // Returns true if |password_form_| has enough information that it is likely |
| 34 // filled out. | 35 // filled out. |
| 35 bool IsPasswordValid() const; | 36 bool IsPasswordValid() const; |
| 36 | 37 |
| 37 const PasswordForm& password_form() const { | 38 const PasswordForm& password_form() const { |
|
engedy
2017/05/10 13:07:42
nit: What's the reason this is const? A comment wo
dvadym
2017/05/10 14:09:25
I think const was introduced in order to decrease
engedy
2017/05/10 14:15:56
Acknowledged.
| |
| 38 DCHECK(IsSet()); | 39 DCHECK(IsSet()); |
| 39 return *password_form_; | 40 return *password_form_; |
| 40 } | 41 } |
| 41 const blink::WebFormElement& form_element() const { return form_element_; } | 42 const blink::WebFormElement& form_element() const { return form_element_; } |
| 42 const blink::WebInputElement& input_element() const { return input_element_; } | 43 const blink::WebInputElement& input_element() const { return input_element_; } |
| 43 | 44 |
| 45 void SetSubmissionIndicatorEvent( | |
| 46 PasswordForm::SubmissionIndicatorEvent event); | |
| 47 | |
| 44 private: | 48 private: |
| 45 std::unique_ptr<PasswordForm> password_form_; | 49 std::unique_ptr<PasswordForm> password_form_; |
| 46 // Last used WebFormElement for the PasswordForm submission. Can be null if | 50 // Last used WebFormElement for the PasswordForm submission. Can be null if |
| 47 // the form is unowned. | 51 // the form is unowned. |
| 48 blink::WebFormElement form_element_; | 52 blink::WebFormElement form_element_; |
| 49 // Last used WebInputElement which led to the PasswordForm update. Can be null | 53 // Last used WebInputElement which led to the PasswordForm update. Can be null |
| 50 // if the user has performed a form submission (via a button, for example). | 54 // if the user has performed a form submission (via a button, for example). |
| 51 blink::WebInputElement input_element_; | 55 blink::WebInputElement input_element_; |
| 52 | 56 |
| 53 DISALLOW_COPY_AND_ASSIGN(ProvisionallySavedPasswordForm); | 57 DISALLOW_COPY_AND_ASSIGN(ProvisionallySavedPasswordForm); |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 } // namespace autofill | 60 } // namespace autofill |
| 57 | 61 |
| 58 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PROVISIONALLY_SAVED_PASSWORD_FOR M_H_ | 62 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PROVISIONALLY_SAVED_PASSWORD_FOR M_H_ |
| OLD | NEW |