| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ |
| 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_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/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 15 #include "components/autofill/core/common/password_form.h" | 16 #include "components/autofill/core/common/password_form.h" |
| 16 #include "components/password_manager/core/browser/password_store_change.h" | 17 #include "components/password_manager/core/browser/password_store_change.h" |
| 17 #include "components/password_manager/core/common/credential_manager_types.h" | 18 #include "components/password_manager/core/common/credential_manager_types.h" |
| 18 #include "components/password_manager/core/common/password_manager_ui.h" | 19 #include "components/password_manager/core/common/password_manager_ui.h" |
| 19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 20 | 21 |
| 21 namespace password_manager { | 22 namespace password_manager { |
| 22 class PasswordFormManager; | 23 class PasswordFormManager; |
| 23 class PasswordManagerClient; | 24 class PasswordManagerClient; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 // The embedder of this class has to set the client for logging. | 38 // The embedder of this class has to set the client for logging. |
| 38 void set_client(password_manager::PasswordManagerClient* client) { | 39 void set_client(password_manager::PasswordManagerClient* client) { |
| 39 client_ = client; | 40 client_ = client; |
| 40 } | 41 } |
| 41 | 42 |
| 42 // The methods below discard the current state/data of the object and move it | 43 // The methods below discard the current state/data of the object and move it |
| 43 // to the specified state. | 44 // to the specified state. |
| 44 | 45 |
| 45 // Move to PENDING_PASSWORD_STATE. | 46 // Move to PENDING_PASSWORD_STATE. |
| 46 void OnPendingPassword( | 47 void OnPendingPassword( |
| 47 std::unique_ptr<password_manager::PasswordFormManager> form_manager); | 48 scoped_refptr<password_manager::PasswordFormManager> form_manager); |
| 48 | 49 |
| 49 // Move to PENDING_PASSWORD_UPDATE_STATE. | 50 // Move to PENDING_PASSWORD_UPDATE_STATE. |
| 50 void OnUpdatePassword( | 51 void OnUpdatePassword( |
| 51 std::unique_ptr<password_manager::PasswordFormManager> form_manager); | 52 scoped_refptr<password_manager::PasswordFormManager> form_manager); |
| 52 | 53 |
| 53 // Move to CREDENTIAL_REQUEST_STATE. | 54 // Move to CREDENTIAL_REQUEST_STATE. |
| 54 void OnRequestCredentials( | 55 void OnRequestCredentials( |
| 55 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 56 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 56 const GURL& origin); | 57 const GURL& origin); |
| 57 | 58 |
| 58 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty. | 59 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty. |
| 59 void OnAutoSignin( | 60 void OnAutoSignin( |
| 60 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, | 61 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, |
| 61 const GURL& origin); | 62 const GURL& origin); |
| 62 | 63 |
| 63 // Move to CONFIRMATION_STATE. | 64 // Move to CONFIRMATION_STATE. |
| 64 void OnAutomaticPasswordSave( | 65 void OnAutomaticPasswordSave( |
| 65 std::unique_ptr<password_manager::PasswordFormManager> form_manager); | 66 scoped_refptr<password_manager::PasswordFormManager> form_manager); |
| 66 | 67 |
| 67 // Move to MANAGE_STATE or INACTIVE_STATE for PSL matched passwords. | 68 // Move to MANAGE_STATE or INACTIVE_STATE for PSL matched passwords. |
| 68 // |password_form_map| contains best matches from the password store for the | 69 // |password_form_map| contains best matches from the password store for the |
| 69 // form which was autofilled, |origin| is an origin of the form which was | 70 // form which was autofilled, |origin| is an origin of the form which was |
| 70 // autofilled. In addition, |federated_matches|, if not null, contains stored | 71 // autofilled. In addition, |federated_matches|, if not null, contains stored |
| 71 // federated credentials to show to the user as well. | 72 // federated credentials to show to the user as well. |
| 72 void OnPasswordAutofilled( | 73 void OnPasswordAutofilled( |
| 73 const std::map<base::string16, const autofill::PasswordForm*>& | 74 const std::map<base::string16, const autofill::PasswordForm*>& |
| 74 password_form_map, | 75 password_form_map, |
| 75 const GURL& origin, | 76 const GURL& origin, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // Removes |form| from the internal state. | 121 // Removes |form| from the internal state. |
| 121 void DeleteForm(const autofill::PasswordForm& form); | 122 void DeleteForm(const autofill::PasswordForm& form); |
| 122 | 123 |
| 123 void SetState(password_manager::ui::State state); | 124 void SetState(password_manager::ui::State state); |
| 124 | 125 |
| 125 // The origin of the current page for which the state is stored. It's used to | 126 // The origin of the current page for which the state is stored. It's used to |
| 126 // determine which PasswordStore changes are applicable to the internal state. | 127 // determine which PasswordStore changes are applicable to the internal state. |
| 127 GURL origin_; | 128 GURL origin_; |
| 128 | 129 |
| 129 // Contains the password that was submitted. | 130 // Contains the password that was submitted. |
| 130 std::unique_ptr<password_manager::PasswordFormManager> form_manager_; | 131 scoped_refptr<password_manager::PasswordFormManager> form_manager_; |
| 131 | 132 |
| 132 // Contains all the current forms. | 133 // Contains all the current forms. |
| 133 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials_forms_; | 134 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials_forms_; |
| 134 | 135 |
| 135 // A callback to be invoked when user selects a credential. | 136 // A callback to be invoked when user selects a credential. |
| 136 CredentialsCallback credentials_callback_; | 137 CredentialsCallback credentials_callback_; |
| 137 | 138 |
| 138 // The current state of the password manager UI. | 139 // The current state of the password manager UI. |
| 139 password_manager::ui::State state_; | 140 password_manager::ui::State state_; |
| 140 | 141 |
| 141 // The client used for logging. | 142 // The client used for logging. |
| 142 password_manager::PasswordManagerClient* client_; | 143 password_manager::PasswordManagerClient* client_; |
| 143 | 144 |
| 144 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); | 145 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); |
| 145 }; | 146 }; |
| 146 | 147 |
| 147 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ | 148 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ |
| OLD | NEW |