NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / password_manager / chrome_password_manager_client.h
blobdf3d28d6af221460c71c182997a7e51cbe5e61c9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/browser/password_manager/content_password_manager_driver.h"
11 #include "chrome/browser/password_manager/password_manager_client.h"
12 #include "content/public/browser/web_contents_user_data.h"
14 class PasswordGenerationManager;
15 class PasswordManager;
16 class Profile;
18 namespace content {
19 class WebContents;
22 // ChromePasswordManagerClient implements the PasswordManagerClient interface.
23 class ChromePasswordManagerClient
24 : public PasswordManagerClient,
25 public content::WebContentsUserData<ChromePasswordManagerClient> {
26 public:
27 virtual ~ChromePasswordManagerClient();
29 // PasswordManagerClient implementation.
30 virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save)
31 OVERRIDE;
32 virtual void PasswordWasAutofilled(
33 const autofill::PasswordFormMap& best_matches) const OVERRIDE;
34 virtual void AuthenticateAutofillAndFillForm(
35 scoped_ptr<autofill::PasswordFormFillData> fill_data) OVERRIDE;
36 virtual PrefService* GetPrefs() OVERRIDE;
37 virtual PasswordStore* GetPasswordStore() OVERRIDE;
38 virtual PasswordManagerDriver* GetDriver() OVERRIDE;
39 virtual base::FieldTrial::Probability GetProbabilityForExperiment(
40 const std::string& experiment_name) OVERRIDE;
41 virtual bool IsPasswordSyncEnabled() OVERRIDE;
43 // Convenience method to allow //chrome code easy access to a PasswordManager
44 // from a WebContents instance.
45 static PasswordManager* GetManagerFromWebContents(
46 content::WebContents* contents);
48 // Convenience method to allow //chrome code easy access to a
49 // PasswordGenerationManager from a WebContents instance.
50 static PasswordGenerationManager* GetGenerationManagerFromWebContents(
51 content::WebContents* contents);
53 private:
54 explicit ChromePasswordManagerClient(content::WebContents* web_contents);
55 friend class content::WebContentsUserData<ChromePasswordManagerClient>;
57 // Callback method to be triggered when authentication is successful for a
58 // given password authentication request. If authentication is disabled or
59 // not supported, this will be triggered directly.
60 void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data);
62 Profile* GetProfile();
64 content::WebContents* web_contents_;
65 ContentPasswordManagerDriver driver_;
67 // Allows authentication callbacks to be destroyed when this client is gone.
68 base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(ChromePasswordManagerClient);
73 #endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_PASSWORD_MANAGER_CLIENT_H_