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