Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_state.h

Issue 2253233005: Change ScopedVector to vector<unique_ptr> in the password's UI code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android+ Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_vector.h"
14 #include "components/autofill/core/common/password_form.h" 13 #include "components/autofill/core/common/password_form.h"
15 #include "components/password_manager/core/browser/password_store_change.h" 14 #include "components/password_manager/core/browser/password_store_change.h"
16 #include "components/password_manager/core/common/credential_manager_types.h" 15 #include "components/password_manager/core/common/credential_manager_types.h"
17 #include "components/password_manager/core/common/password_manager_ui.h" 16 #include "components/password_manager/core/common/password_manager_ui.h"
18 #include "url/gurl.h" 17 #include "url/gurl.h"
19 18
20 namespace password_manager { 19 namespace password_manager {
21 class PasswordFormManager; 20 class PasswordFormManager;
22 class PasswordManagerClient; 21 class PasswordManagerClient;
23 } 22 }
(...skipping 20 matching lines...) Expand all
44 // Move to PENDING_PASSWORD_STATE. 43 // Move to PENDING_PASSWORD_STATE.
45 void OnPendingPassword( 44 void OnPendingPassword(
46 std::unique_ptr<password_manager::PasswordFormManager> form_manager); 45 std::unique_ptr<password_manager::PasswordFormManager> form_manager);
47 46
48 // Move to PENDING_PASSWORD_UPDATE_STATE. 47 // Move to PENDING_PASSWORD_UPDATE_STATE.
49 void OnUpdatePassword( 48 void OnUpdatePassword(
50 std::unique_ptr<password_manager::PasswordFormManager> form_manager); 49 std::unique_ptr<password_manager::PasswordFormManager> form_manager);
51 50
52 // Move to CREDENTIAL_REQUEST_STATE. 51 // Move to CREDENTIAL_REQUEST_STATE.
53 void OnRequestCredentials( 52 void OnRequestCredentials(
54 ScopedVector<autofill::PasswordForm> local_credentials, 53 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
55 ScopedVector<autofill::PasswordForm> federated_credentials, 54 std::vector<std::unique_ptr<autofill::PasswordForm>> federation_providers,
56 const GURL& origin); 55 const GURL& origin);
57 56
58 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty. 57 // Move to AUTO_SIGNIN_STATE. |local_forms| can't be empty.
59 void OnAutoSignin(ScopedVector<autofill::PasswordForm> local_forms, 58 void OnAutoSignin(
60 const GURL& origin); 59 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms,
60 const GURL& origin);
61 61
62 // Move to CONFIRMATION_STATE. 62 // Move to CONFIRMATION_STATE.
63 void OnAutomaticPasswordSave( 63 void OnAutomaticPasswordSave(
64 std::unique_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.
(...skipping 25 matching lines...) Expand all
96 return form_manager_.get(); 96 return form_manager_.get();
97 } 97 }
98 const CredentialsCallback& credentials_callback() { 98 const CredentialsCallback& credentials_callback() {
99 return credentials_callback_; 99 return credentials_callback_;
100 } 100 }
101 void set_credentials_callback(const CredentialsCallback& callback) { 101 void set_credentials_callback(const CredentialsCallback& callback) {
102 credentials_callback_ = callback; 102 credentials_callback_ = callback;
103 } 103 }
104 104
105 // Current local forms. ManagePasswordsState is responsible for the forms. 105 // Current local forms. ManagePasswordsState is responsible for the forms.
106 const std::vector<const autofill::PasswordForm*>& GetCurrentForms() const { 106 const std::vector<std::unique_ptr<autofill::PasswordForm>>& GetCurrentForms()
107 return form_manager_ ? current_forms_weak_ : local_credentials_forms_.get(); 107 const {
108 return local_credentials_forms_;
108 } 109 }
109 110
110 // Current federated forms. 111 // Current federated forms.
111 const std::vector<const autofill::PasswordForm*>& 112 const std::vector<std::unique_ptr<autofill::PasswordForm>>&
112 federated_credentials_forms() const { 113 federation_providers_forms() const {
113 return federated_credentials_forms_.get(); 114 return federation_providers_forms_;
114 } 115 }
115 116
116 private: 117 private:
117 // Removes all the PasswordForms stored in this object. 118 // Removes all the PasswordForms stored in this object.
118 void ClearData(); 119 void ClearData();
119 120
120 // Add |form| to the internal state. 121 // Add |form| to the internal state.
121 void AddForm(const autofill::PasswordForm& form); 122 void AddForm(const autofill::PasswordForm& form);
122 // Updates |form| in the internal state. 123 // Updates |form| in the internal state.
123 bool UpdateForm(const autofill::PasswordForm& form); 124 bool UpdateForm(const autofill::PasswordForm& form);
124 // Removes |form| from the internal state. 125 // Removes |form| from the internal state.
125 void DeleteForm(const autofill::PasswordForm& form); 126 void DeleteForm(const autofill::PasswordForm& form);
126 127
127 void SetState(password_manager::ui::State state); 128 void SetState(password_manager::ui::State state);
128 129
129 // The origin of the current page for which the state is stored. It's used to 130 // The origin of the current page for which the state is stored. It's used to
130 // determine which PasswordStore changes are applicable to the internal state. 131 // determine which PasswordStore changes are applicable to the internal state.
131 GURL origin_; 132 GURL origin_;
132 133
133 // Contains the password that was submitted. 134 // Contains the password that was submitted.
134 std::unique_ptr<password_manager::PasswordFormManager> form_manager_; 135 std::unique_ptr<password_manager::PasswordFormManager> form_manager_;
135 136
136 // Weak references to the passwords for the current status. The hard pointers 137 // Contains all the current forms.
137 // are scattered between |form_manager_| and |local_credentials_forms_|. If 138 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials_forms_;
138 // |form_manager_| is nullptr then all the forms are stored in
139 // |local_credentials_forms_|. |current_forms_weak_| remains empty.
140 std::vector<const autofill::PasswordForm*> current_forms_weak_;
141 139
142 // If |form_manager_| is nullptr then |local_credentials_forms_| contains all 140 // Federation providers for the CREDENTIAL_REQUEST_STATE.
143 // the current forms. Otherwise, it's a container for the new forms coming 141 std::vector<std::unique_ptr<autofill::PasswordForm>>
144 // from the PasswordStore. 142 federation_providers_forms_;
145 ScopedVector<const autofill::PasswordForm> local_credentials_forms_;
146
147 // Federated credentials for the CREDENTIAL_REQUEST_STATE.
148 ScopedVector<const autofill::PasswordForm> federated_credentials_forms_;
149 143
150 // A callback to be invoked when user selects a credential. 144 // A callback to be invoked when user selects a credential.
151 CredentialsCallback credentials_callback_; 145 CredentialsCallback credentials_callback_;
152 146
153 // The current state of the password manager UI. 147 // The current state of the password manager UI.
154 password_manager::ui::State state_; 148 password_manager::ui::State state_;
155 149
156 // The client used for logging. 150 // The client used for logging.
157 password_manager::PasswordManagerClient* client_; 151 password_manager::PasswordManagerClient* client_;
158 152
159 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); 153 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState);
160 }; 154 };
161 155
162 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ 156 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698