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

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

Issue 151413008: Move ownership of Password(Generation)Manager to ContentPasswordDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle WebContents having no PasswordManagerDelegateImpl attached Created 6 years, 10 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) 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.h"
19 #include "components/autofill/core/common/password_form_fill_data.h" 19 #include "components/autofill/core/common/password_form_fill_data.h"
20 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h"
22 21
23 class PasswordManagerDelegate; 22 class PasswordManagerDelegate;
24 class PasswordManagerDriver; 23 class PasswordManagerDriver;
25 class PasswordManagerTest; 24 class PasswordManagerTest;
26 class PasswordFormManager; 25 class PasswordFormManager;
27 class PrefRegistrySimple; 26 class PrefRegistrySimple;
28 27
29 namespace user_prefs { 28 namespace user_prefs {
30 class PrefRegistrySyncable; 29 class PrefRegistrySyncable;
31 } 30 }
32 31
33 // Per-tab password manager. Handles creation and management of UI elements, 32 // Per-tab password manager. Handles creation and management of UI elements,
34 // receiving password form data from the renderer and managing the password 33 // receiving password form data from the renderer and managing the password
35 // database through the PasswordStore. The PasswordManager is a LoginModel 34 // database through the PasswordStore. The PasswordManager is a LoginModel
36 // for purposes of supporting HTTP authentication dialogs. 35 // for purposes of supporting HTTP authentication dialogs.
37 class PasswordManager : public LoginModel, 36 class PasswordManager : public LoginModel, public content::WebContentsObserver {
38 public content::WebContentsObserver,
39 public content::WebContentsUserData<PasswordManager> {
40 public: 37 public:
41 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
42 #if defined(OS_WIN) 39 #if defined(OS_WIN)
43 static void RegisterLocalPrefs(PrefRegistrySimple* registry); 40 static void RegisterLocalPrefs(PrefRegistrySimple* registry);
44 #endif 41 #endif
45 static void CreateForWebContentsAndDelegate( 42 PasswordManager(content::WebContents* web_contents,
46 content::WebContents* contents, 43 PasswordManagerDelegate* delegate);
47 PasswordManagerDelegate* delegate);
48 virtual ~PasswordManager(); 44 virtual ~PasswordManager();
49 45
50 typedef base::Callback<void(const autofill::PasswordForm&)> 46 typedef base::Callback<void(const autofill::PasswordForm&)>
51 PasswordSubmittedCallback; 47 PasswordSubmittedCallback;
52 48
53 // There is no corresponding remove function as currently all of the 49 // There is no corresponding remove function as currently all of the
54 // owners of these callbacks have sufficient lifetimes so that the callbacks 50 // owners of these callbacks have sufficient lifetimes so that the callbacks
55 // should always be valid when called. 51 // should always be valid when called.
56 void AddSubmissionCallback(const PasswordSubmittedCallback& callback); 52 void AddSubmissionCallback(const PasswordSubmittedCallback& callback);
57 53
(...skipping 30 matching lines...) Expand all
88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 84 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
89 85
90 // 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
91 // the LoginPrompt code. 87 // the LoginPrompt code.
92 void OnPasswordFormsParsed( 88 void OnPasswordFormsParsed(
93 const std::vector<autofill::PasswordForm>& forms); 89 const std::vector<autofill::PasswordForm>& forms);
94 void OnPasswordFormsRendered( 90 void OnPasswordFormsRendered(
95 const std::vector<autofill::PasswordForm>& visible_forms); 91 const std::vector<autofill::PasswordForm>& visible_forms);
96 92
97 protected: 93 protected:
98 // Subclassed for unit tests.
99 PasswordManager(content::WebContents* web_contents,
100 PasswordManagerDelegate* delegate);
101 94
102 // Handle notification that a password form was submitted. 95 // Handle notification that a password form was submitted.
103 virtual void OnPasswordFormSubmitted( 96 virtual void OnPasswordFormSubmitted(
104 const autofill::PasswordForm& password_form); 97 const autofill::PasswordForm& password_form);
105 98
106 private: 99 private:
107 friend class content::WebContentsUserData<PasswordManager>;
108
109 enum ProvisionalSaveFailure { 100 enum ProvisionalSaveFailure {
110 SAVING_DISABLED, 101 SAVING_DISABLED,
111 EMPTY_PASSWORD, 102 EMPTY_PASSWORD,
112 NO_MATCHING_FORM, 103 NO_MATCHING_FORM,
113 MATCHING_NOT_COMPLETE, 104 MATCHING_NOT_COMPLETE,
114 FORM_BLACKLISTED, 105 FORM_BLACKLISTED,
115 INVALID_FORM, 106 INVALID_FORM,
116 AUTOCOMPLETE_OFF, 107 AUTOCOMPLETE_OFF,
117 MAX_FAILURE_VALUE 108 MAX_FAILURE_VALUE
118 }; 109 };
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // notification in const member functions. 168 // notification in const member functions.
178 mutable ObserverList<LoginModelObserver> observers_; 169 mutable ObserverList<LoginModelObserver> observers_;
179 170
180 // Callbacks to be notified when a password form has been submitted. 171 // Callbacks to be notified when a password form has been submitted.
181 std::vector<PasswordSubmittedCallback> submission_callbacks_; 172 std::vector<PasswordSubmittedCallback> submission_callbacks_;
182 173
183 DISALLOW_COPY_AND_ASSIGN(PasswordManager); 174 DISALLOW_COPY_AND_ASSIGN(PasswordManager);
184 }; 175 };
185 176
186 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ 177 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698