blob: d2507515804eb70c19b0ec934f05614143aa84ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_
#define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_
#include <map>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "components/autofill/content/common/autofill_agent.mojom.h"
#include "components/autofill/core/common/password_form_field_prediction_map.h"
#include "components/autofill/core/common/password_form_generation_data.h"
#include "components/password_manager/core/browser/password_autofill_manager.h"
#include "components/password_manager/core/browser/password_generation_manager.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
namespace autofill {
struct PasswordForm;
}
namespace content {
class NavigationHandle;
class RenderFrameHost;
}
namespace password_manager {
enum class BadMessageReason;
// There is one ContentPasswordManagerDriver per RenderFrameHost.
// The lifetime is managed by the ContentPasswordManagerDriverFactory.
class ContentPasswordManagerDriver : public PasswordManagerDriver {
public:
ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host,
PasswordManagerClient* client,
autofill::AutofillClient* autofill_client);
~ContentPasswordManagerDriver() override;
// Gets the driver for |render_frame_host|.
static ContentPasswordManagerDriver* GetForRenderFrameHost(
content::RenderFrameHost* render_frame_host);
// PasswordManagerDriver implementation.
void FillPasswordForm(
const autofill::PasswordFormFillData& form_data) override;
void AllowPasswordGenerationForForm(
const autofill::PasswordForm& form) override;
void FormsEligibleForGenerationFound(
const std::vector<autofill::PasswordFormGenerationData>& forms) override;
void AutofillDataReceived(
const std::map<autofill::FormData,
autofill::PasswordFormFieldPredictionMap>& predictions)
override;
void GeneratedPasswordAccepted(const base::string16& password) override;
void FillSuggestion(const base::string16& username,
const base::string16& password) override;
void FillIntoFocusedField(bool is_password,
const base::string16& credential,
base::OnceCallback<void(autofill::FillingStatus)>
compeleted_callback) override;
void PreviewSuggestion(const base::string16& username,
const base::string16& password) override;
void ShowInitialPasswordAccountSuggestions(
const autofill::PasswordFormFillData& form_data) override;
void ClearPreviewedForm() override;
void ForceSavePassword() override;
void GeneratePassword() override;
PasswordGenerationManager* GetPasswordGenerationManager() override;
PasswordManager* GetPasswordManager() override;
PasswordAutofillManager* GetPasswordAutofillManager() override;
void SendLoggingAvailability() override;
void AllowToRunFormClassifier() override;
autofill::AutofillDriver* GetAutofillDriver() override;
bool IsMainFrame() const override;
void DidNavigateFrame(content::NavigationHandle* navigation_handle);
private:
void OnFocusedPasswordFormFound(const autofill::PasswordForm& password_form);
const autofill::mojom::AutofillAgentPtr& GetAutofillAgent();
const autofill::mojom::PasswordAutofillAgentPtr& GetPasswordAutofillAgent();
const autofill::mojom::PasswordGenerationAgentPtr&
GetPasswordGenerationAgent();
// Returns the next key to be used for PasswordFormFillData sent to
// PasswordAutofillManager and PasswordAutofillAgent.
int GetNextKey();
content::RenderFrameHost* render_frame_host_;
PasswordManagerClient* client_;
PasswordGenerationManager password_generation_manager_;
PasswordAutofillManager password_autofill_manager_;
// Every instance of PasswordFormFillData created by |*this| and sent to
// PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that
// the latter two classes can reference to the same instance without sending
// it to each other over IPC. The counter below is used to generate new IDs.
// The counter cycles over a limited range of values, see
// https://crbug.com/846404#c5.
int next_free_key_ = 0;
// It should be filled in the constructor, since later the frame might be
// detached and it would be impossible to check whether the frame is a main
// frame.
const bool is_main_frame_;
autofill::mojom::PasswordAutofillAgentPtr password_autofill_agent_;
autofill::mojom::PasswordGenerationAgentPtr password_gen_agent_;
base::WeakPtrFactory<ContentPasswordManagerDriver> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver);
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRIVER_H_
|