| 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 <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "components/autofill/core/common/password_form.h" | 14 #include "components/autofill/core/common/password_form.h" |
| 15 #include "components/password_manager/core/browser/password_store_change.h" | 15 #include "components/password_manager/core/browser/password_store_change.h" |
| 16 #include "components/password_manager/core/common/credential_manager_types.h" | 16 #include "components/password_manager/core/common/credential_manager_types.h" |
| 17 #include "components/password_manager/core/common/password_manager_ui.h" | 17 #include "components/password_manager/core/common/password_manager_ui.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace password_manager { | 20 namespace password_manager { |
| 21 class PasswordFormManager; | 21 class PasswordFormManager; |
| 22 class PasswordManagerClient; | 22 class PasswordManagerClient; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 36 // The embedder of this class has to set the client for logging. | 36 // The embedder of this class has to set the client for logging. |
| 37 void set_client(password_manager::PasswordManagerClient* client) { | 37 void set_client(password_manager::PasswordManagerClient* client) { |
| 38 client_ = client; | 38 client_ = client; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // The methods below discard the current state/data of the object and move it | 41 // The methods below discard the current state/data of the object and move it |
| 42 // to the specified state. | 42 // to the specified state. |
| 43 | 43 |
| 44 // Move to PENDING_PASSWORD_STATE. | 44 // Move to PENDING_PASSWORD_STATE. |
| 45 void OnPendingPassword( | 45 void OnPendingPassword( |
| 46 scoped_ptr<password_manager::PasswordFormManager> form_manager); | 46 std::unique_ptr<password_manager::PasswordFormManager> form_manager); |
| 47 | 47 |
| 48 // Move to PENDING_PASSWORD_UPDATE_STATE. | 48 // Move to PENDING_PASSWORD_UPDATE_STATE. |
| 49 void OnUpdatePassword( | 49 void OnUpdatePassword( |
| 50 scoped_ptr<password_manager::PasswordFormManager> form_manager); | 50 std::unique_ptr<password_manager::PasswordFormManager> form_manager); |
| 51 | 51 |
| 52 // Move to CREDENTIAL_REQUEST_STATE. | 52 // Move to CREDENTIAL_REQUEST_STATE. |
| 53 void OnRequestCredentials( | 53 void OnRequestCredentials( |
| 54 ScopedVector<autofill::PasswordForm> local_credentials, | 54 ScopedVector<autofill::PasswordForm> local_credentials, |
| 55 ScopedVector<autofill::PasswordForm> federated_credentials, | 55 ScopedVector<autofill::PasswordForm> federated_credentials, |
| 56 const GURL& origin); | 56 const GURL& origin); |
| 57 | 57 |
| 58 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty. | 58 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty. |
| 59 void OnAutoSignin(ScopedVector<autofill::PasswordForm> local_forms, | 59 void OnAutoSignin(ScopedVector<autofill::PasswordForm> local_forms, |
| 60 const GURL& origin); | 60 const GURL& origin); |
| 61 | 61 |
| 62 // Move to CONFIRMATION_STATE. | 62 // Move to CONFIRMATION_STATE. |
| 63 void OnAutomaticPasswordSave( | 63 void OnAutomaticPasswordSave( |
| 64 scoped_ptr<password_manager::PasswordFormManager> form_manager); | 64 std::unique_ptr<password_manager::PasswordFormManager> form_manager); |
| 65 | 65 |
| 66 // Move to MANAGE_STATE or INACTIVE_STATE for PSL matched passwords. | 66 // Move to MANAGE_STATE or INACTIVE_STATE for PSL matched passwords. |
| 67 // |password_form_map| contains best matches from the password store for the | 67 // |password_form_map| contains best matches from the password store for the |
| 68 // form which was autofilled, |origin| is an origin of the form which was | 68 // form which was autofilled, |origin| is an origin of the form which was |
| 69 // autofilled. In addition, |federated_matches|, if not null, contains stored | 69 // autofilled. In addition, |federated_matches|, if not null, contains stored |
| 70 // federated credentials to show to the user as well. | 70 // federated credentials to show to the user as well. |
| 71 void OnPasswordAutofilled( | 71 void OnPasswordAutofilled( |
| 72 const autofill::PasswordFormMap& password_form_map, | 72 const autofill::PasswordFormMap& password_form_map, |
| 73 const GURL& origin, | 73 const GURL& origin, |
| 74 const std::vector<scoped_ptr<autofill::PasswordForm>>* federated_matches); | 74 const std::vector<std::unique_ptr<autofill::PasswordForm>>* |
| 75 federated_matches); |
| 75 | 76 |
| 76 // Move to INACTIVE_STATE. | 77 // Move to INACTIVE_STATE. |
| 77 void OnInactive(); | 78 void OnInactive(); |
| 78 | 79 |
| 79 // Moves the object to |state| without resetting the internal data. Allowed: | 80 // Moves the object to |state| without resetting the internal data. Allowed: |
| 80 // * -> MANAGE_STATE | 81 // * -> MANAGE_STATE |
| 81 void TransitionToState(password_manager::ui::State state); | 82 void TransitionToState(password_manager::ui::State state); |
| 82 | 83 |
| 83 // Updates the internal state applying |changes|. | 84 // Updates the internal state applying |changes|. |
| 84 void ProcessLoginsChanged( | 85 void ProcessLoginsChanged( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Removes |form| from the internal state. | 124 // Removes |form| from the internal state. |
| 124 void DeleteForm(const autofill::PasswordForm& form); | 125 void DeleteForm(const autofill::PasswordForm& form); |
| 125 | 126 |
| 126 void SetState(password_manager::ui::State state); | 127 void SetState(password_manager::ui::State state); |
| 127 | 128 |
| 128 // The origin of the current page for which the state is stored. It's used to | 129 // The origin of the current page for which the state is stored. It's used to |
| 129 // determine which PasswordStore changes are applicable to the internal state. | 130 // determine which PasswordStore changes are applicable to the internal state. |
| 130 GURL origin_; | 131 GURL origin_; |
| 131 | 132 |
| 132 // Contains the password that was submitted. | 133 // Contains the password that was submitted. |
| 133 scoped_ptr<password_manager::PasswordFormManager> form_manager_; | 134 std::unique_ptr<password_manager::PasswordFormManager> form_manager_; |
| 134 | 135 |
| 135 // Weak references to the passwords for the current status. The hard pointers | 136 // Weak references to the passwords for the current status. The hard pointers |
| 136 // are scattered between |form_manager_| and |local_credentials_forms_|. If | 137 // are scattered between |form_manager_| and |local_credentials_forms_|. If |
| 137 // |form_manager_| is nullptr then all the forms are stored in | 138 // |form_manager_| is nullptr then all the forms are stored in |
| 138 // |local_credentials_forms_|. |current_forms_weak_| remains empty. | 139 // |local_credentials_forms_|. |current_forms_weak_| remains empty. |
| 139 std::vector<const autofill::PasswordForm*> current_forms_weak_; | 140 std::vector<const autofill::PasswordForm*> current_forms_weak_; |
| 140 | 141 |
| 141 // If |form_manager_| is nullptr then |local_credentials_forms_| contains all | 142 // If |form_manager_| is nullptr then |local_credentials_forms_| contains all |
| 142 // the current forms. Otherwise, it's a container for the new forms coming | 143 // the current forms. Otherwise, it's a container for the new forms coming |
| 143 // from the PasswordStore. | 144 // from the PasswordStore. |
| 144 ScopedVector<const autofill::PasswordForm> local_credentials_forms_; | 145 ScopedVector<const autofill::PasswordForm> local_credentials_forms_; |
| 145 | 146 |
| 146 // Federated credentials for the CREDENTIAL_REQUEST_STATE. | 147 // Federated credentials for the CREDENTIAL_REQUEST_STATE. |
| 147 ScopedVector<const autofill::PasswordForm> federated_credentials_forms_; | 148 ScopedVector<const autofill::PasswordForm> federated_credentials_forms_; |
| 148 | 149 |
| 149 // A callback to be invoked when user selects a credential. | 150 // A callback to be invoked when user selects a credential. |
| 150 CredentialsCallback credentials_callback_; | 151 CredentialsCallback credentials_callback_; |
| 151 | 152 |
| 152 // The current state of the password manager UI. | 153 // The current state of the password manager UI. |
| 153 password_manager::ui::State state_; | 154 password_manager::ui::State state_; |
| 154 | 155 |
| 155 // The client used for logging. | 156 // The client used for logging. |
| 156 password_manager::PasswordManagerClient* client_; | 157 password_manager::PasswordManagerClient* client_; |
| 157 | 158 |
| 158 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); | 159 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ | 162 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ |
| OLD | NEW |