| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.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 struct CredentialInfo; | |
| 22 class PasswordFormManager; | 21 class PasswordFormManager; |
| 23 class PasswordManagerClient; | 22 class PasswordManagerClient; |
| 24 } | 23 } |
| 25 | 24 |
| 26 | 25 |
| 27 // ManagePasswordsState keeps the current state for ManagePasswordsUIController | 26 // ManagePasswordsState keeps the current state for ManagePasswordsUIController |
| 28 // as well as up-to-date data for this state. | 27 // as well as up-to-date data for this state. |
| 29 class ManagePasswordsState { | 28 class ManagePasswordsState { |
| 30 public: | 29 public: |
| 31 using CredentialsCallback = | 30 using CredentialsCallback = |
| 32 base::Callback<void(const password_manager::CredentialInfo&)>; | 31 base::Callback<void(const autofill::PasswordForm*)>; |
| 33 | 32 |
| 34 ManagePasswordsState(); | 33 ManagePasswordsState(); |
| 35 ~ManagePasswordsState(); | 34 ~ManagePasswordsState(); |
| 36 | 35 |
| 37 // 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. |
| 38 void set_client(password_manager::PasswordManagerClient* client) { | 37 void set_client(password_manager::PasswordManagerClient* client) { |
| 39 client_ = client; | 38 client_ = client; |
| 40 } | 39 } |
| 41 | 40 |
| 42 // 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void OnInactive(); | 77 void OnInactive(); |
| 79 | 78 |
| 80 // Moves the object to |state| without resetting the internal data. Allowed: | 79 // Moves the object to |state| without resetting the internal data. Allowed: |
| 81 // * -> MANAGE_STATE | 80 // * -> MANAGE_STATE |
| 82 void TransitionToState(password_manager::ui::State state); | 81 void TransitionToState(password_manager::ui::State state); |
| 83 | 82 |
| 84 // Updates the internal state applying |changes|. | 83 // Updates the internal state applying |changes|. |
| 85 void ProcessLoginsChanged( | 84 void ProcessLoginsChanged( |
| 86 const password_manager::PasswordStoreChangeList& changes); | 85 const password_manager::PasswordStoreChangeList& changes); |
| 87 | 86 |
| 88 // Called when the user chooses a credential. Using data from |form| and | 87 // Called when the user chooses a credential. |form| is passed to the |
| 89 // |credential_type| it constructs the object which next is passed to the | |
| 90 // credentials callback. Method should be called in the | 88 // credentials callback. Method should be called in the |
| 91 // CREDENTIAL_REQUEST_STATE state. | 89 // CREDENTIAL_REQUEST_STATE state. |
| 92 void ChooseCredential(const autofill::PasswordForm& form, | 90 void ChooseCredential(const autofill::PasswordForm* form); |
| 93 password_manager::CredentialType credential_type); | |
| 94 | 91 |
| 95 password_manager::ui::State state() const { return state_; } | 92 password_manager::ui::State state() const { return state_; } |
| 96 const GURL& origin() const { return origin_; } | 93 const GURL& origin() const { return origin_; } |
| 97 password_manager::PasswordFormManager* form_manager() const { | 94 password_manager::PasswordFormManager* form_manager() const { |
| 98 return form_manager_.get(); | 95 return form_manager_.get(); |
| 99 } | 96 } |
| 100 const CredentialsCallback& credentials_callback() { | 97 const CredentialsCallback& credentials_callback() { |
| 101 return credentials_callback_; | 98 return credentials_callback_; |
| 102 } | 99 } |
| 103 void set_credentials_callback(const CredentialsCallback& callback) { | 100 void set_credentials_callback(const CredentialsCallback& callback) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // The current state of the password manager UI. | 152 // The current state of the password manager UI. |
| 156 password_manager::ui::State state_; | 153 password_manager::ui::State state_; |
| 157 | 154 |
| 158 // The client used for logging. | 155 // The client used for logging. |
| 159 password_manager::PasswordManagerClient* client_; | 156 password_manager::PasswordManagerClient* client_; |
| 160 | 157 |
| 161 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); | 158 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsState); |
| 162 }; | 159 }; |
| 163 | 160 |
| 164 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ | 161 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_STATE_H_ |
| OLD | NEW |