#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_
+#include <string>
#include <vector>
#include "base/callback.h"
#include "components/password_manager/core/browser/login_model.h"
#include "components/password_manager/core/browser/password_form_manager.h"
-class PasswordManagerClient;
-class PasswordManagerDriver;
-class PasswordManagerTest;
-class PasswordFormManager;
class PrefRegistrySimple;
namespace content {
class PrefRegistrySyncable;
}
+namespace password_manager {
+
+class BrowserSavePasswordProgressLogger;
+class PasswordManagerClient;
+class PasswordManagerDriver;
+class PasswordManagerTest;
+class PasswordFormManager;
+
// Per-tab password manager. Handles creation and management of UI elements,
// receiving password form data from the renderer and managing the password
// database through the PasswordStore. The PasswordManager is a LoginModel
// should always be valid when called.
void AddSubmissionCallback(const PasswordSubmittedCallback& callback);
- // Is saving new data for password autofill enabled for the current profile?
- // For example, saving new data is disabled in Incognito mode, whereas filling
- // data is not.
- bool IsSavingEnabled() const;
+ // Is saving new data for password autofill enabled for the current profile
+ // and page? For example, saving new data is disabled in Incognito mode,
+ // whereas filling data is not. Also, saving data is disabled in the presence
+ // of SSL errors on a page.
+ bool IsSavingEnabledForCurrentPage() const;
// Called by a PasswordFormManager when it decides a form can be autofilled
// on the page.
// Handles password forms being rendered.
void OnPasswordFormsRendered(
- const std::vector<autofill::PasswordForm>& visible_forms);
+ const std::vector<autofill::PasswordForm>& visible_forms,
+ bool did_stop_loading);
// Handles a password form being submitted.
virtual void OnPasswordFormSubmitted(
const autofill::PasswordForm& password_form);
+ PasswordManagerClient* client() { return client_; }
+
private:
enum ProvisionalSaveFailure {
SAVING_DISABLED,
FORM_BLACKLISTED,
INVALID_FORM,
AUTOCOMPLETE_OFF,
+ SYNC_CREDENTIAL,
MAX_FAILURE_VALUE
};
+ // Returns if the password manager is enabled for this page. There are certain
+ // situations (e.g. bad SSL cert) where we disable the password manager
+ // temporarily.
+ bool IsEnabledForCurrentPage() const;
+
// Log failure for UMA. Logs additional metrics if the |form_origin|
- // corresponds to one of the top, explicitly monitored websites.
+ // corresponds to one of the top, explicitly monitored websites. For some
+ // values of |failure| also sends logs to the internals page through |logger|,
+ // it |logger| is not NULL.
void RecordFailure(ProvisionalSaveFailure failure,
- const std::string& form_origin);
+ const std::string& form_origin,
+ BrowserSavePasswordProgressLogger* logger);
// Possibly set up FieldTrial for testing other possible usernames. This only
// happens if there are other_possible_usernames to be shown and the
// |provisional_save_manager_|.
bool ShouldPromptUserToSavePassword() const;
+ // Checks for every from in |forms| whether |pending_login_managers_| already
+ // contain a manager for that form. If not, adds a manager for each such form.
+ void CreatePendingLoginManagers(
+ const std::vector<autofill::PasswordForm>& forms);
+
// Note about how a PasswordFormManager can transition from
// pending_login_managers_ to provisional_save_manager_ and the infobar.
//
// The platform-level driver. Must outlive this class.
PasswordManagerDriver* const driver_;
- // Set to false to disable the password manager (will no longer ask if you
+ // Set to false to disable password saving (will no longer ask if you
// want to save passwords but will continue to fill passwords).
- BooleanPrefMember password_manager_enabled_;
+ BooleanPrefMember saving_passwords_enabled_;
// Observers to be notified of LoginModel events. This is mutable to allow
// notification in const member functions.
// Callbacks to be notified when a password form has been submitted.
std::vector<PasswordSubmittedCallback> submission_callbacks_;
+ // Records all visible forms seen during a page load, in all frames of the
+ // page. When the page stops loading, the password manager checks if one of
+ // the recorded forms matches the login form from the previous page
+ // (to see if the login was a failure), and clears the vector.
+ std::vector<autofill::PasswordForm> all_visible_forms_;
+
DISALLOW_COPY_AND_ASSIGN(PasswordManager);
};
+} // namespace password_manager
+
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_H_