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

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

Issue 848723002: Credential Manager API: Showing both local and federated logins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed comments. Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
7 7
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/timer/elapsed_timer.h" 9 #include "base/timer/elapsed_timer.h"
10 #include "components/autofill/core/common/password_form.h" 10 #include "components/autofill/core/common/password_form.h"
11 #include "components/password_manager/core/browser/password_store.h" 11 #include "components/password_manager/core/browser/password_store.h"
12 #include "components/password_manager/core/common/password_manager_ui.h" 12 #include "components/password_manager/core/common/password_manager_ui.h"
13 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h" 14 #include "content/public/browser/web_contents_user_data.h"
15 15
16 namespace content { 16 namespace content {
17 class WebContents; 17 class WebContents;
18 } 18 }
19 19
20 namespace password_manager { 20 namespace password_manager {
21 enum class CredentialType : unsigned int;
vasilii 2015/01/16 14:07:26 I wonder why the type is inherited from "unsigned
melandory 2015/01/19 15:40:15 Yes, we can amend unsigned int and live with defau
21 struct CredentialInfo; 22 struct CredentialInfo;
22 class PasswordFormManager; 23 class PasswordFormManager;
23 } 24 }
24 25
25 class ManagePasswordsIcon; 26 class ManagePasswordsIcon;
26 27
27 // Per-tab class to control the Omnibox password icon and bubble. 28 // Per-tab class to control the Omnibox password icon and bubble.
28 class ManagePasswordsUIController 29 class ManagePasswordsUIController
29 : public content::WebContentsObserver, 30 : public content::WebContentsObserver,
30 public content::WebContentsUserData<ManagePasswordsUIController>, 31 public content::WebContentsUserData<ManagePasswordsUIController>,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void OnLoginsChanged( 74 void OnLoginsChanged(
74 const password_manager::PasswordStoreChangeList& changes) override; 75 const password_manager::PasswordStoreChangeList& changes) override;
75 76
76 // Called from the model when the user chooses to save a password; passes the 77 // Called from the model when the user chooses to save a password; passes the
77 // action off to the FormManager. The controller MUST be in a pending state, 78 // action off to the FormManager. The controller MUST be in a pending state,
78 // and WILL be in MANAGE_STATE after this method executes. 79 // and WILL be in MANAGE_STATE after this method executes.
79 virtual void SavePassword(); 80 virtual void SavePassword();
80 81
81 // Called from the model when the user chooses a credential. 82 // Called from the model when the user chooses a credential.
82 // The controller MUST be in a pending credentials state. 83 // The controller MUST be in a pending credentials state.
83 virtual void ChooseCredential(bool was_chosen, 84 virtual void ChooseCredential(
84 const autofill::PasswordForm& form); 85 const autofill::PasswordForm& form,
86 password_manager::CredentialType credential_type);
85 87
86 // Called from the model when the user chooses to never save passwords; passes 88 // Called from the model when the user chooses to never save passwords; passes
87 // the action off to the FormManager. The controller MUST be in a pending 89 // the action off to the FormManager. The controller MUST be in a pending
88 // state, and WILL be in BLACKLIST_STATE after this method executes. 90 // state, and WILL be in BLACKLIST_STATE after this method executes.
89 virtual void NeverSavePassword(); 91 virtual void NeverSavePassword();
90 92
91 // Called from the model when the user chooses to unblacklist the site. The 93 // Called from the model when the user chooses to unblacklist the site. The
92 // controller MUST be in BLACKLIST_STATE, and WILL be in MANAGE_STATE after 94 // controller MUST be in BLACKLIST_STATE, and WILL be in MANAGE_STATE after
93 // this method executes. 95 // this method executes.
94 virtual void UnblacklistSite(); 96 virtual void UnblacklistSite();
95 97
96 // Open a new tab, pointing to the password manager settings page. 98 // Open a new tab, pointing to the password manager settings page.
97 virtual void NavigateToPasswordManagerSettingsPage(); 99 virtual void NavigateToPasswordManagerSettingsPage();
98 100
99 virtual const autofill::PasswordForm& PendingPassword() const; 101 virtual const autofill::PasswordForm& PendingPassword() const;
100 102
101 // Set the state of the Omnibox icon, and possibly show the associated bubble 103 // Set the state of the Omnibox icon, and possibly show the associated bubble
102 // without user interaction. 104 // without user interaction.
103 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon); 105 virtual void UpdateIconAndBubbleState(ManagePasswordsIcon* icon);
104 106
105 // Called from the model when the bubble is displayed. 107 // Called from the model when the bubble is displayed.
106 void OnBubbleShown(); 108 void OnBubbleShown();
107 109
108 password_manager::ui::State state() const { return state_; } 110 password_manager::ui::State state() const { return state_; }
109 111
110 ScopedVector<autofill::PasswordForm>& new_password_forms() { 112 ScopedVector<autofill::PasswordForm>& federated_credentials_forms() {
111 return new_password_forms_; 113 return federated_credentials_forms_;
114 }
115
116 ScopedVector<autofill::PasswordForm>& local_credentials_forms() {
117 return local_credentials_forms_;
112 } 118 }
113 119
114 // True if a password is sitting around, waiting for a user to decide whether 120 // True if a password is sitting around, waiting for a user to decide whether
115 // or not to save it. 121 // or not to save it.
116 bool PasswordPendingUserDecision() const; 122 bool PasswordPendingUserDecision() const;
117 123
118 const autofill::ConstPasswordFormMap& best_matches() const { 124 const autofill::ConstPasswordFormMap& best_matches() const {
119 return password_form_map_; 125 return password_form_map_;
120 } 126 }
121 127
(...skipping 25 matching lines...) Expand all
147 153
148 // Sets |state_|. Protected so we can manipulate the value in tests. 154 // Sets |state_|. Protected so we can manipulate the value in tests.
149 void SetState(password_manager::ui::State state); 155 void SetState(password_manager::ui::State state);
150 156
151 // We create copies of PasswordForm objects that come in with unclear lifetime 157 // We create copies of PasswordForm objects that come in with unclear lifetime
152 // and store them in this vector as well as in |password_form_map_| to ensure 158 // and store them in this vector as well as in |password_form_map_| to ensure
153 // that we destroy them correctly. If |new_password_forms_| gets cleared then 159 // that we destroy them correctly. If |new_password_forms_| gets cleared then
154 // |password_form_map_| is to be cleared too. 160 // |password_form_map_| is to be cleared too.
155 ScopedVector<autofill::PasswordForm> new_password_forms_; 161 ScopedVector<autofill::PasswordForm> new_password_forms_;
156 162
163 // Federated credentials. Stores federated credentials which will be shown
164 // when Credential Management API was used.
165 ScopedVector<autofill::PasswordForm> federated_credentials_forms_;
166
167 // Local credentials. Stores local credentials which will be shown
168 // when Credential Management API was used.
169 ScopedVector<autofill::PasswordForm> local_credentials_forms_;
170
157 // All previously stored credentials for a specific site. 171 // All previously stored credentials for a specific site.
158 // Protected, not private, so we can mess with the value in 172 // Protected, not private, so we can mess with the value in
159 // ManagePasswordsUIControllerMock. 173 // ManagePasswordsUIControllerMock.
160 autofill::ConstPasswordFormMap password_form_map_; 174 autofill::ConstPasswordFormMap password_form_map_;
161 175
162 private: 176 private:
163 friend class content::WebContentsUserData<ManagePasswordsUIController>; 177 friend class content::WebContentsUserData<ManagePasswordsUIController>;
164 178
165 // Shows the password bubble without user interaction. The controller MUST 179 // Shows the password bubble without user interaction. The controller MUST
166 // be in PENDING_PASSWORD_AND_BUBBLE_STATE. 180 // be in PENDING_PASSWORD_AND_BUBBLE_STATE.
(...skipping 26 matching lines...) Expand all
193 207
194 // The origin of the form we're currently dealing with; we'll use this to 208 // The origin of the form we're currently dealing with; we'll use this to
195 // determine which PasswordStore changes we should care about when updating 209 // determine which PasswordStore changes we should care about when updating
196 // |password_form_map_|. 210 // |password_form_map_|.
197 GURL origin_; 211 GURL origin_;
198 212
199 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController); 213 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIController);
200 }; 214 };
201 215
202 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_ 216 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698