Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/ui/passwords/password_manager_presenter.h

Issue 1589483002: [Password Manager] Implements entries sorting and duplicates omitting on chrome://settings/passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mistype in a comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/password_manager_presenter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
16 #include "components/password_manager/core/browser/password_store.h" 17 #include "components/password_manager/core/browser/password_store.h"
17 #include "components/password_manager/core/browser/password_store_consumer.h" 18 #include "components/password_manager/core/browser/password_store_consumer.h"
18 #include "components/prefs/pref_member.h" 19 #include "components/prefs/pref_member.h"
19 20
20 namespace autofill { 21 namespace autofill {
21 struct PasswordForm; 22 struct PasswordForm;
22 } 23 }
23 24
25 // Multimap from sort key to password forms.
26 using DuplicatesMap =
27 std::multimap<std::string, scoped_ptr<autofill::PasswordForm>>;
28
24 class PasswordUIView; 29 class PasswordUIView;
25 30
26 class Profile; 31 class Profile;
27 32
28 // Contains the common logic used by a PasswordUIView to 33 // Contains the common logic used by a PasswordUIView to
29 // interact with PasswordStore. It provides completion callbacks for 34 // interact with PasswordStore. It provides completion callbacks for
30 // PasswordStore operations and updates the view on PasswordStore changes. 35 // PasswordStore operations and updates the view on PasswordStore changes.
31 class PasswordManagerPresenter 36 class PasswordManagerPresenter
32 : public password_manager::PasswordStore::Observer { 37 : public password_manager::PasswordStore::Observer {
33 public: 38 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private: 70 private:
66 friend class PasswordManagerPresenterTest; 71 friend class PasswordManagerPresenterTest;
67 72
68 // Returns the password store associated with the currently active profile. 73 // Returns the password store associated with the currently active profile.
69 password_manager::PasswordStore* GetPasswordStore(); 74 password_manager::PasswordStore* GetPasswordStore();
70 75
71 // Sets the password and exception list of the UI view. 76 // Sets the password and exception list of the UI view.
72 void SetPasswordList(); 77 void SetPasswordList();
73 void SetPasswordExceptionList(); 78 void SetPasswordExceptionList();
74 79
80 // 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
82 // or Android w/o affiliated web realm). If |username_and_password_in_key|,
83 // username and password are also included in sort key. If there are several
84 // forms with the same key, all such forms but the first one are
85 // stored in |duplicates| instead of |list|.
86 void SortEntriesAndHideDuplicates(
87 const std::string& languages,
88 std::vector<scoped_ptr<autofill::PasswordForm>>* list,
89 DuplicatesMap* duplicates,
90 bool username_and_password_in_key);
91
75 // A short class to mediate requests to the password store. 92 // A short class to mediate requests to the password store.
76 class ListPopulater : public password_manager::PasswordStoreConsumer { 93 class ListPopulater : public password_manager::PasswordStoreConsumer {
77 public: 94 public:
78 explicit ListPopulater(PasswordManagerPresenter* page); 95 explicit ListPopulater(PasswordManagerPresenter* page);
79 ~ListPopulater() override; 96 ~ListPopulater() override;
80 97
81 // Send a query to the password store to populate a list. 98 // Send a query to the password store to populate a list.
82 virtual void Populate() = 0; 99 virtual void Populate() = 0;
83 100
84 protected: 101 protected:
(...skipping 25 matching lines...) Expand all
110 void OnGetPasswordStoreResults( 127 void OnGetPasswordStoreResults(
111 ScopedVector<autofill::PasswordForm> results) override; 128 ScopedVector<autofill::PasswordForm> results) override;
112 }; 129 };
113 130
114 // Password store consumer for populating the password list and exceptions. 131 // Password store consumer for populating the password list and exceptions.
115 PasswordListPopulater populater_; 132 PasswordListPopulater populater_;
116 PasswordExceptionListPopulater exception_populater_; 133 PasswordExceptionListPopulater exception_populater_;
117 134
118 std::vector<scoped_ptr<autofill::PasswordForm>> password_list_; 135 std::vector<scoped_ptr<autofill::PasswordForm>> password_list_;
119 std::vector<scoped_ptr<autofill::PasswordForm>> password_exception_list_; 136 std::vector<scoped_ptr<autofill::PasswordForm>> password_exception_list_;
137 DuplicatesMap password_duplicates_;
138 DuplicatesMap password_exception_duplicates_;
120 139
121 // Whether to show stored passwords or not. 140 // Whether to show stored passwords or not.
122 BooleanPrefMember show_passwords_; 141 BooleanPrefMember show_passwords_;
123 142
124 // Indicates whether or not the password manager should require the user to 143 // Indicates whether or not the password manager should require the user to
125 // reauthenticate before revealing plaintext passwords. 144 // reauthenticate before revealing plaintext passwords.
126 const bool require_reauthentication_; 145 const bool require_reauthentication_;
127 146
128 // The last time the user was successfully authenticated. 147 // The last time the user was successfully authenticated.
129 // Used to determine whether or not to reveal plaintext passwords. 148 // Used to determine whether or not to reveal plaintext passwords.
130 base::TimeTicks last_authentication_time_; 149 base::TimeTicks last_authentication_time_;
131 150
132 // UI view that owns this presenter. 151 // UI view that owns this presenter.
133 PasswordUIView* password_view_; 152 PasswordUIView* password_view_;
134 153
135 // User pref for storing accept languages. 154 // User pref for storing accept languages.
136 std::string languages_; 155 std::string languages_;
137 156
138 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); 157 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter);
139 }; 158 };
140 159
141 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ 160 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/passwords/password_manager_presenter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698