Roll src/third_party/WebKit c63b89c:29324ab (svn 202546:202547)
[chromium-blink-merge.git] / components / password_manager / content / browser / content_password_manager_driver.h
blob6060495c94ab7919eb21f4ece2f8ce8a2f3ac832
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/autofill/core/common/password_form_field_prediction_map.h"
11 #include "components/password_manager/core/browser/password_autofill_manager.h"
12 #include "components/password_manager/core/browser/password_generation_manager.h"
13 #include "components/password_manager/core/browser/password_manager.h"
14 #include "components/password_manager/core/browser/password_manager_driver.h"
16 namespace autofill {
17 class AutofillManager;
18 struct PasswordForm;
21 namespace content {
22 struct FrameNavigateParams;
23 struct LoadCommittedDetails;
24 class RenderFrameHost;
25 class WebContents;
28 namespace IPC {
29 class Message;
32 namespace password_manager {
33 enum class BadMessageReason;
35 // There is one ContentPasswordManagerDriver per RenderFrameHost.
36 // The lifetime is managed by the ContentPasswordManagerDriverFactory.
37 class ContentPasswordManagerDriver : public PasswordManagerDriver {
38 public:
39 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host,
40 PasswordManagerClient* client,
41 autofill::AutofillClient* autofill_client);
42 ~ContentPasswordManagerDriver() override;
44 // Gets the driver for |render_frame_host|.
45 static ContentPasswordManagerDriver* GetForRenderFrameHost(
46 content::RenderFrameHost* render_frame_host);
48 // PasswordManagerDriver implementation.
49 void FillPasswordForm(
50 const autofill::PasswordFormFillData& form_data) override;
51 void AllowPasswordGenerationForForm(
52 const autofill::PasswordForm& form) override;
53 void AccountCreationFormsFound(
54 const std::vector<autofill::FormData>& forms) override;
55 void AutofillDataReceived(
56 const std::map<autofill::FormData,
57 autofill::PasswordFormFieldPredictionMap>& predictions)
58 override;
59 void GeneratedPasswordAccepted(const base::string16& password) override;
60 void FillSuggestion(const base::string16& username,
61 const base::string16& password) override;
62 void PreviewSuggestion(const base::string16& username,
63 const base::string16& password) override;
64 void ClearPreviewedForm() override;
65 void ForceSavePassword() override;
67 PasswordGenerationManager* GetPasswordGenerationManager() override;
68 PasswordManager* GetPasswordManager() override;
69 PasswordAutofillManager* GetPasswordAutofillManager() override;
71 bool HandleMessage(const IPC::Message& message);
72 void DidNavigateFrame(const content::LoadCommittedDetails& details,
73 const content::FrameNavigateParams& params);
75 // Pass-throughs to PasswordManager.
76 void OnPasswordFormsParsed(const std::vector<autofill::PasswordForm>& forms);
77 void OnPasswordFormsParsedNoRenderCheck(
78 const std::vector<autofill::PasswordForm>& forms);
79 void OnPasswordFormsRendered(
80 const std::vector<autofill::PasswordForm>& visible_forms,
81 bool did_stop_loading);
82 void OnPasswordFormSubmitted(const autofill::PasswordForm& password_form);
83 void OnInPageNavigation(const autofill::PasswordForm& password_form);
84 void OnPasswordNoLongerGenerated(const autofill::PasswordForm& password_form);
85 void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form);
87 private:
88 bool CheckChildProcessSecurityPolicy(const GURL& url,
89 BadMessageReason reason);
91 content::RenderFrameHost* render_frame_host_;
92 PasswordManagerClient* client_;
93 PasswordGenerationManager password_generation_manager_;
94 PasswordAutofillManager password_autofill_manager_;
96 // Every instance of PasswordFormFillData created by |*this| and sent to
97 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that
98 // the latter two classes can reference to the same instance without sending
99 // it to each other over IPC. The counter below is used to generate new IDs.
100 int next_free_key_;
102 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver);
105 } // namespace password_manager
107 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_