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

Side by Side Diff: chrome/browser/password_manager/password_manager.h

Issue 9564001: Clean up password manager code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a unit test for sub-frame navigation Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector>
10
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
10 #include "base/stl_util.h" 13 #include "base/stl_util.h"
11 #include "chrome/browser/password_manager/password_form_manager.h" 14 #include "chrome/browser/password_manager/password_form_manager.h"
12 #include "chrome/browser/prefs/pref_member.h" 15 #include "chrome/browser/prefs/pref_member.h"
13 #include "chrome/browser/ui/login/login_model.h" 16 #include "chrome/browser/ui/login/login_model.h"
14 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
15 #include "webkit/forms/password_form.h" 18 #include "webkit/forms/password_form.h"
16 #include "webkit/forms/password_form_dom_manager.h" 19 #include "webkit/forms/password_form_dom_manager.h"
17 20
18 class PasswordManagerDelegate; 21 class PasswordManagerDelegate;
19 class PasswordManagerTest; 22 class PasswordManagerTest;
(...skipping 11 matching lines...) Expand all
31 34
32 // The delegate passed in is required to outlive the PasswordManager. 35 // The delegate passed in is required to outlive the PasswordManager.
33 PasswordManager(content::WebContents* web_contents, 36 PasswordManager(content::WebContents* web_contents,
34 PasswordManagerDelegate* delegate); 37 PasswordManagerDelegate* delegate);
35 virtual ~PasswordManager(); 38 virtual ~PasswordManager();
36 39
37 // Called by a PasswordFormManager when it decides a form can be autofilled 40 // Called by a PasswordFormManager when it decides a form can be autofilled
38 // on the page. 41 // on the page.
39 void Autofill(const webkit::forms::PasswordForm& form_for_autofill, 42 void Autofill(const webkit::forms::PasswordForm& form_for_autofill,
40 const webkit::forms::PasswordFormMap& best_matches, 43 const webkit::forms::PasswordFormMap& best_matches,
41 const webkit::forms::PasswordForm* const preferred_match, 44 const webkit::forms::PasswordForm& preferred_match,
42 bool wait_for_username) const; 45 bool wait_for_username) const;
43 46
44 // LoginModel implementation. 47 // LoginModel implementation.
45 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE; 48 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE;
46 49
50 // TODO(isherman): This should not be public, but is currently being used by
51 // the LoginPrompt code.
Ilya Sherman 2012/03/02 02:51:50 Incidentally, I'm rather confused as to how the Lo
47 // When a form is submitted, we prepare to save the password but wait 52 // When a form is submitted, we prepare to save the password but wait
48 // until we decide the user has successfully logged in. This is step 1 53 // until we decide the user has successfully logged in. This is step 1
49 // of 2 (see SavePassword). 54 // of 2 (see SavePassword).
50 void ProvisionallySavePassword(webkit::forms::PasswordForm form); 55 void ProvisionallySavePassword(const webkit::forms::PasswordForm& form);
51 56
52 // content::WebContentsObserver overrides. 57 // content::WebContentsObserver overrides.
53 virtual void DidStopLoading() OVERRIDE; 58 virtual void DidStopLoading() OVERRIDE;
54 virtual void DidNavigateAnyFrame( 59 virtual void DidNavigateAnyFrame(
55 const content::LoadCommittedDetails& details, 60 const content::LoadCommittedDetails& details,
56 const content::FrameNavigateParams& params) OVERRIDE; 61 const content::FrameNavigateParams& params) OVERRIDE;
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
58 63
64 // TODO(isherman): This should not be public, but is currently being used by
65 // the LoginPrompt code.
59 void OnPasswordFormsFound( 66 void OnPasswordFormsFound(
60 const std::vector<webkit::forms::PasswordForm>& forms); 67 const std::vector<webkit::forms::PasswordForm>& forms);
61 void OnPasswordFormsVisible( 68 void OnPasswordFormsVisible(
62 const std::vector<webkit::forms::PasswordForm>& visible_forms); 69 const std::vector<webkit::forms::PasswordForm>& visible_forms);
63 70
64 private: 71 private:
65 FRIEND_TEST_ALL_PREFIXES(PasswordManagerTest, FormSeenThenLeftPage);
66
67 // Note about how a PasswordFormManager can transition from 72 // Note about how a PasswordFormManager can transition from
68 // pending_login_managers_ to provisional_save_manager_ and the infobar. 73 // pending_login_managers_ to provisional_save_manager_ and the infobar.
69 // 74 //
70 // 1. form "seen" 75 // 1. form "seen"
71 // | new 76 // | new
72 // | ___ Infobar 77 // | ___ Infobar
73 // pending_login -- form submit --> provisional_save ___/ 78 // pending_login -- form submit --> provisional_save ___/
74 // ^ | \___ (update DB) 79 // ^ | \___ (update DB)
75 // | fail 80 // | fail
76 // |-----------<------<---------| !new 81 // |-----------<------<---------| !new
77 // 82 //
78 // When a form is "seen" on a page, a PasswordFormManager is created 83 // When a form is "seen" on a page, a PasswordFormManager is created
79 // and stored in this collection until user navigates away from page. 84 // and stored in this collection until user navigates away from page.
80 85
81 // Clear any pending saves 86 // Is password autofill enabled for the current profile?
82 void ClearProvisionalSave(); 87 bool IsEnabled() const;
83 88
84 // Notification that the user navigated away from the current page. 89 ScopedVector<PasswordFormManager> pending_login_managers_;
85 // Unless this is a password form submission, for our purposes this
86 // means we're done with the current page, so we can clean-up.
87 void DidNavigate();
88
89 typedef std::vector<PasswordFormManager*> LoginManagers;
90 LoginManagers pending_login_managers_;
91
92 // Deleter for pending_login_managers_ when PasswordManager is deleted (e.g
93 // tab closes) on a page with a password form, thus containing login managers.
94 STLElementDeleter<LoginManagers> login_managers_deleter_;
95 90
96 // When the user submits a password/credential, this contains the 91 // When the user submits a password/credential, this contains the
97 // PasswordFormManager for the form in question until we deem the login 92 // PasswordFormManager for the form in question until we deem the login
98 // attempt to have succeeded (as in valid credentials). If it fails, we 93 // attempt to have succeeded (as in valid credentials). If it fails, we
99 // send the PasswordFormManager back to the pending_login_managers_ set. 94 // send the PasswordFormManager back to the pending_login_managers_ set.
100 // Scoped in case PasswordManager gets deleted (e.g tab closes) between the 95 // Scoped in case PasswordManager gets deleted (e.g tab closes) between the
101 // time a user submits a login form and gets to the next page. 96 // time a user submits a login form and gets to the next page.
102 scoped_ptr<PasswordFormManager> provisional_save_manager_; 97 scoped_ptr<PasswordFormManager> provisional_save_manager_;
103 98
104 // Our delegate for carrying out external operations. This is typically the 99 // Our delegate for carrying out external operations. This is typically the
105 // containing TabContents. 100 // containing TabContents.
106 PasswordManagerDelegate* delegate_; 101 PasswordManagerDelegate* const delegate_;
107 102
108 // The LoginModelObserver (i.e LoginView) requiring autofill. 103 // The LoginModelObserver (i.e LoginView) requiring autofill.
109 LoginModelObserver* observer_; 104 LoginModelObserver* observer_;
110 105
111 // Set to false to disable the password manager (will no longer fill 106 // Set to false to disable the password manager (will no longer fill
112 // passwords or ask you if you want to save passwords). 107 // passwords or ask you if you want to save passwords).
113 BooleanPrefMember password_manager_enabled_; 108 BooleanPrefMember password_manager_enabled_;
114 109
115 DISALLOW_COPY_AND_ASSIGN(PasswordManager); 110 DISALLOW_COPY_AND_ASSIGN(PasswordManager);
116 }; 111 };
117 112
118 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ 113 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_form_manager.cc ('k') | chrome/browser/password_manager/password_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698