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

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

Issue 1193143003: Enable import/export of passwords into/from Password Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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
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 <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 21
21 namespace autofill { 22 namespace autofill {
22 struct PasswordForm; 23 struct PasswordForm;
23 } 24 }
24 25
25 // Multimap from sort key to password forms. 26 // Multimap from sort key to password forms.
26 using DuplicatesMap = 27 using DuplicatesMap =
27 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>; 28 std::multimap<std::string, std::unique_ptr<autofill::PasswordForm>>;
28 29
29 class PasswordUIView; 30 class PasswordUIView;
(...skipping 15 matching lines...) Expand all
45 const password_manager::PasswordStoreChangeList& changes) override; 46 const password_manager::PasswordStoreChangeList& changes) override;
46 47
47 // Repopulates the password and exception entries. 48 // Repopulates the password and exception entries.
48 void UpdatePasswordLists(); 49 void UpdatePasswordLists();
49 50
50 void Initialize(); 51 void Initialize();
51 52
52 // Gets the password entry at |index|. 53 // Gets the password entry at |index|.
53 const autofill::PasswordForm* GetPassword(size_t index); 54 const autofill::PasswordForm* GetPassword(size_t index);
54 55
56 // Gets all password entries.
57 std::vector<std::unique_ptr<autofill::PasswordForm>> GetAllPasswords();
58
55 // Gets the password exception entry at |index|. 59 // Gets the password exception entry at |index|.
56 const autofill::PasswordForm* GetPasswordException(size_t index); 60 const autofill::PasswordForm* GetPasswordException(size_t index);
57 61
58 // Removes the saved password entry at |index|. 62 // Removes the saved password entry at |index|.
59 // |index| the entry index to be removed. 63 // |index| the entry index to be removed.
60 void RemoveSavedPassword(size_t index); 64 void RemoveSavedPassword(size_t index);
61 65
62 // Removes the saved password exception entry at |index|. 66 // Removes the saved password exception entry at |index|.
63 // |index| the entry index to be removed. 67 // |index| the entry index to be removed.
64 void RemovePasswordException(size_t index); 68 void RemovePasswordException(size_t index);
65 69
66 // Requests the plain text password for entry at |index| to be revealed. 70 // Requests the plain text password for entry at |index| to be revealed.
67 // |index| The index of the entry. 71 // |index| The index of the entry.
68 void RequestShowPassword(size_t index); 72 void RequestShowPassword(size_t index);
69 73
74 // Returns true if the user is authenticated.
75 virtual bool IsUserAuthenticated();
76
70 private: 77 private:
71 friend class PasswordManagerPresenterTest; 78 friend class PasswordManagerPresenterTest;
72 79
73 // Returns the password store associated with the currently active profile. 80 // Returns true if the user needs to be authenticated before a plaintext
74 password_manager::PasswordStore* GetPasswordStore(); 81 // password is revealed or exported.
82 bool IsAuthenticationRequired();
75 83
76 // Sets the password and exception list of the UI view. 84 // Sets the password and exception list of the UI view.
77 void SetPasswordList(); 85 void SetPasswordList();
78 void SetPasswordExceptionList(); 86 void SetPasswordExceptionList();
79 87
80 // Sort entries of |list| based on sort key. The key is the concatenation of 88 // 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 89 // 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|, 90 // 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 91 // 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 92 // forms with the same key, all such forms but the first one are
85 // stored in |duplicates| instead of |list|. 93 // stored in |duplicates| instead of |list|.
86 void SortEntriesAndHideDuplicates( 94 void SortEntriesAndHideDuplicates(
87 std::vector<std::unique_ptr<autofill::PasswordForm>>* list, 95 std::vector<std::unique_ptr<autofill::PasswordForm>>* list,
88 DuplicatesMap* duplicates, 96 DuplicatesMap* duplicates,
89 bool username_and_password_in_key); 97 bool username_and_password_in_key);
90 98
99 // Returns the password store associated with the currently active profile.
100 password_manager::PasswordStore* GetPasswordStore();
101
91 // A short class to mediate requests to the password store. 102 // A short class to mediate requests to the password store.
92 class ListPopulater : public password_manager::PasswordStoreConsumer { 103 class ListPopulater : public password_manager::PasswordStoreConsumer {
93 public: 104 public:
94 explicit ListPopulater(PasswordManagerPresenter* page); 105 explicit ListPopulater(PasswordManagerPresenter* page);
95 ~ListPopulater() override; 106 ~ListPopulater() override;
96 107
97 // Send a query to the password store to populate a list. 108 // Send a query to the password store to populate a list.
98 virtual void Populate() = 0; 109 virtual void Populate() = 0;
99 110
100 protected: 111 protected:
(...skipping 28 matching lines...) Expand all
129 140
130 // Password store consumer for populating the password list and exceptions. 141 // Password store consumer for populating the password list and exceptions.
131 PasswordListPopulater populater_; 142 PasswordListPopulater populater_;
132 PasswordExceptionListPopulater exception_populater_; 143 PasswordExceptionListPopulater exception_populater_;
133 144
134 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list_; 145 std::vector<std::unique_ptr<autofill::PasswordForm>> password_list_;
135 std::vector<std::unique_ptr<autofill::PasswordForm>> password_exception_list_; 146 std::vector<std::unique_ptr<autofill::PasswordForm>> password_exception_list_;
136 DuplicatesMap password_duplicates_; 147 DuplicatesMap password_duplicates_;
137 DuplicatesMap password_exception_duplicates_; 148 DuplicatesMap password_exception_duplicates_;
138 149
150 // Whether to show stored passwords or not.
151 BooleanPrefMember show_passwords_;
152
139 // The last time the user was successfully authenticated. 153 // The last time the user was successfully authenticated.
140 // Used to determine whether or not to reveal plaintext passwords. 154 // Used to determine whether or not to reveal plaintext passwords.
141 base::TimeTicks last_authentication_time_; 155 base::TimeTicks last_authentication_time_;
142 156
143 // UI view that owns this presenter. 157 // UI view that owns this presenter.
144 PasswordUIView* password_view_; 158 PasswordUIView* password_view_;
145 159
146 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter); 160 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter);
147 }; 161 };
148 162
149 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_ 163 #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORD_MANAGER_PRESENTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698