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