Chromium Code Reviews| 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 <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "components/password_manager/core/browser/password_store.h" | 16 #include "components/password_manager/core/browser/password_store.h" |
| 17 #include "components/password_manager/core/browser/password_store_consumer.h" | 17 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 18 #include "components/prefs/pref_member.h" | 18 #include "components/prefs/pref_member.h" |
| 19 | 19 |
| 20 namespace autofill { | 20 namespace autofill { |
| 21 struct PasswordForm; | 21 struct PasswordForm; |
| 22 | |
| 23 using DuplicatesMap = | |
|
vabr (Chromium)
2016/03/08 13:09:28
Please pull DuplicatesMap out of the autofill name
kolos1
2016/03/08 15:14:24
Done.
| |
| 24 std::multimap<std::string, scoped_ptr<autofill::PasswordForm>>; | |
|
vabr (Chromium)
2016/03/08 13:09:28
#include <ma> for multimap
kolos1
2016/03/08 15:14:24
Done.
| |
| 22 } | 25 } |
| 23 | 26 |
| 24 class PasswordUIView; | 27 class PasswordUIView; |
| 25 | 28 |
| 26 class Profile; | 29 class Profile; |
| 27 | 30 |
| 28 // Contains the common logic used by a PasswordUIView to | 31 // Contains the common logic used by a PasswordUIView to |
| 29 // interact with PasswordStore. It provides completion callbacks for | 32 // interact with PasswordStore. It provides completion callbacks for |
| 30 // PasswordStore operations and updates the view on PasswordStore changes. | 33 // PasswordStore operations and updates the view on PasswordStore changes. |
| 31 class PasswordManagerPresenter | 34 class PasswordManagerPresenter |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 private: | 68 private: |
| 66 friend class PasswordManagerPresenterTest; | 69 friend class PasswordManagerPresenterTest; |
| 67 | 70 |
| 68 // Returns the password store associated with the currently active profile. | 71 // Returns the password store associated with the currently active profile. |
| 69 password_manager::PasswordStore* GetPasswordStore(); | 72 password_manager::PasswordStore* GetPasswordStore(); |
| 70 | 73 |
| 71 // Sets the password and exception list of the UI view. | 74 // Sets the password and exception list of the UI view. |
| 72 void SetPasswordList(); | 75 void SetPasswordList(); |
| 73 void SetPasswordExceptionList(); | 76 void SetPasswordExceptionList(); |
| 74 | 77 |
| 78 // Sort entries of |list| based on sort key. The key is the concatenation of | |
| 79 // origin, username, hashed password and entry type (non-Android credential, | |
| 80 // Android w/ affiliated web realm or Android w/o affiliated web realm). If | |
| 81 // there is several forms with the same key, the duplicates are moved from | |
|
vabr (Chromium)
2016/03/08 13:09:28
nit: To clarify that "duplicates" exclude the firs
kolos1
2016/03/08 15:14:24
Done.
| |
| 82 // |list| to |duplicates| (the multimap from sort key to forms). | |
| 83 // |username_and_password_in_key| defines whether username and hashed | |
|
vabr (Chromium)
2016/03/08 13:09:28
The last sentence is not completely clear -- from
kolos1
2016/03/08 15:14:24
Done.
| |
| 84 // password are included in sort key. | |
| 85 void SortEntriesAndHideDuplicates( | |
| 86 const std::string& languages, | |
| 87 std::vector<scoped_ptr<autofill::PasswordForm>>* list, | |
| 88 autofill::DuplicatesMap* duplicates_, | |
|
vabr (Chromium)
2016/03/08 13:09:28
nit: Remove the trailing underscore in "duplicates
kolos1
2016/03/08 15:14:24
Done.
| |
| 89 bool username_and_password_in_key); | |
| 90 | |
| 75 // A short class to mediate requests to the password store. | 91 // A short class to mediate requests to the password store. |
| 76 class ListPopulater : public password_manager::PasswordStoreConsumer { | 92 class ListPopulater : public password_manager::PasswordStoreConsumer { |
| 77 public: | 93 public: |
| 78 explicit ListPopulater(PasswordManagerPresenter* page); | 94 explicit ListPopulater(PasswordManagerPresenter* page); |
| 79 ~ListPopulater() override; | 95 ~ListPopulater() override; |
| 80 | 96 |
| 81 // Send a query to the password store to populate a list. | 97 // Send a query to the password store to populate a list. |
| 82 virtual void Populate() = 0; | 98 virtual void Populate() = 0; |
| 83 | 99 |
| 84 protected: | 100 protected: |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 110 void OnGetPasswordStoreResults( | 126 void OnGetPasswordStoreResults( |
| 111 ScopedVector<autofill::PasswordForm> results) override; | 127 ScopedVector<autofill::PasswordForm> results) override; |
| 112 }; | 128 }; |
| 113 | 129 |
| 114 // Password store consumer for populating the password list and exceptions. | 130 // Password store consumer for populating the password list and exceptions. |
| 115 PasswordListPopulater populater_; | 131 PasswordListPopulater populater_; |
| 116 PasswordExceptionListPopulater exception_populater_; | 132 PasswordExceptionListPopulater exception_populater_; |
| 117 | 133 |
| 118 std::vector<scoped_ptr<autofill::PasswordForm>> password_list_; | 134 std::vector<scoped_ptr<autofill::PasswordForm>> password_list_; |
| 119 std::vector<scoped_ptr<autofill::PasswordForm>> password_exception_list_; | 135 std::vector<scoped_ptr<autofill::PasswordForm>> password_exception_list_; |
| 136 autofill::DuplicatesMap password_duplicates_; | |
| 137 autofill::DuplicatesMap password_exception_duplicates_; | |
| 120 | 138 |
| 121 // Whether to show stored passwords or not. | 139 // Whether to show stored passwords or not. |
| 122 BooleanPrefMember show_passwords_; | 140 BooleanPrefMember show_passwords_; |
| 123 | 141 |
| 124 // Indicates whether or not the password manager should require the user to | 142 // Indicates whether or not the password manager should require the user to |
| 125 // reauthenticate before revealing plaintext passwords. | 143 // reauthenticate before revealing plaintext passwords. |
| 126 const bool require_reauthentication_; | 144 const bool require_reauthentication_; |
| 127 | 145 |
| 128 // The last time the user was successfully authenticated. | 146 // The last time the user was successfully authenticated. |
| 129 // Used to determine whether or not to reveal plaintext passwords. | 147 // Used to determine whether or not to reveal plaintext passwords. |
| 130 base::TimeTicks last_authentication_time_; | 148 base::TimeTicks last_authentication_time_; |
| 131 | 149 |
| 132 // UI view that owns this presenter. | 150 // UI view that owns this presenter. |
| 133 PasswordUIView* password_view_; | 151 PasswordUIView* password_view_; |
| 134 | 152 |
| 135 // User pref for storing accept languages. | 153 // User pref for storing accept languages. |
| 136 std::string languages_; | 154 std::string languages_; |
| 137 | 155 |
| 138 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); | 156 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); |
| 139 }; | 157 }; |
| 140 | 158 |
| 141 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ | 159 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ |
| OLD | NEW |