Password Save prompt on in page navigation.
[chromium-blink-merge.git] / components / password_manager / content / browser / content_password_manager_driver.h
blob065af805a66e1e34c692705331ae5fe9bfb583ac
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 COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "components/password_manager/core/browser/password_autofill_manager.h"
11 #include "components/password_manager/core/browser/password_generation_manager.h"
12 #include "components/password_manager/core/browser/password_manager.h"
13 #include "components/password_manager/core/browser/password_manager_driver.h"
15 namespace autofill {
16 class AutofillManager;
17 struct PasswordForm;
20 namespace content {
21 struct FrameNavigateParams;
22 struct LoadCommittedDetails;
23 class RenderFrameHost;
24 class WebContents;
27 namespace IPC {
28 class Message;
31 namespace password_manager {
33 // There is one ContentPasswordManagerDriver per RenderFrameHost.
34 // The lifetime is managed by the ContentPasswordManagerDriverFactory.
35 class ContentPasswordManagerDriver : public PasswordManagerDriver {
36 public:
37 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host,
38 PasswordManagerClient* client,
39 autofill::AutofillClient* autofill_client);
40 ~ContentPasswordManagerDriver() override;
42 // Gets the driver for |render_frame_host|.
43 static ContentPasswordManagerDriver* GetForRenderFrameHost(
44 content::RenderFrameHost* render_frame_host);
46 // PasswordManagerDriver implementation.
47 void FillPasswordForm(
48 const autofill::PasswordFormFillData& form_data) override;
49 void AllowPasswordGenerationForForm(
50 const autofill::PasswordForm& form) override;
51 void AccountCreationFormsFound(
52 const std::vector<autofill::FormData>& forms) override;
53 void GeneratedPasswordAccepted(const base::string16& password) override;
54 void FillSuggestion(const base::string16& username,
55 const base::string16& password) override;
56 void PreviewSuggestion(const base::string16& username,
57 const base::string16& password) override;
58 void ClearPreviewedForm() override;
60 PasswordGenerationManager* GetPasswordGenerationManager() override;
61 PasswordManager* GetPasswordManager() override;
62 PasswordAutofillManager* GetPasswordAutofillManager() override;
64 bool HandleMessage(const IPC::Message& message);
65 void DidNavigateFrame(const content::LoadCommittedDetails& details,
66 const content::FrameNavigateParams& params);
68 // Pass-throughs to PasswordManager.
69 void OnPasswordFormsParsed(const std::vector<autofill::PasswordForm>& forms);
70 void OnPasswordFormsRendered(
71 const std::vector<autofill::PasswordForm>& visible_forms,
72 bool did_stop_loading);
73 void OnPasswordFormSubmitted(const autofill::PasswordForm& password_form);
74 void OnInPageNavigation(const autofill::PasswordForm& password_form);
76 private:
77 content::RenderFrameHost* render_frame_host_;
78 PasswordManagerClient* client_;
79 PasswordGenerationManager password_generation_manager_;
80 PasswordAutofillManager password_autofill_manager_;
82 // Every instance of PasswordFormFillData created by |*this| and sent to
83 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that
84 // the latter two classes can reference to the same instance without sending
85 // it to each other over IPC. The counter below is used to generate new IDs.
86 int next_free_key_;
88 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver);
91 } // namespace password_manager
93 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_