OLD | NEW |
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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "chrome/browser/api/prefs/pref_member.h" | 13 #include "chrome/browser/api/prefs/pref_member.h" |
14 #include "chrome/browser/password_manager/password_form_manager.h" | 14 #include "chrome/browser/password_manager/password_form_manager.h" |
15 #include "chrome/browser/ui/login/login_model.h" | 15 #include "chrome/browser/ui/login/login_model.h" |
| 16 #include "chrome/common/password_form_fill_data.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
17 #include "webkit/forms/password_form.h" | 18 #include "content/public/common/password_form.h" |
18 #include "webkit/forms/password_form_dom_manager.h" | |
19 | 19 |
20 class PasswordManagerDelegate; | 20 class PasswordManagerDelegate; |
21 class PasswordManagerTest; | 21 class PasswordManagerTest; |
22 class PasswordFormManager; | 22 class PasswordFormManager; |
23 class PrefService; | 23 class PrefService; |
24 | 24 |
25 // Per-tab password manager. Handles creation and management of UI elements, | 25 // Per-tab password manager. Handles creation and management of UI elements, |
26 // receiving password form data from the renderer and managing the password | 26 // receiving password form data from the renderer and managing the password |
27 // database through the PasswordStore. The PasswordManager is a LoginModel | 27 // database through the PasswordStore. The PasswordManager is a LoginModel |
28 // for purposes of supporting HTTP authentication dialogs. | 28 // for purposes of supporting HTTP authentication dialogs. |
29 class PasswordManager : public LoginModel, | 29 class PasswordManager : public LoginModel, |
30 public content::WebContentsObserver { | 30 public content::WebContentsObserver { |
31 public: | 31 public: |
32 static void RegisterUserPrefs(PrefService* prefs); | 32 static void RegisterUserPrefs(PrefService* prefs); |
33 | 33 |
34 // The delegate passed in is required to outlive the PasswordManager. | 34 // The delegate passed in is required to outlive the PasswordManager. |
35 PasswordManager(content::WebContents* web_contents, | 35 PasswordManager(content::WebContents* web_contents, |
36 PasswordManagerDelegate* delegate); | 36 PasswordManagerDelegate* delegate); |
37 | 37 |
38 virtual ~PasswordManager(); | 38 virtual ~PasswordManager(); |
39 | 39 |
40 // Is saving new data for password autofill enabled for the current profile? | 40 // Is saving new data for password autofill enabled for the current profile? |
41 // For example, saving new data is disabled in Incognito mode, whereas filling | 41 // For example, saving new data is disabled in Incognito mode, whereas filling |
42 // data is not. | 42 // data is not. |
43 bool IsSavingEnabled() const; | 43 bool IsSavingEnabled() const; |
44 | 44 |
45 // Called by a PasswordFormManager when it decides a form can be autofilled | 45 // Called by a PasswordFormManager when it decides a form can be autofilled |
46 // on the page. | 46 // on the page. |
47 virtual void Autofill(const webkit::forms::PasswordForm& form_for_autofill, | 47 virtual void Autofill(const content::PasswordForm& form_for_autofill, |
48 const webkit::forms::PasswordFormMap& best_matches, | 48 const content::PasswordFormMap& best_matches, |
49 const webkit::forms::PasswordForm& preferred_match, | 49 const content::PasswordForm& preferred_match, |
50 bool wait_for_username) const; | 50 bool wait_for_username) const; |
51 | 51 |
52 // LoginModel implementation. | 52 // LoginModel implementation. |
53 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE; | 53 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE; |
54 | 54 |
55 // Mark this form as having a generated password. | 55 // Mark this form as having a generated password. |
56 void SetFormHasGeneratedPassword(const webkit::forms::PasswordForm& form); | 56 void SetFormHasGeneratedPassword(const content::PasswordForm& form); |
57 | 57 |
58 // TODO(isherman): This should not be public, but is currently being used by | 58 // TODO(isherman): This should not be public, but is currently being used by |
59 // the LoginPrompt code. | 59 // the LoginPrompt code. |
60 // When a form is submitted, we prepare to save the password but wait | 60 // When a form is submitted, we prepare to save the password but wait |
61 // until we decide the user has successfully logged in. This is step 1 | 61 // until we decide the user has successfully logged in. This is step 1 |
62 // of 2 (see SavePassword). | 62 // of 2 (see SavePassword). |
63 void ProvisionallySavePassword(const webkit::forms::PasswordForm& form); | 63 void ProvisionallySavePassword(const content::PasswordForm& form); |
64 | 64 |
65 // content::WebContentsObserver overrides. | 65 // content::WebContentsObserver overrides. |
66 virtual void DidNavigateAnyFrame( | 66 virtual void DidNavigateAnyFrame( |
67 const content::LoadCommittedDetails& details, | 67 const content::LoadCommittedDetails& details, |
68 const content::FrameNavigateParams& params) OVERRIDE; | 68 const content::FrameNavigateParams& params) OVERRIDE; |
69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
70 | 70 |
71 // TODO(isherman): This should not be public, but is currently being used by | 71 // TODO(isherman): This should not be public, but is currently being used by |
72 // the LoginPrompt code. | 72 // the LoginPrompt code. |
73 void OnPasswordFormsParsed( | 73 void OnPasswordFormsParsed( |
74 const std::vector<webkit::forms::PasswordForm>& forms); | 74 const std::vector<content::PasswordForm>& forms); |
75 void OnPasswordFormsRendered( | 75 void OnPasswordFormsRendered( |
76 const std::vector<webkit::forms::PasswordForm>& visible_forms); | 76 const std::vector<content::PasswordForm>& visible_forms); |
77 | 77 |
78 private: | 78 private: |
79 // Is password autofill enabled for the current profile? | 79 // Is password autofill enabled for the current profile? |
80 bool IsFillingEnabled() const; | 80 bool IsFillingEnabled() const; |
81 | 81 |
82 // Note about how a PasswordFormManager can transition from | 82 // Note about how a PasswordFormManager can transition from |
83 // pending_login_managers_ to provisional_save_manager_ and the infobar. | 83 // pending_login_managers_ to provisional_save_manager_ and the infobar. |
84 // | 84 // |
85 // 1. form "seen" | 85 // 1. form "seen" |
86 // | new | 86 // | new |
(...skipping 24 matching lines...) Expand all Loading... |
111 LoginModelObserver* observer_; | 111 LoginModelObserver* observer_; |
112 | 112 |
113 // Set to false to disable the password manager (will no longer fill | 113 // Set to false to disable the password manager (will no longer fill |
114 // passwords or ask you if you want to save passwords). | 114 // passwords or ask you if you want to save passwords). |
115 BooleanPrefMember password_manager_enabled_; | 115 BooleanPrefMember password_manager_enabled_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(PasswordManager); | 117 DISALLOW_COPY_AND_ASSIGN(PasswordManager); |
118 }; | 118 }; |
119 | 119 |
120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ | 120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ |
OLD | NEW |