OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PASSWORD_MANAGER_PRESENTER_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
6 #define CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
7 | 7 |
| 8 #include <stddef.h> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
12 #include "base/prefs/pref_member.h" | 13 #include "base/prefs/pref_member.h" |
| 14 #include "base/strings/string16.h" |
13 #include "components/password_manager/core/browser/password_store.h" | 15 #include "components/password_manager/core/browser/password_store.h" |
14 #include "components/password_manager/core/browser/password_store_consumer.h" | 16 #include "components/password_manager/core/browser/password_store_consumer.h" |
15 | 17 |
| 18 class GURL; |
| 19 class PasswordUIView; |
| 20 class Profile; |
| 21 |
16 namespace autofill { | 22 namespace autofill { |
17 struct PasswordForm; | 23 struct PasswordForm; |
18 } | 24 } |
19 | 25 |
20 class PasswordUIView; | |
21 | |
22 class Profile; | |
23 | |
24 // Contains the common logic used by a PasswordUIView to | 26 // Contains the common logic used by a PasswordUIView to |
25 // interact with PasswordStore. It provides completion callbacks for | 27 // interact with PasswordStore. It provides completion callbacks for |
26 // PasswordStore operations and updates the view on PasswordStore changes. | 28 // PasswordStore operations and updates the view on PasswordStore changes. |
27 class PasswordManagerPresenter | 29 class PasswordManagerPresenter |
28 : public password_manager::PasswordStore::Observer { | 30 : public password_manager::PasswordStore::Observer { |
29 public: | 31 public: |
30 // |password_view| the UI view that owns this presenter, must not be NULL. | 32 // |password_view| the UI view that owns this presenter, must not be NULL. |
31 explicit PasswordManagerPresenter(PasswordUIView* password_view); | 33 explicit PasswordManagerPresenter(PasswordUIView* password_view); |
32 virtual ~PasswordManagerPresenter(); | 34 virtual ~PasswordManagerPresenter(); |
33 | 35 |
| 36 // Checks if |origin| is valid for adding a new password entry. |
| 37 static bool CheckOriginValidityForAdding(const GURL& origin); |
| 38 |
34 // PasswordStore::Observer implementation. | 39 // PasswordStore::Observer implementation. |
35 virtual void OnLoginsChanged( | 40 virtual void OnLoginsChanged( |
36 const password_manager::PasswordStoreChangeList& changes) OVERRIDE; | 41 const password_manager::PasswordStoreChangeList& changes) OVERRIDE; |
37 | 42 |
38 // Repopulates the password and exception entries. | 43 // Repopulates the password and exception entries. |
39 void UpdatePasswordLists(); | 44 void UpdatePasswordLists(); |
40 | 45 |
41 void Initialize(); | 46 void Initialize(); |
42 | 47 |
43 // Gets the password entry at |index|. | 48 // Gets the password entry at |index|. |
44 const autofill::PasswordForm* GetPassword(size_t index); | 49 const autofill::PasswordForm* GetPassword(size_t index); |
45 | 50 |
46 // Gets the password exception entry at |index|. | 51 // Gets the password exception entry at |index|. |
47 const autofill::PasswordForm* GetPasswordException(size_t index); | 52 const autofill::PasswordForm* GetPasswordException(size_t index); |
48 | 53 |
| 54 // Adds a new password entry with |origin|, |username_value|, and |
| 55 // |password_value|. |origin| should have been validated by |
| 56 // CheckOriginValidityForAdding, and |password_value| should be non-empty. |
| 57 void AddPassword(const GURL& origin, |
| 58 const base::string16& username_value, |
| 59 const base::string16& password_value); |
| 60 |
| 61 // Updates the entry at |index| with |password_value|. |password_value| should |
| 62 // be non-empty. |
| 63 void UpdatePassword(size_t index, const base::string16& password_value); |
| 64 |
49 // Removes the saved password entry at |index|. | 65 // Removes the saved password entry at |index|. |
50 // |index| the entry index to be removed. | 66 // |index| the entry index to be removed. |
51 void RemoveSavedPassword(size_t index); | 67 void RemoveSavedPassword(size_t index); |
52 | 68 |
53 // Removes the saved password exception entry at |index|. | 69 // Removes the saved password exception entry at |index|. |
54 // |index| the entry index to be removed. | 70 // |index| the entry index to be removed. |
55 void RemovePasswordException(size_t index); | 71 void RemovePasswordException(size_t index); |
56 | 72 |
57 // Requests the plain text password for entry at |index| to be revealed. | 73 // Requests the plain text password for entry at |index| to be revealed. |
58 // |index| The index of the entry. | 74 // |index| The index of the entry. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Used to determine whether or not to reveal plaintext passwords. | 145 // Used to determine whether or not to reveal plaintext passwords. |
130 base::TimeTicks last_authentication_time_; | 146 base::TimeTicks last_authentication_time_; |
131 | 147 |
132 // UI view that owns this presenter. | 148 // UI view that owns this presenter. |
133 PasswordUIView* password_view_; | 149 PasswordUIView* password_view_; |
134 | 150 |
135 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); | 151 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); |
136 }; | 152 }; |
137 | 153 |
138 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ | 154 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
OLD | NEW |