| 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 <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "components/password_manager/core/browser/password_store.h" | 17 #include "components/password_manager/core/browser/password_store.h" |
| 18 #include "components/password_manager/core/browser/password_store_consumer.h" | 18 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 19 #include "components/prefs/pref_member.h" | 19 #include "components/prefs/pref_member.h" |
| 20 | 20 |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 struct PasswordForm; | 22 struct PasswordForm; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // Multimap from sort key to password forms. | 25 // Multimap from sort key to password forms. |
| 26 using DuplicatesMap = | 26 using DuplicatesMap = |
| 27 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>; | 27 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>; |
| 28 | 28 |
| 29 enum class PasswordEntryType { SAVED, BLACKLISTED }; |
| 30 |
| 29 class PasswordUIView; | 31 class PasswordUIView; |
| 30 | 32 |
| 31 class Profile; | 33 class Profile; |
| 32 | 34 |
| 33 // Contains the common logic used by a PasswordUIView to | 35 // Contains the common logic used by a PasswordUIView to |
| 34 // interact with PasswordStore. It provides completion callbacks for | 36 // interact with PasswordStore. It provides completion callbacks for |
| 35 // PasswordStore operations and updates the view on PasswordStore changes. | 37 // PasswordStore operations and updates the view on PasswordStore changes. |
| 36 class PasswordManagerPresenter | 38 class PasswordManagerPresenter |
| 37 : public password_manager::PasswordStore::Observer { | 39 : public password_manager::PasswordStore::Observer { |
| 38 public: | 40 public: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 74 |
| 73 // Returns the password store associated with the currently active profile. | 75 // Returns the password store associated with the currently active profile. |
| 74 password_manager::PasswordStore* GetPasswordStore(); | 76 password_manager::PasswordStore* GetPasswordStore(); |
| 75 | 77 |
| 76 // Sets the password and exception list of the UI view. | 78 // Sets the password and exception list of the UI view. |
| 77 void SetPasswordList(); | 79 void SetPasswordList(); |
| 78 void SetPasswordExceptionList(); | 80 void SetPasswordExceptionList(); |
| 79 | 81 |
| 80 // Sort entries of |list| based on sort key. The key is the concatenation of | 82 // Sort entries of |list| based on sort key. The key is the concatenation of |
| 81 // origin, entry type (non-Android credential, Android w/ affiliated web realm | 83 // origin, entry type (non-Android credential, Android w/ affiliated web realm |
| 82 // or Android w/o affiliated web realm). If |username_and_password_in_key|, | 84 // or Android w/o affiliated web realm). If |entry_type == SAVED|, |
| 83 // username and password are also included in sort key. If there are several | 85 // username, password and federation are also included in sort key. If there |
| 84 // forms with the same key, all such forms but the first one are | 86 // are several forms with the same key, all such forms but the first one are |
| 85 // stored in |duplicates| instead of |list|. | 87 // stored in |duplicates| instead of |list|. |
| 86 void SortEntriesAndHideDuplicates( | 88 void SortEntriesAndHideDuplicates( |
| 87 std::vector<std::unique_ptr<autofill::PasswordForm>>* list, | 89 std::vector<std::unique_ptr<autofill::PasswordForm>>* list, |
| 88 DuplicatesMap* duplicates, | 90 DuplicatesMap* duplicates, |
| 89 bool username_and_password_in_key); | 91 PasswordEntryType entry_type); |
| 90 | 92 |
| 91 // A short class to mediate requests to the password store. | 93 // A short class to mediate requests to the password store. |
| 92 class ListPopulater : public password_manager::PasswordStoreConsumer { | 94 class ListPopulater : public password_manager::PasswordStoreConsumer { |
| 93 public: | 95 public: |
| 94 explicit ListPopulater(PasswordManagerPresenter* page); | 96 explicit ListPopulater(PasswordManagerPresenter* page); |
| 95 ~ListPopulater() override; | 97 ~ListPopulater() override; |
| 96 | 98 |
| 97 // Send a query to the password store to populate a list. | 99 // Send a query to the password store to populate a list. |
| 98 virtual void Populate() = 0; | 100 virtual void Populate() = 0; |
| 99 | 101 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Used to determine whether or not to reveal plaintext passwords. | 142 // Used to determine whether or not to reveal plaintext passwords. |
| 141 base::TimeTicks last_authentication_time_; | 143 base::TimeTicks last_authentication_time_; |
| 142 | 144 |
| 143 // UI view that owns this presenter. | 145 // UI view that owns this presenter. |
| 144 PasswordUIView* password_view_; | 146 PasswordUIView* password_view_; |
| 145 | 147 |
| 146 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); | 148 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); |
| 147 }; | 149 }; |
| 148 | 150 |
| 149 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ | 151 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
| OLD | NEW |