| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "chrome/browser/password_manager/password_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
| 12 #include "chrome/browser/prefs/pref_member.h" | 12 #include "chrome/browser/prefs/pref_member.h" |
| 13 #include "chrome/browser/ui/login/login_model.h" | 13 #include "chrome/browser/ui/login/login_model.h" |
| 14 #include "content/browser/tab_contents/tab_contents_observer.h" | 14 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 15 #include "webkit/glue/password_form.h" | 15 #include "webkit/forms/password_form.h" |
| 16 #include "webkit/glue/password_form_dom_manager.h" | 16 #include "webkit/forms/password_form_dom_manager.h" |
| 17 | 17 |
| 18 class PasswordManagerDelegate; | 18 class PasswordManagerDelegate; |
| 19 class PasswordManagerTest; | 19 class PasswordManagerTest; |
| 20 class PasswordFormManager; | 20 class PasswordFormManager; |
| 21 class PrefService; | 21 class PrefService; |
| 22 | 22 |
| 23 // Per-tab password manager. Handles creation and management of UI elements, | 23 // Per-tab password manager. Handles creation and management of UI elements, |
| 24 // receiving password form data from the renderer and managing the password | 24 // receiving password form data from the renderer and managing the password |
| 25 // database through the WebDataService. The PasswordManager is a LoginModel | 25 // database through the WebDataService. The PasswordManager is a LoginModel |
| 26 // for purposes of supporting HTTP authentication dialogs. | 26 // for purposes of supporting HTTP authentication dialogs. |
| 27 class PasswordManager : public LoginModel, | 27 class PasswordManager : public LoginModel, |
| 28 public TabContentsObserver { | 28 public TabContentsObserver { |
| 29 public: | 29 public: |
| 30 static void RegisterUserPrefs(PrefService* prefs); | 30 static void RegisterUserPrefs(PrefService* prefs); |
| 31 | 31 |
| 32 // The delegate passed in is required to outlive the PasswordManager. | 32 // The delegate passed in is required to outlive the PasswordManager. |
| 33 PasswordManager(TabContents* tab_contents, | 33 PasswordManager(TabContents* tab_contents, |
| 34 PasswordManagerDelegate* delegate); | 34 PasswordManagerDelegate* delegate); |
| 35 virtual ~PasswordManager(); | 35 virtual ~PasswordManager(); |
| 36 | 36 |
| 37 // Called by a PasswordFormManager when it decides a form can be autofilled | 37 // Called by a PasswordFormManager when it decides a form can be autofilled |
| 38 // on the page. | 38 // on the page. |
| 39 void Autofill(const webkit_glue::PasswordForm& form_for_autofill, | 39 void Autofill(const webkit::forms::PasswordForm& form_for_autofill, |
| 40 const webkit_glue::PasswordFormMap& best_matches, | 40 const webkit::forms::PasswordFormMap& best_matches, |
| 41 const webkit_glue::PasswordForm* const preferred_match, | 41 const webkit::forms::PasswordForm* const preferred_match, |
| 42 bool wait_for_username) const; | 42 bool wait_for_username) const; |
| 43 | 43 |
| 44 // LoginModel implementation. | 44 // LoginModel implementation. |
| 45 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE; | 45 virtual void SetObserver(LoginModelObserver* observer) OVERRIDE; |
| 46 | 46 |
| 47 // When a form is submitted, we prepare to save the password but wait | 47 // 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 | 48 // until we decide the user has successfully logged in. This is step 1 |
| 49 // of 2 (see SavePassword). | 49 // of 2 (see SavePassword). |
| 50 void ProvisionallySavePassword(webkit_glue::PasswordForm form); | 50 void ProvisionallySavePassword(webkit::forms::PasswordForm form); |
| 51 | 51 |
| 52 // TabContentsObserver overrides. | 52 // TabContentsObserver overrides. |
| 53 virtual void DidStopLoading() OVERRIDE; | 53 virtual void DidStopLoading() OVERRIDE; |
| 54 virtual void DidNavigateAnyFrame( | 54 virtual void DidNavigateAnyFrame( |
| 55 const content::LoadCommittedDetails& details, | 55 const content::LoadCommittedDetails& details, |
| 56 const content::FrameNavigateParams& params) OVERRIDE; | 56 const content::FrameNavigateParams& params) OVERRIDE; |
| 57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 58 | 58 |
| 59 void OnPasswordFormsFound( | 59 void OnPasswordFormsFound( |
| 60 const std::vector<webkit_glue::PasswordForm>& forms); | 60 const std::vector<webkit::forms::PasswordForm>& forms); |
| 61 void OnPasswordFormsVisible( | 61 void OnPasswordFormsVisible( |
| 62 const std::vector<webkit_glue::PasswordForm>& visible_forms); | 62 const std::vector<webkit::forms::PasswordForm>& visible_forms); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 FRIEND_TEST_ALL_PREFIXES(PasswordManagerTest, FormSeenThenLeftPage); | 65 FRIEND_TEST_ALL_PREFIXES(PasswordManagerTest, FormSeenThenLeftPage); |
| 66 | 66 |
| 67 // Note about how a PasswordFormManager can transition from | 67 // Note about how a PasswordFormManager can transition from |
| 68 // pending_login_managers_ to provisional_save_manager_ and the infobar. | 68 // pending_login_managers_ to provisional_save_manager_ and the infobar. |
| 69 // | 69 // |
| 70 // 1. form "seen" | 70 // 1. form "seen" |
| 71 // | new | 71 // | new |
| 72 // | ___ Infobar | 72 // | ___ Infobar |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 LoginModelObserver* observer_; | 109 LoginModelObserver* observer_; |
| 110 | 110 |
| 111 // Set to false to disable the password manager (will no longer fill | 111 // Set to false to disable the password manager (will no longer fill |
| 112 // passwords or ask you if you want to save passwords). | 112 // passwords or ask you if you want to save passwords). |
| 113 BooleanPrefMember password_manager_enabled_; | 113 BooleanPrefMember password_manager_enabled_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(PasswordManager); | 115 DISALLOW_COPY_AND_ASSIGN(PasswordManager); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ | 118 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_H_ |
| OLD | NEW |