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

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

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Rebase Created 7 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/prefs/pref_member.h" 14 #include "base/prefs/pref_member.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "chrome/browser/password_manager/password_form_manager.h" 16 #include "chrome/browser/password_manager/password_form_manager.h"
17 #include "chrome/browser/ui/login/login_model.h" 17 #include "chrome/browser/ui/login/login_model.h"
18 #include "components/autofill/core/common/password_form.h"
18 #include "components/autofill/core/common/password_form_fill_data.h" 19 #include "components/autofill/core/common/password_form_fill_data.h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/browser/web_contents_user_data.h" 21 #include "content/public/browser/web_contents_user_data.h"
21 #include "content/public/common/password_form.h"
22 22
23 class PasswordManagerDelegate; 23 class PasswordManagerDelegate;
24 class PasswordManagerTest; 24 class PasswordManagerTest;
25 class PasswordFormManager; 25 class PasswordFormManager;
26 26
27 namespace user_prefs { 27 namespace user_prefs {
28 class PrefRegistrySyncable; 28 class PrefRegistrySyncable;
29 } 29 }
30 30
31 // Per-tab password manager. Handles creation and management of UI elements, 31 // Per-tab password manager. Handles creation and management of UI elements,
32 // receiving password form data from the renderer and managing the password 32 // receiving password form data from the renderer and managing the password
33 // database through the PasswordStore. The PasswordManager is a LoginModel 33 // database through the PasswordStore. The PasswordManager is a LoginModel
34 // for purposes of supporting HTTP authentication dialogs. 34 // for purposes of supporting HTTP authentication dialogs.
35 class PasswordManager : public LoginModel, 35 class PasswordManager : public LoginModel,
36 public content::WebContentsObserver, 36 public content::WebContentsObserver,
37 public content::WebContentsUserData<PasswordManager> { 37 public content::WebContentsUserData<PasswordManager> {
38 public: 38 public:
39 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 39 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
40 40
41 static void CreateForWebContentsAndDelegate( 41 static void CreateForWebContentsAndDelegate(
42 content::WebContents* contents, 42 content::WebContents* contents,
43 PasswordManagerDelegate* delegate); 43 PasswordManagerDelegate* delegate);
44 virtual ~PasswordManager(); 44 virtual ~PasswordManager();
45 45
46 typedef base::Callback<void(const content::PasswordForm&)> 46 typedef base::Callback<void(const autofill::PasswordForm&)>
47 PasswordSubmittedCallback; 47 PasswordSubmittedCallback;
48 48
49 // There is no corresponding remove function as currently all of the 49 // There is no corresponding remove function as currently all of the
50 // owners of these callbacks have sufficient lifetimes so that the callbacks 50 // owners of these callbacks have sufficient lifetimes so that the callbacks
51 // should always be valid when called. 51 // should always be valid when called.
52 void AddSubmissionCallback(const PasswordSubmittedCallback& callback); 52 void AddSubmissionCallback(const PasswordSubmittedCallback& callback);
53 53
54 // Is saving new data for password autofill enabled for the current profile? 54 // Is saving new data for password autofill enabled for the current profile?
55 // For example, saving new data is disabled in Incognito mode, whereas filling 55 // For example, saving new data is disabled in Incognito mode, whereas filling
56 // data is not. 56 // data is not.
57 bool IsSavingEnabled() const; 57 bool IsSavingEnabled() const;
58 58
59 // Called by a PasswordFormManager when it decides a form can be autofilled 59 // Called by a PasswordFormManager when it decides a form can be autofilled
60 // on the page. 60 // on the page.
61 virtual void Autofill(const content::PasswordForm& form_for_autofill, 61 virtual void Autofill(const autofill::PasswordForm& form_for_autofill,
62 const content::PasswordFormMap& best_matches, 62 const autofill::PasswordFormMap& best_matches,
63 const content::PasswordForm& preferred_match, 63 const autofill::PasswordForm& preferred_match,
64 bool wait_for_username) const; 64 bool wait_for_username) const;
65 65
66 // LoginModel implementation. 66 // LoginModel implementation.
67 virtual void AddObserver(LoginModelObserver* observer) OVERRIDE; 67 virtual void AddObserver(LoginModelObserver* observer) OVERRIDE;
68 virtual void RemoveObserver(LoginModelObserver* observer) OVERRIDE; 68 virtual void RemoveObserver(LoginModelObserver* observer) OVERRIDE;
69 69
70 // Mark this form as having a generated password. 70 // Mark this form as having a generated password.
71 void SetFormHasGeneratedPassword(const content::PasswordForm& form); 71 void SetFormHasGeneratedPassword(const autofill::PasswordForm& form);
72 72
73 // TODO(isherman): This should not be public, but is currently being used by 73 // TODO(isherman): This should not be public, but is currently being used by
74 // the LoginPrompt code. 74 // the LoginPrompt code.
75 // When a form is submitted, we prepare to save the password but wait 75 // When a form is submitted, we prepare to save the password but wait
76 // until we decide the user has successfully logged in. This is step 1 76 // until we decide the user has successfully logged in. This is step 1
77 // of 2 (see SavePassword). 77 // of 2 (see SavePassword).
78 void ProvisionallySavePassword(const content::PasswordForm& form); 78 void ProvisionallySavePassword(const autofill::PasswordForm& form);
79 79
80 // content::WebContentsObserver overrides. 80 // content::WebContentsObserver overrides.
81 virtual void DidNavigateMainFrame( 81 virtual void DidNavigateMainFrame(
82 const content::LoadCommittedDetails& details, 82 const content::LoadCommittedDetails& details,
83 const content::FrameNavigateParams& params) OVERRIDE; 83 const content::FrameNavigateParams& params) OVERRIDE;
84 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 84 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
85 85
86 // TODO(isherman): This should not be public, but is currently being used by 86 // TODO(isherman): This should not be public, but is currently being used by
87 // the LoginPrompt code. 87 // the LoginPrompt code.
88 void OnPasswordFormsParsed( 88 void OnPasswordFormsParsed(
89 const std::vector<content::PasswordForm>& forms); 89 const std::vector<autofill::PasswordForm>& forms);
90 void OnPasswordFormsRendered( 90 void OnPasswordFormsRendered(
91 const std::vector<content::PasswordForm>& visible_forms); 91 const std::vector<autofill::PasswordForm>& visible_forms);
92 92
93 protected: 93 protected:
94 // Subclassed for unit tests. 94 // Subclassed for unit tests.
95 PasswordManager(content::WebContents* web_contents, 95 PasswordManager(content::WebContents* web_contents,
96 PasswordManagerDelegate* delegate); 96 PasswordManagerDelegate* delegate);
97 97
98 // Handle notification that a password form was submitted. 98 // Handle notification that a password form was submitted.
99 virtual void OnPasswordFormSubmitted( 99 virtual void OnPasswordFormSubmitted(
100 const content::PasswordForm& password_form); 100 const autofill::PasswordForm& password_form);
101 101
102 private: 102 private:
103 friend class content::WebContentsUserData<PasswordManager>; 103 friend class content::WebContentsUserData<PasswordManager>;
104 104
105 enum ProvisionalSaveFailure { 105 enum ProvisionalSaveFailure {
106 SAVING_DISABLED, 106 SAVING_DISABLED,
107 EMPTY_PASSWORD, 107 EMPTY_PASSWORD,
108 NO_MATCHING_FORM, 108 NO_MATCHING_FORM,
109 MATCHING_NOT_COMPLETE, 109 MATCHING_NOT_COMPLETE,
110 FORM_BLACKLISTED, 110 FORM_BLACKLISTED,
111 INVALID_FORM, 111 INVALID_FORM,
112 AUTOCOMPLETE_OFF, 112 AUTOCOMPLETE_OFF,
113 MAX_FAILURE_VALUE 113 MAX_FAILURE_VALUE
114 }; 114 };
115 115
116 // Log failure for UMA 116 // Log failure for UMA
117 void RecordFailure(ProvisionalSaveFailure failure); 117 void RecordFailure(ProvisionalSaveFailure failure);
118 118
119 // Possibly set up FieldTrial for testing other possible usernames. This only 119 // Possibly set up FieldTrial for testing other possible usernames. This only
120 // happens if there are other_possible_usernames to be shown and the 120 // happens if there are other_possible_usernames to be shown and the
121 // experiment hasn't already been initialized. We setup the experiment at 121 // experiment hasn't already been initialized. We setup the experiment at
122 // such a late time because this experiment will only affect a small number 122 // such a late time because this experiment will only affect a small number
123 // of users so we want to include a larger fraction of these users than the 123 // of users so we want to include a larger fraction of these users than the
124 // normal 10%. 124 // normal 10%.
125 void PossiblyInitializeUsernamesExperiment( 125 void PossiblyInitializeUsernamesExperiment(
126 const content::PasswordFormMap& matches) const; 126 const autofill::PasswordFormMap& matches) const;
127 127
128 // Returns true if we can show possible usernames to users in cases where 128 // Returns true if we can show possible usernames to users in cases where
129 // the username for the form is ambigious. 129 // the username for the form is ambigious.
130 bool OtherPossibleUsernamesEnabled() const; 130 bool OtherPossibleUsernamesEnabled() const;
131 131
132 // Returns true if we should show an infobar instead of automatically saving 132 // Returns true if we should show an infobar instead of automatically saving
133 // the password, based on inspecting the state of |provisional_save_manager_|. 133 // the password, based on inspecting the state of |provisional_save_manager_|.
134 bool ShouldShowSavePasswordInfoBar() const; 134 bool ShouldShowSavePasswordInfoBar() const;
135 135
136 // Note about how a PasswordFormManager can transition from 136 // Note about how a PasswordFormManager can transition from
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // notification in const member functions. 169 // notification in const member functions.
170 mutable ObserverList<LoginModelObserver> observers_; 170 mutable ObserverList<LoginModelObserver> observers_;
171 171
172 // Callbacks to be notified when a password form has been submitted. 172 // Callbacks to be notified when a password form has been submitted.
173 std::vector<PasswordSubmittedCallback> submission_callbacks_; 173 std::vector<PasswordSubmittedCallback> submission_callbacks_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(PasswordManager); 175 DISALLOW_COPY_AND_ASSIGN(PasswordManager);
176 }; 176 };
177 177
178 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ 178 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_generation_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