| 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 #include "ui/shell_dialogs/select_file_dialog.h" | 20 #include "ui/shell_dialogs/select_file_dialog.h" |
| 21 | 21 |
| 22 namespace autofill { | 22 namespace autofill { |
| 23 struct PasswordForm; | 23 struct PasswordForm; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // Multimap from sort key to password forms. | 26 // Multimap from sort key to password forms. |
| 27 using DuplicatesMap = | 27 using DuplicatesMap = |
| 28 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>; | 28 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>; |
| 29 | 29 |
| 30 enum class PasswordEntryType { SAVED, BLACKLISTED }; |
| 31 |
| 30 class PasswordUIView; | 32 class PasswordUIView; |
| 31 | 33 |
| 32 class Profile; | 34 class Profile; |
| 33 | 35 |
| 34 // Contains the common logic used by a PasswordUIView to | 36 // Contains the common logic used by a PasswordUIView to |
| 35 // interact with PasswordStore. It provides completion callbacks for | 37 // interact with PasswordStore. It provides completion callbacks for |
| 36 // PasswordStore operations and updates the view on PasswordStore changes. | 38 // PasswordStore operations and updates the view on PasswordStore changes. |
| 37 class PasswordManagerPresenter | 39 class PasswordManagerPresenter |
| 38 : public password_manager::PasswordStore::Observer { | 40 : public password_manager::PasswordStore::Observer { |
| 39 public: | 41 public: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 78 |
| 77 private: | 79 private: |
| 78 friend class PasswordManagerPresenterTest; | 80 friend class PasswordManagerPresenterTest; |
| 79 | 81 |
| 80 // Sets the password and exception list of the UI view. | 82 // Sets the password and exception list of the UI view. |
| 81 void SetPasswordList(); | 83 void SetPasswordList(); |
| 82 void SetPasswordExceptionList(); | 84 void SetPasswordExceptionList(); |
| 83 | 85 |
| 84 // Sort entries of |list| based on sort key. The key is the concatenation of | 86 // Sort entries of |list| based on sort key. The key is the concatenation of |
| 85 // origin, entry type (non-Android credential, Android w/ affiliated web realm | 87 // origin, entry type (non-Android credential, Android w/ affiliated web realm |
| 86 // or Android w/o affiliated web realm). If |username_and_password_in_key|, | 88 // or Android w/o affiliated web realm). If |entry_type == SAVED|, |
| 87 // username and password are also included in sort key. If there are several | 89 // username, password and federation are also included in sort key. If there |
| 88 // forms with the same key, all such forms but the first one are | 90 // are several forms with the same key, all such forms but the first one are |
| 89 // stored in |duplicates| instead of |list|. | 91 // stored in |duplicates| instead of |list|. |
| 90 void SortEntriesAndHideDuplicates( | 92 void SortEntriesAndHideDuplicates( |
| 91 std::vector<std::unique_ptr<autofill::PasswordForm>>* list, | 93 std::vector<std::unique_ptr<autofill::PasswordForm>>* list, |
| 92 DuplicatesMap* duplicates, | 94 DuplicatesMap* duplicates, |
| 93 bool username_and_password_in_key); | 95 PasswordEntryType entry_type); |
| 94 | 96 |
| 95 // Returns the password store associated with the currently active profile. | 97 // Returns the password store associated with the currently active profile. |
| 96 password_manager::PasswordStore* GetPasswordStore(); | 98 password_manager::PasswordStore* GetPasswordStore(); |
| 97 | 99 |
| 98 // A short class to mediate requests to the password store. | 100 // A short class to mediate requests to the password store. |
| 99 class ListPopulater : public password_manager::PasswordStoreConsumer { | 101 class ListPopulater : public password_manager::PasswordStoreConsumer { |
| 100 public: | 102 public: |
| 101 explicit ListPopulater(PasswordManagerPresenter* page); | 103 explicit ListPopulater(PasswordManagerPresenter* page); |
| 102 ~ListPopulater() override; | 104 ~ListPopulater() override; |
| 103 | 105 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // Used to determine whether or not to reveal plaintext passwords. | 152 // Used to determine whether or not to reveal plaintext passwords. |
| 151 base::TimeTicks last_authentication_time_; | 153 base::TimeTicks last_authentication_time_; |
| 152 | 154 |
| 153 // UI view that owns this presenter. | 155 // UI view that owns this presenter. |
| 154 PasswordUIView* password_view_; | 156 PasswordUIView* password_view_; |
| 155 | 157 |
| 156 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); | 158 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); |
| 157 }; | 159 }; |
| 158 | 160 |
| 159 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ | 161 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
| OLD | NEW |