#ifndef CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "components/password_manager/content/browser/content_password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "ui/gfx/rect.h"
class PasswordGenerationManager;
class PasswordManager;
class Profile;
namespace autofill {
class PasswordGenerationPopupObserver;
class PasswordGenerationPopupControllerImpl;
}
namespace content {
class WebContents;
}
class ChromePasswordManagerClient
: public PasswordManagerClient,
public content::WebContentsObserver,
public content::WebContentsUserData<ChromePasswordManagerClient> {
public:
virtual ~ChromePasswordManagerClient();
virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save)
OVERRIDE;
virtual void PasswordWasAutofilled(
const autofill::PasswordFormMap& best_matches) const OVERRIDE;
virtual void AuthenticateAutofillAndFillForm(
scoped_ptr<autofill::PasswordFormFillData> fill_data) OVERRIDE;
virtual PrefService* GetPrefs() OVERRIDE;
virtual PasswordStore* GetPasswordStore() OVERRIDE;
virtual PasswordManagerDriver* GetDriver() OVERRIDE;
virtual base::FieldTrial::Probability GetProbabilityForExperiment(
const std::string& experiment_name) OVERRIDE;
virtual bool IsPasswordSyncEnabled() OVERRIDE;
virtual void SetLogger(PasswordManagerLogger* logger) OVERRIDE;
virtual void LogSavePasswordProgress(const std::string& text) OVERRIDE;
void HidePasswordGenerationPopup();
static PasswordManager* GetManagerFromWebContents(
content::WebContents* contents);
static PasswordGenerationManager* GetGenerationManagerFromWebContents(
content::WebContents* contents);
void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer);
private:
explicit ChromePasswordManagerClient(content::WebContents* web_contents);
friend class content::WebContentsUserData<ChromePasswordManagerClient>;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data);
gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds);
void ShowPasswordGenerationPopup(const gfx::RectF& bounds,
int max_length,
const autofill::PasswordForm& form);
void ShowPasswordEditingPopup(
const gfx::RectF& bounds, const autofill::PasswordForm& form);
Profile* GetProfile();
ContentPasswordManagerDriver driver_;
autofill::PasswordGenerationPopupObserver* observer_;
base::WeakPtr<
autofill::PasswordGenerationPopupControllerImpl> popup_controller_;
base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_;
PasswordManagerLogger* logger_;
DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient);
};
#endif