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

Side by Side Diff: chrome/browser/ui/webui/options/password_manager_presenter.h

Issue 71003002: Merge browser/ui/password and browser/ui/passwords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_PRESENTER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_PRESENTER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/scoped_vector.h"
12 #include "base/prefs/pref_member.h"
13 #include "chrome/browser/password_manager/password_store.h"
14 #include "chrome/browser/password_manager/password_store_consumer.h"
15 #include "chrome/browser/ui/webui/options/options_ui.h"
16
17 namespace autofill {
18 struct PasswordForm;
19 }
20
21 namespace passwords_ui {
22 class PasswordUIView;
23 }
24
25 class Profile;
26
27 namespace options {
28
29 // Contains the common logic used by a PasswordUIView to
30 // interact with PasswordStore. It provides completion callbacks for
31 // PasswordStore operations and updates the view on PasswordStore changes.
32 class PasswordManagerPresenter : public PasswordStore::Observer {
33 public:
34 // |password_view| the UI view that owns this presenter, must not be NULL.
35 explicit PasswordManagerPresenter(
36 passwords_ui::PasswordUIView* password_view);
37 virtual ~PasswordManagerPresenter();
38
39 // PasswordStore::Observer implementation.
40 virtual void OnLoginsChanged() OVERRIDE;
41
42 // Repopulates the password and exception entries.
43 void UpdatePasswordLists();
44
45 void Initialize();
46
47 // Gets the password entry at |index|.
48 const autofill::PasswordForm& GetPassword(size_t index);
49
50 // Gets the password exception entry at |index|.
51 const autofill::PasswordForm& GetPasswordException(size_t index);
52
53 // Removes the saved password entry at |index|.
54 // |index| the entry index to be removed.
55 void HandleRemoveSavedPassword(size_t index);
56
57 // Removes the saved password exception entry at |index|.
58 // |index| the entry index to be removed.
59 void HandleRemovePasswordException(size_t index);
60
61 // Requests the plain text password for entry at |index| to be revealed.
62 // |index| The index of the entry.
63 void HandleRequestShowPassword(size_t index);
64
65 private:
66 friend class PasswordManagerPresenterTest;
67
68 // Returns the password store associated with the currently active profile.
69 PasswordStore* GetPasswordStore();
70
71 // Returns true if the user needs to be authenticated before a plaintext
72 // password is revealed.
73 bool IsAuthenticationRequired();
74
75 // Sets the password and exception list of the UI view.
76 void SetPasswordList();
77 void SetPasswordExceptionList();
78
79 // A short class to mediate requests to the password store.
80 class ListPopulater : public PasswordStoreConsumer {
81 public:
82 explicit ListPopulater(PasswordManagerPresenter* page);
83 virtual ~ListPopulater();
84
85 // Send a query to the password store to populate a list.
86 virtual void Populate() = 0;
87
88 protected:
89 PasswordManagerPresenter* page_;
90 CancelableRequestProvider::Handle pending_login_query_;
91 };
92
93 // A short class to mediate requests to the password store for passwordlist.
94 class PasswordListPopulater : public ListPopulater {
95 public:
96 explicit PasswordListPopulater(PasswordManagerPresenter* page);
97
98 // Send a query to the password store to populate a password list.
99 virtual void Populate() OVERRIDE;
100
101 // Send the password store's reply back to the handler.
102 virtual void OnPasswordStoreRequestDone(
103 CancelableRequestProvider::Handle handle,
104 const std::vector<autofill::PasswordForm*>& result) OVERRIDE;
105 virtual void OnGetPasswordStoreResults(
106 const std::vector<autofill::PasswordForm*>& results) OVERRIDE;
107 };
108
109 // A short class to mediate requests to the password store for exceptions.
110 class PasswordExceptionListPopulater : public ListPopulater {
111 public:
112 explicit PasswordExceptionListPopulater(PasswordManagerPresenter* page);
113
114 // Send a query to the password store to populate a passwordException list.
115 virtual void Populate() OVERRIDE;
116
117 // Send the password store's reply back to the handler.
118 virtual void OnPasswordStoreRequestDone(
119 CancelableRequestProvider::Handle handle,
120 const std::vector<autofill::PasswordForm*>& result) OVERRIDE;
121 virtual void OnGetPasswordStoreResults(
122 const std::vector<autofill::PasswordForm*>& results) OVERRIDE;
123 };
124
125 // Password store consumer for populating the password list and exceptions.
126 PasswordListPopulater populater_;
127 PasswordExceptionListPopulater exception_populater_;
128
129 ScopedVector<autofill::PasswordForm> password_list_;
130 ScopedVector<autofill::PasswordForm> password_exception_list_;
131
132 // Whether to show stored passwords or not.
133 BooleanPrefMember show_passwords_;
134
135 // Indicates whether or not the password manager should require the user to
136 // reauthenticate before revealing plaintext passwords.
137 bool require_reauthentication_;
138
139 // The last time the user was successfully authenticated.
140 // Used to determine whether or not to reveal plaintext passwords.
141 base::TimeTicks last_authentication_time_;
142
143 // UI view that owns this presenter.
144 passwords_ui::PasswordUIView* password_view_;
145
146 DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenter);
147 };
148
149 } // namespace options
150
151 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PASSWORD_MANAGER_PRESENTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698